blob: 76ed08d693b8eb314097799a7b704691e4b05167 [file] [log] [blame]
piotr437f5462014-02-04 17:57:25 +01001/* -*- c++ -*- */
piotrd0bf1492014-02-05 17:27:32 +01002/*
ptrkrysik529895b2014-12-02 18:07:38 +01003 * @file
4 * @author Piotr Krysik <ptrkrysik@gmail.com>
5 * @section LICENSE
piotrd0bf1492014-02-05 17:27:32 +01006 *
ptrkrysik529895b2014-12-02 18:07:38 +01007 * Gr-gsm is free software; you can redistribute it and/or modify
piotr437f5462014-02-04 17:57:25 +01008 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
piotrd0bf1492014-02-05 17:27:32 +010011 *
ptrkrysik529895b2014-12-02 18:07:38 +010012 * Gr-gsm is distributed in the hope that it will be useful,
piotr437f5462014-02-04 17:57:25 +010013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
piotrd0bf1492014-02-05 17:27:32 +010016 *
piotr437f5462014-02-04 17:57:25 +010017 * You should have received a copy of the GNU General Public License
ptrkrysik529895b2014-12-02 18:07:38 +010018 * along with gr-gsm; see the file COPYING. If not, write to
piotr437f5462014-02-04 17:57:25 +010019 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include <gnuradio/io_signature.h>
piotr437f5462014-02-04 17:57:25 +010028#include <gnuradio/math.h>
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070029
piotr437f5462014-02-04 17:57:25 +010030#include <algorithm>
piotr437f5462014-02-04 17:57:25 +010031#include <string.h>
piotr437f5462014-02-04 17:57:25 +010032#include <iostream>
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070033#include <numeric>
34#include <math.h>
35#include <vector>
ptrkrysik3be74a72014-12-13 10:11:00 +010036
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070037#include <boost/circular_buffer.hpp>
38#include <boost/scoped_ptr.hpp>
ptrkrysik3be74a72014-12-13 10:11:00 +010039#include <grgsm/endian.h>
ptrkrysik58213792014-10-30 09:05:15 +010040
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070041#include "receiver_impl.h"
42#include "viterbi_detector.h"
43#include "sch.h"
44
45#if 0
46/* Files included for debuging */
47#include "plotting/plotting.hpp"
48#include <pthread.h>
49#include <iomanip>
50#endif
piotr437f5462014-02-04 17:57:25 +010051
52#define SYNC_SEARCH_RANGE 30
53
piotrd0bf1492014-02-05 17:27:32 +010054namespace gr
55{
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070056 namespace gsm
57 {
piotrd0bf1492014-02-05 17:27:32 +010058
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070059 /* The public constructor */
60 receiver::sptr
61 receiver::make(
62 int osr, const std::vector<int> &cell_allocation,
63 const std::vector<int> &tseq_nums, bool process_uplink)
piotr437f5462014-02-04 17:57:25 +010064 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070065 return gnuradio::get_initial_sptr
66 (new receiver_impl(osr, cell_allocation,
67 tseq_nums, process_uplink));
piotr437f5462014-02-04 17:57:25 +010068 }
69
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070070 /* The private constructor */
71 receiver_impl::receiver_impl(
72 int osr, const std::vector<int> &cell_allocation,
73 const std::vector<int> &tseq_nums, bool process_uplink
74 ) : gr::sync_block("receiver",
75 gr::io_signature::make(1, -1, sizeof(gr_complex)),
76 gr::io_signature::make(0, 0, 0)),
77 d_OSR(osr),
78 d_process_uplink(process_uplink),
79 d_chan_imp_length(CHAN_IMP_RESP_LENGTH),
80 d_counter(0),
81 d_fcch_start_pos(0),
82 d_freq_offset_setting(0),
83 d_state(fcch_search),
84 d_burst_nr(osr),
85 d_failed_sch(0),
86 d_signal_dbm(-120),
87 d_tseq_nums(tseq_nums),
88 d_cell_allocation(cell_allocation),
89 d_last_time(0.0)
ptrkrysik32c21162015-04-04 14:01:52 +020090 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070091 /**
92 * Don't send samples to the receiver
93 * until there are at least samples for one
94 */
95 set_output_multiple(floor((TS_BITS + 2 * GUARD_PERIOD) * d_OSR));
96
97 /**
98 * Prepare SCH sequence bits
99 *
100 * (TS_BITS + 2 * GUARD_PERIOD)
101 * Burst and two guard periods
102 * (one guard period is an arbitrary overlap)
103 */
104 gmsk_mapper(SYNC_BITS, N_SYNC_BITS,
105 d_sch_training_seq, gr_complex(0.0, -1.0));
106
107 /* Prepare bits of training sequences */
108 for (int i = 0; i < TRAIN_SEQ_NUM; i++) {
109 /**
110 * If first bit of the sequence is 0
111 * => first symbol is 1, else -1
112 */
113 gr_complex startpoint = train_seq[i][0] == 0 ?
114 gr_complex(1.0, 0.0) : gr_complex(-1.0, 0.0);
115 gmsk_mapper(train_seq[i], N_TRAIN_BITS,
116 d_norm_training_seq[i], startpoint);
117 }
118
119 /* Register output ports */
120 message_port_register_out(pmt::mp("C0"));
121 message_port_register_out(pmt::mp("CX"));
122 message_port_register_out(pmt::mp("measurements"));
123
124 /**
125 * Configure the receiver,
126 * i.e. tell it where to find which burst type
127 */
128 configure_receiver();
129 }
130
131 /* Our virtual destructor */
132 receiver_impl::~receiver_impl() {}
133
134 int
135 receiver_impl::work(
136 int noutput_items,
137 gr_vector_const_void_star &input_items,
138 gr_vector_void_star &output_items)
139 {
140 gr_complex *input = (gr_complex *) input_items[0];
141 uint64_t start = nitems_read(0);
142 uint64_t stop = start + noutput_items;
143 d_freq_offset_tag_in_fcch = false;
144
145#if 0
146 /* FIXME: jak zrobić to rzutowanie poprawnie */
147 std::vector<const gr_complex *> iii =
148 (std::vector<const gr_complex *>) input_items;
149#endif
150
151 /* Time synchronization loop */
152 float current_time =
153 static_cast<float>(start / (GSM_SYMBOL_RATE * d_OSR));
154 if ((current_time - d_last_time) > 0.1) {
155 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("current_time"),
156 pmt::from_double(current_time));
ptrkrysik32c21162015-04-04 14:01:52 +0200157 message_port_pub(pmt::mp("measurements"), msg);
158 d_last_time = current_time;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700159 }
ptrkrysik32c21162015-04-04 14:01:52 +0200160
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700161 /* Frequency correction loop */
162 std::vector<tag_t> freq_offset_tags;
163 pmt::pmt_t key = pmt::string_to_symbol("setting_freq_offset");
164 get_tags_in_range(freq_offset_tags, 0, start, stop, key);
165
166 if (!freq_offset_tags.empty()) {
piotr4089c1a2014-08-06 14:10:56 +0200167 tag_t freq_offset_tag = freq_offset_tags[0];
Piotr Krysik43af70d2016-07-20 21:37:24 +0200168 uint64_t tag_offset = freq_offset_tag.offset - start;
Piotr Krysik43af70d2016-07-20 21:37:24 +0200169 d_freq_offset_setting = pmt::to_double(freq_offset_tag.value);
piotr4089c1a2014-08-06 14:10:56 +0200170
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700171 burst_type b_type = d_channel_conf.get_burst_type(d_burst_nr);
172 if (d_state == synchronized && b_type == fcch_burst){
173 uint64_t last_sample_nr =
174 ceil((GUARD_PERIOD + 2.0 * TAIL_BITS + 156.25) * d_OSR) + 1;
175 d_freq_offset_tag_in_fcch = tag_offset < last_sample_nr;
piotrd0bf1492014-02-05 17:27:32 +0100176 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700177 }
178
179 /* Main state machine */
180 switch (d_state) {
181 case fcch_search:
182 fcch_search_handler(input, noutput_items);
piotrd0bf1492014-02-05 17:27:32 +0100183 break;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700184 case sch_search:
185 sch_search_handler(input, noutput_items);
piotrd0bf1492014-02-05 17:27:32 +0100186 break;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700187 case synchronized:
188 synchronized_handler(input, input_items, noutput_items);
189 break;
190 }
191
192 return 0;
piotrd0bf1492014-02-05 17:27:32 +0100193 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700194
195 void
196 receiver_impl::fcch_search_handler(gr_complex *input, int noutput_items)
piotrd0bf1492014-02-05 17:27:32 +0100197 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700198 double freq_offset_tmp;
ptrkrysik58213792014-10-30 09:05:15 +0100199
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700200 /* Check if received samples is a FCCN burst */
201 if (!find_fcch_burst(input, noutput_items, freq_offset_tmp))
202 return;
piotr437f5462014-02-04 17:57:25 +0100203
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700204 /* We found it, compose a message */
205 pmt::pmt_t msg = pmt::make_tuple(
206 pmt::mp("freq_offset"),
207 pmt::from_double(freq_offset_tmp - d_freq_offset_setting),
208 pmt::mp("fcch_search")
209 );
Piotr Krysik9bc0fc02017-01-18 21:53:17 +0100210
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700211 /* Notify FCCH loop */
212 message_port_pub(pmt::mp("measurements"), msg);
213
214 /* Update current state */
215 d_state = sch_search;
piotrd0bf1492014-02-05 17:27:32 +0100216 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700217
218 void
219 receiver_impl::sch_search_handler(gr_complex *input, int noutput_items)
220 {
221 std::vector<gr_complex> channel_imp_resp(CHAN_IMP_RESP_LENGTH * d_OSR);
222 unsigned char burst_buf[BURST_SIZE];
223 int rc, t1, t2, t3;
224 int burst_start;
225
226 /* Wait until we get a SCH burst */
227 if (!reach_sch_burst(noutput_items))
228 return;
229
230 /* Get channel impulse response from it */
231 burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]);
232
233 /* Detect bits using MLSE detection */
234 detect_burst(input, &channel_imp_resp[0], burst_start, burst_buf);
235
236 /* Attempt to decode BSIC and frame number */
237 rc = decode_sch(&burst_buf[3], &t1, &t2, &t3, &d_ncc, &d_bcc);
238 if (rc) {
239 /**
240 * There is error in the SCH burst,
241 * go back to the FCCH search state
242 */
243 d_state = fcch_search;
244 return;
245 }
246
247 /* Set counter of bursts value */
248 d_burst_nr.set(t1, t2, t3, 0);
249 d_burst_nr++;
250
251 /* Consume samples up to the next guard period */
252 consume_each(burst_start + BURST_SIZE * d_OSR + 4 * d_OSR);
253
254 /* Update current state */
255 d_state = synchronized;
piotr437f5462014-02-04 17:57:25 +0100256 }
piotr437f5462014-02-04 17:57:25 +0100257
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700258 void
259 receiver_impl::synchronized_handler(gr_complex *input,
260 gr_vector_const_void_star &input_items, int noutput_items)
piotr437f5462014-02-04 17:57:25 +0100261 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700262 /**
263 * In this state receiver is synchronized and it processes
264 * bursts according to burst type for given burst number
265 */
266 std::vector<gr_complex> channel_imp_resp(CHAN_IMP_RESP_LENGTH * d_OSR);
267 unsigned int inputs_to_process = d_cell_allocation.size();
268 unsigned char output_binary[BURST_SIZE];
269 burst_type b_type;
270 int to_consume = 0;
271 int offset = 0;
piotr437f5462014-02-04 17:57:25 +0100272
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700273 if (d_process_uplink)
274 inputs_to_process *= 2;
piotr437f5462014-02-04 17:57:25 +0100275
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700276 /* Process all connected inputs */
277 for (int input_nr = 0; input_nr < inputs_to_process; input_nr++) {
278 input = (gr_complex *) input_items[input_nr];
279 double signal_pwr = 0;
280
281 for (int ii = GUARD_PERIOD; ii < TS_BITS; ii++)
282 signal_pwr += abs(input[ii]) * abs(input[ii]);
283
284 signal_pwr = signal_pwr / (TS_BITS);
285 d_signal_dbm = round(10 * log10(signal_pwr / 50));
286
287 if (input_nr == 0)
288 d_c0_signal_dbm = d_signal_dbm;
289
290 /* Get burst type for given burst number */
291 b_type = input_nr == 0 ?
292 d_channel_conf.get_burst_type(d_burst_nr) : normal_or_noise;
293
294 /* Process burst according to its type */
295 switch (b_type) {
296 case fcch_burst:
piotrd0bf1492014-02-05 17:27:32 +0100297 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700298 if (d_freq_offset_tag_in_fcch)
piotr437f5462014-02-04 17:57:25 +0100299 break;
300
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700301 /* Send all-zero sequence message */
302 send_burst(d_burst_nr, fc_fb, GSMTAP_BURST_FCCH, input_nr);
piotr437f5462014-02-04 17:57:25 +0100303
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700304 /* Extract frequency offset */
305 const unsigned first_sample =
306 ceil((GUARD_PERIOD + 2 * TAIL_BITS) * d_OSR) + 1;
307 const unsigned last_sample =
308 first_sample + USEFUL_BITS * d_OSR - TAIL_BITS * d_OSR;
309 double freq_offset_tmp =
310 compute_freq_offset(input, first_sample, last_sample);
piotr437f5462014-02-04 17:57:25 +0100311
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700312 /* Frequency correction loop */
313 pmt::pmt_t msg = pmt::make_tuple(
314 pmt::mp("freq_offset"),
315 pmt::from_double(freq_offset_tmp - d_freq_offset_setting),
316 pmt::mp("synchronized"));
317 message_port_pub(pmt::mp("measurements"), msg);
318
319 break;
320 }
321
322 case sch_burst:
323 {
324 int d_ncc, d_bcc;
325 int t1, t2, t3;
326 int rc;
327
328 /* Get channel impulse response */
329 d_c0_burst_start = get_sch_chan_imp_resp(input,
330 &channel_imp_resp[0]);
331
332 /* Perform MLSE detection */
333 detect_burst(input, &channel_imp_resp[0],
334 d_c0_burst_start, output_binary);
335
336 /* Compose a message with GSMTAP header and bits */
337 send_burst(d_burst_nr, output_binary,
338 GSMTAP_BURST_SCH, input_nr);
339
340 /* Attempt to decode SCH burst */
341 rc = decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc);
342 if (rc) {
343 if (++d_failed_sch >= MAX_SCH_ERRORS) {
344 /* We have to resynchronize, change state */
345 d_state = fcch_search;
346
347 /* Frequency correction loop */
348 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),
349 pmt::from_double(0.0),pmt::mp("sync_loss"));
350 message_port_pub(pmt::mp("measurements"), msg);
piotr437f5462014-02-04 17:57:25 +0100351 }
352
353 break;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700354 }
piotr437f5462014-02-04 17:57:25 +0100355
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700356 /**
357 * Decoding was successful, now
358 * compute offset from burst_start,
359 * burst should start after a guard period.
360 */
361 offset = d_c0_burst_start - floor((GUARD_PERIOD) * d_OSR);
362 to_consume += offset;
363 d_failed_sch = 0;
piotr437f5462014-02-04 17:57:25 +0100364
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700365 break;
piotrd0bf1492014-02-05 17:27:32 +0100366 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700367
368 case normal_burst:
369 {
370 float normal_corr_max;
371 /**
372 * Get channel impulse response for given
373 * training sequence number - d_bcc
374 */
375 d_c0_burst_start = get_norm_chan_imp_resp(input,
376 &channel_imp_resp[0], &normal_corr_max, d_bcc);
377
378 /* Perform MLSE detection */
379 detect_burst(input, &channel_imp_resp[0],
380 d_c0_burst_start, output_binary);
381
382 /* Compose a message with GSMTAP header and bits */
383 send_burst(d_burst_nr, output_binary,
384 GSMTAP_BURST_NORMAL, input_nr);
385
386 break;
387 }
388
389 case dummy_or_normal:
390 {
391 unsigned int normal_burst_start, dummy_burst_start;
392 float dummy_corr_max, normal_corr_max;
393
394 dummy_burst_start = get_norm_chan_imp_resp(input,
395 &channel_imp_resp[0], &dummy_corr_max, TS_DUMMY);
396 normal_burst_start = get_norm_chan_imp_resp(input,
397 &channel_imp_resp[0], &normal_corr_max, d_bcc);
398
399 if (normal_corr_max > dummy_corr_max) {
400 d_c0_burst_start = normal_burst_start;
401
402 /* Perform MLSE detection */
403 detect_burst(input, &channel_imp_resp[0],
404 normal_burst_start, output_binary);
405
406 /* Compose a message with GSMTAP header and bits */
407 send_burst(d_burst_nr, output_binary,
408 GSMTAP_BURST_NORMAL, input_nr);
409 } else {
410 d_c0_burst_start = dummy_burst_start;
411
412 /* Compose a message with GSMTAP header and bits */
413 send_burst(d_burst_nr, dummy_burst,
414 GSMTAP_BURST_DUMMY, input_nr);
415 }
416
417 break;
418 }
419
420 case normal_or_noise:
421 {
422 std::vector<gr_complex> v(input, input + noutput_items);
423 float normal_corr_max = -1e6;
424 float normal_corr_max_tmp;
425 unsigned int burst_start;
426 int max_tn, tseq_num;
427
428 if (d_tseq_nums.size() == 0) {
429 /**
430 * There is no information about training sequence,
431 * however the receiver can detect it with use of a
432 * very simple algorithm based on finding
433 */
434 get_norm_chan_imp_resp(input, &channel_imp_resp[0],
435 &normal_corr_max, 0);
436
437 float ts_max = normal_corr_max;
438 int ts_max_num = 0;
439
440 for (int ss = 1; ss <= 7; ss++) {
441 get_norm_chan_imp_resp(input, &channel_imp_resp[0],
442 &normal_corr_max, ss);
443
444 if (ts_max < normal_corr_max) {
445 ts_max = normal_corr_max;
446 ts_max_num = ss;
447 }
448 }
449
450 d_tseq_nums.push_back(ts_max_num);
451 }
452
453 /* Choose proper training sequence number */
454 tseq_num = input_nr <= d_tseq_nums.size() ?
455 d_tseq_nums[input_nr - 1] : d_tseq_nums.back();
456
457 /* Get channel impulse response */
458 burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0],
459 &normal_corr_max, tseq_num);
460
461 /* Perform MLSE detection */
462 detect_burst(input, &channel_imp_resp[0],
463 burst_start, output_binary);
464
465 /* Compose a message with GSMTAP header and bits */
466 send_burst(d_burst_nr, output_binary, GSMTAP_BURST_NORMAL, input_nr);
467
468 break;
469 }
470
471 case dummy:
472 send_burst(d_burst_nr, dummy_burst, GSMTAP_BURST_DUMMY, input_nr);
473 break;
474
475 case rach_burst:
476 case empty:
477 /* Do nothing */
478 break;
479 }
480
481 if (input_nr == input_items.size() - 1) {
482 /* Go to the next burst */
483 d_burst_nr++;
484
485 /* Consume samples of the burst up to next guard period */
486 to_consume += TS_BITS * d_OSR + d_burst_nr.get_offset();
487 consume_each(to_consume);
488 }
489 }
490 }
491
492 bool
493 receiver_impl::find_fcch_burst(const gr_complex *input,
494 const int nitems, double &computed_freq_offset)
495 {
496 /* Circular buffer used to scan through signal to find */
497 boost::circular_buffer<float>
498 phase_diff_buffer(FCCH_HITS_NEEDED * d_OSR);
499 boost::circular_buffer<float>::iterator buffer_iter;
500
501 float lowest_max_min_diff;
502 float phase_diff; /* Best match for FCCH burst */
503 float min_phase_diff;
504 float max_phase_diff;
505 double best_sum = 0;
506 gr_complex conjprod;
507 int start_pos;
508 int hit_count;
509 int miss_count;
510
511 int sample_number = 0;
512 int to_consume = 0;
513 bool result = false;
514 bool end = false;
515
516 /* Possible states of FCCH search algorithm */
517 enum states
518 {
519 init, /* initialize variables */
520 search, /* search for positive samples */
521 found_something, /* search for FCCH and the best position of it */
522 fcch_found, /* when FCCH was found */
523 search_fail /* when there is no FCCH in the input vector */
524 } fcch_search_state;
525
526 /* Set initial state */
527 fcch_search_state = init;
528
529 while (!end)
530 {
531 switch (fcch_search_state) {
532 case init:
533 {
534 hit_count = 0;
535 miss_count = 0;
536 start_pos = -1;
537 lowest_max_min_diff = 99999;
538 phase_diff_buffer.clear();
539
540 /* Change current state */
541 fcch_search_state = search;
542
543 break;
544 }
545
546 case search:
547 {
548 sample_number++;
549
550 if (sample_number > nitems - FCCH_HITS_NEEDED * d_OSR) {
551 /**
552 * If it isn't possible to find FCCH, because
553 * there is too few samples left to look into,
554 * don't do anything with those samples which are left
555 * and consume only those which were checked
556 */
557 to_consume = sample_number;
558 fcch_search_state = search_fail;
559 break;
560 }
561
562 phase_diff = compute_phase_diff(input[sample_number],
563 input[sample_number - 1]);
564
565 /**
566 * If a positive phase difference was found
567 * switch to state in which searches for FCCH
568 */
569 if (phase_diff > 0) {
570 to_consume = sample_number;
571 fcch_search_state = found_something;
572 } else {
573 fcch_search_state = search;
574 }
575
576 break;
577 }
578
579 case found_something:
580 {
581 if (phase_diff > 0)
582 hit_count++;
583 else
584 miss_count++;
585
586 if ((miss_count >= FCCH_MAX_MISSES * d_OSR)
587 && (hit_count <= FCCH_HITS_NEEDED * d_OSR))
588 {
589 /* If miss_count exceeds limit before hit_count */
590 fcch_search_state = init;
591 continue;
592 }
593
594 if (((miss_count >= FCCH_MAX_MISSES * d_OSR)
595 && (hit_count > FCCH_HITS_NEEDED * d_OSR))
596 || (hit_count > 2 * FCCH_HITS_NEEDED * d_OSR))
597 {
598 /**
599 * If hit_count and miss_count exceeds
600 * limit then FCCH was found
601 */
602 fcch_search_state = fcch_found;
603 continue;
604 }
605
606 if ((miss_count < FCCH_MAX_MISSES * d_OSR)
607 && (hit_count > FCCH_HITS_NEEDED * d_OSR))
608 {
609 /**
610 * Find difference between minimal and maximal
611 * element in the buffer. For FCCH this value
612 * should be low. This part is searching for
613 * a region where this value is lowest.
614 */
615 min_phase_diff = *(min_element(phase_diff_buffer.begin(),
616 phase_diff_buffer.end()));
617 max_phase_diff = *(max_element(phase_diff_buffer.begin(),
618 phase_diff_buffer.end()));
619
620 if (lowest_max_min_diff > max_phase_diff - min_phase_diff) {
621 lowest_max_min_diff = max_phase_diff - min_phase_diff;
622 start_pos = sample_number - FCCH_HITS_NEEDED
623 * d_OSR - FCCH_MAX_MISSES * d_OSR;
624 best_sum = 0;
625
626 for (buffer_iter = phase_diff_buffer.begin();
627 buffer_iter != (phase_diff_buffer.end());
628 buffer_iter++) {
629 /* Store best value of phase offset sum */
630 best_sum += *buffer_iter - (M_PI / 2) / d_OSR;
631 }
632 }
633 }
634
635 /* If there is no single sample left to check */
636 if (++sample_number >= nitems) {
637 fcch_search_state = search_fail;
638 continue;
639 }
640
641 phase_diff = compute_phase_diff(input[sample_number],
642 input[sample_number-1]);
643 phase_diff_buffer.push_back(phase_diff);
644 fcch_search_state = found_something;
645
646 break;
647 }
piotrd0bf1492014-02-05 17:27:32 +0100648
649 case fcch_found:
650 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700651 /* Consume one FCCH burst */
652 to_consume = start_pos + FCCH_HITS_NEEDED * d_OSR + 1;
653 d_fcch_start_pos = d_counter + start_pos;
piotrd0bf1492014-02-05 17:27:32 +0100654
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700655 /**
656 * Compute frequency offset
657 *
658 * 1625000.0 / 6 - GMSK symbol rate in GSM
659 */
660 double phase_offset = best_sum / FCCH_HITS_NEEDED;
661 double freq_offset = phase_offset * 1625000.0 / 6 / (2 * M_PI);
662 computed_freq_offset = freq_offset;
piotrd0bf1492014-02-05 17:27:32 +0100663
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700664 end = true;
665 result = true;
piotrd0bf1492014-02-05 17:27:32 +0100666
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700667 break;
piotrd0bf1492014-02-05 17:27:32 +0100668 }
piotr437f5462014-02-04 17:57:25 +0100669
piotrd0bf1492014-02-05 17:27:32 +0100670 case search_fail:
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700671 end = true;
672 result = false;
673 break;
piotr437f5462014-02-04 17:57:25 +0100674 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700675 }
676
677 d_counter += to_consume;
678 consume_each(to_consume);
679
680 return result;
piotr437f5462014-02-04 17:57:25 +0100681 }
682
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700683 double
684 receiver_impl::compute_freq_offset(const gr_complex * input,
685 unsigned first_sample, unsigned last_sample)
Piotr Krysik654d6522017-01-23 21:53:48 +0100686 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700687 double phase_sum = 0;
688 unsigned ii;
689
690 for (ii = first_sample; ii < last_sample; ii++)
691 {
692 double phase_diff = compute_phase_diff(input[ii],
693 input[ii-1]) - (M_PI / 2) / d_OSR;
Piotr Krysik654d6522017-01-23 21:53:48 +0100694 phase_sum += phase_diff;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700695 }
696
697 double phase_offset = phase_sum / (last_sample - first_sample);
698 double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI);
699
700 return freq_offset;
Piotr Krysik654d6522017-01-23 21:53:48 +0100701 }
702
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700703 inline float
704 receiver_impl::compute_phase_diff(gr_complex val1, gr_complex val2)
piotrd0bf1492014-02-05 17:27:32 +0100705 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700706 gr_complex conjprod = val1 * conj(val2);
707 return fast_atan2f(imag(conjprod), real(conjprod));
piotrd0bf1492014-02-05 17:27:32 +0100708 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700709
710 bool
711 receiver_impl::reach_sch_burst(const int nitems)
piotrd0bf1492014-02-05 17:27:32 +0100712 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700713 /* It just consumes samples to get near to a SCH burst */
714 int to_consume = 0;
715 bool result = false;
716 unsigned sample_nr = d_fcch_start_pos
717 + (FRAME_BITS - SAFETY_MARGIN) * d_OSR;
718
719 /* Consume samples until d_counter will be equal to sample_nr */
720 if (d_counter < sample_nr) {
721 to_consume = d_counter + nitems >= sample_nr ?
722 sample_nr - d_counter : nitems;
723 } else {
piotr437f5462014-02-04 17:57:25 +0100724 to_consume = 0;
725 result = true;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700726 }
727
728 d_counter += to_consume;
729 consume_each(to_consume);
730
731 return result;
piotr437f5462014-02-04 17:57:25 +0100732 }
733
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700734 int
735 receiver_impl::get_sch_chan_imp_resp(const gr_complex *input,
736 gr_complex * chan_imp_resp)
piotr437f5462014-02-04 17:57:25 +0100737 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700738 std::vector<gr_complex> correlation_buffer;
739 std::vector<float> window_energy_buffer;
740 std::vector<float> power_buffer;
741
742 int chan_imp_resp_center = 0;
743 int strongest_window_nr;
744 int burst_start;
745 float energy = 0;
746
747 int len = (SYNC_POS + SYNC_SEARCH_RANGE) * d_OSR;
748 for (int ii = SYNC_POS * d_OSR; ii < len; ii++) {
749 gr_complex correlation = correlate_sequence(&d_sch_training_seq[5],
750 N_SYNC_BITS - 10, &input[ii]);
piotr437f5462014-02-04 17:57:25 +0100751 correlation_buffer.push_back(correlation);
752 power_buffer.push_back(std::pow(abs(correlation), 2));
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700753 }
754
755 /* Compute window energies */
756 std::vector<float>::iterator iter = power_buffer.begin();
757 while (iter != power_buffer.end()) {
ptrkrysikef5e2db2015-01-03 12:10:14 +0100758 std::vector<float>::iterator iter_ii = iter;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700759 bool loop_end = false;
piotr437f5462014-02-04 17:57:25 +0100760 energy = 0;
761
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700762 for (int ii = 0; ii < (d_chan_imp_length) * d_OSR; ii++, iter_ii++) {
763 if (iter_ii == power_buffer.end()) {
764 loop_end = true;
piotrd0bf1492014-02-05 17:27:32 +0100765 break;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700766 }
767
768 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100769 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700770
771 if (loop_end)
772 break;
773
piotr437f5462014-02-04 17:57:25 +0100774 window_energy_buffer.push_back(energy);
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700775 iter++;
776 }
piotr437f5462014-02-04 17:57:25 +0100777
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700778 strongest_window_nr = max_element(window_energy_buffer.begin(),
779 window_energy_buffer.end()) - window_energy_buffer.begin();
piotr437f5462014-02-04 17:57:25 +0100780
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700781#if 0
782 d_channel_imp_resp.clear();
783#endif
784
785 float max_correlation = 0;
786 for (int ii = 0; ii < (d_chan_imp_length) * d_OSR; ii++) {
piotr437f5462014-02-04 17:57:25 +0100787 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700788 if (abs(correlation) > max_correlation) {
789 chan_imp_resp_center = ii;
790 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100791 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700792
793#if 0
794 d_channel_imp_resp.push_back(correlation);
795#endif
796
piotr437f5462014-02-04 17:57:25 +0100797 chan_imp_resp[ii] = correlation;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700798 }
799
800 burst_start = strongest_window_nr + chan_imp_resp_center
801 - 48 * d_OSR - 2 * d_OSR + 2 + SYNC_POS * d_OSR;
802 return burst_start;
piotr437f5462014-02-04 17:57:25 +0100803 }
804
805
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700806 void
807 receiver_impl::detect_burst(const gr_complex * input,
808 gr_complex * chan_imp_resp, int burst_start,
809 unsigned char * output_binary)
piotr437f5462014-02-04 17:57:25 +0100810 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700811 std::vector<gr_complex> rhh_temp(CHAN_IMP_RESP_LENGTH * d_OSR);
812 unsigned int stop_states[2] = {4, 12};
813 gr_complex filtered_burst[BURST_SIZE];
814 gr_complex rhh[CHAN_IMP_RESP_LENGTH];
815 float output[BURST_SIZE];
816 int start_state = 3;
817
818 autocorrelation(chan_imp_resp, &rhh_temp[0], d_chan_imp_length*d_OSR);
819 for (int ii = 0; ii < d_chan_imp_length; ii++)
piotr437f5462014-02-04 17:57:25 +0100820 rhh[ii] = conj(rhh_temp[ii*d_OSR]);
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700821
822 mafi(&input[burst_start], BURST_SIZE, chan_imp_resp,
823 d_chan_imp_length * d_OSR, filtered_burst);
824
825 viterbi_detector(filtered_burst, BURST_SIZE, rhh,
826 start_state, stop_states, 2, output);
827
828 for (int i = 0; i < BURST_SIZE; i++)
829 output_binary[i] = output[i] > 0;
piotr437f5462014-02-04 17:57:25 +0100830 }
831
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700832 void
833 receiver_impl::gmsk_mapper(const unsigned char * input,
834 int nitems, gr_complex * gmsk_output, gr_complex start_point)
piotr437f5462014-02-04 17:57:25 +0100835 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700836 gr_complex j = gr_complex(0.0, 1.0);
837 gmsk_output[0] = start_point;
piotr437f5462014-02-04 17:57:25 +0100838
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700839 int previous_symbol = 2 * input[0] - 1;
840 int current_symbol;
841 int encoded_symbol;
piotr437f5462014-02-04 17:57:25 +0100842
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700843 for (int i = 1; i < nitems; i++) {
844 /* Change bits representation to NRZ */
piotr437f5462014-02-04 17:57:25 +0100845 current_symbol = 2 * input[i] - 1;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700846
847 /* Differentially encode */
piotr437f5462014-02-04 17:57:25 +0100848 encoded_symbol = current_symbol * previous_symbol;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700849
850 /* And do GMSK mapping */
851 gmsk_output[i] = j * gr_complex(encoded_symbol, 0.0)
852 * gmsk_output[i-1];
853
piotr437f5462014-02-04 17:57:25 +0100854 previous_symbol = current_symbol;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700855 }
piotr437f5462014-02-04 17:57:25 +0100856 }
857
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700858 gr_complex
859 receiver_impl::correlate_sequence(const gr_complex * sequence,
860 int length, const gr_complex * input)
piotr437f5462014-02-04 17:57:25 +0100861 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700862 gr_complex result(0.0, 0.0);
863
864 for (int ii = 0; ii < length; ii++)
865 result += sequence[ii] * conj(input[ii * d_OSR]);
866
867 return result / gr_complex(length, 0);
868 }
869
870 /* Computes autocorrelation for positive arguments */
871 inline void
872 receiver_impl::autocorrelation(const gr_complex * input,
873 gr_complex * out, int nitems)
874 {
875 for (int k = nitems - 1; k >= 0; k--) {
piotr437f5462014-02-04 17:57:25 +0100876 out[k] = gr_complex(0, 0);
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700877 for (int i = k; i < nitems; i++)
878 out[k] += input[i] * conj(input[i - k]);
879 }
piotr437f5462014-02-04 17:57:25 +0100880 }
881
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700882 inline void
883 receiver_impl::mafi(const gr_complex * input, int nitems,
884 gr_complex * filter, int filter_length, gr_complex * output)
piotr437f5462014-02-04 17:57:25 +0100885 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700886 for (int n = 0; n < nitems; n++) {
887 int a = n * d_OSR;
piotr437f5462014-02-04 17:57:25 +0100888 output[n] = 0;
piotr437f5462014-02-04 17:57:25 +0100889
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700890 for (int ii = 0; ii < filter_length; ii++) {
891 if ((a + ii) >= nitems * d_OSR)
piotrd0bf1492014-02-05 17:27:32 +0100892 break;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700893
894 output[n] += input[a + ii] * filter[ii];
piotr437f5462014-02-04 17:57:25 +0100895 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700896 }
897 }
898
899 /* Especially computations of strongest_window_nr */
900 int
901 receiver_impl::get_norm_chan_imp_resp(const gr_complex *input,
902 gr_complex *chan_imp_resp, float *corr_max, int bcc)
903 {
904 std::vector<gr_complex> correlation_buffer;
905 std::vector<float> window_energy_buffer;
906 std::vector<float> power_buffer;
907
908 int search_center = (int) (TRAIN_POS + GUARD_PERIOD) * d_OSR;
909 int search_start_pos = search_center + 1 - 5 * d_OSR;
910 int search_stop_pos = search_center
911 + d_chan_imp_length * d_OSR + 5 * d_OSR;
912
913 for (int ii = search_start_pos; ii < search_stop_pos; ii++) {
914 gr_complex correlation = correlate_sequence(
915 &d_norm_training_seq[bcc][TRAIN_BEGINNING],
916 N_TRAIN_BITS - 10, &input[ii]);
917 correlation_buffer.push_back(correlation);
918 power_buffer.push_back(std::pow(abs(correlation), 2));
919 }
920
921#if 0
922 plot(power_buffer);
923#endif
924
925 /* Compute window energies */
926 std::vector<float>::iterator iter = power_buffer.begin();
927 while (iter != power_buffer.end()) {
928 std::vector<float>::iterator iter_ii = iter;
929 bool loop_end = false;
930 float energy = 0;
931
932 int len = d_chan_imp_length * d_OSR;
933 for (int ii = 0; ii < len; ii++, iter_ii++) {
934 if (iter_ii == power_buffer.end()) {
935 loop_end = true;
936 break;
937 }
938
939 energy += (*iter_ii);
940 }
941
942 if (loop_end)
943 break;
piotr437f5462014-02-04 17:57:25 +0100944
945 window_energy_buffer.push_back(energy);
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700946 iter++;
947 }
piotr437f5462014-02-04 17:57:25 +0100948
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700949 /* Calculate the strongest window number */
950 int strongest_window_nr = max_element(window_energy_buffer.begin(),
951 window_energy_buffer.end() - d_chan_imp_length * d_OSR)
952 - window_energy_buffer.begin();
953
954 if (strongest_window_nr < 0)
955 strongest_window_nr = 0;
956
957 float max_correlation = 0;
958 for (int ii = 0; ii < d_chan_imp_length * d_OSR; ii++) {
piotr437f5462014-02-04 17:57:25 +0100959 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100960 if (abs(correlation) > max_correlation)
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700961 max_correlation = abs(correlation);
962
963#if 0
964 d_channel_imp_resp.push_back(correlation);
965#endif
966
piotr437f5462014-02-04 17:57:25 +0100967 chan_imp_resp[ii] = correlation;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700968 }
969
970 *corr_max = max_correlation;
971
972 /**
973 * Compute first sample position, which corresponds
974 * to the first sample of the impulse response
975 */
976 return search_start_pos + strongest_window_nr - TRAIN_POS * d_OSR;
piotr437f5462014-02-04 17:57:25 +0100977 }
978
979
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700980 void
981 receiver_impl::send_burst(burst_counter burst_nr,
982 const unsigned char * burst_binary, uint8_t burst_type,
983 unsigned int input_nr)
ptrkrysik380dea82015-08-06 10:11:58 +0200984 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700985 /* Buffer for GSMTAP header and burst */
986 uint8_t buf[sizeof(gsmtap_hdr) + BURST_SIZE];
987 uint32_t frame_number;
988 uint16_t arfcn;
989 uint8_t tn;
ptrkrysik617ba032014-11-21 10:11:05 +0100990
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700991 /* Set pointers to GSMTAP header and burst inside buffer */
992 struct gsmtap_hdr *tap_header = (struct gsmtap_hdr *) buf;
993 uint8_t *burst = buf + sizeof(gsmtap_hdr);
994
995 tap_header->version = GSMTAP_VERSION;
996 tap_header->hdr_len = sizeof(gsmtap_hdr) / 4;
997 tap_header->type = GSMTAP_TYPE_UM_BURST;
998 tap_header->sub_type = burst_type;
999
1000 bool dl_burst = !(input_nr >= d_cell_allocation.size());
1001 if (dl_burst) {
1002 tn = static_cast<uint8_t>(d_burst_nr.get_timeslot_nr());
1003 frame_number = htobe32(d_burst_nr.get_frame_nr());
1004 arfcn = htobe16(d_cell_allocation[input_nr]);
1005 } else {
1006 input_nr -= d_cell_allocation.size();
1007 tn = static_cast<uint8_t>
1008 (d_burst_nr.subtract_timeslots(3).get_timeslot_nr());
1009 frame_number = htobe32(
1010 d_burst_nr.subtract_timeslots(3).get_frame_nr());
1011 arfcn = htobe16(
1012 d_cell_allocation[input_nr] | GSMTAP_ARFCN_F_UPLINK);
1013 }
1014
1015 tap_header->frame_number = frame_number;
1016 tap_header->timeslot = tn;
1017 tap_header->arfcn = arfcn;
1018
1019 tap_header->signal_dbm = static_cast<int8_t>(d_signal_dbm);
1020 tap_header->snr_db = 0; /* FIXME: Can we calculate this? */
1021
1022 /* Copy burst to the buffer */
1023 memcpy(burst, burst_binary, BURST_SIZE);
1024
1025 /* Allocate a new message */
1026 pmt::pmt_t blob = pmt::make_blob(buf, sizeof(gsmtap_hdr) + BURST_SIZE);
1027 pmt::pmt_t msg = pmt::cons(pmt::PMT_NIL, blob);
1028
1029 /* Send message */
1030 if (input_nr == 0)
ptrkrysike518bbf2014-11-06 14:50:59 +01001031 message_port_pub(pmt::mp("C0"), msg);
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001032 else
ptrkrysike518bbf2014-11-06 14:50:59 +01001033 message_port_pub(pmt::mp("CX"), msg);
1034 }
piotr6d152d92014-02-21 00:02:44 +01001035
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001036 void
1037 receiver_impl::configure_receiver(void)
1038 {
1039 d_channel_conf.set_multiframe_type(TIMESLOT0, multiframe_51);
1040 d_channel_conf.set_burst_types(TIMESLOT0, TEST51,
1041 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
1042 d_channel_conf.set_burst_types(TIMESLOT0, TEST_CCH_FRAMES,
1043 sizeof(TEST_CCH_FRAMES) / sizeof(unsigned), dummy_or_normal);
1044 d_channel_conf.set_burst_types(TIMESLOT0, FCCH_FRAMES,
1045 sizeof(FCCH_FRAMES) / sizeof(unsigned), fcch_burst);
1046 d_channel_conf.set_burst_types(TIMESLOT0, SCH_FRAMES,
1047 sizeof(SCH_FRAMES) / sizeof(unsigned), sch_burst);
piotr437f5462014-02-04 17:57:25 +01001048
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001049 d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_51);
1050 d_channel_conf.set_burst_types(TIMESLOT1, TEST51,
1051 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotr437f5462014-02-04 17:57:25 +01001052
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001053 d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_51);
1054 d_channel_conf.set_burst_types(TIMESLOT2, TEST51,
1055 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotr437f5462014-02-04 17:57:25 +01001056
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001057 d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_51);
1058 d_channel_conf.set_burst_types(TIMESLOT3, TEST51,
1059 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
ptrkrysike518bbf2014-11-06 14:50:59 +01001060
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001061 d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_51);
1062 d_channel_conf.set_burst_types(TIMESLOT4, TEST51,
1063 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotrf2b6a1b2014-08-04 11:28:59 +02001064
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001065 d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_51);
1066 d_channel_conf.set_burst_types(TIMESLOT5, TEST51,
1067 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotr437f5462014-02-04 17:57:25 +01001068
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001069 d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_51);
1070 d_channel_conf.set_burst_types(TIMESLOT6, TEST51,
1071 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
1072
1073 d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_51);
1074 d_channel_conf.set_burst_types(TIMESLOT7, TEST51,
1075 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
1076 }
1077
1078 void
1079 receiver_impl::set_cell_allocation(
1080 const std::vector<int> &cell_allocation)
1081 {
1082 d_cell_allocation = cell_allocation;
1083 }
1084
1085 void
1086 receiver_impl::set_tseq_nums(const std::vector<int> &tseq_nums)
1087 {
1088 d_tseq_nums = tseq_nums;
1089 }
1090
1091 void
1092 receiver_impl::reset(void)
1093 {
1094 d_state = fcch_search;
1095 }
1096
1097 } /* namespace gsm */
piotr437f5462014-02-04 17:57:25 +01001098} /* namespace gr */