blob: de3438c0ccc579e9cc08ff404576d25c9a0920cf [file] [log] [blame]
piotr437f5462014-02-04 17:57:25 +01001/* -*- c++ -*- */
piotrd0bf1492014-02-05 17:27:32 +01002/*
piotrc1d47df2014-04-17 09:45:50 +02003 * Copyright 2014 Piotr Krysik <pkrysik@elka.pw.edu.pl>.
piotrd0bf1492014-02-05 17:27:32 +01004 *
piotr437f5462014-02-04 17:57:25 +01005 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
8 * any later version.
piotrd0bf1492014-02-05 17:27:32 +01009 *
piotr437f5462014-02-04 17:57:25 +010010 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
piotrd0bf1492014-02-05 17:27:32 +010014 *
piotr437f5462014-02-04 17:57:25 +010015 * You should have received a copy of the GNU General Public License
16 * along with this software; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifdef HAVE_CONFIG_H
22#include "config.h"
23#endif
24
25#include <gnuradio/io_signature.h>
26#include "receiver_impl.h"
27
28#include <gnuradio/io_signature.h>
29#include <gnuradio/math.h>
30#include <math.h>
31#include <boost/circular_buffer.hpp>
32#include <algorithm>
33#include <numeric>
34#include <viterbi_detector.h>
35#include <string.h>
36#include <sch.h>
37#include <iostream>
38#include <iomanip>
piotr437f5462014-02-04 17:57:25 +010039#include <assert.h>
piotr6d152d92014-02-21 00:02:44 +010040#include <boost/scoped_ptr.hpp>
ptrkrysik58213792014-10-30 09:05:15 +010041
42#include "plotting/plotting.hpp"
43#include <pthread.h>
piotr437f5462014-02-04 17:57:25 +010044
45#define SYNC_SEARCH_RANGE 30
46
piotrd0bf1492014-02-05 17:27:32 +010047namespace gr
48{
49namespace gsm
50{
piotr437f5462014-02-04 17:57:25 +010051
piotrd0bf1492014-02-05 17:27:32 +010052typedef std::list<float> list_float;
53typedef std::vector<float> vector_float;
piotr437f5462014-02-04 17:57:25 +010054
piotrd0bf1492014-02-05 17:27:32 +010055typedef boost::circular_buffer<float> circular_buffer_float;
piotr437f5462014-02-04 17:57:25 +010056
piotrd0bf1492014-02-05 17:27:32 +010057receiver::sptr
Piotr K608a08e2014-08-07 17:01:55 +020058receiver::make(int osr, int arfcn)
piotrd0bf1492014-02-05 17:27:32 +010059{
60 return gnuradio::get_initial_sptr
Piotr K608a08e2014-08-07 17:01:55 +020061 (new receiver_impl(osr, arfcn));
piotrd0bf1492014-02-05 17:27:32 +010062}
63
64/*
65 * The private constructor
66 */
Piotr K608a08e2014-08-07 17:01:55 +020067receiver_impl::receiver_impl(int osr, int arfcn)
piotrc7c249a2014-05-02 17:24:08 +020068 : gr::sync_block("receiver",
ptrkrysik58213792014-10-30 09:05:15 +010069 gr::io_signature::make(1, -1, sizeof(gr_complex)),
piotr7c82b172014-02-08 14:15:27 +010070 gr::io_signature::make(0, 0, 0)),
piotrd0bf1492014-02-05 17:27:32 +010071 d_OSR(osr),
72 d_chan_imp_length(CHAN_IMP_RESP_LENGTH),
piotrd0bf1492014-02-05 17:27:32 +010073 d_counter(0),
74 d_fcch_start_pos(0),
piotr4089c1a2014-08-06 14:10:56 +020075 d_freq_offset_setting(0),
piotrd6d66872014-08-06 15:20:33 +020076 d_state(fcch_search),
piotrd0bf1492014-02-05 17:27:32 +010077 d_burst_nr(osr),
piotr6d152d92014-02-21 00:02:44 +010078 d_failed_sch(0),
79 d_arfcn((int)(arfcn)),
80 d_signal_dbm(-120)
piotrd0bf1492014-02-05 17:27:32 +010081{
82 int i;
piotr4089c1a2014-08-06 14:10:56 +020083 //don't send samples to the receiver until there are at least samples for one
piotr7f3f3662014-07-08 16:47:53 +020084 set_output_multiple(floor((TS_BITS + 2 * GUARD_PERIOD) * d_OSR)); // burst and two gurad periods (one gurard period is an arbitrary overlap)
piotrd0bf1492014-02-05 17:27:32 +010085 gmsk_mapper(SYNC_BITS, N_SYNC_BITS, d_sch_training_seq, gr_complex(0.0, -1.0));
86 for (i = 0; i < TRAIN_SEQ_NUM; i++)
piotr437f5462014-02-04 17:57:25 +010087 {
piotrf502e0f2014-04-24 10:28:29 +020088 gr_complex startpoint = (train_seq[i][0]==0) ? gr_complex(1.0, 0.0) : gr_complex(-1.0, 0.0); //if first bit of the seqeunce ==0 first symbol ==1
piotr7f3f3662014-07-08 16:47:53 +020089 //if first bit of the seqeunce ==1 first symbol ==-1
piotr437f5462014-02-04 17:57:25 +010090 gmsk_mapper(train_seq[i], N_TRAIN_BITS, d_norm_training_seq[i], startpoint);
piotr437f5462014-02-04 17:57:25 +010091 }
piotr7c82b172014-02-08 14:15:27 +010092 message_port_register_out(pmt::mp("bursts"));
piotr4089c1a2014-08-06 14:10:56 +020093 message_port_register_out(pmt::mp("measurements"));
piotr903b1d62014-04-17 11:33:27 +020094 configure_receiver(); //configure the receiver - tell it where to find which burst type
piotrd0bf1492014-02-05 17:27:32 +010095}
piotr437f5462014-02-04 17:57:25 +010096
piotrd0bf1492014-02-05 17:27:32 +010097/*
98 * Our virtual destructor.
99 */
100receiver_impl::~receiver_impl()
101{
102}
103
piotrd0bf1492014-02-05 17:27:32 +0100104int
piotrc7c249a2014-05-02 17:24:08 +0200105receiver_impl::work(int noutput_items,
106 gr_vector_const_void_star &input_items,
107 gr_vector_void_star &output_items)
piotrd0bf1492014-02-05 17:27:32 +0100108{
ptrkrysik58213792014-10-30 09:05:15 +0100109// std::vector<const gr_complex *> iii = (std::vector<const gr_complex *>) input_items; // jak zrobić to rzutowanie poprawnie
110 gr_complex * input = (gr_complex *) input_items[0];
piotr4089c1a2014-08-06 14:10:56 +0200111 std::vector<tag_t> freq_offset_tags;
112 uint64_t start = nitems_read(0);
113 uint64_t stop = start + noutput_items;
piotr7c82b172014-02-08 14:15:27 +0100114
piotr4089c1a2014-08-06 14:10:56 +0200115 pmt::pmt_t key = pmt::string_to_symbol("setting_freq_offset");
116 get_tags_in_range(freq_offset_tags, 0, start, stop, key);
117 bool freq_offset_tag_in_fcch = false;
118 uint64_t tag_offset=-1; //-1 - just some clearly invalid value
119
120 if(!freq_offset_tags.empty()){
121 tag_t freq_offset_tag = freq_offset_tags[0];
122 tag_offset = freq_offset_tag.offset - start;
123
124 burst_type b_type = d_channel_conf.get_burst_type(d_burst_nr);
125 if(d_state == synchronized && b_type == fcch_burst){
126 uint64_t last_sample_nr = ceil((GUARD_PERIOD + 2.0 * TAIL_BITS + 156.25) * d_OSR) + 1;
127 if(tag_offset < last_sample_nr){
piotr4089c1a2014-08-06 14:10:56 +0200128 freq_offset_tag_in_fcch = true;
129 }
130 d_freq_offset_setting = pmt::to_double(freq_offset_tag.value);
131 } else {
132 d_freq_offset_setting = pmt::to_double(freq_offset_tag.value);
133 }
134 }
135
piotrd0bf1492014-02-05 17:27:32 +0100136 switch (d_state)
piotr437f5462014-02-04 17:57:25 +0100137 {
piotrd0bf1492014-02-05 17:27:32 +0100138 //bootstrapping
ptrkrysik58213792014-10-30 09:05:15 +0100139 case fcch_search:
piotrd0bf1492014-02-05 17:27:32 +0100140 {
piotr4089c1a2014-08-06 14:10:56 +0200141 double freq_offset_tmp;
142 if (find_fcch_burst(input, noutput_items,freq_offset_tmp))
piotrd0bf1492014-02-05 17:27:32 +0100143 {
piotrd6d66872014-08-06 15:20:33 +0200144 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(freq_offset_tmp-d_freq_offset_setting),pmt::mp("fcch_search"));
piotr4089c1a2014-08-06 14:10:56 +0200145 message_port_pub(pmt::mp("measurements"), msg);
146
piotrd0bf1492014-02-05 17:27:32 +0100147 d_state = sch_search;
148 }
149 else
150 {
piotrd6d66872014-08-06 15:20:33 +0200151 d_state = fcch_search;
piotrd0bf1492014-02-05 17:27:32 +0100152 }
153 break;
154 }
piotr437f5462014-02-04 17:57:25 +0100155
piotrd0bf1492014-02-05 17:27:32 +0100156 case sch_search:
157 {
piotrd0bf1492014-02-05 17:27:32 +0100158 vector_complex channel_imp_resp(CHAN_IMP_RESP_LENGTH*d_OSR);
159 int t1, t2, t3;
160 int burst_start = 0;
161 unsigned char output_binary[BURST_SIZE];
piotr437f5462014-02-04 17:57:25 +0100162
piotrc7c249a2014-05-02 17:24:08 +0200163 if (reach_sch_burst(noutput_items)) //wait for a SCH burst
piotrd0bf1492014-02-05 17:27:32 +0100164 {
165 burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]); //get channel impulse response from it
166 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //detect bits using MLSE detection
167 if (decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc) == 0) //decode SCH burst
168 {
piotr437f5462014-02-04 17:57:25 +0100169 d_burst_nr.set(t1, t2, t3, 0); //set counter of bursts value
piotr437f5462014-02-04 17:57:25 +0100170 d_burst_nr++;
171
piotr7f3f3662014-07-08 16:47:53 +0200172 consume_each(burst_start + BURST_SIZE * d_OSR + 4*d_OSR); //consume samples up to next guard period
piotr437f5462014-02-04 17:57:25 +0100173 d_state = synchronized;
piotrd0bf1492014-02-05 17:27:32 +0100174 }
175 else
176 {
piotrd6d66872014-08-06 15:20:33 +0200177 d_state = fcch_search; //if there is error in the sch burst go back to fcch search phase
piotr437f5462014-02-04 17:57:25 +0100178 }
piotrd0bf1492014-02-05 17:27:32 +0100179 }
180 else
181 {
182 d_state = sch_search;
183 }
184 break;
185 }
186 //in this state receiver is synchronized and it processes bursts according to burst type for given burst number
187 case synchronized:
188 {
piotrd0bf1492014-02-05 17:27:32 +0100189 vector_complex channel_imp_resp(CHAN_IMP_RESP_LENGTH*d_OSR);
piotrd0bf1492014-02-05 17:27:32 +0100190 int offset = 0;
191 int to_consume = 0;
192 unsigned char output_binary[BURST_SIZE];
piotr437f5462014-02-04 17:57:25 +0100193
ptrkrysik58213792014-10-30 09:05:15 +0100194 burst_type b_type;
piotr6d152d92014-02-21 00:02:44 +0100195
ptrkrysik58213792014-10-30 09:05:15 +0100196 for(int input_nr=0;input_nr<input_items.size();input_nr++)
piotrd0bf1492014-02-05 17:27:32 +0100197 {
ptrkrysik58213792014-10-30 09:05:15 +0100198 double signal_pwr = 0;
199 input = (gr_complex *)input_items[input_nr];
piotr4089c1a2014-08-06 14:10:56 +0200200
ptrkrysik58213792014-10-30 09:05:15 +0100201 for(int ii=GUARD_PERIOD;ii<TS_BITS;ii++)
piotrd0bf1492014-02-05 17:27:32 +0100202 {
ptrkrysik58213792014-10-30 09:05:15 +0100203 signal_pwr += abs(input[ii])*abs(input[ii]);
piotrd0bf1492014-02-05 17:27:32 +0100204 }
ptrkrysik58213792014-10-30 09:05:15 +0100205 signal_pwr = signal_pwr/(TS_BITS);
206 d_signal_dbm = round(10*log10(signal_pwr/50));
207 if(input_nr==0){
208 d_c0_signal_dbm = d_signal_dbm;
209 }
210
211 if(input_nr==0) //for c0 channel burst type is controlled by channel configuration
piotrd0bf1492014-02-05 17:27:32 +0100212 {
ptrkrysik58213792014-10-30 09:05:15 +0100213 b_type = d_channel_conf.get_burst_type(d_burst_nr); //get burst type for given burst number
214 }
215 else
216 {
217 b_type = normal_or_noise; //for the rest it can be only normal burst or noise (at least at this moment of development)
218 }
219
220 switch (b_type)
221 {
222 case fcch_burst: //if it's FCCH burst
223 {
224 const unsigned first_sample = ceil((GUARD_PERIOD + 2 * TAIL_BITS) * d_OSR) + 1;
225 const unsigned last_sample = first_sample + USEFUL_BITS * d_OSR - TAIL_BITS * d_OSR;
226 double freq_offset_tmp = compute_freq_offset(input, first_sample, last_sample); //extract frequency offset from it
227
228 send_burst(d_burst_nr, fc_fb, b_type);
229
230 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(freq_offset_tmp-d_freq_offset_setting),pmt::mp("synchronized"));
231 message_port_pub(pmt::mp("measurements"), msg);
232 break;
233 }
234 case sch_burst: //if it's SCH burst
235 {
236 int t1, t2, t3, d_ncc, d_bcc;
237 d_c0_burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]); //get channel impulse response
238
239 detect_burst(input, &channel_imp_resp[0], d_c0_burst_start, output_binary); //MLSE detection of bits
240 send_burst(d_burst_nr, output_binary, b_type);
241 if (decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc) == 0) //and decode SCH data
piotrd0bf1492014-02-05 17:27:32 +0100242 {
ptrkrysik58213792014-10-30 09:05:15 +0100243 // d_burst_nr.set(t1, t2, t3, 0); //but only to check if burst_start value is correct
244 d_failed_sch = 0;
245 offset = d_c0_burst_start - floor((GUARD_PERIOD) * d_OSR); //compute offset from burst_start - burst should start after a guard period
246 to_consume += offset; //adjust with offset number of samples to be consumed
piotr437f5462014-02-04 17:57:25 +0100247 }
ptrkrysik58213792014-10-30 09:05:15 +0100248 else
249 {
250 d_failed_sch++;
251 if (d_failed_sch >= MAX_SCH_ERRORS)
252 {
253 d_state = fcch_search;
254 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(0.0),pmt::mp("sync_loss"));
255 message_port_pub(pmt::mp("measurements"), msg);
256 DCOUT("Re-Synchronization!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
257 }
258 }
259 break;
piotr437f5462014-02-04 17:57:25 +0100260 }
ptrkrysik58213792014-10-30 09:05:15 +0100261 case normal_burst:
262 {
263 float normal_corr_max; //if it's normal burst
264 d_c0_burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], &normal_corr_max, d_bcc); //get channel impulse response for given training sequence number - d_bcc
265 detect_burst(input, &channel_imp_resp[0], d_c0_burst_start, output_binary); //MLSE detection of bits
266 send_burst(d_burst_nr, output_binary, b_type);
267 break;
268 }
269 case dummy_or_normal:
270 {
271 unsigned int normal_burst_start, dummy_burst_start;
272 float dummy_corr_max, normal_corr_max;
piotr437f5462014-02-04 17:57:25 +0100273
ptrkrysik58213792014-10-30 09:05:15 +0100274 dummy_burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], &dummy_corr_max, TS_DUMMY);
275 normal_burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], &normal_corr_max, d_bcc);
276
277 if (normal_corr_max > dummy_corr_max)
278 {
279 d_c0_burst_start = normal_burst_start;
280 detect_burst(input, &channel_imp_resp[0], normal_burst_start, output_binary);
281 send_burst(d_burst_nr, output_binary, b_type);
282 }
283 else
284 {
285 d_c0_burst_start = dummy_burst_start;
286 send_burst(d_burst_nr, dummy_burst, b_type);
287 }
288 break;
piotrd0bf1492014-02-05 17:27:32 +0100289 }
ptrkrysik58213792014-10-30 09:05:15 +0100290 case rach_burst:
291 break;
292 case dummy:
piotr6d152d92014-02-21 00:02:44 +0100293 send_burst(d_burst_nr, dummy_burst, b_type);
ptrkrysik58213792014-10-30 09:05:15 +0100294 break;
295 case normal_or_noise:
296 {
297 unsigned int burst_start;
298 float normal_corr_max_tmp;
299 float normal_corr_max=-1e6;
300 int max_tn;
301 std::vector<gr_complex> v(input, input + noutput_items);
302 if(d_signal_dbm>=d_c0_signal_dbm-13)
303 {
304 plot(v);
piotrd0bf1492014-02-05 17:27:32 +0100305
ptrkrysik58213792014-10-30 09:05:15 +0100306 burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], &normal_corr_max, 7);
307// if(abs(d_c0_burst_start-burst_start)<=2){
308 if((normal_corr_max/sqrt(signal_pwr))>=0.9){
309 std::cout << static_cast<int>(d_signal_dbm) << std::endl;
310 COUT("d_c0_burst_start: " << d_c0_burst_start);
311 COUT("burst_start: " << burst_start);
312 std::cout << "corr max to signal ratio: " << (normal_corr_max/sqrt(signal_pwr)) << std::endl;
313 usleep(4e6);
314 }
315 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary);
316 send_burst(d_burst_nr, output_binary, b_type);
317 }
318 break;
319 }
320 case empty: //if it's empty burst
321 break; //do nothing
322 }
323
324 if(input_nr==0)
325 {
326 d_burst_nr++; //go to next burst
327 to_consume += TS_BITS * d_OSR + d_burst_nr.get_offset(); //consume samples of the burst up to next guard period
328 }
329
330 if(input_nr==input_items.size()-1)
331 {
332 consume_each(to_consume);
333 }
334 //and add offset which is introduced by
335 //0.25 fractional part of a guard period
336 }
piotrd0bf1492014-02-05 17:27:32 +0100337 }
338 break;
piotr437f5462014-02-04 17:57:25 +0100339 }
piotr6d152d92014-02-21 00:02:44 +0100340 return 0;
piotrd0bf1492014-02-05 17:27:32 +0100341}
piotr437f5462014-02-04 17:57:25 +0100342
piotr4089c1a2014-08-06 14:10:56 +0200343bool receiver_impl::find_fcch_burst(const gr_complex *input, const int nitems, double & computed_freq_offset)
piotrd0bf1492014-02-05 17:27:32 +0100344{
345 circular_buffer_float phase_diff_buffer(FCCH_HITS_NEEDED * d_OSR); //circular buffer used to scan throug signal to find
346 //best match for FCCH burst
347 float phase_diff = 0;
348 gr_complex conjprod;
349 int start_pos = -1;
350 int hit_count = 0;
351 int miss_count = 0;
352 float min_phase_diff;
353 float max_phase_diff;
354 double best_sum = 0;
355 float lowest_max_min_diff = 99999;
356
357 int to_consume = 0;
358 int sample_number = 0;
359 bool end = false;
360 bool result = false;
361 circular_buffer_float::iterator buffer_iter;
piotr6d152d92014-02-21 00:02:44 +0100362
piotrd0bf1492014-02-05 17:27:32 +0100363 /**@name Possible states of FCCH search algorithm*/
364 //@{
365 enum states
piotr437f5462014-02-04 17:57:25 +0100366 {
piotr437f5462014-02-04 17:57:25 +0100367 init, ///< initialize variables
368 search, ///< search for positive samples
369 found_something, ///< search for FCCH and the best position of it
370 fcch_found, ///< when FCCH was found
371 search_fail ///< when there is no FCCH in the input vector
piotrd0bf1492014-02-05 17:27:32 +0100372 } fcch_search_state;
373 //@}
piotr437f5462014-02-04 17:57:25 +0100374
piotrd0bf1492014-02-05 17:27:32 +0100375 fcch_search_state = init;
piotr437f5462014-02-04 17:57:25 +0100376
piotrd0bf1492014-02-05 17:27:32 +0100377 while (!end)
378 {
379 switch (fcch_search_state)
380 {
piotr437f5462014-02-04 17:57:25 +0100381
piotrd0bf1492014-02-05 17:27:32 +0100382 case init: //initialize variables
piotr437f5462014-02-04 17:57:25 +0100383 hit_count = 0;
384 miss_count = 0;
385 start_pos = -1;
386 lowest_max_min_diff = 99999;
387 phase_diff_buffer.clear();
388 fcch_search_state = search;
389
390 break;
391
piotr7c82b172014-02-08 14:15:27 +0100392 case search: // search for positive samples
piotr437f5462014-02-04 17:57:25 +0100393 sample_number++;
394
piotrd0bf1492014-02-05 17:27:32 +0100395 if (sample_number > nitems - FCCH_HITS_NEEDED * d_OSR) //if it isn't possible to find FCCH because
396 {
piotr7c82b172014-02-08 14:15:27 +0100397 //there's too few samples left to look into,
piotrd0bf1492014-02-05 17:27:32 +0100398 to_consume = sample_number; //don't do anything with those samples which are left
piotr7c82b172014-02-08 14:15:27 +0100399 //and consume only those which were checked
piotrd0bf1492014-02-05 17:27:32 +0100400 fcch_search_state = search_fail;
401 }
402 else
403 {
404 phase_diff = compute_phase_diff(input[sample_number], input[sample_number-1]);
piotr437f5462014-02-04 17:57:25 +0100405
piotrd0bf1492014-02-05 17:27:32 +0100406 if (phase_diff > 0) //if a positive phase difference was found
407 {
408 to_consume = sample_number;
409 fcch_search_state = found_something; //switch to state in which searches for FCCH
410 }
411 else
412 {
413 fcch_search_state = search;
414 }
piotr437f5462014-02-04 17:57:25 +0100415 }
416
417 break;
418
piotrd0bf1492014-02-05 17:27:32 +0100419 case found_something: // search for FCCH and the best position of it
420 {
421 if (phase_diff > 0)
422 {
piotr437f5462014-02-04 17:57:25 +0100423 hit_count++; //positive phase differencies increases hits_count
piotrd0bf1492014-02-05 17:27:32 +0100424 }
425 else
426 {
piotr437f5462014-02-04 17:57:25 +0100427 miss_count++; //negative increases miss_count
piotrd0bf1492014-02-05 17:27:32 +0100428 }
piotr437f5462014-02-04 17:57:25 +0100429
piotrd0bf1492014-02-05 17:27:32 +0100430 if ((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count <= FCCH_HITS_NEEDED * d_OSR))
431 {
piotr437f5462014-02-04 17:57:25 +0100432 //if miss_count exceeds limit before hit_count
433 fcch_search_state = init; //go to init
434 continue;
piotrd0bf1492014-02-05 17:27:32 +0100435 }
436 else if (((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR)) || (hit_count > 2 * FCCH_HITS_NEEDED * d_OSR))
437 {
piotr437f5462014-02-04 17:57:25 +0100438 //if hit_count and miss_count exceeds limit then FCCH was found
439 fcch_search_state = fcch_found;
440 continue;
piotrd0bf1492014-02-05 17:27:32 +0100441 }
442 else if ((miss_count < FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR))
443 {
piotr437f5462014-02-04 17:57:25 +0100444 //find difference between minimal and maximal element in the buffer
445 //for FCCH this value should be low
446 //this part is searching for a region where this value is lowest
447 min_phase_diff = * (min_element(phase_diff_buffer.begin(), phase_diff_buffer.end()));
448 max_phase_diff = * (max_element(phase_diff_buffer.begin(), phase_diff_buffer.end()));
449
piotrd0bf1492014-02-05 17:27:32 +0100450 if (lowest_max_min_diff > max_phase_diff - min_phase_diff)
451 {
452 lowest_max_min_diff = max_phase_diff - min_phase_diff;
453 start_pos = sample_number - FCCH_HITS_NEEDED * d_OSR - FCCH_MAX_MISSES * d_OSR; //store start pos
454 best_sum = 0;
piotr437f5462014-02-04 17:57:25 +0100455
piotrd0bf1492014-02-05 17:27:32 +0100456 for (buffer_iter = phase_diff_buffer.begin();
457 buffer_iter != (phase_diff_buffer.end());
458 buffer_iter++)
459 {
460 best_sum += *buffer_iter - (M_PI / 2) / d_OSR; //store best value of phase offset sum
461 }
piotr437f5462014-02-04 17:57:25 +0100462 }
piotrd0bf1492014-02-05 17:27:32 +0100463 }
piotr437f5462014-02-04 17:57:25 +0100464
piotrd0bf1492014-02-05 17:27:32 +0100465 sample_number++;
piotr437f5462014-02-04 17:57:25 +0100466
piotrd0bf1492014-02-05 17:27:32 +0100467 if (sample_number >= nitems) //if there's no single sample left to check
468 {
piotr437f5462014-02-04 17:57:25 +0100469 fcch_search_state = search_fail;//FCCH search failed
470 continue;
piotr437f5462014-02-04 17:57:25 +0100471 }
piotrd0bf1492014-02-05 17:27:32 +0100472
473 phase_diff = compute_phase_diff(input[sample_number], input[sample_number-1]);
474 phase_diff_buffer.push_back(phase_diff);
475 fcch_search_state = found_something;
476 }
477 break;
478
479 case fcch_found:
480 {
piotrd0bf1492014-02-05 17:27:32 +0100481 to_consume = start_pos + FCCH_HITS_NEEDED * d_OSR + 1; //consume one FCCH burst
482
483 d_fcch_start_pos = d_counter + start_pos;
484
485 //compute frequency offset
486 double phase_offset = best_sum / FCCH_HITS_NEEDED;
piotr4089c1a2014-08-06 14:10:56 +0200487 double freq_offset = phase_offset * 1625000.0/6 / (2 * M_PI); //1625000.0/6 - GMSK symbol rate in GSM
488 computed_freq_offset = freq_offset;
piotrd0bf1492014-02-05 17:27:32 +0100489
490 end = true;
491 result = true;
piotr437f5462014-02-04 17:57:25 +0100492 break;
piotrd0bf1492014-02-05 17:27:32 +0100493 }
piotr437f5462014-02-04 17:57:25 +0100494
piotrd0bf1492014-02-05 17:27:32 +0100495 case search_fail:
piotr437f5462014-02-04 17:57:25 +0100496 end = true;
497 result = false;
498 break;
499 }
piotr437f5462014-02-04 17:57:25 +0100500 }
501
piotrd0bf1492014-02-05 17:27:32 +0100502 d_counter += to_consume;
503 consume_each(to_consume);
piotr437f5462014-02-04 17:57:25 +0100504
piotrd0bf1492014-02-05 17:27:32 +0100505 return result;
506}
507
piotrd0bf1492014-02-05 17:27:32 +0100508double receiver_impl::compute_freq_offset(const gr_complex * input, unsigned first_sample, unsigned last_sample)
509{
510 double phase_sum = 0;
511 unsigned ii;
512
513 for (ii = first_sample; ii < last_sample; ii++)
piotr437f5462014-02-04 17:57:25 +0100514 {
piotr437f5462014-02-04 17:57:25 +0100515 double phase_diff = compute_phase_diff(input[ii], input[ii-1]) - (M_PI / 2) / d_OSR;
516 phase_sum += phase_diff;
piotr437f5462014-02-04 17:57:25 +0100517 }
518
piotrd0bf1492014-02-05 17:27:32 +0100519 double phase_offset = phase_sum / (last_sample - first_sample);
520 double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI);
521 return freq_offset;
522}
piotr437f5462014-02-04 17:57:25 +0100523
piotrd0bf1492014-02-05 17:27:32 +0100524inline float receiver_impl::compute_phase_diff(gr_complex val1, gr_complex val2)
525{
526 gr_complex conjprod = val1 * conj(val2);
527 return fast_atan2f(imag(conjprod), real(conjprod));
528}
piotr437f5462014-02-04 17:57:25 +0100529
piotrd0bf1492014-02-05 17:27:32 +0100530bool receiver_impl::reach_sch_burst(const int nitems)
531{
532 //it just consumes samples to get near to a SCH burst
533 int to_consume = 0;
534 bool result = false;
535 unsigned sample_nr_near_sch_start = d_fcch_start_pos + (FRAME_BITS - SAFETY_MARGIN) * d_OSR;
536
537 //consume samples until d_counter will be equal to sample_nr_near_sch_start
538 if (d_counter < sample_nr_near_sch_start)
539 {
540 if (d_counter + nitems >= sample_nr_near_sch_start)
541 {
542 to_consume = sample_nr_near_sch_start - d_counter;
543 }
544 else
545 {
546 to_consume = nitems;
piotr437f5462014-02-04 17:57:25 +0100547 }
548 result = false;
piotrd0bf1492014-02-05 17:27:32 +0100549 }
550 else
551 {
piotr437f5462014-02-04 17:57:25 +0100552 to_consume = 0;
553 result = true;
piotr437f5462014-02-04 17:57:25 +0100554 }
555
piotrd0bf1492014-02-05 17:27:32 +0100556 d_counter += to_consume;
557 consume_each(to_consume);
558 return result;
559}
560
561int receiver_impl::get_sch_chan_imp_resp(const gr_complex *input, gr_complex * chan_imp_resp)
562{
563 vector_complex correlation_buffer;
564 vector_float power_buffer;
565 vector_float window_energy_buffer;
566
567 int strongest_window_nr;
568 int burst_start = 0;
569 int chan_imp_resp_center = 0;
570 float max_correlation = 0;
571 float energy = 0;
572
573 for (int ii = SYNC_POS * d_OSR; ii < (SYNC_POS + SYNC_SEARCH_RANGE) *d_OSR; ii++)
piotr437f5462014-02-04 17:57:25 +0100574 {
piotr437f5462014-02-04 17:57:25 +0100575 gr_complex correlation = correlate_sequence(&d_sch_training_seq[5], N_SYNC_BITS - 10, &input[ii]);
576 correlation_buffer.push_back(correlation);
577 power_buffer.push_back(std::pow(abs(correlation), 2));
piotrd0bf1492014-02-05 17:27:32 +0100578 }
piotrd0bf1492014-02-05 17:27:32 +0100579 //compute window energies
580 vector_float::iterator iter = power_buffer.begin();
581 bool loop_end = false;
582 while (iter != power_buffer.end())
583 {
piotr437f5462014-02-04 17:57:25 +0100584 vector_float::iterator iter_ii = iter;
585 energy = 0;
586
piotrd0bf1492014-02-05 17:27:32 +0100587 for (int ii = 0; ii < (d_chan_imp_length) *d_OSR; ii++, iter_ii++)
588 {
589 if (iter_ii == power_buffer.end())
590 {
591 loop_end = true;
592 break;
593 }
594 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100595 }
piotrd0bf1492014-02-05 17:27:32 +0100596 if (loop_end)
597 {
598 break;
piotr437f5462014-02-04 17:57:25 +0100599 }
600 iter++;
601 window_energy_buffer.push_back(energy);
piotrd0bf1492014-02-05 17:27:32 +0100602 }
piotr437f5462014-02-04 17:57:25 +0100603
piotrd0bf1492014-02-05 17:27:32 +0100604 strongest_window_nr = max_element(window_energy_buffer.begin(), window_energy_buffer.end()) - window_energy_buffer.begin();
piotr437f5462014-02-04 17:57:25 +0100605 // d_channel_imp_resp.clear();
606
piotrd0bf1492014-02-05 17:27:32 +0100607 max_correlation = 0;
608 for (int ii = 0; ii < (d_chan_imp_length) *d_OSR; ii++)
609 {
piotr437f5462014-02-04 17:57:25 +0100610 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100611 if (abs(correlation) > max_correlation)
612 {
613 chan_imp_resp_center = ii;
614 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100615 }
piotrd0bf1492014-02-05 17:27:32 +0100616 // d_channel_imp_resp.push_back(correlation);
piotr437f5462014-02-04 17:57:25 +0100617 chan_imp_resp[ii] = correlation;
piotr437f5462014-02-04 17:57:25 +0100618 }
619
piotrd0bf1492014-02-05 17:27:32 +0100620 burst_start = strongest_window_nr + chan_imp_resp_center - 48 * d_OSR - 2 * d_OSR + 2 + SYNC_POS * d_OSR;
621 return burst_start;
622}
piotr437f5462014-02-04 17:57:25 +0100623
624
piotrd0bf1492014-02-05 17:27:32 +0100625
626void receiver_impl::detect_burst(const gr_complex * input, gr_complex * chan_imp_resp, int burst_start, unsigned char * output_binary)
627{
628 float output[BURST_SIZE];
629 gr_complex rhh_temp[CHAN_IMP_RESP_LENGTH*d_OSR];
630 gr_complex rhh[CHAN_IMP_RESP_LENGTH];
631 gr_complex filtered_burst[BURST_SIZE];
632 int start_state = 3;
633 unsigned int stop_states[2] = {4, 12};
634
635 autocorrelation(chan_imp_resp, rhh_temp, d_chan_imp_length*d_OSR);
636 for (int ii = 0; ii < (d_chan_imp_length); ii++)
piotr437f5462014-02-04 17:57:25 +0100637 {
piotr437f5462014-02-04 17:57:25 +0100638 rhh[ii] = conj(rhh_temp[ii*d_OSR]);
piotr437f5462014-02-04 17:57:25 +0100639 }
640
piotrd0bf1492014-02-05 17:27:32 +0100641 mafi(&input[burst_start], BURST_SIZE, chan_imp_resp, d_chan_imp_length*d_OSR, filtered_burst);
642
643 viterbi_detector(filtered_burst, BURST_SIZE, rhh, start_state, stop_states, 2, output);
644
645 for (int i = 0; i < BURST_SIZE ; i++)
piotr437f5462014-02-04 17:57:25 +0100646 {
piotrd0bf1492014-02-05 17:27:32 +0100647 output_binary[i] = (output[i] > 0);
648 }
649}
piotr437f5462014-02-04 17:57:25 +0100650
piotrd0bf1492014-02-05 17:27:32 +0100651void receiver_impl::gmsk_mapper(const unsigned char * input, int nitems, gr_complex * gmsk_output, gr_complex start_point)
652{
653 gr_complex j = gr_complex(0.0, 1.0);
piotr437f5462014-02-04 17:57:25 +0100654
piotrd0bf1492014-02-05 17:27:32 +0100655 int current_symbol;
656 int encoded_symbol;
657 int previous_symbol = 2 * input[0] - 1;
658 gmsk_output[0] = start_point;
659
660 for (int i = 1; i < nitems; i++)
661 {
piotr437f5462014-02-04 17:57:25 +0100662 //change bits representation to NRZ
663 current_symbol = 2 * input[i] - 1;
664 //differentially encode
665 encoded_symbol = current_symbol * previous_symbol;
666 //and do gmsk mapping
667 gmsk_output[i] = j * gr_complex(encoded_symbol, 0.0) * gmsk_output[i-1];
668 previous_symbol = current_symbol;
piotr437f5462014-02-04 17:57:25 +0100669 }
piotrd0bf1492014-02-05 17:27:32 +0100670}
piotr437f5462014-02-04 17:57:25 +0100671
piotrd0bf1492014-02-05 17:27:32 +0100672gr_complex receiver_impl::correlate_sequence(const gr_complex * sequence, int length, const gr_complex * input)
673{
674 gr_complex result(0.0, 0.0);
675 int sample_number = 0;
676
677 for (int ii = 0; ii < length; ii++)
piotr437f5462014-02-04 17:57:25 +0100678 {
piotr437f5462014-02-04 17:57:25 +0100679 sample_number = (ii * d_OSR) ;
680 result += sequence[ii] * conj(input[sample_number]);
piotr437f5462014-02-04 17:57:25 +0100681 }
682
piotrd0bf1492014-02-05 17:27:32 +0100683 result = result / gr_complex(length, 0);
684 return result;
685}
686
687//computes autocorrelation for positive arguments
piotrd0bf1492014-02-05 17:27:32 +0100688inline void receiver_impl::autocorrelation(const gr_complex * input, gr_complex * out, int nitems)
689{
690 int i, k;
691 for (k = nitems - 1; k >= 0; k--)
piotr437f5462014-02-04 17:57:25 +0100692 {
piotr437f5462014-02-04 17:57:25 +0100693 out[k] = gr_complex(0, 0);
piotrd0bf1492014-02-05 17:27:32 +0100694 for (i = k; i < nitems; i++)
695 {
696 out[k] += input[i] * conj(input[i-k]);
piotr437f5462014-02-04 17:57:25 +0100697 }
piotr437f5462014-02-04 17:57:25 +0100698 }
piotrd0bf1492014-02-05 17:27:32 +0100699}
piotr437f5462014-02-04 17:57:25 +0100700
piotrd0bf1492014-02-05 17:27:32 +0100701inline void receiver_impl::mafi(const gr_complex * input, int nitems, gr_complex * filter, int filter_length, gr_complex * output)
702{
703 int ii = 0, n, a;
704
705 for (n = 0; n < nitems; n++)
piotr437f5462014-02-04 17:57:25 +0100706 {
piotr437f5462014-02-04 17:57:25 +0100707 a = n * d_OSR;
708 output[n] = 0;
709 ii = 0;
710
piotrd0bf1492014-02-05 17:27:32 +0100711 while (ii < filter_length)
712 {
piotrda8a0662014-04-24 10:29:38 +0200713 if ((a + ii) >= nitems*d_OSR){
piotrd0bf1492014-02-05 17:27:32 +0100714 break;
piotrda8a0662014-04-24 10:29:38 +0200715 }
piotrd0bf1492014-02-05 17:27:32 +0100716 output[n] += input[a+ii] * filter[ii];
717 ii++;
piotr437f5462014-02-04 17:57:25 +0100718 }
piotr437f5462014-02-04 17:57:25 +0100719 }
piotrd0bf1492014-02-05 17:27:32 +0100720}
piotr437f5462014-02-04 17:57:25 +0100721
piotrd0bf1492014-02-05 17:27:32 +0100722//especially computations of strongest_window_nr
piotr7e3b0db2014-02-05 22:44:30 +0100723int receiver_impl::get_norm_chan_imp_resp(const gr_complex *input, gr_complex * chan_imp_resp, float *corr_max, int bcc)
piotrd0bf1492014-02-05 17:27:32 +0100724{
725 vector_complex correlation_buffer;
726 vector_float power_buffer;
727 vector_float window_energy_buffer;
piotr437f5462014-02-04 17:57:25 +0100728
piotrd0bf1492014-02-05 17:27:32 +0100729 int strongest_window_nr;
730 int burst_start = 0;
731 int chan_imp_resp_center = 0;
732 float max_correlation = 0;
733 float energy = 0;
piotr5c820252014-04-17 09:43:02 +0200734
piotrd0bf1492014-02-05 17:27:32 +0100735 int search_center = (int)((TRAIN_POS + GUARD_PERIOD) * d_OSR);
piotr7c82b172014-02-08 14:15:27 +0100736 int search_start_pos = search_center + 1 - 5*d_OSR;
piotr437f5462014-02-04 17:57:25 +0100737 // int search_start_pos = search_center - d_chan_imp_length * d_OSR;
piotr5c820252014-04-17 09:43:02 +0200738 int search_stop_pos = search_center + d_chan_imp_length * d_OSR + 5 * d_OSR;
piotr437f5462014-02-04 17:57:25 +0100739
ptrkrysik58213792014-10-30 09:05:15 +0100740 for(int ii = search_start_pos; ii < search_stop_pos; ii++)
piotrd0bf1492014-02-05 17:27:32 +0100741 {
piotr437f5462014-02-04 17:57:25 +0100742 gr_complex correlation = correlate_sequence(&d_norm_training_seq[bcc][TRAIN_BEGINNING], N_TRAIN_BITS - 10, &input[ii]);
piotr437f5462014-02-04 17:57:25 +0100743 correlation_buffer.push_back(correlation);
744 power_buffer.push_back(std::pow(abs(correlation), 2));
piotrd0bf1492014-02-05 17:27:32 +0100745 }
ptrkrysik58213792014-10-30 09:05:15 +0100746 //plot(power_buffer);
piotrd0bf1492014-02-05 17:27:32 +0100747 //compute window energies
748 vector_float::iterator iter = power_buffer.begin();
749 bool loop_end = false;
750 while (iter != power_buffer.end())
751 {
piotr437f5462014-02-04 17:57:25 +0100752 vector_float::iterator iter_ii = iter;
753 energy = 0;
754
piotrd0bf1492014-02-05 17:27:32 +0100755 for (int ii = 0; ii < (d_chan_imp_length - 2)*d_OSR; ii++, iter_ii++)
756 {
piotrd0bf1492014-02-05 17:27:32 +0100757 if (iter_ii == power_buffer.end())
758 {
759 loop_end = true;
760 break;
761 }
762 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100763 }
piotrd0bf1492014-02-05 17:27:32 +0100764 if (loop_end)
765 {
766 break;
piotr437f5462014-02-04 17:57:25 +0100767 }
768 iter++;
769
770 window_energy_buffer.push_back(energy);
piotrd0bf1492014-02-05 17:27:32 +0100771 }
piotr437f5462014-02-04 17:57:25 +0100772
piotr5c820252014-04-17 09:43:02 +0200773 strongest_window_nr = max_element(window_energy_buffer.begin(), window_energy_buffer.end()-((d_chan_imp_length)*d_OSR)) - window_energy_buffer.begin();
774 //strongest_window_nr = strongest_window_nr-d_OSR;
775 if(strongest_window_nr<0){
776 strongest_window_nr = 0;
777 }
piotr6d152d92014-02-21 00:02:44 +0100778
piotrd0bf1492014-02-05 17:27:32 +0100779 max_correlation = 0;
780 for (int ii = 0; ii < (d_chan_imp_length)*d_OSR; ii++)
781 {
piotr437f5462014-02-04 17:57:25 +0100782 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100783 if (abs(correlation) > max_correlation)
784 {
785 chan_imp_resp_center = ii;
786 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100787 }
piotrd0bf1492014-02-05 17:27:32 +0100788 // d_channel_imp_resp.push_back(correlation);
piotr437f5462014-02-04 17:57:25 +0100789 chan_imp_resp[ii] = correlation;
piotr437f5462014-02-04 17:57:25 +0100790 }
piotr7c82b172014-02-08 14:15:27 +0100791
piotr7e3b0db2014-02-05 22:44:30 +0100792 *corr_max = max_correlation;
piotrd0bf1492014-02-05 17:27:32 +0100793
ptrkrysik58213792014-10-30 09:05:15 +0100794 //DCOUT("strongest_window_nr_new: " << strongest_window_nr);
piotrc7c249a2014-05-02 17:24:08 +0200795 burst_start = search_start_pos + strongest_window_nr - TRAIN_POS * d_OSR; //compute first sample posiiton which corresponds to the first sample of the impulse response
piotr7c82b172014-02-08 14:15:27 +0100796
ptrkrysik58213792014-10-30 09:05:15 +0100797 //DCOUT("burst_start: " << burst_start);
piotrd0bf1492014-02-05 17:27:32 +0100798 return burst_start;
799}
piotr437f5462014-02-04 17:57:25 +0100800
801
piotr6d152d92014-02-21 00:02:44 +0100802void receiver_impl::send_burst(burst_counter burst_nr, const unsigned char * burst_binary, burst_type b_type)
piotrd0bf1492014-02-05 17:27:32 +0100803{
piotr7c82b172014-02-08 14:15:27 +0100804
piotr6d152d92014-02-21 00:02:44 +0100805 boost::scoped_ptr<gsmtap_hdr> tap_header(new gsmtap_hdr());
806
807 tap_header->version = GSMTAP_VERSION;
808 tap_header->hdr_len = BURST_SIZE/4;
809 tap_header->type = GSMTAP_TYPE_UM_BURST;
810 tap_header->timeslot = static_cast<uint8_t>(d_burst_nr.get_timeslot_nr());
811 tap_header->frame_number = d_burst_nr.get_frame_nr();
812 tap_header->sub_type = static_cast<uint8_t>(b_type);
813 tap_header->arfcn = d_arfcn;
814 tap_header->signal_dbm = static_cast<int8_t>(d_signal_dbm);
815 pmt::pmt_t header_blob=pmt::make_blob(tap_header.get(),sizeof(gsmtap_hdr));
816 pmt::pmt_t burst_binary_blob=pmt::make_blob(burst_binary,BURST_SIZE);
817 pmt::pmt_t msg = pmt::cons(header_blob, burst_binary_blob);
piotrf2b6a1b2014-08-04 11:28:59 +0200818
piotr6d152d92014-02-21 00:02:44 +0100819 message_port_pub(pmt::mp("bursts"), msg);
piotrd0bf1492014-02-05 17:27:32 +0100820}
piotr6d152d92014-02-21 00:02:44 +0100821
piotrd0bf1492014-02-05 17:27:32 +0100822void receiver_impl::configure_receiver()
823{
piotrce92f982014-04-17 23:37:18 +0200824 d_channel_conf.set_multiframe_type(TIMESLOT0, multiframe_51);
piotrd0bf1492014-02-05 17:27:32 +0100825 d_channel_conf.set_burst_types(TIMESLOT0, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotr437f5462014-02-04 17:57:25 +0100826
piotrce92f982014-04-17 23:37:18 +0200827 d_channel_conf.set_burst_types(TIMESLOT0, TEST_CCH_FRAMES, sizeof(TEST_CCH_FRAMES) / sizeof(unsigned), dummy_or_normal);
828 d_channel_conf.set_burst_types(TIMESLOT0, FCCH_FRAMES, sizeof(FCCH_FRAMES) / sizeof(unsigned), fcch_burst);
829 d_channel_conf.set_burst_types(TIMESLOT0, SCH_FRAMES, sizeof(SCH_FRAMES) / sizeof(unsigned), sch_burst);
piotr437f5462014-02-04 17:57:25 +0100830
piotrd0bf1492014-02-05 17:27:32 +0100831 d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_51);
832 d_channel_conf.set_burst_types(TIMESLOT1, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
833 d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_51);
834 d_channel_conf.set_burst_types(TIMESLOT2, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
835 d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_51);
836 d_channel_conf.set_burst_types(TIMESLOT3, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
837 d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_51);
838 d_channel_conf.set_burst_types(TIMESLOT4, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
839 d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_51);
840 d_channel_conf.set_burst_types(TIMESLOT5, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
841 d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_51);
842 d_channel_conf.set_burst_types(TIMESLOT6, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
843 d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_51);
844 d_channel_conf.set_burst_types(TIMESLOT7, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotrd0bf1492014-02-05 17:27:32 +0100845}
piotr437f5462014-02-04 17:57:25 +0100846
piotrf2b6a1b2014-08-04 11:28:59 +0200847void receiver_impl::set_arfcn(int arfcn) //!!
848{
849 d_arfcn = arfcn;
piotrf2b6a1b2014-08-04 11:28:59 +0200850}
851
852void receiver_impl::reset()
853{
piotrd6d66872014-08-06 15:20:33 +0200854 d_state = fcch_search;
piotrf2b6a1b2014-08-04 11:28:59 +0200855}
piotr437f5462014-02-04 17:57:25 +0100856
piotrd0bf1492014-02-05 17:27:32 +0100857} /* namespace gsm */
piotr437f5462014-02-04 17:57:25 +0100858} /* namespace gr */
859