blob: 0917f1eee5124417751ff7e720ec075626012051 [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
Piotr K608a08e2014-08-07 17:01:55 +020056receiver::make(int osr, int arfcn)
piotrd0bf1492014-02-05 17:27:32 +010057{
58 return gnuradio::get_initial_sptr
Piotr K608a08e2014-08-07 17:01:55 +020059 (new receiver_impl(osr, arfcn));
piotrd0bf1492014-02-05 17:27:32 +010060}
61
62/*
63 * The private constructor
64 */
Piotr K608a08e2014-08-07 17:01:55 +020065receiver_impl::receiver_impl(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),
piotrd0bf1492014-02-05 17:27:32 +010071 d_counter(0),
72 d_fcch_start_pos(0),
piotr4089c1a2014-08-06 14:10:56 +020073 d_freq_offset_setting(0),
piotrd6d66872014-08-06 15:20:33 +020074 d_state(fcch_search),
piotrd0bf1492014-02-05 17:27:32 +010075 d_burst_nr(osr),
piotr6d152d92014-02-21 00:02:44 +010076 d_failed_sch(0),
77 d_arfcn((int)(arfcn)),
78 d_signal_dbm(-120)
piotrd0bf1492014-02-05 17:27:32 +010079{
80 int i;
piotr4089c1a2014-08-06 14:10:56 +020081 //don't send samples to the receiver until there are at least samples for one
piotr7f3f3662014-07-08 16:47:53 +020082 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 +010083 gmsk_mapper(SYNC_BITS, N_SYNC_BITS, d_sch_training_seq, gr_complex(0.0, -1.0));
84 for (i = 0; i < TRAIN_SEQ_NUM; i++)
piotr437f5462014-02-04 17:57:25 +010085 {
piotrf502e0f2014-04-24 10:28:29 +020086 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 +020087 //if first bit of the seqeunce ==1 first symbol ==-1
piotr437f5462014-02-04 17:57:25 +010088 gmsk_mapper(train_seq[i], N_TRAIN_BITS, d_norm_training_seq[i], startpoint);
piotr437f5462014-02-04 17:57:25 +010089 }
piotr7c82b172014-02-08 14:15:27 +010090 message_port_register_out(pmt::mp("bursts"));
piotr4089c1a2014-08-06 14:10:56 +020091 message_port_register_out(pmt::mp("measurements"));
piotr903b1d62014-04-17 11:33:27 +020092 configure_receiver(); //configure the receiver - tell it where to find which burst type
piotrd0bf1492014-02-05 17:27:32 +010093}
piotr437f5462014-02-04 17:57:25 +010094
piotrd0bf1492014-02-05 17:27:32 +010095/*
96 * Our virtual destructor.
97 */
98receiver_impl::~receiver_impl()
99{
100}
101
piotrd0bf1492014-02-05 17:27:32 +0100102int
piotrc7c249a2014-05-02 17:24:08 +0200103receiver_impl::work(int noutput_items,
104 gr_vector_const_void_star &input_items,
105 gr_vector_void_star &output_items)
piotrd0bf1492014-02-05 17:27:32 +0100106{
107 const gr_complex *input = (const gr_complex *) input_items[0];
piotr4089c1a2014-08-06 14:10:56 +0200108 std::vector<tag_t> freq_offset_tags;
109 uint64_t start = nitems_read(0);
110 uint64_t stop = start + noutput_items;
piotr7c82b172014-02-08 14:15:27 +0100111
piotr4089c1a2014-08-06 14:10:56 +0200112 pmt::pmt_t key = pmt::string_to_symbol("setting_freq_offset");
113 get_tags_in_range(freq_offset_tags, 0, start, stop, key);
114 bool freq_offset_tag_in_fcch = false;
115 uint64_t tag_offset=-1; //-1 - just some clearly invalid value
116
117 if(!freq_offset_tags.empty()){
118 tag_t freq_offset_tag = freq_offset_tags[0];
119 tag_offset = freq_offset_tag.offset - start;
120
121 burst_type b_type = d_channel_conf.get_burst_type(d_burst_nr);
122 if(d_state == synchronized && b_type == fcch_burst){
123 uint64_t last_sample_nr = ceil((GUARD_PERIOD + 2.0 * TAIL_BITS + 156.25) * d_OSR) + 1;
124 if(tag_offset < last_sample_nr){
125 DCOUT("Freq change inside FCCH burst!!!!!!!!!!!!!!");
126 freq_offset_tag_in_fcch = true;
127 }
128 d_freq_offset_setting = pmt::to_double(freq_offset_tag.value);
129 } else {
130 d_freq_offset_setting = pmt::to_double(freq_offset_tag.value);
131 }
132 }
133
piotrd0bf1492014-02-05 17:27:32 +0100134 switch (d_state)
piotr437f5462014-02-04 17:57:25 +0100135 {
piotrd0bf1492014-02-05 17:27:32 +0100136 //bootstrapping
piotrd6d66872014-08-06 15:20:33 +0200137 case fcch_search: //this state is used because it takes some time (a bunch of buffered samples)
piotrd0bf1492014-02-05 17:27:32 +0100138 {
piotrd6d66872014-08-06 15:20:33 +0200139 DCOUT("FCCH search");
piotr4089c1a2014-08-06 14:10:56 +0200140 double freq_offset_tmp;
141 if (find_fcch_burst(input, noutput_items,freq_offset_tmp))
piotrd0bf1492014-02-05 17:27:32 +0100142 {
piotrd6d66872014-08-06 15:20:33 +0200143 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 +0200144 message_port_pub(pmt::mp("measurements"), msg);
145
piotrd0bf1492014-02-05 17:27:32 +0100146 d_state = sch_search;
147 }
148 else
149 {
piotrd6d66872014-08-06 15:20:33 +0200150 d_state = fcch_search;
piotrd0bf1492014-02-05 17:27:32 +0100151 }
152 break;
153 }
piotr437f5462014-02-04 17:57:25 +0100154
piotrd0bf1492014-02-05 17:27:32 +0100155 case sch_search:
156 {
piotr7c82b172014-02-08 14:15:27 +0100157 DCOUT("SCH search");
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 {
piotr6d152d92014-02-21 00:02:44 +0100169 DCOUT("sch burst_start: " << burst_start);
170 DCOUT("bcc: " << d_bcc << " ncc: " << d_ncc << " t1: " << t1 << " t2: " << t2 << " t3: " << t3);
piotr437f5462014-02-04 17:57:25 +0100171 d_burst_nr.set(t1, t2, t3, 0); //set counter of bursts value
piotr437f5462014-02-04 17:57:25 +0100172 d_burst_nr++;
173
piotr7f3f3662014-07-08 16:47:53 +0200174 consume_each(burst_start + BURST_SIZE * d_OSR + 4*d_OSR); //consume samples up to next guard period
piotr437f5462014-02-04 17:57:25 +0100175 d_state = synchronized;
piotrd0bf1492014-02-05 17:27:32 +0100176 }
177 else
178 {
piotrd6d66872014-08-06 15:20:33 +0200179 d_state = fcch_search; //if there is error in the sch burst go back to fcch search phase
piotr437f5462014-02-04 17:57:25 +0100180 }
piotrd0bf1492014-02-05 17:27:32 +0100181 }
182 else
183 {
184 d_state = sch_search;
185 }
186 break;
187 }
188 //in this state receiver is synchronized and it processes bursts according to burst type for given burst number
189 case synchronized:
190 {
piotr6d152d92014-02-21 00:02:44 +0100191 DCOUT("Synchronized");
piotrd0bf1492014-02-05 17:27:32 +0100192 vector_complex channel_imp_resp(CHAN_IMP_RESP_LENGTH*d_OSR);
193 int burst_start;
194 int offset = 0;
195 int to_consume = 0;
196 unsigned char output_binary[BURST_SIZE];
piotr437f5462014-02-04 17:57:25 +0100197
piotrd0bf1492014-02-05 17:27:32 +0100198 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 +0200199 double signal_pwr = 0;
piotrc7c249a2014-05-02 17:24:08 +0200200 for(int ii=0;ii<noutput_items;ii++)
piotr6d152d92014-02-21 00:02:44 +0100201 {
202 signal_pwr += abs(input[ii])*abs(input[ii]);
203 }
piotrf2b6a1b2014-08-04 11:28:59 +0200204 d_signal_dbm=static_cast<int8_t>(round(10*log10(signal_pwr/50/noutput_items)));
piotr6d152d92014-02-21 00:02:44 +0100205
piotrd0bf1492014-02-05 17:27:32 +0100206 switch (b_type)
207 {
208 case fcch_burst: //if it's FCCH burst
209 {
210 const unsigned first_sample = ceil((GUARD_PERIOD + 2 * TAIL_BITS) * d_OSR) + 1;
211 const unsigned last_sample = first_sample + USEFUL_BITS * d_OSR - TAIL_BITS * d_OSR;
piotr4089c1a2014-08-06 14:10:56 +0200212 double freq_offset_tmp = compute_freq_offset(input, first_sample, last_sample); //extract frequency offset from it
piotr437f5462014-02-04 17:57:25 +0100213
piotr6d152d92014-02-21 00:02:44 +0100214 send_burst(d_burst_nr, fc_fb, b_type);
215
piotr4089c1a2014-08-06 14:10:56 +0200216 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(freq_offset_tmp-d_freq_offset_setting),pmt::mp("synchronized"));
217 message_port_pub(pmt::mp("measurements"), msg);
piotrd0bf1492014-02-05 17:27:32 +0100218 }
219 break;
220 case sch_burst: //if it's SCH burst
221 {
222 int t1, t2, t3, d_ncc, d_bcc;
223 burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]); //get channel impulse response
piotr4089c1a2014-08-06 14:10:56 +0200224
piotrd0bf1492014-02-05 17:27:32 +0100225 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //MLSE detection of bits
piotr6d152d92014-02-21 00:02:44 +0100226 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100227 if (decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc) == 0) //and decode SCH data
228 {
229 // d_burst_nr.set(t1, t2, t3, 0); //but only to check if burst_start value is correct
230 d_failed_sch = 0;
231 DCOUT("bcc: " << d_bcc << " ncc: " << d_ncc << " t1: " << t1 << " t2: " << t2 << " t3: " << t3);
232 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 +0100233 DCOUT("offset: "<<offset);
piotrd0bf1492014-02-05 17:27:32 +0100234 to_consume += offset; //adjust with offset number of samples to be consumed
235 }
236 else
237 {
238 d_failed_sch++;
239 if (d_failed_sch >= MAX_SCH_ERRORS)
240 {
piotrd6d66872014-08-06 15:20:33 +0200241 d_state = fcch_search;
piotr4089c1a2014-08-06 14:10:56 +0200242 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(0.0),pmt::mp("sync_loss"));
243 message_port_pub(pmt::mp("measurements"), msg);
Piotr K66bb3cd2014-08-13 19:04:57 +0200244 COUT("Re-Synchronization!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
piotr437f5462014-02-04 17:57:25 +0100245 }
piotr437f5462014-02-04 17:57:25 +0100246 }
piotrd0bf1492014-02-05 17:27:32 +0100247 }
248 break;
piotr437f5462014-02-04 17:57:25 +0100249
piotr7e3b0db2014-02-05 22:44:30 +0100250 case normal_burst:
251 {
252 float normal_corr_max; //if it's normal burst
253 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 +0100254 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //MLSE detection of bits
piotr8dc74a42014-04-17 09:48:46 +0200255 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100256 break;
piotr7e3b0db2014-02-05 22:44:30 +0100257 }
piotrd0bf1492014-02-05 17:27:32 +0100258 case dummy_or_normal:
259 {
piotr7e3b0db2014-02-05 22:44:30 +0100260 unsigned int normal_burst_start;
261 float dummy_corr_max, normal_corr_max;
262 get_norm_chan_imp_resp(input, &channel_imp_resp[0], &dummy_corr_max, TS_DUMMY);
263 normal_burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], &normal_corr_max, d_bcc);
264
piotr7c82b172014-02-08 14:15:27 +0100265 DCOUT("normal_corr_max: " << normal_corr_max << " dummy_corr_max:" << dummy_corr_max);
piotr7e3b0db2014-02-05 22:44:30 +0100266 if (normal_corr_max > dummy_corr_max)
piotrd0bf1492014-02-05 17:27:32 +0100267 {
piotr7e3b0db2014-02-05 22:44:30 +0100268 detect_burst(input, &channel_imp_resp[0], normal_burst_start, output_binary);
piotr8dc74a42014-04-17 09:48:46 +0200269 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100270 }
271 else
272 {
piotr6d152d92014-02-21 00:02:44 +0100273 send_burst(d_burst_nr, dummy_burst, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100274 }
275 }
276 case rach_burst:
piotrd0bf1492014-02-05 17:27:32 +0100277 break;
piotr7e3b0db2014-02-05 22:44:30 +0100278 case dummy:
piotr6d152d92014-02-21 00:02:44 +0100279 send_burst(d_burst_nr, dummy_burst, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100280 break;
281 case empty: //if it's empty burst
282 break; //do nothing
283 }
284
285 d_burst_nr++; //go to next burst
piotrd0bf1492014-02-05 17:27:32 +0100286 to_consume += TS_BITS * d_OSR + d_burst_nr.get_offset(); //consume samples of the burst up to next guard period
287 //and add offset which is introduced by
288 //0.25 fractional part of a guard period
piotrd0bf1492014-02-05 17:27:32 +0100289 consume_each(to_consume);
290 }
291 break;
piotr437f5462014-02-04 17:57:25 +0100292 }
293
piotr6d152d92014-02-21 00:02:44 +0100294 return 0;
piotrd0bf1492014-02-05 17:27:32 +0100295}
piotr437f5462014-02-04 17:57:25 +0100296
piotr4089c1a2014-08-06 14:10:56 +0200297bool receiver_impl::find_fcch_burst(const gr_complex *input, const int nitems, double & computed_freq_offset)
piotrd0bf1492014-02-05 17:27:32 +0100298{
299 circular_buffer_float phase_diff_buffer(FCCH_HITS_NEEDED * d_OSR); //circular buffer used to scan throug signal to find
300 //best match for FCCH burst
301 float phase_diff = 0;
302 gr_complex conjprod;
303 int start_pos = -1;
304 int hit_count = 0;
305 int miss_count = 0;
306 float min_phase_diff;
307 float max_phase_diff;
308 double best_sum = 0;
309 float lowest_max_min_diff = 99999;
310
311 int to_consume = 0;
312 int sample_number = 0;
313 bool end = false;
314 bool result = false;
315 circular_buffer_float::iterator buffer_iter;
piotr6d152d92014-02-21 00:02:44 +0100316
piotrd0bf1492014-02-05 17:27:32 +0100317 /**@name Possible states of FCCH search algorithm*/
318 //@{
319 enum states
piotr437f5462014-02-04 17:57:25 +0100320 {
piotr437f5462014-02-04 17:57:25 +0100321 init, ///< initialize variables
322 search, ///< search for positive samples
323 found_something, ///< search for FCCH and the best position of it
324 fcch_found, ///< when FCCH was found
325 search_fail ///< when there is no FCCH in the input vector
piotrd0bf1492014-02-05 17:27:32 +0100326 } fcch_search_state;
327 //@}
piotr437f5462014-02-04 17:57:25 +0100328
piotrd0bf1492014-02-05 17:27:32 +0100329 fcch_search_state = init;
piotr437f5462014-02-04 17:57:25 +0100330
piotrd0bf1492014-02-05 17:27:32 +0100331 while (!end)
332 {
333 switch (fcch_search_state)
334 {
piotr437f5462014-02-04 17:57:25 +0100335
piotrd0bf1492014-02-05 17:27:32 +0100336 case init: //initialize variables
piotr437f5462014-02-04 17:57:25 +0100337 hit_count = 0;
338 miss_count = 0;
339 start_pos = -1;
340 lowest_max_min_diff = 99999;
341 phase_diff_buffer.clear();
342 fcch_search_state = search;
343
344 break;
345
piotr7c82b172014-02-08 14:15:27 +0100346 case search: // search for positive samples
piotr437f5462014-02-04 17:57:25 +0100347 sample_number++;
348
piotrd0bf1492014-02-05 17:27:32 +0100349 if (sample_number > nitems - FCCH_HITS_NEEDED * d_OSR) //if it isn't possible to find FCCH because
350 {
piotr7c82b172014-02-08 14:15:27 +0100351 //there's too few samples left to look into,
piotrd0bf1492014-02-05 17:27:32 +0100352 to_consume = sample_number; //don't do anything with those samples which are left
piotr7c82b172014-02-08 14:15:27 +0100353 //and consume only those which were checked
piotrd0bf1492014-02-05 17:27:32 +0100354 fcch_search_state = search_fail;
355 }
356 else
357 {
358 phase_diff = compute_phase_diff(input[sample_number], input[sample_number-1]);
piotr437f5462014-02-04 17:57:25 +0100359
piotrd0bf1492014-02-05 17:27:32 +0100360 if (phase_diff > 0) //if a positive phase difference was found
361 {
362 to_consume = sample_number;
363 fcch_search_state = found_something; //switch to state in which searches for FCCH
364 }
365 else
366 {
367 fcch_search_state = search;
368 }
piotr437f5462014-02-04 17:57:25 +0100369 }
370
371 break;
372
piotrd0bf1492014-02-05 17:27:32 +0100373 case found_something: // search for FCCH and the best position of it
374 {
375 if (phase_diff > 0)
376 {
piotr437f5462014-02-04 17:57:25 +0100377 hit_count++; //positive phase differencies increases hits_count
piotrd0bf1492014-02-05 17:27:32 +0100378 }
379 else
380 {
piotr437f5462014-02-04 17:57:25 +0100381 miss_count++; //negative increases miss_count
piotrd0bf1492014-02-05 17:27:32 +0100382 }
piotr437f5462014-02-04 17:57:25 +0100383
piotrd0bf1492014-02-05 17:27:32 +0100384 if ((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count <= FCCH_HITS_NEEDED * d_OSR))
385 {
piotr437f5462014-02-04 17:57:25 +0100386 //if miss_count exceeds limit before hit_count
387 fcch_search_state = init; //go to init
388 continue;
piotrd0bf1492014-02-05 17:27:32 +0100389 }
390 else if (((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR)) || (hit_count > 2 * FCCH_HITS_NEEDED * d_OSR))
391 {
piotr437f5462014-02-04 17:57:25 +0100392 //if hit_count and miss_count exceeds limit then FCCH was found
393 fcch_search_state = fcch_found;
394 continue;
piotrd0bf1492014-02-05 17:27:32 +0100395 }
396 else if ((miss_count < FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR))
397 {
piotr437f5462014-02-04 17:57:25 +0100398 //find difference between minimal and maximal element in the buffer
399 //for FCCH this value should be low
400 //this part is searching for a region where this value is lowest
401 min_phase_diff = * (min_element(phase_diff_buffer.begin(), phase_diff_buffer.end()));
402 max_phase_diff = * (max_element(phase_diff_buffer.begin(), phase_diff_buffer.end()));
403
piotrd0bf1492014-02-05 17:27:32 +0100404 if (lowest_max_min_diff > max_phase_diff - min_phase_diff)
405 {
406 lowest_max_min_diff = max_phase_diff - min_phase_diff;
407 start_pos = sample_number - FCCH_HITS_NEEDED * d_OSR - FCCH_MAX_MISSES * d_OSR; //store start pos
408 best_sum = 0;
piotr437f5462014-02-04 17:57:25 +0100409
piotrd0bf1492014-02-05 17:27:32 +0100410 for (buffer_iter = phase_diff_buffer.begin();
411 buffer_iter != (phase_diff_buffer.end());
412 buffer_iter++)
413 {
414 best_sum += *buffer_iter - (M_PI / 2) / d_OSR; //store best value of phase offset sum
415 }
piotr437f5462014-02-04 17:57:25 +0100416 }
piotrd0bf1492014-02-05 17:27:32 +0100417 }
piotr437f5462014-02-04 17:57:25 +0100418
piotrd0bf1492014-02-05 17:27:32 +0100419 sample_number++;
piotr437f5462014-02-04 17:57:25 +0100420
piotrd0bf1492014-02-05 17:27:32 +0100421 if (sample_number >= nitems) //if there's no single sample left to check
422 {
piotr437f5462014-02-04 17:57:25 +0100423 fcch_search_state = search_fail;//FCCH search failed
424 continue;
piotr437f5462014-02-04 17:57:25 +0100425 }
piotrd0bf1492014-02-05 17:27:32 +0100426
427 phase_diff = compute_phase_diff(input[sample_number], input[sample_number-1]);
428 phase_diff_buffer.push_back(phase_diff);
429 fcch_search_state = found_something;
430 }
431 break;
432
433 case fcch_found:
434 {
435 DCOUT("fcch found on position: " << d_counter + start_pos);
436 to_consume = start_pos + FCCH_HITS_NEEDED * d_OSR + 1; //consume one FCCH burst
437
438 d_fcch_start_pos = d_counter + start_pos;
439
440 //compute frequency offset
441 double phase_offset = best_sum / FCCH_HITS_NEEDED;
piotr4089c1a2014-08-06 14:10:56 +0200442 double freq_offset = phase_offset * 1625000.0/6 / (2 * M_PI); //1625000.0/6 - GMSK symbol rate in GSM
443 computed_freq_offset = freq_offset;
piotrd0bf1492014-02-05 17:27:32 +0100444
445 end = true;
446 result = true;
piotr437f5462014-02-04 17:57:25 +0100447 break;
piotrd0bf1492014-02-05 17:27:32 +0100448 }
piotr437f5462014-02-04 17:57:25 +0100449
piotrd0bf1492014-02-05 17:27:32 +0100450 case search_fail:
piotr437f5462014-02-04 17:57:25 +0100451 end = true;
452 result = false;
453 break;
454 }
piotr437f5462014-02-04 17:57:25 +0100455 }
456
piotrd0bf1492014-02-05 17:27:32 +0100457 d_counter += to_consume;
458 consume_each(to_consume);
piotr437f5462014-02-04 17:57:25 +0100459
piotrd0bf1492014-02-05 17:27:32 +0100460 return result;
461}
462
piotrd0bf1492014-02-05 17:27:32 +0100463double receiver_impl::compute_freq_offset(const gr_complex * input, unsigned first_sample, unsigned last_sample)
464{
465 double phase_sum = 0;
466 unsigned ii;
467
468 for (ii = first_sample; ii < last_sample; ii++)
piotr437f5462014-02-04 17:57:25 +0100469 {
piotr437f5462014-02-04 17:57:25 +0100470 double phase_diff = compute_phase_diff(input[ii], input[ii-1]) - (M_PI / 2) / d_OSR;
471 phase_sum += phase_diff;
piotr437f5462014-02-04 17:57:25 +0100472 }
473
piotrd0bf1492014-02-05 17:27:32 +0100474 double phase_offset = phase_sum / (last_sample - first_sample);
475 double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI);
476 return freq_offset;
477}
piotr437f5462014-02-04 17:57:25 +0100478
piotrd0bf1492014-02-05 17:27:32 +0100479inline float receiver_impl::compute_phase_diff(gr_complex val1, gr_complex val2)
480{
481 gr_complex conjprod = val1 * conj(val2);
482 return fast_atan2f(imag(conjprod), real(conjprod));
483}
piotr437f5462014-02-04 17:57:25 +0100484
piotrd0bf1492014-02-05 17:27:32 +0100485bool receiver_impl::reach_sch_burst(const int nitems)
486{
487 //it just consumes samples to get near to a SCH burst
488 int to_consume = 0;
489 bool result = false;
490 unsigned sample_nr_near_sch_start = d_fcch_start_pos + (FRAME_BITS - SAFETY_MARGIN) * d_OSR;
491
492 //consume samples until d_counter will be equal to sample_nr_near_sch_start
493 if (d_counter < sample_nr_near_sch_start)
494 {
495 if (d_counter + nitems >= sample_nr_near_sch_start)
496 {
497 to_consume = sample_nr_near_sch_start - d_counter;
498 }
499 else
500 {
501 to_consume = nitems;
piotr437f5462014-02-04 17:57:25 +0100502 }
503 result = false;
piotrd0bf1492014-02-05 17:27:32 +0100504 }
505 else
506 {
piotr437f5462014-02-04 17:57:25 +0100507 to_consume = 0;
508 result = true;
piotr437f5462014-02-04 17:57:25 +0100509 }
510
piotrd0bf1492014-02-05 17:27:32 +0100511 d_counter += to_consume;
512 consume_each(to_consume);
513 return result;
514}
515
516int receiver_impl::get_sch_chan_imp_resp(const gr_complex *input, gr_complex * chan_imp_resp)
517{
518 vector_complex correlation_buffer;
519 vector_float power_buffer;
520 vector_float window_energy_buffer;
521
522 int strongest_window_nr;
523 int burst_start = 0;
524 int chan_imp_resp_center = 0;
525 float max_correlation = 0;
526 float energy = 0;
527
528 for (int ii = SYNC_POS * d_OSR; ii < (SYNC_POS + SYNC_SEARCH_RANGE) *d_OSR; ii++)
piotr437f5462014-02-04 17:57:25 +0100529 {
piotr437f5462014-02-04 17:57:25 +0100530 gr_complex correlation = correlate_sequence(&d_sch_training_seq[5], N_SYNC_BITS - 10, &input[ii]);
531 correlation_buffer.push_back(correlation);
532 power_buffer.push_back(std::pow(abs(correlation), 2));
piotrd0bf1492014-02-05 17:27:32 +0100533 }
piotr7f3f3662014-07-08 16:47:53 +0200534 //plot(power_buffer);
piotrd0bf1492014-02-05 17:27:32 +0100535 //compute window energies
536 vector_float::iterator iter = power_buffer.begin();
537 bool loop_end = false;
538 while (iter != power_buffer.end())
539 {
piotr437f5462014-02-04 17:57:25 +0100540 vector_float::iterator iter_ii = iter;
541 energy = 0;
542
piotrd0bf1492014-02-05 17:27:32 +0100543 for (int ii = 0; ii < (d_chan_imp_length) *d_OSR; ii++, iter_ii++)
544 {
545 if (iter_ii == power_buffer.end())
546 {
547 loop_end = true;
548 break;
549 }
550 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100551 }
piotrd0bf1492014-02-05 17:27:32 +0100552 if (loop_end)
553 {
554 break;
piotr437f5462014-02-04 17:57:25 +0100555 }
556 iter++;
557 window_energy_buffer.push_back(energy);
piotrd0bf1492014-02-05 17:27:32 +0100558 }
piotr437f5462014-02-04 17:57:25 +0100559
piotrd0bf1492014-02-05 17:27:32 +0100560 strongest_window_nr = max_element(window_energy_buffer.begin(), window_energy_buffer.end()) - window_energy_buffer.begin();
piotr437f5462014-02-04 17:57:25 +0100561 // d_channel_imp_resp.clear();
562
piotrd0bf1492014-02-05 17:27:32 +0100563 max_correlation = 0;
564 for (int ii = 0; ii < (d_chan_imp_length) *d_OSR; ii++)
565 {
piotr437f5462014-02-04 17:57:25 +0100566 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100567 if (abs(correlation) > max_correlation)
568 {
569 chan_imp_resp_center = ii;
570 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100571 }
piotrd0bf1492014-02-05 17:27:32 +0100572 // d_channel_imp_resp.push_back(correlation);
piotr437f5462014-02-04 17:57:25 +0100573 chan_imp_resp[ii] = correlation;
piotr437f5462014-02-04 17:57:25 +0100574 }
575
piotrd0bf1492014-02-05 17:27:32 +0100576 burst_start = strongest_window_nr + chan_imp_resp_center - 48 * d_OSR - 2 * d_OSR + 2 + SYNC_POS * d_OSR;
577 return burst_start;
578}
piotr437f5462014-02-04 17:57:25 +0100579
580
piotrd0bf1492014-02-05 17:27:32 +0100581
582void receiver_impl::detect_burst(const gr_complex * input, gr_complex * chan_imp_resp, int burst_start, unsigned char * output_binary)
583{
584 float output[BURST_SIZE];
585 gr_complex rhh_temp[CHAN_IMP_RESP_LENGTH*d_OSR];
586 gr_complex rhh[CHAN_IMP_RESP_LENGTH];
587 gr_complex filtered_burst[BURST_SIZE];
588 int start_state = 3;
589 unsigned int stop_states[2] = {4, 12};
590
591 autocorrelation(chan_imp_resp, rhh_temp, d_chan_imp_length*d_OSR);
592 for (int ii = 0; ii < (d_chan_imp_length); ii++)
piotr437f5462014-02-04 17:57:25 +0100593 {
piotr437f5462014-02-04 17:57:25 +0100594 rhh[ii] = conj(rhh_temp[ii*d_OSR]);
piotr437f5462014-02-04 17:57:25 +0100595 }
596
piotrd0bf1492014-02-05 17:27:32 +0100597 mafi(&input[burst_start], BURST_SIZE, chan_imp_resp, d_chan_imp_length*d_OSR, filtered_burst);
598
599 viterbi_detector(filtered_burst, BURST_SIZE, rhh, start_state, stop_states, 2, output);
600
601 for (int i = 0; i < BURST_SIZE ; i++)
piotr437f5462014-02-04 17:57:25 +0100602 {
piotrd0bf1492014-02-05 17:27:32 +0100603 output_binary[i] = (output[i] > 0);
604 }
605}
piotr437f5462014-02-04 17:57:25 +0100606
piotrd0bf1492014-02-05 17:27:32 +0100607void receiver_impl::gmsk_mapper(const unsigned char * input, int nitems, gr_complex * gmsk_output, gr_complex start_point)
608{
609 gr_complex j = gr_complex(0.0, 1.0);
piotr437f5462014-02-04 17:57:25 +0100610
piotrd0bf1492014-02-05 17:27:32 +0100611 int current_symbol;
612 int encoded_symbol;
613 int previous_symbol = 2 * input[0] - 1;
614 gmsk_output[0] = start_point;
615
616 for (int i = 1; i < nitems; i++)
617 {
piotr437f5462014-02-04 17:57:25 +0100618 //change bits representation to NRZ
619 current_symbol = 2 * input[i] - 1;
620 //differentially encode
621 encoded_symbol = current_symbol * previous_symbol;
622 //and do gmsk mapping
623 gmsk_output[i] = j * gr_complex(encoded_symbol, 0.0) * gmsk_output[i-1];
624 previous_symbol = current_symbol;
piotr437f5462014-02-04 17:57:25 +0100625 }
piotrd0bf1492014-02-05 17:27:32 +0100626}
piotr437f5462014-02-04 17:57:25 +0100627
piotrd0bf1492014-02-05 17:27:32 +0100628gr_complex receiver_impl::correlate_sequence(const gr_complex * sequence, int length, const gr_complex * input)
629{
630 gr_complex result(0.0, 0.0);
631 int sample_number = 0;
632
633 for (int ii = 0; ii < length; ii++)
piotr437f5462014-02-04 17:57:25 +0100634 {
piotr437f5462014-02-04 17:57:25 +0100635 sample_number = (ii * d_OSR) ;
636 result += sequence[ii] * conj(input[sample_number]);
piotr437f5462014-02-04 17:57:25 +0100637 }
638
piotrd0bf1492014-02-05 17:27:32 +0100639 result = result / gr_complex(length, 0);
640 return result;
641}
642
643//computes autocorrelation for positive arguments
piotrd0bf1492014-02-05 17:27:32 +0100644inline void receiver_impl::autocorrelation(const gr_complex * input, gr_complex * out, int nitems)
645{
646 int i, k;
647 for (k = nitems - 1; k >= 0; k--)
piotr437f5462014-02-04 17:57:25 +0100648 {
piotr437f5462014-02-04 17:57:25 +0100649 out[k] = gr_complex(0, 0);
piotrd0bf1492014-02-05 17:27:32 +0100650 for (i = k; i < nitems; i++)
651 {
652 out[k] += input[i] * conj(input[i-k]);
piotr437f5462014-02-04 17:57:25 +0100653 }
piotr437f5462014-02-04 17:57:25 +0100654 }
piotrd0bf1492014-02-05 17:27:32 +0100655}
piotr437f5462014-02-04 17:57:25 +0100656
piotrd0bf1492014-02-05 17:27:32 +0100657inline void receiver_impl::mafi(const gr_complex * input, int nitems, gr_complex * filter, int filter_length, gr_complex * output)
658{
659 int ii = 0, n, a;
660
661 for (n = 0; n < nitems; n++)
piotr437f5462014-02-04 17:57:25 +0100662 {
piotr437f5462014-02-04 17:57:25 +0100663 a = n * d_OSR;
664 output[n] = 0;
665 ii = 0;
666
piotrd0bf1492014-02-05 17:27:32 +0100667 while (ii < filter_length)
668 {
piotrda8a0662014-04-24 10:29:38 +0200669 if ((a + ii) >= nitems*d_OSR){
piotrd0bf1492014-02-05 17:27:32 +0100670 break;
piotrda8a0662014-04-24 10:29:38 +0200671 }
piotrd0bf1492014-02-05 17:27:32 +0100672 output[n] += input[a+ii] * filter[ii];
673 ii++;
piotr437f5462014-02-04 17:57:25 +0100674 }
piotr437f5462014-02-04 17:57:25 +0100675 }
piotrd0bf1492014-02-05 17:27:32 +0100676}
piotr437f5462014-02-04 17:57:25 +0100677
piotrd0bf1492014-02-05 17:27:32 +0100678//especially computations of strongest_window_nr
piotr7e3b0db2014-02-05 22:44:30 +0100679int 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 +0100680{
681 vector_complex correlation_buffer;
682 vector_float power_buffer;
683 vector_float window_energy_buffer;
piotr437f5462014-02-04 17:57:25 +0100684
piotrd0bf1492014-02-05 17:27:32 +0100685 int strongest_window_nr;
686 int burst_start = 0;
687 int chan_imp_resp_center = 0;
688 float max_correlation = 0;
689 float energy = 0;
piotr5c820252014-04-17 09:43:02 +0200690
piotrd0bf1492014-02-05 17:27:32 +0100691 int search_center = (int)((TRAIN_POS + GUARD_PERIOD) * d_OSR);
piotr7c82b172014-02-08 14:15:27 +0100692 int search_start_pos = search_center + 1 - 5*d_OSR;
piotr437f5462014-02-04 17:57:25 +0100693 // int search_start_pos = search_center - d_chan_imp_length * d_OSR;
piotr5c820252014-04-17 09:43:02 +0200694 int search_stop_pos = search_center + d_chan_imp_length * d_OSR + 5 * d_OSR;
piotr437f5462014-02-04 17:57:25 +0100695
piotrd0bf1492014-02-05 17:27:32 +0100696 for (int ii = search_start_pos; ii < search_stop_pos; ii++)
697 {
piotr437f5462014-02-04 17:57:25 +0100698 gr_complex correlation = correlate_sequence(&d_norm_training_seq[bcc][TRAIN_BEGINNING], N_TRAIN_BITS - 10, &input[ii]);
699
700 correlation_buffer.push_back(correlation);
701 power_buffer.push_back(std::pow(abs(correlation), 2));
piotrd0bf1492014-02-05 17:27:32 +0100702 }
piotr437f5462014-02-04 17:57:25 +0100703
piotrd0bf1492014-02-05 17:27:32 +0100704 //compute window energies
705 vector_float::iterator iter = power_buffer.begin();
706 bool loop_end = false;
707 while (iter != power_buffer.end())
708 {
piotr437f5462014-02-04 17:57:25 +0100709 vector_float::iterator iter_ii = iter;
710 energy = 0;
711
piotrd0bf1492014-02-05 17:27:32 +0100712 for (int ii = 0; ii < (d_chan_imp_length - 2)*d_OSR; ii++, iter_ii++)
713 {
piotrd0bf1492014-02-05 17:27:32 +0100714 if (iter_ii == power_buffer.end())
715 {
716 loop_end = true;
717 break;
718 }
719 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100720 }
piotrd0bf1492014-02-05 17:27:32 +0100721 if (loop_end)
722 {
723 break;
piotr437f5462014-02-04 17:57:25 +0100724 }
725 iter++;
726
727 window_energy_buffer.push_back(energy);
piotrd0bf1492014-02-05 17:27:32 +0100728 }
piotr437f5462014-02-04 17:57:25 +0100729
piotr5c820252014-04-17 09:43:02 +0200730 strongest_window_nr = max_element(window_energy_buffer.begin(), window_energy_buffer.end()-((d_chan_imp_length)*d_OSR)) - window_energy_buffer.begin();
731 //strongest_window_nr = strongest_window_nr-d_OSR;
732 if(strongest_window_nr<0){
733 strongest_window_nr = 0;
734 }
piotr6d152d92014-02-21 00:02:44 +0100735
piotrd0bf1492014-02-05 17:27:32 +0100736 max_correlation = 0;
737 for (int ii = 0; ii < (d_chan_imp_length)*d_OSR; ii++)
738 {
piotr437f5462014-02-04 17:57:25 +0100739 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100740 if (abs(correlation) > max_correlation)
741 {
742 chan_imp_resp_center = ii;
743 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100744 }
piotrd0bf1492014-02-05 17:27:32 +0100745 // d_channel_imp_resp.push_back(correlation);
piotr437f5462014-02-04 17:57:25 +0100746 chan_imp_resp[ii] = correlation;
piotr437f5462014-02-04 17:57:25 +0100747 }
piotr7c82b172014-02-08 14:15:27 +0100748
piotr7e3b0db2014-02-05 22:44:30 +0100749 *corr_max = max_correlation;
piotrd0bf1492014-02-05 17:27:32 +0100750
piotr7c82b172014-02-08 14:15:27 +0100751 DCOUT("strongest_window_nr_new: " << strongest_window_nr);
piotrc7c249a2014-05-02 17:24:08 +0200752 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 +0100753
754 DCOUT("burst_start: " << burst_start);
piotrd0bf1492014-02-05 17:27:32 +0100755 return burst_start;
756}
piotr437f5462014-02-04 17:57:25 +0100757
758
piotr6d152d92014-02-21 00:02:44 +0100759void receiver_impl::send_burst(burst_counter burst_nr, const unsigned char * burst_binary, burst_type b_type)
piotrd0bf1492014-02-05 17:27:32 +0100760{
piotr7c82b172014-02-08 14:15:27 +0100761
piotr6d152d92014-02-21 00:02:44 +0100762 boost::scoped_ptr<gsmtap_hdr> tap_header(new gsmtap_hdr());
763
764 tap_header->version = GSMTAP_VERSION;
765 tap_header->hdr_len = BURST_SIZE/4;
766 tap_header->type = GSMTAP_TYPE_UM_BURST;
767 tap_header->timeslot = static_cast<uint8_t>(d_burst_nr.get_timeslot_nr());
768 tap_header->frame_number = d_burst_nr.get_frame_nr();
769 tap_header->sub_type = static_cast<uint8_t>(b_type);
770 tap_header->arfcn = d_arfcn;
771 tap_header->signal_dbm = static_cast<int8_t>(d_signal_dbm);
772 pmt::pmt_t header_blob=pmt::make_blob(tap_header.get(),sizeof(gsmtap_hdr));
773 pmt::pmt_t burst_binary_blob=pmt::make_blob(burst_binary,BURST_SIZE);
774 pmt::pmt_t msg = pmt::cons(header_blob, burst_binary_blob);
piotrf2b6a1b2014-08-04 11:28:59 +0200775
piotr6d152d92014-02-21 00:02:44 +0100776 message_port_pub(pmt::mp("bursts"), msg);
piotrd0bf1492014-02-05 17:27:32 +0100777}
piotr6d152d92014-02-21 00:02:44 +0100778
piotrd0bf1492014-02-05 17:27:32 +0100779void receiver_impl::configure_receiver()
780{
piotrce92f982014-04-17 23:37:18 +0200781 d_channel_conf.set_multiframe_type(TIMESLOT0, multiframe_51);
piotrd0bf1492014-02-05 17:27:32 +0100782 d_channel_conf.set_burst_types(TIMESLOT0, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotr437f5462014-02-04 17:57:25 +0100783
piotrce92f982014-04-17 23:37:18 +0200784 d_channel_conf.set_burst_types(TIMESLOT0, TEST_CCH_FRAMES, sizeof(TEST_CCH_FRAMES) / sizeof(unsigned), dummy_or_normal);
785 d_channel_conf.set_burst_types(TIMESLOT0, FCCH_FRAMES, sizeof(FCCH_FRAMES) / sizeof(unsigned), fcch_burst);
786 d_channel_conf.set_burst_types(TIMESLOT0, SCH_FRAMES, sizeof(SCH_FRAMES) / sizeof(unsigned), sch_burst);
piotr437f5462014-02-04 17:57:25 +0100787
788 // d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_26);
789 // d_channel_conf.set_burst_types(TIMESLOT1, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
790 // d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_26);
791 // d_channel_conf.set_burst_types(TIMESLOT2, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
792 // d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_26);
793 // d_channel_conf.set_burst_types(TIMESLOT3, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
794 // d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_26);
795 // d_channel_conf.set_burst_types(TIMESLOT4, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
796 // d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_26);
797 // d_channel_conf.set_burst_types(TIMESLOT5, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
798 // d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_26);
799 // d_channel_conf.set_burst_types(TIMESLOT6, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
800 // d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_26);
801 // 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 +0100802
piotrd0bf1492014-02-05 17:27:32 +0100803 d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_51);
804 d_channel_conf.set_burst_types(TIMESLOT1, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
805 d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_51);
806 d_channel_conf.set_burst_types(TIMESLOT2, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
807 d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_51);
808 d_channel_conf.set_burst_types(TIMESLOT3, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
809 d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_51);
810 d_channel_conf.set_burst_types(TIMESLOT4, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
811 d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_51);
812 d_channel_conf.set_burst_types(TIMESLOT5, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
813 d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_51);
814 d_channel_conf.set_burst_types(TIMESLOT6, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
815 d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_51);
816 d_channel_conf.set_burst_types(TIMESLOT7, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotrd0bf1492014-02-05 17:27:32 +0100817}
piotr437f5462014-02-04 17:57:25 +0100818
piotrf2b6a1b2014-08-04 11:28:59 +0200819void receiver_impl::set_arfcn(int arfcn) //!!
820{
821 d_arfcn = arfcn;
piotrf2b6a1b2014-08-04 11:28:59 +0200822}
823
824void receiver_impl::reset()
825{
piotrd6d66872014-08-06 15:20:33 +0200826 d_state = fcch_search;
piotrf2b6a1b2014-08-04 11:28:59 +0200827}
piotr437f5462014-02-04 17:57:25 +0100828
piotrd0bf1492014-02-05 17:27:32 +0100829} /* namespace gsm */
piotr437f5462014-02-04 17:57:25 +0100830} /* namespace gr */
831