Skip to content

Commit

Permalink
Include Extracting BSIC with grgsm_scanner ptrkrysik#573 @matan1008
Browse files Browse the repository at this point in the history
  • Loading branch information
bkerler committed Aug 13, 2021
1 parent 7a40650 commit 314601c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
11 changes: 7 additions & 4 deletions apps/grgsm_scanner
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class wideband_scanner(gr.top_block):


class channel_info(object):
def __init__(self, arfcn, freq, cid, lac, mcc, mnc, ccch_conf, power, neighbours, cell_arfcns):
def __init__(self, arfcn, freq, cid, lac, mcc, mnc, ccch_conf, power, neighbours, cell_arfcns, ncc, bcc):
self.arfcn = arfcn
self.freq = freq
self.cid = cid
Expand All @@ -260,6 +260,8 @@ class channel_info(object):
self.power = power
self.neighbours = neighbours
self.cell_arfcns = cell_arfcns
self.ncc = ncc
self.bcc = bcc

def __lt__(self, other):
return self.arfcn < other.arfcn
Expand Down Expand Up @@ -299,8 +301,8 @@ class channel_info(object):
self.neighbours, self.cell_arfcns)

def __str__(self):
return "ARFCN: %4u, Freq: %6.1fM, CID: %5u, LAC: %5u, MCC: %3u, MNC: %3u, Pwr: %3i" % (
self.arfcn, self.freq / 1e6, self.cid, self.lac, self.mcc, self.mnc, self.power)
return "ARFCN: %4u, Freq: %6.1fM, CID: %5u, LAC: %5u, MCC: %3u, MNC: %3u, Pwr: %3i, NCC: %d, BCC: %d" % (
self.arfcn, self.freq / 1e6, self.cid, self.lac, self.mcc, self.mnc, self.power, self.ncc, self.bcc)

def do_scan(samp_rate, band, speed, ppm, gain, args, prn = None, debug = False):
signallist = []
Expand Down Expand Up @@ -357,10 +359,11 @@ def do_scan(samp_rate, band, speed, ppm, gain, args, prn = None, debug = False):
for i in range(0, len(chans)):
cell_arfcn_list = scanner.gsm_extract_system_info.get_cell_arfcns(chans[i])
neighbour_list = scanner.gsm_extract_system_info.get_neighbours(chans[i])
receiver = scanner.wideband_receiver.receivers_with_decoders[chans[i]].gsm_receiver_0

info = channel_info(gsm.arfcn.downlink2arfcn(found_freqs[i]), found_freqs[i],
cell_ids[i], lacs[i], mccs[i], mncs[i], ccch_confs[i], powers[i],
neighbour_list, cell_arfcn_list)
neighbour_list, cell_arfcn_list, receiver.get_ncc(), receiver.get_bcc())
found_list.append(info)

scanner = None
Expand Down
2 changes: 2 additions & 0 deletions include/gsm/receiver/receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ namespace gr {
virtual void set_cell_allocation(const std::vector<int> &cell_allocation) = 0;
virtual void set_tseq_nums(const std::vector<int> & tseq_nums) = 0;
virtual void reset() = 0;
virtual int get_ncc() = 0;
virtual int get_bcc() = 0;
};

} // namespace gsm
Expand Down
27 changes: 25 additions & 2 deletions lib/receiver/receiver_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ namespace gr
d_signal_dbm(-120),
d_tseq_nums(tseq_nums),
d_cell_allocation(cell_allocation),
d_last_time(0.0)
d_last_time(0.0),
d_ncc(0),
d_bcc(0)
{
/**
* Don't send samples to the receiver
Expand Down Expand Up @@ -242,6 +244,7 @@ namespace gr
unsigned char burst_buf[BURST_SIZE];
int rc, t1, t2, t3;
int burst_start;
int ncc, bcc;

/* Wait until we get a SCH burst */
if (!reach_sch_burst(noutput_items))
Expand All @@ -254,7 +257,7 @@ namespace gr
detect_burst(input, &channel_imp_resp[0], burst_start, burst_buf);

/* Attempt to decode BSIC and frame number */
rc = decode_sch(&burst_buf[3], &t1, &t2, &t3, &d_ncc, &d_bcc);
rc = decode_sch(&burst_buf[3], &t1, &t2, &t3, &ncc, &bcc);
if (rc) {
/**
* There is error in the SCH burst,
Expand All @@ -264,6 +267,10 @@ namespace gr
return;
}

/* Save the NCC and BCC */
d_ncc = ncc;
d_bcc = bcc;

/* Set counter of bursts value */
d_burst_nr.set(t1, t2, t3, 0);
d_burst_nr++;
Expand Down Expand Up @@ -371,6 +378,10 @@ namespace gr
break;
}

/* Save the NCC and BCC */
d_ncc = ncc;
d_bcc = bcc;

/* Compose a message with GSMTAP header and bits */
send_burst(d_burst_nr, output_binary,
GSMTAP_BURST_SCH, input_nr, d_c0_burst_start);
Expand Down Expand Up @@ -1132,5 +1143,17 @@ namespace gr
{
d_state = fcch_search;
}

int
receiver_impl::get_ncc(void)
{
return d_ncc;
}

int
receiver_impl::get_bcc(void)
{
return d_bcc;
}
} /* namespace gsm */
} /* namespace gr */
2 changes: 2 additions & 0 deletions lib/receiver/receiver_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ namespace gr {
virtual void set_cell_allocation(const std::vector<int> &cell_allocation);
virtual void set_tseq_nums(const std::vector<int> & tseq_nums);
virtual void reset();
virtual int get_ncc();
virtual int get_bcc();
};
} // namespace gsm
} // namespace gr
Expand Down

0 comments on commit 314601c

Please sign in to comment.