blob: c7626b5a445af45693ca89fc8d881b73f0c27fc2 [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
Piotr Krysika6268a52017-08-23 16:02:19 +02004 * @author (C) 2009-2017 by Piotr Krysik <ptrkrysik@gmail.com>
ptrkrysik529895b2014-12-02 18:07:38 +01005 * @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>
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070034#include <vector>
ptrkrysik3be74a72014-12-13 10:11:00 +010035
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070036#include <boost/circular_buffer.hpp>
37#include <boost/scoped_ptr.hpp>
ptrkrysik3be74a72014-12-13 10:11:00 +010038#include <grgsm/endian.h>
ptrkrysik58213792014-10-30 09:05:15 +010039
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070040#include "receiver_impl.h"
41#include "viterbi_detector.h"
42#include "sch.h"
43
44#if 0
45/* Files included for debuging */
46#include "plotting/plotting.hpp"
47#include <pthread.h>
48#include <iomanip>
49#endif
piotr437f5462014-02-04 17:57:25 +010050
51#define SYNC_SEARCH_RANGE 30
52
piotrd0bf1492014-02-05 17:27:32 +010053namespace gr
54{
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070055 namespace gsm
56 {
piotrd0bf1492014-02-05 17:27:32 +010057
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070058 /* The public constructor */
59 receiver::sptr
60 receiver::make(
61 int osr, const std::vector<int> &cell_allocation,
62 const std::vector<int> &tseq_nums, bool process_uplink)
piotr437f5462014-02-04 17:57:25 +010063 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070064 return gnuradio::get_initial_sptr
65 (new receiver_impl(osr, cell_allocation,
66 tseq_nums, process_uplink));
piotr437f5462014-02-04 17:57:25 +010067 }
68
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070069 /* The private constructor */
70 receiver_impl::receiver_impl(
71 int osr, const std::vector<int> &cell_allocation,
72 const std::vector<int> &tseq_nums, bool process_uplink
73 ) : gr::sync_block("receiver",
74 gr::io_signature::make(1, -1, sizeof(gr_complex)),
75 gr::io_signature::make(0, 0, 0)),
76 d_OSR(osr),
77 d_process_uplink(process_uplink),
78 d_chan_imp_length(CHAN_IMP_RESP_LENGTH),
79 d_counter(0),
80 d_fcch_start_pos(0),
81 d_freq_offset_setting(0),
82 d_state(fcch_search),
83 d_burst_nr(osr),
84 d_failed_sch(0),
85 d_signal_dbm(-120),
86 d_tseq_nums(tseq_nums),
87 d_cell_allocation(cell_allocation),
88 d_last_time(0.0)
ptrkrysik32c21162015-04-04 14:01:52 +020089 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +070090 /**
91 * Don't send samples to the receiver
92 * until there are at least samples for one
93 */
94 set_output_multiple(floor((TS_BITS + 2 * GUARD_PERIOD) * d_OSR));
95
96 /**
97 * Prepare SCH sequence bits
98 *
99 * (TS_BITS + 2 * GUARD_PERIOD)
100 * Burst and two guard periods
101 * (one guard period is an arbitrary overlap)
102 */
103 gmsk_mapper(SYNC_BITS, N_SYNC_BITS,
104 d_sch_training_seq, gr_complex(0.0, -1.0));
105
106 /* Prepare bits of training sequences */
107 for (int i = 0; i < TRAIN_SEQ_NUM; i++) {
108 /**
109 * If first bit of the sequence is 0
110 * => first symbol is 1, else -1
111 */
112 gr_complex startpoint = train_seq[i][0] == 0 ?
113 gr_complex(1.0, 0.0) : gr_complex(-1.0, 0.0);
114 gmsk_mapper(train_seq[i], N_TRAIN_BITS,
115 d_norm_training_seq[i], startpoint);
116 }
117
118 /* Register output ports */
119 message_port_register_out(pmt::mp("C0"));
120 message_port_register_out(pmt::mp("CX"));
121 message_port_register_out(pmt::mp("measurements"));
122
123 /**
124 * Configure the receiver,
125 * i.e. tell it where to find which burst type
126 */
127 configure_receiver();
128 }
129
130 /* Our virtual destructor */
131 receiver_impl::~receiver_impl() {}
132
133 int
134 receiver_impl::work(
135 int noutput_items,
136 gr_vector_const_void_star &input_items,
137 gr_vector_void_star &output_items)
138 {
139 gr_complex *input = (gr_complex *) input_items[0];
140 uint64_t start = nitems_read(0);
141 uint64_t stop = start + noutput_items;
142 d_freq_offset_tag_in_fcch = false;
143
144#if 0
145 /* FIXME: jak zrobić to rzutowanie poprawnie */
146 std::vector<const gr_complex *> iii =
147 (std::vector<const gr_complex *>) input_items;
148#endif
149
150 /* Time synchronization loop */
151 float current_time =
152 static_cast<float>(start / (GSM_SYMBOL_RATE * d_OSR));
153 if ((current_time - d_last_time) > 0.1) {
154 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("current_time"),
155 pmt::from_double(current_time));
ptrkrysik32c21162015-04-04 14:01:52 +0200156 message_port_pub(pmt::mp("measurements"), msg);
157 d_last_time = current_time;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700158 }
ptrkrysik32c21162015-04-04 14:01:52 +0200159
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700160 /* Frequency correction loop */
161 std::vector<tag_t> freq_offset_tags;
162 pmt::pmt_t key = pmt::string_to_symbol("setting_freq_offset");
163 get_tags_in_range(freq_offset_tags, 0, start, stop, key);
164
165 if (!freq_offset_tags.empty()) {
piotr4089c1a2014-08-06 14:10:56 +0200166 tag_t freq_offset_tag = freq_offset_tags[0];
Piotr Krysik43af70d2016-07-20 21:37:24 +0200167 uint64_t tag_offset = freq_offset_tag.offset - start;
Piotr Krysik43af70d2016-07-20 21:37:24 +0200168 d_freq_offset_setting = pmt::to_double(freq_offset_tag.value);
piotr4089c1a2014-08-06 14:10:56 +0200169
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700170 burst_type b_type = d_channel_conf.get_burst_type(d_burst_nr);
171 if (d_state == synchronized && b_type == fcch_burst){
172 uint64_t last_sample_nr =
173 ceil((GUARD_PERIOD + 2.0 * TAIL_BITS + 156.25) * d_OSR) + 1;
174 d_freq_offset_tag_in_fcch = tag_offset < last_sample_nr;
piotrd0bf1492014-02-05 17:27:32 +0100175 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700176 }
177
178 /* Main state machine */
179 switch (d_state) {
180 case fcch_search:
181 fcch_search_handler(input, noutput_items);
piotrd0bf1492014-02-05 17:27:32 +0100182 break;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700183 case sch_search:
184 sch_search_handler(input, noutput_items);
piotrd0bf1492014-02-05 17:27:32 +0100185 break;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700186 case synchronized:
187 synchronized_handler(input, input_items, noutput_items);
188 break;
189 }
190
191 return 0;
piotrd0bf1492014-02-05 17:27:32 +0100192 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700193
194 void
195 receiver_impl::fcch_search_handler(gr_complex *input, int noutput_items)
piotrd0bf1492014-02-05 17:27:32 +0100196 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700197 double freq_offset_tmp;
ptrkrysik58213792014-10-30 09:05:15 +0100198
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700199 /* Check if received samples is a FCCN burst */
200 if (!find_fcch_burst(input, noutput_items, freq_offset_tmp))
201 return;
piotr437f5462014-02-04 17:57:25 +0100202
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700203 /* We found it, compose a message */
204 pmt::pmt_t msg = pmt::make_tuple(
205 pmt::mp("freq_offset"),
206 pmt::from_double(freq_offset_tmp - d_freq_offset_setting),
207 pmt::mp("fcch_search")
208 );
Piotr Krysik9bc0fc02017-01-18 21:53:17 +0100209
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700210 /* Notify FCCH loop */
211 message_port_pub(pmt::mp("measurements"), msg);
212
213 /* Update current state */
214 d_state = sch_search;
piotrd0bf1492014-02-05 17:27:32 +0100215 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700216
217 void
218 receiver_impl::sch_search_handler(gr_complex *input, int noutput_items)
219 {
220 std::vector<gr_complex> channel_imp_resp(CHAN_IMP_RESP_LENGTH * d_OSR);
221 unsigned char burst_buf[BURST_SIZE];
222 int rc, t1, t2, t3;
223 int burst_start;
224
225 /* Wait until we get a SCH burst */
226 if (!reach_sch_burst(noutput_items))
227 return;
228
229 /* Get channel impulse response from it */
230 burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]);
231
232 /* Detect bits using MLSE detection */
233 detect_burst(input, &channel_imp_resp[0], burst_start, burst_buf);
234
235 /* Attempt to decode BSIC and frame number */
236 rc = decode_sch(&burst_buf[3], &t1, &t2, &t3, &d_ncc, &d_bcc);
237 if (rc) {
238 /**
239 * There is error in the SCH burst,
240 * go back to the FCCH search state
241 */
242 d_state = fcch_search;
243 return;
244 }
245
246 /* Set counter of bursts value */
247 d_burst_nr.set(t1, t2, t3, 0);
248 d_burst_nr++;
249
250 /* Consume samples up to the next guard period */
251 consume_each(burst_start + BURST_SIZE * d_OSR + 4 * d_OSR);
252
253 /* Update current state */
254 d_state = synchronized;
piotr437f5462014-02-04 17:57:25 +0100255 }
piotr437f5462014-02-04 17:57:25 +0100256
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700257 void
258 receiver_impl::synchronized_handler(gr_complex *input,
259 gr_vector_const_void_star &input_items, int noutput_items)
piotr437f5462014-02-04 17:57:25 +0100260 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700261 /**
262 * In this state receiver is synchronized and it processes
263 * bursts according to burst type for given burst number
264 */
265 std::vector<gr_complex> channel_imp_resp(CHAN_IMP_RESP_LENGTH * d_OSR);
Piotr Krysik3b116892018-02-27 08:43:30 +0100266 size_t inputs_to_process = d_cell_allocation.size();
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700267 unsigned char output_binary[BURST_SIZE];
268 burst_type b_type;
269 int to_consume = 0;
270 int offset = 0;
piotr437f5462014-02-04 17:57:25 +0100271
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700272 if (d_process_uplink)
273 inputs_to_process *= 2;
piotr437f5462014-02-04 17:57:25 +0100274
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700275 /* Process all connected inputs */
Piotr Krysik3b116892018-02-27 08:43:30 +0100276 for (size_t input_nr = 0; input_nr < inputs_to_process; input_nr++) {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700277 input = (gr_complex *) input_items[input_nr];
278 double signal_pwr = 0;
279
280 for (int ii = GUARD_PERIOD; ii < TS_BITS; ii++)
281 signal_pwr += abs(input[ii]) * abs(input[ii]);
282
283 signal_pwr = signal_pwr / (TS_BITS);
284 d_signal_dbm = round(10 * log10(signal_pwr / 50));
285
286 if (input_nr == 0)
287 d_c0_signal_dbm = d_signal_dbm;
288
289 /* Get burst type for given burst number */
290 b_type = input_nr == 0 ?
291 d_channel_conf.get_burst_type(d_burst_nr) : normal_or_noise;
292
293 /* Process burst according to its type */
294 switch (b_type) {
295 case fcch_burst:
piotrd0bf1492014-02-05 17:27:32 +0100296 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700297 if (d_freq_offset_tag_in_fcch)
piotr437f5462014-02-04 17:57:25 +0100298 break;
299
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700300 /* Send all-zero sequence message */
301 send_burst(d_burst_nr, fc_fb, GSMTAP_BURST_FCCH, input_nr);
piotr437f5462014-02-04 17:57:25 +0100302
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700303 /* Extract frequency offset */
304 const unsigned first_sample =
305 ceil((GUARD_PERIOD + 2 * TAIL_BITS) * d_OSR) + 1;
306 const unsigned last_sample =
307 first_sample + USEFUL_BITS * d_OSR - TAIL_BITS * d_OSR;
308 double freq_offset_tmp =
309 compute_freq_offset(input, first_sample, last_sample);
piotr437f5462014-02-04 17:57:25 +0100310
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700311 /* Frequency correction loop */
312 pmt::pmt_t msg = pmt::make_tuple(
313 pmt::mp("freq_offset"),
314 pmt::from_double(freq_offset_tmp - d_freq_offset_setting),
315 pmt::mp("synchronized"));
316 message_port_pub(pmt::mp("measurements"), msg);
317
318 break;
319 }
320
321 case sch_burst:
322 {
323 int d_ncc, d_bcc;
324 int t1, t2, t3;
325 int rc;
326
327 /* Get channel impulse response */
328 d_c0_burst_start = get_sch_chan_imp_resp(input,
329 &channel_imp_resp[0]);
330
331 /* Perform MLSE detection */
332 detect_burst(input, &channel_imp_resp[0],
333 d_c0_burst_start, output_binary);
334
335 /* Compose a message with GSMTAP header and bits */
336 send_burst(d_burst_nr, output_binary,
337 GSMTAP_BURST_SCH, input_nr);
338
339 /* Attempt to decode SCH burst */
340 rc = decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc);
341 if (rc) {
342 if (++d_failed_sch >= MAX_SCH_ERRORS) {
343 /* We have to resynchronize, change state */
344 d_state = fcch_search;
345
346 /* Frequency correction loop */
347 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),
348 pmt::from_double(0.0),pmt::mp("sync_loss"));
349 message_port_pub(pmt::mp("measurements"), msg);
piotr437f5462014-02-04 17:57:25 +0100350 }
351
352 break;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700353 }
piotr437f5462014-02-04 17:57:25 +0100354
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700355 /**
356 * Decoding was successful, now
357 * compute offset from burst_start,
358 * burst should start after a guard period.
359 */
360 offset = d_c0_burst_start - floor((GUARD_PERIOD) * d_OSR);
361 to_consume += offset;
362 d_failed_sch = 0;
piotr437f5462014-02-04 17:57:25 +0100363
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700364 break;
piotrd0bf1492014-02-05 17:27:32 +0100365 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700366
367 case normal_burst:
368 {
369 float normal_corr_max;
370 /**
371 * Get channel impulse response for given
372 * training sequence number - d_bcc
373 */
374 d_c0_burst_start = get_norm_chan_imp_resp(input,
375 &channel_imp_resp[0], &normal_corr_max, d_bcc);
376
377 /* Perform MLSE detection */
378 detect_burst(input, &channel_imp_resp[0],
379 d_c0_burst_start, output_binary);
380
381 /* Compose a message with GSMTAP header and bits */
382 send_burst(d_burst_nr, output_binary,
383 GSMTAP_BURST_NORMAL, input_nr);
384
385 break;
386 }
387
388 case dummy_or_normal:
389 {
390 unsigned int normal_burst_start, dummy_burst_start;
391 float dummy_corr_max, normal_corr_max;
392
393 dummy_burst_start = get_norm_chan_imp_resp(input,
394 &channel_imp_resp[0], &dummy_corr_max, TS_DUMMY);
395 normal_burst_start = get_norm_chan_imp_resp(input,
396 &channel_imp_resp[0], &normal_corr_max, d_bcc);
397
398 if (normal_corr_max > dummy_corr_max) {
399 d_c0_burst_start = normal_burst_start;
400
401 /* Perform MLSE detection */
402 detect_burst(input, &channel_imp_resp[0],
403 normal_burst_start, output_binary);
404
405 /* Compose a message with GSMTAP header and bits */
406 send_burst(d_burst_nr, output_binary,
407 GSMTAP_BURST_NORMAL, input_nr);
408 } else {
409 d_c0_burst_start = dummy_burst_start;
410
411 /* Compose a message with GSMTAP header and bits */
412 send_burst(d_burst_nr, dummy_burst,
413 GSMTAP_BURST_DUMMY, input_nr);
414 }
415
416 break;
417 }
418
419 case normal_or_noise:
420 {
421 std::vector<gr_complex> v(input, input + noutput_items);
422 float normal_corr_max = -1e6;
Piotr Krysik3b116892018-02-27 08:43:30 +0100423// float normal_corr_max_tmp;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700424 unsigned int burst_start;
425 int max_tn, tseq_num;
426
427 if (d_tseq_nums.size() == 0) {
428 /**
429 * There is no information about training sequence,
430 * however the receiver can detect it with use of a
431 * very simple algorithm based on finding
432 */
433 get_norm_chan_imp_resp(input, &channel_imp_resp[0],
434 &normal_corr_max, 0);
435
436 float ts_max = normal_corr_max;
437 int ts_max_num = 0;
438
439 for (int ss = 1; ss <= 7; ss++) {
440 get_norm_chan_imp_resp(input, &channel_imp_resp[0],
441 &normal_corr_max, ss);
442
443 if (ts_max < normal_corr_max) {
444 ts_max = normal_corr_max;
445 ts_max_num = ss;
446 }
447 }
448
449 d_tseq_nums.push_back(ts_max_num);
450 }
451
452 /* Choose proper training sequence number */
453 tseq_num = input_nr <= d_tseq_nums.size() ?
454 d_tseq_nums[input_nr - 1] : d_tseq_nums.back();
455
456 /* Get channel impulse response */
457 burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0],
458 &normal_corr_max, tseq_num);
459
460 /* Perform MLSE detection */
461 detect_burst(input, &channel_imp_resp[0],
462 burst_start, output_binary);
463
464 /* Compose a message with GSMTAP header and bits */
465 send_burst(d_burst_nr, output_binary, GSMTAP_BURST_NORMAL, input_nr);
466
467 break;
468 }
469
470 case dummy:
471 send_burst(d_burst_nr, dummy_burst, GSMTAP_BURST_DUMMY, input_nr);
472 break;
473
474 case rach_burst:
475 case empty:
476 /* Do nothing */
477 break;
478 }
479
480 if (input_nr == input_items.size() - 1) {
481 /* Go to the next burst */
482 d_burst_nr++;
483
484 /* Consume samples of the burst up to next guard period */
485 to_consume += TS_BITS * d_OSR + d_burst_nr.get_offset();
486 consume_each(to_consume);
487 }
488 }
489 }
490
491 bool
492 receiver_impl::find_fcch_burst(const gr_complex *input,
493 const int nitems, double &computed_freq_offset)
494 {
495 /* Circular buffer used to scan through signal to find */
496 boost::circular_buffer<float>
497 phase_diff_buffer(FCCH_HITS_NEEDED * d_OSR);
498 boost::circular_buffer<float>::iterator buffer_iter;
499
500 float lowest_max_min_diff;
501 float phase_diff; /* Best match for FCCH burst */
502 float min_phase_diff;
503 float max_phase_diff;
504 double best_sum = 0;
505 gr_complex conjprod;
506 int start_pos;
507 int hit_count;
508 int miss_count;
509
510 int sample_number = 0;
511 int to_consume = 0;
512 bool result = false;
513 bool end = false;
514
515 /* Possible states of FCCH search algorithm */
516 enum states
517 {
518 init, /* initialize variables */
519 search, /* search for positive samples */
520 found_something, /* search for FCCH and the best position of it */
521 fcch_found, /* when FCCH was found */
522 search_fail /* when there is no FCCH in the input vector */
523 } fcch_search_state;
524
525 /* Set initial state */
526 fcch_search_state = init;
527
528 while (!end)
529 {
530 switch (fcch_search_state) {
531 case init:
532 {
533 hit_count = 0;
534 miss_count = 0;
535 start_pos = -1;
536 lowest_max_min_diff = 99999;
537 phase_diff_buffer.clear();
538
539 /* Change current state */
540 fcch_search_state = search;
541
542 break;
543 }
544
545 case search:
546 {
547 sample_number++;
548
549 if (sample_number > nitems - FCCH_HITS_NEEDED * d_OSR) {
550 /**
551 * If it isn't possible to find FCCH, because
552 * there is too few samples left to look into,
553 * don't do anything with those samples which are left
554 * and consume only those which were checked
555 */
556 to_consume = sample_number;
557 fcch_search_state = search_fail;
558 break;
559 }
560
561 phase_diff = compute_phase_diff(input[sample_number],
562 input[sample_number - 1]);
563
564 /**
565 * If a positive phase difference was found
566 * switch to state in which searches for FCCH
567 */
568 if (phase_diff > 0) {
569 to_consume = sample_number;
570 fcch_search_state = found_something;
571 } else {
572 fcch_search_state = search;
573 }
574
575 break;
576 }
577
578 case found_something:
579 {
580 if (phase_diff > 0)
581 hit_count++;
582 else
583 miss_count++;
584
585 if ((miss_count >= FCCH_MAX_MISSES * d_OSR)
586 && (hit_count <= FCCH_HITS_NEEDED * d_OSR))
587 {
588 /* If miss_count exceeds limit before hit_count */
589 fcch_search_state = init;
590 continue;
591 }
592
593 if (((miss_count >= FCCH_MAX_MISSES * d_OSR)
594 && (hit_count > FCCH_HITS_NEEDED * d_OSR))
595 || (hit_count > 2 * FCCH_HITS_NEEDED * d_OSR))
596 {
597 /**
598 * If hit_count and miss_count exceeds
599 * limit then FCCH was found
600 */
601 fcch_search_state = fcch_found;
602 continue;
603 }
604
605 if ((miss_count < FCCH_MAX_MISSES * d_OSR)
606 && (hit_count > FCCH_HITS_NEEDED * d_OSR))
607 {
608 /**
609 * Find difference between minimal and maximal
610 * element in the buffer. For FCCH this value
611 * should be low. This part is searching for
612 * a region where this value is lowest.
613 */
614 min_phase_diff = *(min_element(phase_diff_buffer.begin(),
615 phase_diff_buffer.end()));
616 max_phase_diff = *(max_element(phase_diff_buffer.begin(),
617 phase_diff_buffer.end()));
618
619 if (lowest_max_min_diff > max_phase_diff - min_phase_diff) {
620 lowest_max_min_diff = max_phase_diff - min_phase_diff;
621 start_pos = sample_number - FCCH_HITS_NEEDED
622 * d_OSR - FCCH_MAX_MISSES * d_OSR;
623 best_sum = 0;
624
625 for (buffer_iter = phase_diff_buffer.begin();
626 buffer_iter != (phase_diff_buffer.end());
627 buffer_iter++) {
628 /* Store best value of phase offset sum */
629 best_sum += *buffer_iter - (M_PI / 2) / d_OSR;
630 }
631 }
632 }
633
634 /* If there is no single sample left to check */
635 if (++sample_number >= nitems) {
636 fcch_search_state = search_fail;
637 continue;
638 }
639
640 phase_diff = compute_phase_diff(input[sample_number],
641 input[sample_number-1]);
642 phase_diff_buffer.push_back(phase_diff);
643 fcch_search_state = found_something;
644
645 break;
646 }
piotrd0bf1492014-02-05 17:27:32 +0100647
648 case fcch_found:
649 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700650 /* Consume one FCCH burst */
651 to_consume = start_pos + FCCH_HITS_NEEDED * d_OSR + 1;
652 d_fcch_start_pos = d_counter + start_pos;
piotrd0bf1492014-02-05 17:27:32 +0100653
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700654 /**
655 * Compute frequency offset
656 *
657 * 1625000.0 / 6 - GMSK symbol rate in GSM
658 */
659 double phase_offset = best_sum / FCCH_HITS_NEEDED;
660 double freq_offset = phase_offset * 1625000.0 / 6 / (2 * M_PI);
661 computed_freq_offset = freq_offset;
piotrd0bf1492014-02-05 17:27:32 +0100662
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700663 end = true;
664 result = true;
piotrd0bf1492014-02-05 17:27:32 +0100665
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700666 break;
piotrd0bf1492014-02-05 17:27:32 +0100667 }
piotr437f5462014-02-04 17:57:25 +0100668
piotrd0bf1492014-02-05 17:27:32 +0100669 case search_fail:
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700670 end = true;
671 result = false;
672 break;
piotr437f5462014-02-04 17:57:25 +0100673 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700674 }
675
676 d_counter += to_consume;
677 consume_each(to_consume);
678
679 return result;
piotr437f5462014-02-04 17:57:25 +0100680 }
681
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700682 double
683 receiver_impl::compute_freq_offset(const gr_complex * input,
684 unsigned first_sample, unsigned last_sample)
Piotr Krysik654d6522017-01-23 21:53:48 +0100685 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700686 double phase_sum = 0;
687 unsigned ii;
688
689 for (ii = first_sample; ii < last_sample; ii++)
690 {
691 double phase_diff = compute_phase_diff(input[ii],
692 input[ii-1]) - (M_PI / 2) / d_OSR;
Piotr Krysik654d6522017-01-23 21:53:48 +0100693 phase_sum += phase_diff;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700694 }
695
696 double phase_offset = phase_sum / (last_sample - first_sample);
697 double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI);
698
699 return freq_offset;
Piotr Krysik654d6522017-01-23 21:53:48 +0100700 }
701
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700702 inline float
703 receiver_impl::compute_phase_diff(gr_complex val1, gr_complex val2)
piotrd0bf1492014-02-05 17:27:32 +0100704 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700705 gr_complex conjprod = val1 * conj(val2);
706 return fast_atan2f(imag(conjprod), real(conjprod));
piotrd0bf1492014-02-05 17:27:32 +0100707 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700708
709 bool
710 receiver_impl::reach_sch_burst(const int nitems)
piotrd0bf1492014-02-05 17:27:32 +0100711 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700712 /* It just consumes samples to get near to a SCH burst */
713 int to_consume = 0;
714 bool result = false;
715 unsigned sample_nr = d_fcch_start_pos
716 + (FRAME_BITS - SAFETY_MARGIN) * d_OSR;
717
718 /* Consume samples until d_counter will be equal to sample_nr */
719 if (d_counter < sample_nr) {
720 to_consume = d_counter + nitems >= sample_nr ?
721 sample_nr - d_counter : nitems;
722 } else {
piotr437f5462014-02-04 17:57:25 +0100723 to_consume = 0;
724 result = true;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700725 }
726
727 d_counter += to_consume;
728 consume_each(to_consume);
729
730 return result;
piotr437f5462014-02-04 17:57:25 +0100731 }
732
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700733 int
734 receiver_impl::get_sch_chan_imp_resp(const gr_complex *input,
735 gr_complex * chan_imp_resp)
piotr437f5462014-02-04 17:57:25 +0100736 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700737 std::vector<gr_complex> correlation_buffer;
738 std::vector<float> window_energy_buffer;
739 std::vector<float> power_buffer;
740
741 int chan_imp_resp_center = 0;
742 int strongest_window_nr;
743 int burst_start;
744 float energy = 0;
745
746 int len = (SYNC_POS + SYNC_SEARCH_RANGE) * d_OSR;
747 for (int ii = SYNC_POS * d_OSR; ii < len; ii++) {
748 gr_complex correlation = correlate_sequence(&d_sch_training_seq[5],
749 N_SYNC_BITS - 10, &input[ii]);
piotr437f5462014-02-04 17:57:25 +0100750 correlation_buffer.push_back(correlation);
751 power_buffer.push_back(std::pow(abs(correlation), 2));
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700752 }
753
754 /* Compute window energies */
755 std::vector<float>::iterator iter = power_buffer.begin();
756 while (iter != power_buffer.end()) {
ptrkrysikef5e2db2015-01-03 12:10:14 +0100757 std::vector<float>::iterator iter_ii = iter;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700758 bool loop_end = false;
piotr437f5462014-02-04 17:57:25 +0100759 energy = 0;
760
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700761 for (int ii = 0; ii < (d_chan_imp_length) * d_OSR; ii++, iter_ii++) {
762 if (iter_ii == power_buffer.end()) {
763 loop_end = true;
piotrd0bf1492014-02-05 17:27:32 +0100764 break;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700765 }
766
767 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100768 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700769
770 if (loop_end)
771 break;
772
piotr437f5462014-02-04 17:57:25 +0100773 window_energy_buffer.push_back(energy);
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700774 iter++;
775 }
piotr437f5462014-02-04 17:57:25 +0100776
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700777 strongest_window_nr = max_element(window_energy_buffer.begin(),
778 window_energy_buffer.end()) - window_energy_buffer.begin();
piotr437f5462014-02-04 17:57:25 +0100779
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700780#if 0
781 d_channel_imp_resp.clear();
782#endif
783
784 float max_correlation = 0;
785 for (int ii = 0; ii < (d_chan_imp_length) * d_OSR; ii++) {
piotr437f5462014-02-04 17:57:25 +0100786 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700787 if (abs(correlation) > max_correlation) {
788 chan_imp_resp_center = ii;
789 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100790 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700791
792#if 0
793 d_channel_imp_resp.push_back(correlation);
794#endif
795
piotr437f5462014-02-04 17:57:25 +0100796 chan_imp_resp[ii] = correlation;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700797 }
798
799 burst_start = strongest_window_nr + chan_imp_resp_center
800 - 48 * d_OSR - 2 * d_OSR + 2 + SYNC_POS * d_OSR;
801 return burst_start;
piotr437f5462014-02-04 17:57:25 +0100802 }
803
804
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700805 void
806 receiver_impl::detect_burst(const gr_complex * input,
807 gr_complex * chan_imp_resp, int burst_start,
808 unsigned char * output_binary)
piotr437f5462014-02-04 17:57:25 +0100809 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700810 std::vector<gr_complex> rhh_temp(CHAN_IMP_RESP_LENGTH * d_OSR);
811 unsigned int stop_states[2] = {4, 12};
812 gr_complex filtered_burst[BURST_SIZE];
813 gr_complex rhh[CHAN_IMP_RESP_LENGTH];
814 float output[BURST_SIZE];
815 int start_state = 3;
816
817 autocorrelation(chan_imp_resp, &rhh_temp[0], d_chan_imp_length*d_OSR);
818 for (int ii = 0; ii < d_chan_imp_length; ii++)
piotr437f5462014-02-04 17:57:25 +0100819 rhh[ii] = conj(rhh_temp[ii*d_OSR]);
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700820
821 mafi(&input[burst_start], BURST_SIZE, chan_imp_resp,
822 d_chan_imp_length * d_OSR, filtered_burst);
823
824 viterbi_detector(filtered_burst, BURST_SIZE, rhh,
825 start_state, stop_states, 2, output);
826
827 for (int i = 0; i < BURST_SIZE; i++)
828 output_binary[i] = output[i] > 0;
piotr437f5462014-02-04 17:57:25 +0100829 }
830
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700831 void
832 receiver_impl::gmsk_mapper(const unsigned char * input,
833 int nitems, gr_complex * gmsk_output, gr_complex start_point)
piotr437f5462014-02-04 17:57:25 +0100834 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700835 gr_complex j = gr_complex(0.0, 1.0);
836 gmsk_output[0] = start_point;
piotr437f5462014-02-04 17:57:25 +0100837
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700838 int previous_symbol = 2 * input[0] - 1;
839 int current_symbol;
840 int encoded_symbol;
piotr437f5462014-02-04 17:57:25 +0100841
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700842 for (int i = 1; i < nitems; i++) {
843 /* Change bits representation to NRZ */
piotr437f5462014-02-04 17:57:25 +0100844 current_symbol = 2 * input[i] - 1;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700845
846 /* Differentially encode */
piotr437f5462014-02-04 17:57:25 +0100847 encoded_symbol = current_symbol * previous_symbol;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700848
849 /* And do GMSK mapping */
850 gmsk_output[i] = j * gr_complex(encoded_symbol, 0.0)
851 * gmsk_output[i-1];
852
piotr437f5462014-02-04 17:57:25 +0100853 previous_symbol = current_symbol;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700854 }
piotr437f5462014-02-04 17:57:25 +0100855 }
856
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700857 gr_complex
858 receiver_impl::correlate_sequence(const gr_complex * sequence,
859 int length, const gr_complex * input)
piotr437f5462014-02-04 17:57:25 +0100860 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700861 gr_complex result(0.0, 0.0);
862
863 for (int ii = 0; ii < length; ii++)
864 result += sequence[ii] * conj(input[ii * d_OSR]);
865
866 return result / gr_complex(length, 0);
867 }
868
869 /* Computes autocorrelation for positive arguments */
870 inline void
871 receiver_impl::autocorrelation(const gr_complex * input,
872 gr_complex * out, int nitems)
873 {
874 for (int k = nitems - 1; k >= 0; k--) {
piotr437f5462014-02-04 17:57:25 +0100875 out[k] = gr_complex(0, 0);
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700876 for (int i = k; i < nitems; i++)
877 out[k] += input[i] * conj(input[i - k]);
878 }
piotr437f5462014-02-04 17:57:25 +0100879 }
880
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700881 inline void
882 receiver_impl::mafi(const gr_complex * input, int nitems,
883 gr_complex * filter, int filter_length, gr_complex * output)
piotr437f5462014-02-04 17:57:25 +0100884 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700885 for (int n = 0; n < nitems; n++) {
886 int a = n * d_OSR;
piotr437f5462014-02-04 17:57:25 +0100887 output[n] = 0;
piotr437f5462014-02-04 17:57:25 +0100888
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700889 for (int ii = 0; ii < filter_length; ii++) {
890 if ((a + ii) >= nitems * d_OSR)
piotrd0bf1492014-02-05 17:27:32 +0100891 break;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700892
893 output[n] += input[a + ii] * filter[ii];
piotr437f5462014-02-04 17:57:25 +0100894 }
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700895 }
896 }
897
898 /* Especially computations of strongest_window_nr */
899 int
900 receiver_impl::get_norm_chan_imp_resp(const gr_complex *input,
901 gr_complex *chan_imp_resp, float *corr_max, int bcc)
902 {
903 std::vector<gr_complex> correlation_buffer;
904 std::vector<float> window_energy_buffer;
905 std::vector<float> power_buffer;
906
907 int search_center = (int) (TRAIN_POS + GUARD_PERIOD) * d_OSR;
908 int search_start_pos = search_center + 1 - 5 * d_OSR;
909 int search_stop_pos = search_center
910 + d_chan_imp_length * d_OSR + 5 * d_OSR;
911
912 for (int ii = search_start_pos; ii < search_stop_pos; ii++) {
913 gr_complex correlation = correlate_sequence(
914 &d_norm_training_seq[bcc][TRAIN_BEGINNING],
915 N_TRAIN_BITS - 10, &input[ii]);
916 correlation_buffer.push_back(correlation);
917 power_buffer.push_back(std::pow(abs(correlation), 2));
918 }
919
920#if 0
921 plot(power_buffer);
922#endif
923
924 /* Compute window energies */
925 std::vector<float>::iterator iter = power_buffer.begin();
926 while (iter != power_buffer.end()) {
927 std::vector<float>::iterator iter_ii = iter;
928 bool loop_end = false;
929 float energy = 0;
930
931 int len = d_chan_imp_length * d_OSR;
932 for (int ii = 0; ii < len; ii++, iter_ii++) {
933 if (iter_ii == power_buffer.end()) {
934 loop_end = true;
935 break;
936 }
937
938 energy += (*iter_ii);
939 }
940
941 if (loop_end)
942 break;
piotr437f5462014-02-04 17:57:25 +0100943
944 window_energy_buffer.push_back(energy);
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700945 iter++;
946 }
piotr437f5462014-02-04 17:57:25 +0100947
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700948 /* Calculate the strongest window number */
949 int strongest_window_nr = max_element(window_energy_buffer.begin(),
950 window_energy_buffer.end() - d_chan_imp_length * d_OSR)
951 - window_energy_buffer.begin();
952
953 if (strongest_window_nr < 0)
954 strongest_window_nr = 0;
955
956 float max_correlation = 0;
957 for (int ii = 0; ii < d_chan_imp_length * d_OSR; ii++) {
piotr437f5462014-02-04 17:57:25 +0100958 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100959 if (abs(correlation) > max_correlation)
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700960 max_correlation = abs(correlation);
961
962#if 0
963 d_channel_imp_resp.push_back(correlation);
964#endif
965
piotr437f5462014-02-04 17:57:25 +0100966 chan_imp_resp[ii] = correlation;
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700967 }
968
969 *corr_max = max_correlation;
970
971 /**
972 * Compute first sample position, which corresponds
973 * to the first sample of the impulse response
974 */
975 return search_start_pos + strongest_window_nr - TRAIN_POS * d_OSR;
piotr437f5462014-02-04 17:57:25 +0100976 }
977
978
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700979 void
980 receiver_impl::send_burst(burst_counter burst_nr,
981 const unsigned char * burst_binary, uint8_t burst_type,
Piotr Krysik3b116892018-02-27 08:43:30 +0100982 size_t input_nr)
ptrkrysik380dea82015-08-06 10:11:58 +0200983 {
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700984 /* Buffer for GSMTAP header and burst */
985 uint8_t buf[sizeof(gsmtap_hdr) + BURST_SIZE];
986 uint32_t frame_number;
987 uint16_t arfcn;
988 uint8_t tn;
ptrkrysik617ba032014-11-21 10:11:05 +0100989
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +0700990 /* Set pointers to GSMTAP header and burst inside buffer */
991 struct gsmtap_hdr *tap_header = (struct gsmtap_hdr *) buf;
992 uint8_t *burst = buf + sizeof(gsmtap_hdr);
993
994 tap_header->version = GSMTAP_VERSION;
995 tap_header->hdr_len = sizeof(gsmtap_hdr) / 4;
996 tap_header->type = GSMTAP_TYPE_UM_BURST;
997 tap_header->sub_type = burst_type;
998
999 bool dl_burst = !(input_nr >= d_cell_allocation.size());
1000 if (dl_burst) {
1001 tn = static_cast<uint8_t>(d_burst_nr.get_timeslot_nr());
1002 frame_number = htobe32(d_burst_nr.get_frame_nr());
1003 arfcn = htobe16(d_cell_allocation[input_nr]);
1004 } else {
1005 input_nr -= d_cell_allocation.size();
1006 tn = static_cast<uint8_t>
1007 (d_burst_nr.subtract_timeslots(3).get_timeslot_nr());
1008 frame_number = htobe32(
1009 d_burst_nr.subtract_timeslots(3).get_frame_nr());
1010 arfcn = htobe16(
1011 d_cell_allocation[input_nr] | GSMTAP_ARFCN_F_UPLINK);
1012 }
1013
1014 tap_header->frame_number = frame_number;
1015 tap_header->timeslot = tn;
1016 tap_header->arfcn = arfcn;
1017
1018 tap_header->signal_dbm = static_cast<int8_t>(d_signal_dbm);
1019 tap_header->snr_db = 0; /* FIXME: Can we calculate this? */
1020
1021 /* Copy burst to the buffer */
1022 memcpy(burst, burst_binary, BURST_SIZE);
1023
1024 /* Allocate a new message */
1025 pmt::pmt_t blob = pmt::make_blob(buf, sizeof(gsmtap_hdr) + BURST_SIZE);
1026 pmt::pmt_t msg = pmt::cons(pmt::PMT_NIL, blob);
1027
1028 /* Send message */
1029 if (input_nr == 0)
ptrkrysike518bbf2014-11-06 14:50:59 +01001030 message_port_pub(pmt::mp("C0"), msg);
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001031 else
ptrkrysike518bbf2014-11-06 14:50:59 +01001032 message_port_pub(pmt::mp("CX"), msg);
1033 }
piotr6d152d92014-02-21 00:02:44 +01001034
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001035 void
1036 receiver_impl::configure_receiver(void)
1037 {
1038 d_channel_conf.set_multiframe_type(TIMESLOT0, multiframe_51);
1039 d_channel_conf.set_burst_types(TIMESLOT0, TEST51,
1040 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
1041 d_channel_conf.set_burst_types(TIMESLOT0, TEST_CCH_FRAMES,
1042 sizeof(TEST_CCH_FRAMES) / sizeof(unsigned), dummy_or_normal);
1043 d_channel_conf.set_burst_types(TIMESLOT0, FCCH_FRAMES,
1044 sizeof(FCCH_FRAMES) / sizeof(unsigned), fcch_burst);
1045 d_channel_conf.set_burst_types(TIMESLOT0, SCH_FRAMES,
1046 sizeof(SCH_FRAMES) / sizeof(unsigned), sch_burst);
piotr437f5462014-02-04 17:57:25 +01001047
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001048 d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_51);
1049 d_channel_conf.set_burst_types(TIMESLOT1, TEST51,
1050 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotr437f5462014-02-04 17:57:25 +01001051
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001052 d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_51);
1053 d_channel_conf.set_burst_types(TIMESLOT2, TEST51,
1054 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotr437f5462014-02-04 17:57:25 +01001055
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001056 d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_51);
1057 d_channel_conf.set_burst_types(TIMESLOT3, TEST51,
1058 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
ptrkrysike518bbf2014-11-06 14:50:59 +01001059
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001060 d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_51);
1061 d_channel_conf.set_burst_types(TIMESLOT4, TEST51,
1062 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotrf2b6a1b2014-08-04 11:28:59 +02001063
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001064 d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_51);
1065 d_channel_conf.set_burst_types(TIMESLOT5, TEST51,
1066 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotr437f5462014-02-04 17:57:25 +01001067
Vadim Yanitskiycc82cf02017-07-24 19:21:02 +07001068 d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_51);
1069 d_channel_conf.set_burst_types(TIMESLOT6, TEST51,
1070 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
1071
1072 d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_51);
1073 d_channel_conf.set_burst_types(TIMESLOT7, TEST51,
1074 sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
1075 }
1076
1077 void
1078 receiver_impl::set_cell_allocation(
1079 const std::vector<int> &cell_allocation)
1080 {
1081 d_cell_allocation = cell_allocation;
1082 }
1083
1084 void
1085 receiver_impl::set_tseq_nums(const std::vector<int> &tseq_nums)
1086 {
1087 d_tseq_nums = tseq_nums;
1088 }
1089
1090 void
1091 receiver_impl::reset(void)
1092 {
1093 d_state = fcch_search;
1094 }
1095
1096 } /* namespace gsm */
piotr437f5462014-02-04 17:57:25 +01001097} /* namespace gr */