blob: f1382ede6840f3db656b8109c59acc22ff865458 [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>
piotr7f3f3662014-07-08 16:47:53 +020041//#include "plotting/plotting.hpp"
piotr437f5462014-02-04 17:57:25 +010042
43#define SYNC_SEARCH_RANGE 30
44
piotrd0bf1492014-02-05 17:27:32 +010045namespace gr
46{
47namespace gsm
48{
piotr437f5462014-02-04 17:57:25 +010049
piotrd0bf1492014-02-05 17:27:32 +010050typedef std::list<float> list_float;
51typedef std::vector<float> vector_float;
piotr437f5462014-02-04 17:57:25 +010052
piotrd0bf1492014-02-05 17:27:32 +010053typedef boost::circular_buffer<float> circular_buffer_float;
piotr437f5462014-02-04 17:57:25 +010054
piotrd0bf1492014-02-05 17:27:32 +010055receiver::sptr
piotr6d152d92014-02-21 00:02:44 +010056receiver::make(feval_dd * tuner, int osr, int arfcn)
piotrd0bf1492014-02-05 17:27:32 +010057{
58 return gnuradio::get_initial_sptr
piotr6d152d92014-02-21 00:02:44 +010059 (new receiver_impl(tuner, osr, arfcn));
piotrd0bf1492014-02-05 17:27:32 +010060}
61
62/*
63 * The private constructor
64 */
piotr6d152d92014-02-21 00:02:44 +010065receiver_impl::receiver_impl(feval_dd * tuner, int osr, int arfcn)
piotrc7c249a2014-05-02 17:24:08 +020066 : gr::sync_block("receiver",
piotrd0bf1492014-02-05 17:27:32 +010067 gr::io_signature::make(1, 1, sizeof(gr_complex)),
piotr7c82b172014-02-08 14:15:27 +010068 gr::io_signature::make(0, 0, 0)),
piotrd0bf1492014-02-05 17:27:32 +010069 d_OSR(osr),
70 d_chan_imp_length(CHAN_IMP_RESP_LENGTH),
71 d_tuner(tuner),
72 d_counter(0),
73 d_fcch_start_pos(0),
piotr4089c1a2014-08-06 14:10:56 +020074 d_freq_offset_setting(0),
piotrd6d66872014-08-06 15:20:33 +020075 d_state(fcch_search),
piotrd0bf1492014-02-05 17:27:32 +010076 d_burst_nr(osr),
piotr6d152d92014-02-21 00:02:44 +010077 d_failed_sch(0),
78 d_arfcn((int)(arfcn)),
79 d_signal_dbm(-120)
piotrd0bf1492014-02-05 17:27:32 +010080{
81 int i;
piotr4089c1a2014-08-06 14:10:56 +020082 //don't send samples to the receiver until there are at least samples for one
piotr7f3f3662014-07-08 16:47:53 +020083 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 +010084 gmsk_mapper(SYNC_BITS, N_SYNC_BITS, d_sch_training_seq, gr_complex(0.0, -1.0));
85 for (i = 0; i < TRAIN_SEQ_NUM; i++)
piotr437f5462014-02-04 17:57:25 +010086 {
piotrf502e0f2014-04-24 10:28:29 +020087 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 +020088 //if first bit of the seqeunce ==1 first symbol ==-1
piotr437f5462014-02-04 17:57:25 +010089 gmsk_mapper(train_seq[i], N_TRAIN_BITS, d_norm_training_seq[i], startpoint);
piotr437f5462014-02-04 17:57:25 +010090 }
piotr7c82b172014-02-08 14:15:27 +010091 message_port_register_out(pmt::mp("bursts"));
piotr4089c1a2014-08-06 14:10:56 +020092 message_port_register_out(pmt::mp("measurements"));
piotr903b1d62014-04-17 11:33:27 +020093 configure_receiver(); //configure the receiver - tell it where to find which burst type
piotrd0bf1492014-02-05 17:27:32 +010094}
piotr437f5462014-02-04 17:57:25 +010095
piotrd0bf1492014-02-05 17:27:32 +010096/*
97 * Our virtual destructor.
98 */
99receiver_impl::~receiver_impl()
100{
101}
102
piotrd0bf1492014-02-05 17:27:32 +0100103int
piotrc7c249a2014-05-02 17:24:08 +0200104receiver_impl::work(int noutput_items,
105 gr_vector_const_void_star &input_items,
106 gr_vector_void_star &output_items)
piotrd0bf1492014-02-05 17:27:32 +0100107{
108 const gr_complex *input = (const gr_complex *) input_items[0];
piotr4089c1a2014-08-06 14:10:56 +0200109 std::vector<tag_t> freq_offset_tags;
110 uint64_t start = nitems_read(0);
111 uint64_t stop = start + noutput_items;
piotr7c82b172014-02-08 14:15:27 +0100112
piotr4089c1a2014-08-06 14:10:56 +0200113 pmt::pmt_t key = pmt::string_to_symbol("setting_freq_offset");
114 get_tags_in_range(freq_offset_tags, 0, start, stop, key);
115 bool freq_offset_tag_in_fcch = false;
116 uint64_t tag_offset=-1; //-1 - just some clearly invalid value
117
118 if(!freq_offset_tags.empty()){
119 tag_t freq_offset_tag = freq_offset_tags[0];
120 tag_offset = freq_offset_tag.offset - start;
121
122 burst_type b_type = d_channel_conf.get_burst_type(d_burst_nr);
123 if(d_state == synchronized && b_type == fcch_burst){
124 uint64_t last_sample_nr = ceil((GUARD_PERIOD + 2.0 * TAIL_BITS + 156.25) * d_OSR) + 1;
125 if(tag_offset < last_sample_nr){
126 DCOUT("Freq change inside FCCH burst!!!!!!!!!!!!!!");
127 freq_offset_tag_in_fcch = true;
128 }
129 d_freq_offset_setting = pmt::to_double(freq_offset_tag.value);
130 } else {
131 d_freq_offset_setting = pmt::to_double(freq_offset_tag.value);
132 }
133 }
134
piotrd0bf1492014-02-05 17:27:32 +0100135 switch (d_state)
piotr437f5462014-02-04 17:57:25 +0100136 {
piotrd0bf1492014-02-05 17:27:32 +0100137 //bootstrapping
piotrd6d66872014-08-06 15:20:33 +0200138 case fcch_search: //this state is used because it takes some time (a bunch of buffered samples)
piotrd0bf1492014-02-05 17:27:32 +0100139 {
piotrd6d66872014-08-06 15:20:33 +0200140 DCOUT("FCCH search");
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 {
piotr7c82b172014-02-08 14:15:27 +0100158 DCOUT("SCH search");
piotrd0bf1492014-02-05 17:27:32 +0100159 vector_complex channel_imp_resp(CHAN_IMP_RESP_LENGTH*d_OSR);
160 int t1, t2, t3;
161 int burst_start = 0;
162 unsigned char output_binary[BURST_SIZE];
piotr437f5462014-02-04 17:57:25 +0100163
piotrc7c249a2014-05-02 17:24:08 +0200164 if (reach_sch_burst(noutput_items)) //wait for a SCH burst
piotrd0bf1492014-02-05 17:27:32 +0100165 {
166 burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]); //get channel impulse response from it
167 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //detect bits using MLSE detection
168 if (decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc) == 0) //decode SCH burst
169 {
piotr6d152d92014-02-21 00:02:44 +0100170 DCOUT("sch burst_start: " << burst_start);
171 DCOUT("bcc: " << d_bcc << " ncc: " << d_ncc << " t1: " << t1 << " t2: " << t2 << " t3: " << t3);
piotr437f5462014-02-04 17:57:25 +0100172 d_burst_nr.set(t1, t2, t3, 0); //set counter of bursts value
piotr437f5462014-02-04 17:57:25 +0100173 d_burst_nr++;
174
piotr7f3f3662014-07-08 16:47:53 +0200175 consume_each(burst_start + BURST_SIZE * d_OSR + 4*d_OSR); //consume samples up to next guard period
piotr437f5462014-02-04 17:57:25 +0100176 d_state = synchronized;
piotrd0bf1492014-02-05 17:27:32 +0100177 }
178 else
179 {
piotrd6d66872014-08-06 15:20:33 +0200180 d_state = fcch_search; //if there is error in the sch burst go back to fcch search phase
piotr437f5462014-02-04 17:57:25 +0100181 }
piotrd0bf1492014-02-05 17:27:32 +0100182 }
183 else
184 {
185 d_state = sch_search;
186 }
187 break;
188 }
189 //in this state receiver is synchronized and it processes bursts according to burst type for given burst number
190 case synchronized:
191 {
piotr6d152d92014-02-21 00:02:44 +0100192 DCOUT("Synchronized");
piotrd0bf1492014-02-05 17:27:32 +0100193 vector_complex channel_imp_resp(CHAN_IMP_RESP_LENGTH*d_OSR);
194 int burst_start;
195 int offset = 0;
196 int to_consume = 0;
197 unsigned char output_binary[BURST_SIZE];
piotr437f5462014-02-04 17:57:25 +0100198
piotrd0bf1492014-02-05 17:27:32 +0100199 burst_type b_type = d_channel_conf.get_burst_type(d_burst_nr); //get burst type for given burst number
piotrf2b6a1b2014-08-04 11:28:59 +0200200 double signal_pwr = 0;
piotrc7c249a2014-05-02 17:24:08 +0200201 for(int ii=0;ii<noutput_items;ii++)
piotr6d152d92014-02-21 00:02:44 +0100202 {
203 signal_pwr += abs(input[ii])*abs(input[ii]);
204 }
piotrf2b6a1b2014-08-04 11:28:59 +0200205 d_signal_dbm=static_cast<int8_t>(round(10*log10(signal_pwr/50/noutput_items)));
piotr6d152d92014-02-21 00:02:44 +0100206
piotrd0bf1492014-02-05 17:27:32 +0100207 switch (b_type)
208 {
209 case fcch_burst: //if it's FCCH burst
210 {
211 const unsigned first_sample = ceil((GUARD_PERIOD + 2 * TAIL_BITS) * d_OSR) + 1;
212 const unsigned last_sample = first_sample + USEFUL_BITS * d_OSR - TAIL_BITS * d_OSR;
piotr4089c1a2014-08-06 14:10:56 +0200213 double freq_offset_tmp = compute_freq_offset(input, first_sample, last_sample); //extract frequency offset from it
piotr437f5462014-02-04 17:57:25 +0100214
piotr6d152d92014-02-21 00:02:44 +0100215 send_burst(d_burst_nr, fc_fb, b_type);
216
piotr4089c1a2014-08-06 14:10:56 +0200217 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(freq_offset_tmp-d_freq_offset_setting),pmt::mp("synchronized"));
218 message_port_pub(pmt::mp("measurements"), msg);
piotrd0bf1492014-02-05 17:27:32 +0100219 }
220 break;
221 case sch_burst: //if it's SCH burst
222 {
223 int t1, t2, t3, d_ncc, d_bcc;
224 burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]); //get channel impulse response
piotr4089c1a2014-08-06 14:10:56 +0200225
piotrd0bf1492014-02-05 17:27:32 +0100226 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //MLSE detection of bits
piotr6d152d92014-02-21 00:02:44 +0100227 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100228 if (decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc) == 0) //and decode SCH data
229 {
230 // d_burst_nr.set(t1, t2, t3, 0); //but only to check if burst_start value is correct
231 d_failed_sch = 0;
232 DCOUT("bcc: " << d_bcc << " ncc: " << d_ncc << " t1: " << t1 << " t2: " << t2 << " t3: " << t3);
233 offset = burst_start - floor((GUARD_PERIOD) * d_OSR); //compute offset from burst_start - burst should start after a guard period
piotr7c82b172014-02-08 14:15:27 +0100234 DCOUT("offset: "<<offset);
piotrd0bf1492014-02-05 17:27:32 +0100235 to_consume += offset; //adjust with offset number of samples to be consumed
236 }
237 else
238 {
239 d_failed_sch++;
240 if (d_failed_sch >= MAX_SCH_ERRORS)
241 {
piotrd6d66872014-08-06 15:20:33 +0200242 d_state = fcch_search;
piotr4089c1a2014-08-06 14:10:56 +0200243 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(0.0),pmt::mp("sync_loss"));
244 message_port_pub(pmt::mp("measurements"), msg);
245 DCOUT("Re-Synchronization!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
piotr437f5462014-02-04 17:57:25 +0100246 }
piotr437f5462014-02-04 17:57:25 +0100247 }
piotrd0bf1492014-02-05 17:27:32 +0100248 }
249 break;
piotr437f5462014-02-04 17:57:25 +0100250
piotr7e3b0db2014-02-05 22:44:30 +0100251 case normal_burst:
252 {
253 float normal_corr_max; //if it's normal burst
254 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
piotrd0bf1492014-02-05 17:27:32 +0100255 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //MLSE detection of bits
piotr8dc74a42014-04-17 09:48:46 +0200256 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100257 break;
piotr7e3b0db2014-02-05 22:44:30 +0100258 }
piotrd0bf1492014-02-05 17:27:32 +0100259 case dummy_or_normal:
260 {
piotr7e3b0db2014-02-05 22:44:30 +0100261 unsigned int normal_burst_start;
262 float dummy_corr_max, normal_corr_max;
263 get_norm_chan_imp_resp(input, &channel_imp_resp[0], &dummy_corr_max, TS_DUMMY);
264 normal_burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], &normal_corr_max, d_bcc);
265
piotr7c82b172014-02-08 14:15:27 +0100266 DCOUT("normal_corr_max: " << normal_corr_max << " dummy_corr_max:" << dummy_corr_max);
piotr7e3b0db2014-02-05 22:44:30 +0100267 if (normal_corr_max > dummy_corr_max)
piotrd0bf1492014-02-05 17:27:32 +0100268 {
piotr7e3b0db2014-02-05 22:44:30 +0100269 detect_burst(input, &channel_imp_resp[0], normal_burst_start, output_binary);
piotr8dc74a42014-04-17 09:48:46 +0200270 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100271 }
272 else
273 {
piotr6d152d92014-02-21 00:02:44 +0100274 send_burst(d_burst_nr, dummy_burst, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100275 }
276 }
277 case rach_burst:
piotrd0bf1492014-02-05 17:27:32 +0100278 break;
piotr7e3b0db2014-02-05 22:44:30 +0100279 case dummy:
piotr6d152d92014-02-21 00:02:44 +0100280 send_burst(d_burst_nr, dummy_burst, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100281 break;
282 case empty: //if it's empty burst
283 break; //do nothing
284 }
285
286 d_burst_nr++; //go to next burst
piotrd0bf1492014-02-05 17:27:32 +0100287 to_consume += TS_BITS * d_OSR + d_burst_nr.get_offset(); //consume samples of the burst up to next guard period
288 //and add offset which is introduced by
289 //0.25 fractional part of a guard period
piotrd0bf1492014-02-05 17:27:32 +0100290 consume_each(to_consume);
291 }
292 break;
piotr437f5462014-02-04 17:57:25 +0100293 }
294
piotr6d152d92014-02-21 00:02:44 +0100295 return 0;
piotrd0bf1492014-02-05 17:27:32 +0100296}
piotr437f5462014-02-04 17:57:25 +0100297
piotr4089c1a2014-08-06 14:10:56 +0200298bool receiver_impl::find_fcch_burst(const gr_complex *input, const int nitems, double & computed_freq_offset)
piotrd0bf1492014-02-05 17:27:32 +0100299{
300 circular_buffer_float phase_diff_buffer(FCCH_HITS_NEEDED * d_OSR); //circular buffer used to scan throug signal to find
301 //best match for FCCH burst
302 float phase_diff = 0;
303 gr_complex conjprod;
304 int start_pos = -1;
305 int hit_count = 0;
306 int miss_count = 0;
307 float min_phase_diff;
308 float max_phase_diff;
309 double best_sum = 0;
310 float lowest_max_min_diff = 99999;
311
312 int to_consume = 0;
313 int sample_number = 0;
314 bool end = false;
315 bool result = false;
316 circular_buffer_float::iterator buffer_iter;
piotr6d152d92014-02-21 00:02:44 +0100317
piotrd0bf1492014-02-05 17:27:32 +0100318 /**@name Possible states of FCCH search algorithm*/
319 //@{
320 enum states
piotr437f5462014-02-04 17:57:25 +0100321 {
piotr437f5462014-02-04 17:57:25 +0100322 init, ///< initialize variables
323 search, ///< search for positive samples
324 found_something, ///< search for FCCH and the best position of it
325 fcch_found, ///< when FCCH was found
326 search_fail ///< when there is no FCCH in the input vector
piotrd0bf1492014-02-05 17:27:32 +0100327 } fcch_search_state;
328 //@}
piotr437f5462014-02-04 17:57:25 +0100329
piotrd0bf1492014-02-05 17:27:32 +0100330 fcch_search_state = init;
piotr437f5462014-02-04 17:57:25 +0100331
piotrd0bf1492014-02-05 17:27:32 +0100332 while (!end)
333 {
334 switch (fcch_search_state)
335 {
piotr437f5462014-02-04 17:57:25 +0100336
piotrd0bf1492014-02-05 17:27:32 +0100337 case init: //initialize variables
piotr437f5462014-02-04 17:57:25 +0100338 hit_count = 0;
339 miss_count = 0;
340 start_pos = -1;
341 lowest_max_min_diff = 99999;
342 phase_diff_buffer.clear();
343 fcch_search_state = search;
344
345 break;
346
piotr7c82b172014-02-08 14:15:27 +0100347 case search: // search for positive samples
piotr437f5462014-02-04 17:57:25 +0100348 sample_number++;
349
piotrd0bf1492014-02-05 17:27:32 +0100350 if (sample_number > nitems - FCCH_HITS_NEEDED * d_OSR) //if it isn't possible to find FCCH because
351 {
piotr7c82b172014-02-08 14:15:27 +0100352 //there's too few samples left to look into,
piotrd0bf1492014-02-05 17:27:32 +0100353 to_consume = sample_number; //don't do anything with those samples which are left
piotr7c82b172014-02-08 14:15:27 +0100354 //and consume only those which were checked
piotrd0bf1492014-02-05 17:27:32 +0100355 fcch_search_state = search_fail;
356 }
357 else
358 {
359 phase_diff = compute_phase_diff(input[sample_number], input[sample_number-1]);
piotr437f5462014-02-04 17:57:25 +0100360
piotrd0bf1492014-02-05 17:27:32 +0100361 if (phase_diff > 0) //if a positive phase difference was found
362 {
363 to_consume = sample_number;
364 fcch_search_state = found_something; //switch to state in which searches for FCCH
365 }
366 else
367 {
368 fcch_search_state = search;
369 }
piotr437f5462014-02-04 17:57:25 +0100370 }
371
372 break;
373
piotrd0bf1492014-02-05 17:27:32 +0100374 case found_something: // search for FCCH and the best position of it
375 {
376 if (phase_diff > 0)
377 {
piotr437f5462014-02-04 17:57:25 +0100378 hit_count++; //positive phase differencies increases hits_count
piotrd0bf1492014-02-05 17:27:32 +0100379 }
380 else
381 {
piotr437f5462014-02-04 17:57:25 +0100382 miss_count++; //negative increases miss_count
piotrd0bf1492014-02-05 17:27:32 +0100383 }
piotr437f5462014-02-04 17:57:25 +0100384
piotrd0bf1492014-02-05 17:27:32 +0100385 if ((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count <= FCCH_HITS_NEEDED * d_OSR))
386 {
piotr437f5462014-02-04 17:57:25 +0100387 //if miss_count exceeds limit before hit_count
388 fcch_search_state = init; //go to init
389 continue;
piotrd0bf1492014-02-05 17:27:32 +0100390 }
391 else if (((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR)) || (hit_count > 2 * FCCH_HITS_NEEDED * d_OSR))
392 {
piotr437f5462014-02-04 17:57:25 +0100393 //if hit_count and miss_count exceeds limit then FCCH was found
394 fcch_search_state = fcch_found;
395 continue;
piotrd0bf1492014-02-05 17:27:32 +0100396 }
397 else if ((miss_count < FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR))
398 {
piotr437f5462014-02-04 17:57:25 +0100399 //find difference between minimal and maximal element in the buffer
400 //for FCCH this value should be low
401 //this part is searching for a region where this value is lowest
402 min_phase_diff = * (min_element(phase_diff_buffer.begin(), phase_diff_buffer.end()));
403 max_phase_diff = * (max_element(phase_diff_buffer.begin(), phase_diff_buffer.end()));
404
piotrd0bf1492014-02-05 17:27:32 +0100405 if (lowest_max_min_diff > max_phase_diff - min_phase_diff)
406 {
407 lowest_max_min_diff = max_phase_diff - min_phase_diff;
408 start_pos = sample_number - FCCH_HITS_NEEDED * d_OSR - FCCH_MAX_MISSES * d_OSR; //store start pos
409 best_sum = 0;
piotr437f5462014-02-04 17:57:25 +0100410
piotrd0bf1492014-02-05 17:27:32 +0100411 for (buffer_iter = phase_diff_buffer.begin();
412 buffer_iter != (phase_diff_buffer.end());
413 buffer_iter++)
414 {
415 best_sum += *buffer_iter - (M_PI / 2) / d_OSR; //store best value of phase offset sum
416 }
piotr437f5462014-02-04 17:57:25 +0100417 }
piotrd0bf1492014-02-05 17:27:32 +0100418 }
piotr437f5462014-02-04 17:57:25 +0100419
piotrd0bf1492014-02-05 17:27:32 +0100420 sample_number++;
piotr437f5462014-02-04 17:57:25 +0100421
piotrd0bf1492014-02-05 17:27:32 +0100422 if (sample_number >= nitems) //if there's no single sample left to check
423 {
piotr437f5462014-02-04 17:57:25 +0100424 fcch_search_state = search_fail;//FCCH search failed
425 continue;
piotr437f5462014-02-04 17:57:25 +0100426 }
piotrd0bf1492014-02-05 17:27:32 +0100427
428 phase_diff = compute_phase_diff(input[sample_number], input[sample_number-1]);
429 phase_diff_buffer.push_back(phase_diff);
430 fcch_search_state = found_something;
431 }
432 break;
433
434 case fcch_found:
435 {
436 DCOUT("fcch found on position: " << d_counter + start_pos);
437 to_consume = start_pos + FCCH_HITS_NEEDED * d_OSR + 1; //consume one FCCH burst
438
439 d_fcch_start_pos = d_counter + start_pos;
440
441 //compute frequency offset
442 double phase_offset = best_sum / FCCH_HITS_NEEDED;
piotr4089c1a2014-08-06 14:10:56 +0200443 double freq_offset = phase_offset * 1625000.0/6 / (2 * M_PI); //1625000.0/6 - GMSK symbol rate in GSM
444 computed_freq_offset = freq_offset;
piotrd0bf1492014-02-05 17:27:32 +0100445
446 end = true;
447 result = true;
piotr437f5462014-02-04 17:57:25 +0100448 break;
piotrd0bf1492014-02-05 17:27:32 +0100449 }
piotr437f5462014-02-04 17:57:25 +0100450
piotrd0bf1492014-02-05 17:27:32 +0100451 case search_fail:
piotr437f5462014-02-04 17:57:25 +0100452 end = true;
453 result = false;
454 break;
455 }
piotr437f5462014-02-04 17:57:25 +0100456 }
457
piotrd0bf1492014-02-05 17:27:32 +0100458 d_counter += to_consume;
459 consume_each(to_consume);
piotr437f5462014-02-04 17:57:25 +0100460
piotrd0bf1492014-02-05 17:27:32 +0100461 return result;
462}
463
piotrd0bf1492014-02-05 17:27:32 +0100464double receiver_impl::compute_freq_offset(const gr_complex * input, unsigned first_sample, unsigned last_sample)
465{
466 double phase_sum = 0;
467 unsigned ii;
468
469 for (ii = first_sample; ii < last_sample; ii++)
piotr437f5462014-02-04 17:57:25 +0100470 {
piotr437f5462014-02-04 17:57:25 +0100471 double phase_diff = compute_phase_diff(input[ii], input[ii-1]) - (M_PI / 2) / d_OSR;
472 phase_sum += phase_diff;
piotr437f5462014-02-04 17:57:25 +0100473 }
474
piotrd0bf1492014-02-05 17:27:32 +0100475 double phase_offset = phase_sum / (last_sample - first_sample);
476 double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI);
477 return freq_offset;
478}
piotr437f5462014-02-04 17:57:25 +0100479
piotrd0bf1492014-02-05 17:27:32 +0100480void receiver_impl::set_frequency(double freq_offset)
481{
482 d_tuner->calleval(freq_offset);
483}
piotr437f5462014-02-04 17:57:25 +0100484
piotrd0bf1492014-02-05 17:27:32 +0100485inline float receiver_impl::compute_phase_diff(gr_complex val1, gr_complex val2)
486{
487 gr_complex conjprod = val1 * conj(val2);
488 return fast_atan2f(imag(conjprod), real(conjprod));
489}
piotr437f5462014-02-04 17:57:25 +0100490
piotrd0bf1492014-02-05 17:27:32 +0100491bool receiver_impl::reach_sch_burst(const int nitems)
492{
493 //it just consumes samples to get near to a SCH burst
494 int to_consume = 0;
495 bool result = false;
496 unsigned sample_nr_near_sch_start = d_fcch_start_pos + (FRAME_BITS - SAFETY_MARGIN) * d_OSR;
497
498 //consume samples until d_counter will be equal to sample_nr_near_sch_start
499 if (d_counter < sample_nr_near_sch_start)
500 {
501 if (d_counter + nitems >= sample_nr_near_sch_start)
502 {
503 to_consume = sample_nr_near_sch_start - d_counter;
504 }
505 else
506 {
507 to_consume = nitems;
piotr437f5462014-02-04 17:57:25 +0100508 }
509 result = false;
piotrd0bf1492014-02-05 17:27:32 +0100510 }
511 else
512 {
piotr437f5462014-02-04 17:57:25 +0100513 to_consume = 0;
514 result = true;
piotr437f5462014-02-04 17:57:25 +0100515 }
516
piotrd0bf1492014-02-05 17:27:32 +0100517 d_counter += to_consume;
518 consume_each(to_consume);
519 return result;
520}
521
522int receiver_impl::get_sch_chan_imp_resp(const gr_complex *input, gr_complex * chan_imp_resp)
523{
524 vector_complex correlation_buffer;
525 vector_float power_buffer;
526 vector_float window_energy_buffer;
527
528 int strongest_window_nr;
529 int burst_start = 0;
530 int chan_imp_resp_center = 0;
531 float max_correlation = 0;
532 float energy = 0;
533
534 for (int ii = SYNC_POS * d_OSR; ii < (SYNC_POS + SYNC_SEARCH_RANGE) *d_OSR; ii++)
piotr437f5462014-02-04 17:57:25 +0100535 {
piotr437f5462014-02-04 17:57:25 +0100536 gr_complex correlation = correlate_sequence(&d_sch_training_seq[5], N_SYNC_BITS - 10, &input[ii]);
537 correlation_buffer.push_back(correlation);
538 power_buffer.push_back(std::pow(abs(correlation), 2));
piotrd0bf1492014-02-05 17:27:32 +0100539 }
piotr7f3f3662014-07-08 16:47:53 +0200540 //plot(power_buffer);
piotrd0bf1492014-02-05 17:27:32 +0100541 //compute window energies
542 vector_float::iterator iter = power_buffer.begin();
543 bool loop_end = false;
544 while (iter != power_buffer.end())
545 {
piotr437f5462014-02-04 17:57:25 +0100546 vector_float::iterator iter_ii = iter;
547 energy = 0;
548
piotrd0bf1492014-02-05 17:27:32 +0100549 for (int ii = 0; ii < (d_chan_imp_length) *d_OSR; ii++, iter_ii++)
550 {
551 if (iter_ii == power_buffer.end())
552 {
553 loop_end = true;
554 break;
555 }
556 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100557 }
piotrd0bf1492014-02-05 17:27:32 +0100558 if (loop_end)
559 {
560 break;
piotr437f5462014-02-04 17:57:25 +0100561 }
562 iter++;
563 window_energy_buffer.push_back(energy);
piotrd0bf1492014-02-05 17:27:32 +0100564 }
piotr437f5462014-02-04 17:57:25 +0100565
piotrd0bf1492014-02-05 17:27:32 +0100566 strongest_window_nr = max_element(window_energy_buffer.begin(), window_energy_buffer.end()) - window_energy_buffer.begin();
piotr437f5462014-02-04 17:57:25 +0100567 // d_channel_imp_resp.clear();
568
piotrd0bf1492014-02-05 17:27:32 +0100569 max_correlation = 0;
570 for (int ii = 0; ii < (d_chan_imp_length) *d_OSR; ii++)
571 {
piotr437f5462014-02-04 17:57:25 +0100572 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100573 if (abs(correlation) > max_correlation)
574 {
575 chan_imp_resp_center = ii;
576 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100577 }
piotrd0bf1492014-02-05 17:27:32 +0100578 // d_channel_imp_resp.push_back(correlation);
piotr437f5462014-02-04 17:57:25 +0100579 chan_imp_resp[ii] = correlation;
piotr437f5462014-02-04 17:57:25 +0100580 }
581
piotrd0bf1492014-02-05 17:27:32 +0100582 burst_start = strongest_window_nr + chan_imp_resp_center - 48 * d_OSR - 2 * d_OSR + 2 + SYNC_POS * d_OSR;
583 return burst_start;
584}
piotr437f5462014-02-04 17:57:25 +0100585
586
piotrd0bf1492014-02-05 17:27:32 +0100587
588void receiver_impl::detect_burst(const gr_complex * input, gr_complex * chan_imp_resp, int burst_start, unsigned char * output_binary)
589{
590 float output[BURST_SIZE];
591 gr_complex rhh_temp[CHAN_IMP_RESP_LENGTH*d_OSR];
592 gr_complex rhh[CHAN_IMP_RESP_LENGTH];
593 gr_complex filtered_burst[BURST_SIZE];
594 int start_state = 3;
595 unsigned int stop_states[2] = {4, 12};
596
597 autocorrelation(chan_imp_resp, rhh_temp, d_chan_imp_length*d_OSR);
598 for (int ii = 0; ii < (d_chan_imp_length); ii++)
piotr437f5462014-02-04 17:57:25 +0100599 {
piotr437f5462014-02-04 17:57:25 +0100600 rhh[ii] = conj(rhh_temp[ii*d_OSR]);
piotr437f5462014-02-04 17:57:25 +0100601 }
602
piotrd0bf1492014-02-05 17:27:32 +0100603 mafi(&input[burst_start], BURST_SIZE, chan_imp_resp, d_chan_imp_length*d_OSR, filtered_burst);
604
605 viterbi_detector(filtered_burst, BURST_SIZE, rhh, start_state, stop_states, 2, output);
606
607 for (int i = 0; i < BURST_SIZE ; i++)
piotr437f5462014-02-04 17:57:25 +0100608 {
piotrd0bf1492014-02-05 17:27:32 +0100609 output_binary[i] = (output[i] > 0);
610 }
611}
piotr437f5462014-02-04 17:57:25 +0100612
piotrd0bf1492014-02-05 17:27:32 +0100613void receiver_impl::gmsk_mapper(const unsigned char * input, int nitems, gr_complex * gmsk_output, gr_complex start_point)
614{
615 gr_complex j = gr_complex(0.0, 1.0);
piotr437f5462014-02-04 17:57:25 +0100616
piotrd0bf1492014-02-05 17:27:32 +0100617 int current_symbol;
618 int encoded_symbol;
619 int previous_symbol = 2 * input[0] - 1;
620 gmsk_output[0] = start_point;
621
622 for (int i = 1; i < nitems; i++)
623 {
piotr437f5462014-02-04 17:57:25 +0100624 //change bits representation to NRZ
625 current_symbol = 2 * input[i] - 1;
626 //differentially encode
627 encoded_symbol = current_symbol * previous_symbol;
628 //and do gmsk mapping
629 gmsk_output[i] = j * gr_complex(encoded_symbol, 0.0) * gmsk_output[i-1];
630 previous_symbol = current_symbol;
piotr437f5462014-02-04 17:57:25 +0100631 }
piotrd0bf1492014-02-05 17:27:32 +0100632}
piotr437f5462014-02-04 17:57:25 +0100633
piotrd0bf1492014-02-05 17:27:32 +0100634gr_complex receiver_impl::correlate_sequence(const gr_complex * sequence, int length, const gr_complex * input)
635{
636 gr_complex result(0.0, 0.0);
637 int sample_number = 0;
638
639 for (int ii = 0; ii < length; ii++)
piotr437f5462014-02-04 17:57:25 +0100640 {
piotr437f5462014-02-04 17:57:25 +0100641 sample_number = (ii * d_OSR) ;
642 result += sequence[ii] * conj(input[sample_number]);
piotr437f5462014-02-04 17:57:25 +0100643 }
644
piotrd0bf1492014-02-05 17:27:32 +0100645 result = result / gr_complex(length, 0);
646 return result;
647}
648
649//computes autocorrelation for positive arguments
piotrd0bf1492014-02-05 17:27:32 +0100650inline void receiver_impl::autocorrelation(const gr_complex * input, gr_complex * out, int nitems)
651{
652 int i, k;
653 for (k = nitems - 1; k >= 0; k--)
piotr437f5462014-02-04 17:57:25 +0100654 {
piotr437f5462014-02-04 17:57:25 +0100655 out[k] = gr_complex(0, 0);
piotrd0bf1492014-02-05 17:27:32 +0100656 for (i = k; i < nitems; i++)
657 {
658 out[k] += input[i] * conj(input[i-k]);
piotr437f5462014-02-04 17:57:25 +0100659 }
piotr437f5462014-02-04 17:57:25 +0100660 }
piotrd0bf1492014-02-05 17:27:32 +0100661}
piotr437f5462014-02-04 17:57:25 +0100662
piotrd0bf1492014-02-05 17:27:32 +0100663inline void receiver_impl::mafi(const gr_complex * input, int nitems, gr_complex * filter, int filter_length, gr_complex * output)
664{
665 int ii = 0, n, a;
666
667 for (n = 0; n < nitems; n++)
piotr437f5462014-02-04 17:57:25 +0100668 {
piotr437f5462014-02-04 17:57:25 +0100669 a = n * d_OSR;
670 output[n] = 0;
671 ii = 0;
672
piotrd0bf1492014-02-05 17:27:32 +0100673 while (ii < filter_length)
674 {
piotrda8a0662014-04-24 10:29:38 +0200675 if ((a + ii) >= nitems*d_OSR){
piotrd0bf1492014-02-05 17:27:32 +0100676 break;
piotrda8a0662014-04-24 10:29:38 +0200677 }
piotrd0bf1492014-02-05 17:27:32 +0100678 output[n] += input[a+ii] * filter[ii];
679 ii++;
piotr437f5462014-02-04 17:57:25 +0100680 }
piotr437f5462014-02-04 17:57:25 +0100681 }
piotrd0bf1492014-02-05 17:27:32 +0100682}
piotr437f5462014-02-04 17:57:25 +0100683
piotrd0bf1492014-02-05 17:27:32 +0100684//especially computations of strongest_window_nr
piotr7e3b0db2014-02-05 22:44:30 +0100685int 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 +0100686{
687 vector_complex correlation_buffer;
688 vector_float power_buffer;
689 vector_float window_energy_buffer;
piotr437f5462014-02-04 17:57:25 +0100690
piotrd0bf1492014-02-05 17:27:32 +0100691 int strongest_window_nr;
692 int burst_start = 0;
693 int chan_imp_resp_center = 0;
694 float max_correlation = 0;
695 float energy = 0;
piotr5c820252014-04-17 09:43:02 +0200696
piotrd0bf1492014-02-05 17:27:32 +0100697 int search_center = (int)((TRAIN_POS + GUARD_PERIOD) * d_OSR);
piotr7c82b172014-02-08 14:15:27 +0100698 int search_start_pos = search_center + 1 - 5*d_OSR;
piotr437f5462014-02-04 17:57:25 +0100699 // int search_start_pos = search_center - d_chan_imp_length * d_OSR;
piotr5c820252014-04-17 09:43:02 +0200700 int search_stop_pos = search_center + d_chan_imp_length * d_OSR + 5 * d_OSR;
piotr437f5462014-02-04 17:57:25 +0100701
piotrd0bf1492014-02-05 17:27:32 +0100702 for (int ii = search_start_pos; ii < search_stop_pos; ii++)
703 {
piotr437f5462014-02-04 17:57:25 +0100704 gr_complex correlation = correlate_sequence(&d_norm_training_seq[bcc][TRAIN_BEGINNING], N_TRAIN_BITS - 10, &input[ii]);
705
706 correlation_buffer.push_back(correlation);
707 power_buffer.push_back(std::pow(abs(correlation), 2));
piotrd0bf1492014-02-05 17:27:32 +0100708 }
piotr437f5462014-02-04 17:57:25 +0100709
piotrd0bf1492014-02-05 17:27:32 +0100710 //compute window energies
711 vector_float::iterator iter = power_buffer.begin();
712 bool loop_end = false;
713 while (iter != power_buffer.end())
714 {
piotr437f5462014-02-04 17:57:25 +0100715 vector_float::iterator iter_ii = iter;
716 energy = 0;
717
piotrd0bf1492014-02-05 17:27:32 +0100718 for (int ii = 0; ii < (d_chan_imp_length - 2)*d_OSR; ii++, iter_ii++)
719 {
piotrd0bf1492014-02-05 17:27:32 +0100720 if (iter_ii == power_buffer.end())
721 {
722 loop_end = true;
723 break;
724 }
725 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100726 }
piotrd0bf1492014-02-05 17:27:32 +0100727 if (loop_end)
728 {
729 break;
piotr437f5462014-02-04 17:57:25 +0100730 }
731 iter++;
732
733 window_energy_buffer.push_back(energy);
piotrd0bf1492014-02-05 17:27:32 +0100734 }
piotr437f5462014-02-04 17:57:25 +0100735
piotr5c820252014-04-17 09:43:02 +0200736 strongest_window_nr = max_element(window_energy_buffer.begin(), window_energy_buffer.end()-((d_chan_imp_length)*d_OSR)) - window_energy_buffer.begin();
737 //strongest_window_nr = strongest_window_nr-d_OSR;
738 if(strongest_window_nr<0){
739 strongest_window_nr = 0;
740 }
piotr6d152d92014-02-21 00:02:44 +0100741
piotrd0bf1492014-02-05 17:27:32 +0100742 max_correlation = 0;
743 for (int ii = 0; ii < (d_chan_imp_length)*d_OSR; ii++)
744 {
piotr437f5462014-02-04 17:57:25 +0100745 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100746 if (abs(correlation) > max_correlation)
747 {
748 chan_imp_resp_center = ii;
749 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100750 }
piotrd0bf1492014-02-05 17:27:32 +0100751 // d_channel_imp_resp.push_back(correlation);
piotr437f5462014-02-04 17:57:25 +0100752 chan_imp_resp[ii] = correlation;
piotr437f5462014-02-04 17:57:25 +0100753 }
piotr7c82b172014-02-08 14:15:27 +0100754
piotr7e3b0db2014-02-05 22:44:30 +0100755 *corr_max = max_correlation;
piotrd0bf1492014-02-05 17:27:32 +0100756
piotr7c82b172014-02-08 14:15:27 +0100757 DCOUT("strongest_window_nr_new: " << strongest_window_nr);
piotrc7c249a2014-05-02 17:24:08 +0200758 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 +0100759
760 DCOUT("burst_start: " << burst_start);
piotrd0bf1492014-02-05 17:27:32 +0100761 return burst_start;
762}
piotr437f5462014-02-04 17:57:25 +0100763
764
piotr6d152d92014-02-21 00:02:44 +0100765void receiver_impl::send_burst(burst_counter burst_nr, const unsigned char * burst_binary, burst_type b_type)
piotrd0bf1492014-02-05 17:27:32 +0100766{
piotr7c82b172014-02-08 14:15:27 +0100767
piotr6d152d92014-02-21 00:02:44 +0100768 boost::scoped_ptr<gsmtap_hdr> tap_header(new gsmtap_hdr());
769
770 tap_header->version = GSMTAP_VERSION;
771 tap_header->hdr_len = BURST_SIZE/4;
772 tap_header->type = GSMTAP_TYPE_UM_BURST;
773 tap_header->timeslot = static_cast<uint8_t>(d_burst_nr.get_timeslot_nr());
774 tap_header->frame_number = d_burst_nr.get_frame_nr();
775 tap_header->sub_type = static_cast<uint8_t>(b_type);
776 tap_header->arfcn = d_arfcn;
777 tap_header->signal_dbm = static_cast<int8_t>(d_signal_dbm);
778 pmt::pmt_t header_blob=pmt::make_blob(tap_header.get(),sizeof(gsmtap_hdr));
779 pmt::pmt_t burst_binary_blob=pmt::make_blob(burst_binary,BURST_SIZE);
780 pmt::pmt_t msg = pmt::cons(header_blob, burst_binary_blob);
piotrf2b6a1b2014-08-04 11:28:59 +0200781
piotr6d152d92014-02-21 00:02:44 +0100782 message_port_pub(pmt::mp("bursts"), msg);
piotrd0bf1492014-02-05 17:27:32 +0100783}
piotr6d152d92014-02-21 00:02:44 +0100784
piotrd0bf1492014-02-05 17:27:32 +0100785void receiver_impl::configure_receiver()
786{
piotrce92f982014-04-17 23:37:18 +0200787 d_channel_conf.set_multiframe_type(TIMESLOT0, multiframe_51);
piotrd0bf1492014-02-05 17:27:32 +0100788 d_channel_conf.set_burst_types(TIMESLOT0, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotr437f5462014-02-04 17:57:25 +0100789
piotrce92f982014-04-17 23:37:18 +0200790 d_channel_conf.set_burst_types(TIMESLOT0, TEST_CCH_FRAMES, sizeof(TEST_CCH_FRAMES) / sizeof(unsigned), dummy_or_normal);
791 d_channel_conf.set_burst_types(TIMESLOT0, FCCH_FRAMES, sizeof(FCCH_FRAMES) / sizeof(unsigned), fcch_burst);
792 d_channel_conf.set_burst_types(TIMESLOT0, SCH_FRAMES, sizeof(SCH_FRAMES) / sizeof(unsigned), sch_burst);
piotr437f5462014-02-04 17:57:25 +0100793
794 // d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_26);
795 // d_channel_conf.set_burst_types(TIMESLOT1, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
796 // d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_26);
797 // d_channel_conf.set_burst_types(TIMESLOT2, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
798 // d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_26);
799 // d_channel_conf.set_burst_types(TIMESLOT3, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
800 // d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_26);
801 // d_channel_conf.set_burst_types(TIMESLOT4, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
802 // d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_26);
803 // d_channel_conf.set_burst_types(TIMESLOT5, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
804 // d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_26);
805 // d_channel_conf.set_burst_types(TIMESLOT6, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
806 // d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_26);
807 // d_channel_conf.set_burst_types(TIMESLOT7, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
piotr7e3b0db2014-02-05 22:44:30 +0100808
piotrd0bf1492014-02-05 17:27:32 +0100809 d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_51);
810 d_channel_conf.set_burst_types(TIMESLOT1, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
811 d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_51);
812 d_channel_conf.set_burst_types(TIMESLOT2, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
813 d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_51);
814 d_channel_conf.set_burst_types(TIMESLOT3, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
815 d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_51);
816 d_channel_conf.set_burst_types(TIMESLOT4, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
817 d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_51);
818 d_channel_conf.set_burst_types(TIMESLOT5, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
819 d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_51);
820 d_channel_conf.set_burst_types(TIMESLOT6, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
821 d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_51);
822 d_channel_conf.set_burst_types(TIMESLOT7, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotrd0bf1492014-02-05 17:27:32 +0100823}
piotr437f5462014-02-04 17:57:25 +0100824
piotrf2b6a1b2014-08-04 11:28:59 +0200825void receiver_impl::set_arfcn(int arfcn) //!!
826{
827 d_arfcn = arfcn;
piotrf2b6a1b2014-08-04 11:28:59 +0200828}
829
830void receiver_impl::reset()
831{
piotrd6d66872014-08-06 15:20:33 +0200832 d_state = fcch_search;
piotrf2b6a1b2014-08-04 11:28:59 +0200833}
piotr437f5462014-02-04 17:57:25 +0100834
piotrd0bf1492014-02-05 17:27:32 +0100835} /* namespace gsm */
piotr437f5462014-02-04 17:57:25 +0100836} /* namespace gr */
837