blob: c333ccf41967390b720189e8cd17c72659420b9b [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),
piotrd0bf1492014-02-05 17:27:32 +010075 d_state(first_fcch_search),
76 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
138 case first_fcch_search:
piotr7e3b0db2014-02-05 22:44:30 +0100139 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)) //find frequency correction burst in the input buffer
piotrd0bf1492014-02-05 17:27:32 +0100142 {
piotr4089c1a2014-08-06 14:10:56 +0200143 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(freq_offset_tmp-d_freq_offset_setting),pmt::mp("first_fcch_search"));
144 message_port_pub(pmt::mp("measurements"), msg);
145
piotr437f5462014-02-04 17:57:25 +0100146 d_state = next_fcch_search;
piotrd0bf1492014-02-05 17:27:32 +0100147 }
148 else
149 {
piotr437f5462014-02-04 17:57:25 +0100150 d_state = first_fcch_search;
piotrd0bf1492014-02-05 17:27:32 +0100151 }
152 break;
piotr437f5462014-02-04 17:57:25 +0100153
piotrd0bf1492014-02-05 17:27:32 +0100154 case next_fcch_search: //this state is used because it takes some time (a bunch of buffered samples)
155 {
piotr7e3b0db2014-02-05 22:44:30 +0100156 DCOUT("NEXT FCCH search");
piotr4089c1a2014-08-06 14:10:56 +0200157 double freq_offset_tmp;
158 if (find_fcch_burst(input, noutput_items,freq_offset_tmp))
piotrd0bf1492014-02-05 17:27:32 +0100159 {
piotr4089c1a2014-08-06 14:10:56 +0200160 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(freq_offset_tmp-d_freq_offset_setting),pmt::mp("next_fcch_search"));
161 message_port_pub(pmt::mp("measurements"), msg);
162
piotrd0bf1492014-02-05 17:27:32 +0100163 d_state = sch_search;
164 }
165 else
166 {
piotrd0bf1492014-02-05 17:27:32 +0100167 d_state = next_fcch_search;
168 }
169 break;
170 }
piotr437f5462014-02-04 17:57:25 +0100171
piotrd0bf1492014-02-05 17:27:32 +0100172 case sch_search:
173 {
piotr7c82b172014-02-08 14:15:27 +0100174 DCOUT("SCH search");
piotrd0bf1492014-02-05 17:27:32 +0100175 vector_complex channel_imp_resp(CHAN_IMP_RESP_LENGTH*d_OSR);
176 int t1, t2, t3;
177 int burst_start = 0;
178 unsigned char output_binary[BURST_SIZE];
piotr437f5462014-02-04 17:57:25 +0100179
piotrc7c249a2014-05-02 17:24:08 +0200180 if (reach_sch_burst(noutput_items)) //wait for a SCH burst
piotrd0bf1492014-02-05 17:27:32 +0100181 {
182 burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]); //get channel impulse response from it
183 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //detect bits using MLSE detection
184 if (decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc) == 0) //decode SCH burst
185 {
piotr6d152d92014-02-21 00:02:44 +0100186 DCOUT("sch burst_start: " << burst_start);
187 DCOUT("bcc: " << d_bcc << " ncc: " << d_ncc << " t1: " << t1 << " t2: " << t2 << " t3: " << t3);
piotr437f5462014-02-04 17:57:25 +0100188 d_burst_nr.set(t1, t2, t3, 0); //set counter of bursts value
piotr437f5462014-02-04 17:57:25 +0100189 d_burst_nr++;
190
piotr7f3f3662014-07-08 16:47:53 +0200191 consume_each(burst_start + BURST_SIZE * d_OSR + 4*d_OSR); //consume samples up to next guard period
piotr437f5462014-02-04 17:57:25 +0100192 d_state = synchronized;
piotrd0bf1492014-02-05 17:27:32 +0100193 }
194 else
195 {
piotr437f5462014-02-04 17:57:25 +0100196 d_state = next_fcch_search; //if there is error in the sch burst go back to fcch search phase
piotr437f5462014-02-04 17:57:25 +0100197 }
piotrd0bf1492014-02-05 17:27:32 +0100198 }
199 else
200 {
201 d_state = sch_search;
202 }
203 break;
204 }
205 //in this state receiver is synchronized and it processes bursts according to burst type for given burst number
206 case synchronized:
207 {
piotr6d152d92014-02-21 00:02:44 +0100208 DCOUT("Synchronized");
piotrd0bf1492014-02-05 17:27:32 +0100209 vector_complex channel_imp_resp(CHAN_IMP_RESP_LENGTH*d_OSR);
210 int burst_start;
211 int offset = 0;
212 int to_consume = 0;
213 unsigned char output_binary[BURST_SIZE];
piotr437f5462014-02-04 17:57:25 +0100214
piotrd0bf1492014-02-05 17:27:32 +0100215 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 +0200216 double signal_pwr = 0;
piotrc7c249a2014-05-02 17:24:08 +0200217 for(int ii=0;ii<noutput_items;ii++)
piotr6d152d92014-02-21 00:02:44 +0100218 {
219 signal_pwr += abs(input[ii])*abs(input[ii]);
220 }
piotrf2b6a1b2014-08-04 11:28:59 +0200221 d_signal_dbm=static_cast<int8_t>(round(10*log10(signal_pwr/50/noutput_items)));
piotr6d152d92014-02-21 00:02:44 +0100222
piotrd0bf1492014-02-05 17:27:32 +0100223 switch (b_type)
224 {
225 case fcch_burst: //if it's FCCH burst
226 {
227 const unsigned first_sample = ceil((GUARD_PERIOD + 2 * TAIL_BITS) * d_OSR) + 1;
228 const unsigned last_sample = first_sample + USEFUL_BITS * d_OSR - TAIL_BITS * d_OSR;
piotr4089c1a2014-08-06 14:10:56 +0200229 double freq_offset_tmp = compute_freq_offset(input, first_sample, last_sample); //extract frequency offset from it
piotr437f5462014-02-04 17:57:25 +0100230
piotr6d152d92014-02-21 00:02:44 +0100231 send_burst(d_burst_nr, fc_fb, b_type);
232
piotr4089c1a2014-08-06 14:10:56 +0200233 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(freq_offset_tmp-d_freq_offset_setting),pmt::mp("synchronized"));
234 message_port_pub(pmt::mp("measurements"), msg);
piotrd0bf1492014-02-05 17:27:32 +0100235 }
236 break;
237 case sch_burst: //if it's SCH burst
238 {
239 int t1, t2, t3, d_ncc, d_bcc;
240 burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]); //get channel impulse response
piotr4089c1a2014-08-06 14:10:56 +0200241
242 if(d_prev_burst_start != burst_start){
243 d_prev_burst_start = burst_start;
244 DCOUT("burst start" << burst_start);
245 }
246
piotrd0bf1492014-02-05 17:27:32 +0100247 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //MLSE detection of bits
piotr6d152d92014-02-21 00:02:44 +0100248 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100249 if (decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc) == 0) //and decode SCH data
250 {
251 // d_burst_nr.set(t1, t2, t3, 0); //but only to check if burst_start value is correct
252 d_failed_sch = 0;
253 DCOUT("bcc: " << d_bcc << " ncc: " << d_ncc << " t1: " << t1 << " t2: " << t2 << " t3: " << t3);
254 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 +0100255 DCOUT("offset: "<<offset);
piotrd0bf1492014-02-05 17:27:32 +0100256 to_consume += offset; //adjust with offset number of samples to be consumed
257 }
258 else
259 {
260 d_failed_sch++;
261 if (d_failed_sch >= MAX_SCH_ERRORS)
262 {
piotr54624012014-04-17 23:36:27 +0200263 d_state = next_fcch_search;
piotr4089c1a2014-08-06 14:10:56 +0200264 pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"),pmt::from_double(0.0),pmt::mp("sync_loss"));
265 message_port_pub(pmt::mp("measurements"), msg);
266 DCOUT("Re-Synchronization!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
piotr437f5462014-02-04 17:57:25 +0100267 }
piotr437f5462014-02-04 17:57:25 +0100268 }
piotrd0bf1492014-02-05 17:27:32 +0100269 }
270 break;
piotr437f5462014-02-04 17:57:25 +0100271
piotr7e3b0db2014-02-05 22:44:30 +0100272 case normal_burst:
273 {
274 float normal_corr_max; //if it's normal burst
275 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 +0100276 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //MLSE detection of bits
piotr8dc74a42014-04-17 09:48:46 +0200277 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100278 break;
piotr7e3b0db2014-02-05 22:44:30 +0100279 }
piotrd0bf1492014-02-05 17:27:32 +0100280 case dummy_or_normal:
281 {
piotr7e3b0db2014-02-05 22:44:30 +0100282 unsigned int normal_burst_start;
283 float dummy_corr_max, normal_corr_max;
284 get_norm_chan_imp_resp(input, &channel_imp_resp[0], &dummy_corr_max, TS_DUMMY);
285 normal_burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], &normal_corr_max, d_bcc);
286
piotr7c82b172014-02-08 14:15:27 +0100287 DCOUT("normal_corr_max: " << normal_corr_max << " dummy_corr_max:" << dummy_corr_max);
piotr7e3b0db2014-02-05 22:44:30 +0100288 if (normal_corr_max > dummy_corr_max)
piotrd0bf1492014-02-05 17:27:32 +0100289 {
piotr7e3b0db2014-02-05 22:44:30 +0100290 detect_burst(input, &channel_imp_resp[0], normal_burst_start, output_binary);
piotr8dc74a42014-04-17 09:48:46 +0200291 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100292 }
293 else
294 {
piotr6d152d92014-02-21 00:02:44 +0100295 send_burst(d_burst_nr, dummy_burst, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100296 }
297 }
298 case rach_burst:
piotrd0bf1492014-02-05 17:27:32 +0100299 break;
piotr7e3b0db2014-02-05 22:44:30 +0100300 case dummy:
piotr6d152d92014-02-21 00:02:44 +0100301 send_burst(d_burst_nr, dummy_burst, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100302 break;
303 case empty: //if it's empty burst
304 break; //do nothing
305 }
306
307 d_burst_nr++; //go to next burst
piotrd0bf1492014-02-05 17:27:32 +0100308 to_consume += TS_BITS * d_OSR + d_burst_nr.get_offset(); //consume samples of the burst up to next guard period
309 //and add offset which is introduced by
310 //0.25 fractional part of a guard period
piotrd0bf1492014-02-05 17:27:32 +0100311 consume_each(to_consume);
312 }
313 break;
piotr437f5462014-02-04 17:57:25 +0100314 }
315
piotr6d152d92014-02-21 00:02:44 +0100316 return 0;
piotrd0bf1492014-02-05 17:27:32 +0100317}
piotr437f5462014-02-04 17:57:25 +0100318
piotr4089c1a2014-08-06 14:10:56 +0200319bool receiver_impl::find_fcch_burst(const gr_complex *input, const int nitems, double & computed_freq_offset)
piotrd0bf1492014-02-05 17:27:32 +0100320{
321 circular_buffer_float phase_diff_buffer(FCCH_HITS_NEEDED * d_OSR); //circular buffer used to scan throug signal to find
322 //best match for FCCH burst
323 float phase_diff = 0;
324 gr_complex conjprod;
325 int start_pos = -1;
326 int hit_count = 0;
327 int miss_count = 0;
328 float min_phase_diff;
329 float max_phase_diff;
330 double best_sum = 0;
331 float lowest_max_min_diff = 99999;
332
333 int to_consume = 0;
334 int sample_number = 0;
335 bool end = false;
336 bool result = false;
337 circular_buffer_float::iterator buffer_iter;
piotr6d152d92014-02-21 00:02:44 +0100338
piotrd0bf1492014-02-05 17:27:32 +0100339 /**@name Possible states of FCCH search algorithm*/
340 //@{
341 enum states
piotr437f5462014-02-04 17:57:25 +0100342 {
piotr437f5462014-02-04 17:57:25 +0100343 init, ///< initialize variables
344 search, ///< search for positive samples
345 found_something, ///< search for FCCH and the best position of it
346 fcch_found, ///< when FCCH was found
347 search_fail ///< when there is no FCCH in the input vector
piotrd0bf1492014-02-05 17:27:32 +0100348 } fcch_search_state;
349 //@}
piotr437f5462014-02-04 17:57:25 +0100350
piotrd0bf1492014-02-05 17:27:32 +0100351 fcch_search_state = init;
piotr437f5462014-02-04 17:57:25 +0100352
piotrd0bf1492014-02-05 17:27:32 +0100353 while (!end)
354 {
355 switch (fcch_search_state)
356 {
piotr437f5462014-02-04 17:57:25 +0100357
piotrd0bf1492014-02-05 17:27:32 +0100358 case init: //initialize variables
piotr437f5462014-02-04 17:57:25 +0100359 hit_count = 0;
360 miss_count = 0;
361 start_pos = -1;
362 lowest_max_min_diff = 99999;
363 phase_diff_buffer.clear();
364 fcch_search_state = search;
365
366 break;
367
piotr7c82b172014-02-08 14:15:27 +0100368 case search: // search for positive samples
piotr437f5462014-02-04 17:57:25 +0100369 sample_number++;
370
piotrd0bf1492014-02-05 17:27:32 +0100371 if (sample_number > nitems - FCCH_HITS_NEEDED * d_OSR) //if it isn't possible to find FCCH because
372 {
piotr7c82b172014-02-08 14:15:27 +0100373 //there's too few samples left to look into,
piotrd0bf1492014-02-05 17:27:32 +0100374 to_consume = sample_number; //don't do anything with those samples which are left
piotr7c82b172014-02-08 14:15:27 +0100375 //and consume only those which were checked
piotrd0bf1492014-02-05 17:27:32 +0100376 fcch_search_state = search_fail;
377 }
378 else
379 {
380 phase_diff = compute_phase_diff(input[sample_number], input[sample_number-1]);
piotr437f5462014-02-04 17:57:25 +0100381
piotrd0bf1492014-02-05 17:27:32 +0100382 if (phase_diff > 0) //if a positive phase difference was found
383 {
384 to_consume = sample_number;
385 fcch_search_state = found_something; //switch to state in which searches for FCCH
386 }
387 else
388 {
389 fcch_search_state = search;
390 }
piotr437f5462014-02-04 17:57:25 +0100391 }
392
393 break;
394
piotrd0bf1492014-02-05 17:27:32 +0100395 case found_something: // search for FCCH and the best position of it
396 {
397 if (phase_diff > 0)
398 {
piotr437f5462014-02-04 17:57:25 +0100399 hit_count++; //positive phase differencies increases hits_count
piotrd0bf1492014-02-05 17:27:32 +0100400 }
401 else
402 {
piotr437f5462014-02-04 17:57:25 +0100403 miss_count++; //negative increases miss_count
piotrd0bf1492014-02-05 17:27:32 +0100404 }
piotr437f5462014-02-04 17:57:25 +0100405
piotrd0bf1492014-02-05 17:27:32 +0100406 if ((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count <= FCCH_HITS_NEEDED * d_OSR))
407 {
piotr437f5462014-02-04 17:57:25 +0100408 //if miss_count exceeds limit before hit_count
409 fcch_search_state = init; //go to init
410 continue;
piotrd0bf1492014-02-05 17:27:32 +0100411 }
412 else if (((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR)) || (hit_count > 2 * FCCH_HITS_NEEDED * d_OSR))
413 {
piotr437f5462014-02-04 17:57:25 +0100414 //if hit_count and miss_count exceeds limit then FCCH was found
415 fcch_search_state = fcch_found;
416 continue;
piotrd0bf1492014-02-05 17:27:32 +0100417 }
418 else if ((miss_count < FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR))
419 {
piotr437f5462014-02-04 17:57:25 +0100420 //find difference between minimal and maximal element in the buffer
421 //for FCCH this value should be low
422 //this part is searching for a region where this value is lowest
423 min_phase_diff = * (min_element(phase_diff_buffer.begin(), phase_diff_buffer.end()));
424 max_phase_diff = * (max_element(phase_diff_buffer.begin(), phase_diff_buffer.end()));
425
piotrd0bf1492014-02-05 17:27:32 +0100426 if (lowest_max_min_diff > max_phase_diff - min_phase_diff)
427 {
428 lowest_max_min_diff = max_phase_diff - min_phase_diff;
429 start_pos = sample_number - FCCH_HITS_NEEDED * d_OSR - FCCH_MAX_MISSES * d_OSR; //store start pos
430 best_sum = 0;
piotr437f5462014-02-04 17:57:25 +0100431
piotrd0bf1492014-02-05 17:27:32 +0100432 for (buffer_iter = phase_diff_buffer.begin();
433 buffer_iter != (phase_diff_buffer.end());
434 buffer_iter++)
435 {
436 best_sum += *buffer_iter - (M_PI / 2) / d_OSR; //store best value of phase offset sum
437 }
piotr437f5462014-02-04 17:57:25 +0100438 }
piotrd0bf1492014-02-05 17:27:32 +0100439 }
piotr437f5462014-02-04 17:57:25 +0100440
piotrd0bf1492014-02-05 17:27:32 +0100441 sample_number++;
piotr437f5462014-02-04 17:57:25 +0100442
piotrd0bf1492014-02-05 17:27:32 +0100443 if (sample_number >= nitems) //if there's no single sample left to check
444 {
piotr437f5462014-02-04 17:57:25 +0100445 fcch_search_state = search_fail;//FCCH search failed
446 continue;
piotr437f5462014-02-04 17:57:25 +0100447 }
piotrd0bf1492014-02-05 17:27:32 +0100448
449 phase_diff = compute_phase_diff(input[sample_number], input[sample_number-1]);
450 phase_diff_buffer.push_back(phase_diff);
451 fcch_search_state = found_something;
452 }
453 break;
454
455 case fcch_found:
456 {
457 DCOUT("fcch found on position: " << d_counter + start_pos);
458 to_consume = start_pos + FCCH_HITS_NEEDED * d_OSR + 1; //consume one FCCH burst
459
460 d_fcch_start_pos = d_counter + start_pos;
461
462 //compute frequency offset
463 double phase_offset = best_sum / FCCH_HITS_NEEDED;
piotr4089c1a2014-08-06 14:10:56 +0200464 double freq_offset = phase_offset * 1625000.0/6 / (2 * M_PI); //1625000.0/6 - GMSK symbol rate in GSM
465 computed_freq_offset = freq_offset;
piotrd0bf1492014-02-05 17:27:32 +0100466
467 end = true;
468 result = true;
piotr437f5462014-02-04 17:57:25 +0100469 break;
piotrd0bf1492014-02-05 17:27:32 +0100470 }
piotr437f5462014-02-04 17:57:25 +0100471
piotrd0bf1492014-02-05 17:27:32 +0100472 case search_fail:
piotr437f5462014-02-04 17:57:25 +0100473 end = true;
474 result = false;
475 break;
476 }
piotr437f5462014-02-04 17:57:25 +0100477 }
478
piotrd0bf1492014-02-05 17:27:32 +0100479 d_counter += to_consume;
480 consume_each(to_consume);
piotr437f5462014-02-04 17:57:25 +0100481
piotrd0bf1492014-02-05 17:27:32 +0100482 return result;
483}
484
piotrd0bf1492014-02-05 17:27:32 +0100485double receiver_impl::compute_freq_offset(const gr_complex * input, unsigned first_sample, unsigned last_sample)
486{
487 double phase_sum = 0;
488 unsigned ii;
489
490 for (ii = first_sample; ii < last_sample; ii++)
piotr437f5462014-02-04 17:57:25 +0100491 {
piotr437f5462014-02-04 17:57:25 +0100492 double phase_diff = compute_phase_diff(input[ii], input[ii-1]) - (M_PI / 2) / d_OSR;
493 phase_sum += phase_diff;
piotr437f5462014-02-04 17:57:25 +0100494 }
495
piotrd0bf1492014-02-05 17:27:32 +0100496 double phase_offset = phase_sum / (last_sample - first_sample);
497 double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI);
498 return freq_offset;
499}
piotr437f5462014-02-04 17:57:25 +0100500
piotrd0bf1492014-02-05 17:27:32 +0100501void receiver_impl::set_frequency(double freq_offset)
502{
503 d_tuner->calleval(freq_offset);
504}
piotr437f5462014-02-04 17:57:25 +0100505
piotrd0bf1492014-02-05 17:27:32 +0100506inline float receiver_impl::compute_phase_diff(gr_complex val1, gr_complex val2)
507{
508 gr_complex conjprod = val1 * conj(val2);
509 return fast_atan2f(imag(conjprod), real(conjprod));
510}
piotr437f5462014-02-04 17:57:25 +0100511
piotrd0bf1492014-02-05 17:27:32 +0100512bool receiver_impl::reach_sch_burst(const int nitems)
513{
514 //it just consumes samples to get near to a SCH burst
515 int to_consume = 0;
516 bool result = false;
517 unsigned sample_nr_near_sch_start = d_fcch_start_pos + (FRAME_BITS - SAFETY_MARGIN) * d_OSR;
518
519 //consume samples until d_counter will be equal to sample_nr_near_sch_start
520 if (d_counter < sample_nr_near_sch_start)
521 {
522 if (d_counter + nitems >= sample_nr_near_sch_start)
523 {
524 to_consume = sample_nr_near_sch_start - d_counter;
525 }
526 else
527 {
528 to_consume = nitems;
piotr437f5462014-02-04 17:57:25 +0100529 }
530 result = false;
piotrd0bf1492014-02-05 17:27:32 +0100531 }
532 else
533 {
piotr437f5462014-02-04 17:57:25 +0100534 to_consume = 0;
535 result = true;
piotr437f5462014-02-04 17:57:25 +0100536 }
537
piotrd0bf1492014-02-05 17:27:32 +0100538 d_counter += to_consume;
539 consume_each(to_consume);
540 return result;
541}
542
543int receiver_impl::get_sch_chan_imp_resp(const gr_complex *input, gr_complex * chan_imp_resp)
544{
545 vector_complex correlation_buffer;
546 vector_float power_buffer;
547 vector_float window_energy_buffer;
548
549 int strongest_window_nr;
550 int burst_start = 0;
551 int chan_imp_resp_center = 0;
552 float max_correlation = 0;
553 float energy = 0;
554
555 for (int ii = SYNC_POS * d_OSR; ii < (SYNC_POS + SYNC_SEARCH_RANGE) *d_OSR; ii++)
piotr437f5462014-02-04 17:57:25 +0100556 {
piotr437f5462014-02-04 17:57:25 +0100557 gr_complex correlation = correlate_sequence(&d_sch_training_seq[5], N_SYNC_BITS - 10, &input[ii]);
558 correlation_buffer.push_back(correlation);
559 power_buffer.push_back(std::pow(abs(correlation), 2));
piotrd0bf1492014-02-05 17:27:32 +0100560 }
piotr7f3f3662014-07-08 16:47:53 +0200561 //plot(power_buffer);
piotrd0bf1492014-02-05 17:27:32 +0100562 //compute window energies
563 vector_float::iterator iter = power_buffer.begin();
564 bool loop_end = false;
565 while (iter != power_buffer.end())
566 {
piotr437f5462014-02-04 17:57:25 +0100567 vector_float::iterator iter_ii = iter;
568 energy = 0;
569
piotrd0bf1492014-02-05 17:27:32 +0100570 for (int ii = 0; ii < (d_chan_imp_length) *d_OSR; ii++, iter_ii++)
571 {
572 if (iter_ii == power_buffer.end())
573 {
574 loop_end = true;
575 break;
576 }
577 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100578 }
piotrd0bf1492014-02-05 17:27:32 +0100579 if (loop_end)
580 {
581 break;
piotr437f5462014-02-04 17:57:25 +0100582 }
583 iter++;
584 window_energy_buffer.push_back(energy);
piotrd0bf1492014-02-05 17:27:32 +0100585 }
piotr437f5462014-02-04 17:57:25 +0100586
piotrd0bf1492014-02-05 17:27:32 +0100587 strongest_window_nr = max_element(window_energy_buffer.begin(), window_energy_buffer.end()) - window_energy_buffer.begin();
piotr437f5462014-02-04 17:57:25 +0100588 // d_channel_imp_resp.clear();
589
piotrd0bf1492014-02-05 17:27:32 +0100590 max_correlation = 0;
591 for (int ii = 0; ii < (d_chan_imp_length) *d_OSR; ii++)
592 {
piotr437f5462014-02-04 17:57:25 +0100593 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100594 if (abs(correlation) > max_correlation)
595 {
596 chan_imp_resp_center = ii;
597 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100598 }
piotrd0bf1492014-02-05 17:27:32 +0100599 // d_channel_imp_resp.push_back(correlation);
piotr437f5462014-02-04 17:57:25 +0100600 chan_imp_resp[ii] = correlation;
piotr437f5462014-02-04 17:57:25 +0100601 }
602
piotrd0bf1492014-02-05 17:27:32 +0100603 burst_start = strongest_window_nr + chan_imp_resp_center - 48 * d_OSR - 2 * d_OSR + 2 + SYNC_POS * d_OSR;
604 return burst_start;
605}
piotr437f5462014-02-04 17:57:25 +0100606
607
piotrd0bf1492014-02-05 17:27:32 +0100608
609void receiver_impl::detect_burst(const gr_complex * input, gr_complex * chan_imp_resp, int burst_start, unsigned char * output_binary)
610{
611 float output[BURST_SIZE];
612 gr_complex rhh_temp[CHAN_IMP_RESP_LENGTH*d_OSR];
613 gr_complex rhh[CHAN_IMP_RESP_LENGTH];
614 gr_complex filtered_burst[BURST_SIZE];
615 int start_state = 3;
616 unsigned int stop_states[2] = {4, 12};
617
618 autocorrelation(chan_imp_resp, rhh_temp, d_chan_imp_length*d_OSR);
619 for (int ii = 0; ii < (d_chan_imp_length); ii++)
piotr437f5462014-02-04 17:57:25 +0100620 {
piotr437f5462014-02-04 17:57:25 +0100621 rhh[ii] = conj(rhh_temp[ii*d_OSR]);
piotr437f5462014-02-04 17:57:25 +0100622 }
623
piotrd0bf1492014-02-05 17:27:32 +0100624 mafi(&input[burst_start], BURST_SIZE, chan_imp_resp, d_chan_imp_length*d_OSR, filtered_burst);
625
626 viterbi_detector(filtered_burst, BURST_SIZE, rhh, start_state, stop_states, 2, output);
627
628 for (int i = 0; i < BURST_SIZE ; i++)
piotr437f5462014-02-04 17:57:25 +0100629 {
piotrd0bf1492014-02-05 17:27:32 +0100630 output_binary[i] = (output[i] > 0);
631 }
632}
piotr437f5462014-02-04 17:57:25 +0100633
piotrd0bf1492014-02-05 17:27:32 +0100634void receiver_impl::gmsk_mapper(const unsigned char * input, int nitems, gr_complex * gmsk_output, gr_complex start_point)
635{
636 gr_complex j = gr_complex(0.0, 1.0);
piotr437f5462014-02-04 17:57:25 +0100637
piotrd0bf1492014-02-05 17:27:32 +0100638 int current_symbol;
639 int encoded_symbol;
640 int previous_symbol = 2 * input[0] - 1;
641 gmsk_output[0] = start_point;
642
643 for (int i = 1; i < nitems; i++)
644 {
piotr437f5462014-02-04 17:57:25 +0100645 //change bits representation to NRZ
646 current_symbol = 2 * input[i] - 1;
647 //differentially encode
648 encoded_symbol = current_symbol * previous_symbol;
649 //and do gmsk mapping
650 gmsk_output[i] = j * gr_complex(encoded_symbol, 0.0) * gmsk_output[i-1];
651 previous_symbol = current_symbol;
piotr437f5462014-02-04 17:57:25 +0100652 }
piotrd0bf1492014-02-05 17:27:32 +0100653}
piotr437f5462014-02-04 17:57:25 +0100654
piotrd0bf1492014-02-05 17:27:32 +0100655gr_complex receiver_impl::correlate_sequence(const gr_complex * sequence, int length, const gr_complex * input)
656{
657 gr_complex result(0.0, 0.0);
658 int sample_number = 0;
659
660 for (int ii = 0; ii < length; ii++)
piotr437f5462014-02-04 17:57:25 +0100661 {
piotr437f5462014-02-04 17:57:25 +0100662 sample_number = (ii * d_OSR) ;
663 result += sequence[ii] * conj(input[sample_number]);
piotr437f5462014-02-04 17:57:25 +0100664 }
665
piotrd0bf1492014-02-05 17:27:32 +0100666 result = result / gr_complex(length, 0);
667 return result;
668}
669
670//computes autocorrelation for positive arguments
piotrd0bf1492014-02-05 17:27:32 +0100671inline void receiver_impl::autocorrelation(const gr_complex * input, gr_complex * out, int nitems)
672{
673 int i, k;
674 for (k = nitems - 1; k >= 0; k--)
piotr437f5462014-02-04 17:57:25 +0100675 {
piotr437f5462014-02-04 17:57:25 +0100676 out[k] = gr_complex(0, 0);
piotrd0bf1492014-02-05 17:27:32 +0100677 for (i = k; i < nitems; i++)
678 {
679 out[k] += input[i] * conj(input[i-k]);
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 +0100684inline void receiver_impl::mafi(const gr_complex * input, int nitems, gr_complex * filter, int filter_length, gr_complex * output)
685{
686 int ii = 0, n, a;
687
688 for (n = 0; n < nitems; n++)
piotr437f5462014-02-04 17:57:25 +0100689 {
piotr437f5462014-02-04 17:57:25 +0100690 a = n * d_OSR;
691 output[n] = 0;
692 ii = 0;
693
piotrd0bf1492014-02-05 17:27:32 +0100694 while (ii < filter_length)
695 {
piotrda8a0662014-04-24 10:29:38 +0200696 if ((a + ii) >= nitems*d_OSR){
piotrd0bf1492014-02-05 17:27:32 +0100697 break;
piotrda8a0662014-04-24 10:29:38 +0200698 }
piotrd0bf1492014-02-05 17:27:32 +0100699 output[n] += input[a+ii] * filter[ii];
700 ii++;
piotr437f5462014-02-04 17:57:25 +0100701 }
piotr437f5462014-02-04 17:57:25 +0100702 }
piotrd0bf1492014-02-05 17:27:32 +0100703}
piotr437f5462014-02-04 17:57:25 +0100704
piotrd0bf1492014-02-05 17:27:32 +0100705//especially computations of strongest_window_nr
piotr7e3b0db2014-02-05 22:44:30 +0100706int 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 +0100707{
708 vector_complex correlation_buffer;
709 vector_float power_buffer;
710 vector_float window_energy_buffer;
piotr437f5462014-02-04 17:57:25 +0100711
piotrd0bf1492014-02-05 17:27:32 +0100712 int strongest_window_nr;
713 int burst_start = 0;
714 int chan_imp_resp_center = 0;
715 float max_correlation = 0;
716 float energy = 0;
piotr5c820252014-04-17 09:43:02 +0200717
piotrd0bf1492014-02-05 17:27:32 +0100718 int search_center = (int)((TRAIN_POS + GUARD_PERIOD) * d_OSR);
piotr7c82b172014-02-08 14:15:27 +0100719 int search_start_pos = search_center + 1 - 5*d_OSR;
piotr437f5462014-02-04 17:57:25 +0100720 // int search_start_pos = search_center - d_chan_imp_length * d_OSR;
piotr5c820252014-04-17 09:43:02 +0200721 int search_stop_pos = search_center + d_chan_imp_length * d_OSR + 5 * d_OSR;
piotr437f5462014-02-04 17:57:25 +0100722
piotrd0bf1492014-02-05 17:27:32 +0100723 for (int ii = search_start_pos; ii < search_stop_pos; ii++)
724 {
piotr437f5462014-02-04 17:57:25 +0100725 gr_complex correlation = correlate_sequence(&d_norm_training_seq[bcc][TRAIN_BEGINNING], N_TRAIN_BITS - 10, &input[ii]);
726
727 correlation_buffer.push_back(correlation);
728 power_buffer.push_back(std::pow(abs(correlation), 2));
piotrd0bf1492014-02-05 17:27:32 +0100729 }
piotr437f5462014-02-04 17:57:25 +0100730
piotrd0bf1492014-02-05 17:27:32 +0100731 //compute window energies
732 vector_float::iterator iter = power_buffer.begin();
733 bool loop_end = false;
734 while (iter != power_buffer.end())
735 {
piotr437f5462014-02-04 17:57:25 +0100736 vector_float::iterator iter_ii = iter;
737 energy = 0;
738
piotrd0bf1492014-02-05 17:27:32 +0100739 for (int ii = 0; ii < (d_chan_imp_length - 2)*d_OSR; ii++, iter_ii++)
740 {
piotrd0bf1492014-02-05 17:27:32 +0100741 if (iter_ii == power_buffer.end())
742 {
743 loop_end = true;
744 break;
745 }
746 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100747 }
piotrd0bf1492014-02-05 17:27:32 +0100748 if (loop_end)
749 {
750 break;
piotr437f5462014-02-04 17:57:25 +0100751 }
752 iter++;
753
754 window_energy_buffer.push_back(energy);
piotrd0bf1492014-02-05 17:27:32 +0100755 }
piotr437f5462014-02-04 17:57:25 +0100756
piotr5c820252014-04-17 09:43:02 +0200757 strongest_window_nr = max_element(window_energy_buffer.begin(), window_energy_buffer.end()-((d_chan_imp_length)*d_OSR)) - window_energy_buffer.begin();
758 //strongest_window_nr = strongest_window_nr-d_OSR;
759 if(strongest_window_nr<0){
760 strongest_window_nr = 0;
761 }
piotr6d152d92014-02-21 00:02:44 +0100762
piotrd0bf1492014-02-05 17:27:32 +0100763 max_correlation = 0;
764 for (int ii = 0; ii < (d_chan_imp_length)*d_OSR; ii++)
765 {
piotr437f5462014-02-04 17:57:25 +0100766 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100767 if (abs(correlation) > max_correlation)
768 {
769 chan_imp_resp_center = ii;
770 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100771 }
piotrd0bf1492014-02-05 17:27:32 +0100772 // d_channel_imp_resp.push_back(correlation);
piotr437f5462014-02-04 17:57:25 +0100773 chan_imp_resp[ii] = correlation;
piotr437f5462014-02-04 17:57:25 +0100774 }
piotr7c82b172014-02-08 14:15:27 +0100775
piotr7e3b0db2014-02-05 22:44:30 +0100776 *corr_max = max_correlation;
piotrd0bf1492014-02-05 17:27:32 +0100777
piotr7c82b172014-02-08 14:15:27 +0100778 DCOUT("strongest_window_nr_new: " << strongest_window_nr);
piotrc7c249a2014-05-02 17:24:08 +0200779 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 +0100780
781 DCOUT("burst_start: " << burst_start);
piotrd0bf1492014-02-05 17:27:32 +0100782 return burst_start;
783}
piotr437f5462014-02-04 17:57:25 +0100784
785
piotr6d152d92014-02-21 00:02:44 +0100786void receiver_impl::send_burst(burst_counter burst_nr, const unsigned char * burst_binary, burst_type b_type)
piotrd0bf1492014-02-05 17:27:32 +0100787{
piotr7c82b172014-02-08 14:15:27 +0100788
piotr6d152d92014-02-21 00:02:44 +0100789 boost::scoped_ptr<gsmtap_hdr> tap_header(new gsmtap_hdr());
790
791 tap_header->version = GSMTAP_VERSION;
792 tap_header->hdr_len = BURST_SIZE/4;
793 tap_header->type = GSMTAP_TYPE_UM_BURST;
794 tap_header->timeslot = static_cast<uint8_t>(d_burst_nr.get_timeslot_nr());
795 tap_header->frame_number = d_burst_nr.get_frame_nr();
796 tap_header->sub_type = static_cast<uint8_t>(b_type);
797 tap_header->arfcn = d_arfcn;
798 tap_header->signal_dbm = static_cast<int8_t>(d_signal_dbm);
799 pmt::pmt_t header_blob=pmt::make_blob(tap_header.get(),sizeof(gsmtap_hdr));
800 pmt::pmt_t burst_binary_blob=pmt::make_blob(burst_binary,BURST_SIZE);
801 pmt::pmt_t msg = pmt::cons(header_blob, burst_binary_blob);
piotrf2b6a1b2014-08-04 11:28:59 +0200802
piotr6d152d92014-02-21 00:02:44 +0100803 message_port_pub(pmt::mp("bursts"), msg);
piotrd0bf1492014-02-05 17:27:32 +0100804}
piotr6d152d92014-02-21 00:02:44 +0100805
piotrd0bf1492014-02-05 17:27:32 +0100806void receiver_impl::configure_receiver()
807{
piotrce92f982014-04-17 23:37:18 +0200808 d_channel_conf.set_multiframe_type(TIMESLOT0, multiframe_51);
piotrd0bf1492014-02-05 17:27:32 +0100809 d_channel_conf.set_burst_types(TIMESLOT0, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotr437f5462014-02-04 17:57:25 +0100810
piotrce92f982014-04-17 23:37:18 +0200811 d_channel_conf.set_burst_types(TIMESLOT0, TEST_CCH_FRAMES, sizeof(TEST_CCH_FRAMES) / sizeof(unsigned), dummy_or_normal);
812 d_channel_conf.set_burst_types(TIMESLOT0, FCCH_FRAMES, sizeof(FCCH_FRAMES) / sizeof(unsigned), fcch_burst);
813 d_channel_conf.set_burst_types(TIMESLOT0, SCH_FRAMES, sizeof(SCH_FRAMES) / sizeof(unsigned), sch_burst);
piotr437f5462014-02-04 17:57:25 +0100814
815 // d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_26);
816 // d_channel_conf.set_burst_types(TIMESLOT1, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
817 // d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_26);
818 // d_channel_conf.set_burst_types(TIMESLOT2, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
819 // d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_26);
820 // d_channel_conf.set_burst_types(TIMESLOT3, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
821 // d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_26);
822 // d_channel_conf.set_burst_types(TIMESLOT4, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
823 // d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_26);
824 // d_channel_conf.set_burst_types(TIMESLOT5, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
825 // d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_26);
826 // d_channel_conf.set_burst_types(TIMESLOT6, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
827 // d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_26);
828 // 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 +0100829
piotrd0bf1492014-02-05 17:27:32 +0100830 d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_51);
831 d_channel_conf.set_burst_types(TIMESLOT1, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
832 d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_51);
833 d_channel_conf.set_burst_types(TIMESLOT2, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
834 d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_51);
835 d_channel_conf.set_burst_types(TIMESLOT3, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
836 d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_51);
837 d_channel_conf.set_burst_types(TIMESLOT4, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
838 d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_51);
839 d_channel_conf.set_burst_types(TIMESLOT5, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
840 d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_51);
841 d_channel_conf.set_burst_types(TIMESLOT6, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
842 d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_51);
843 d_channel_conf.set_burst_types(TIMESLOT7, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotrd0bf1492014-02-05 17:27:32 +0100844}
piotr437f5462014-02-04 17:57:25 +0100845
piotrf2b6a1b2014-08-04 11:28:59 +0200846void receiver_impl::set_arfcn(int arfcn) //!!
847{
848 d_arfcn = arfcn;
piotrf2b6a1b2014-08-04 11:28:59 +0200849}
850
851void receiver_impl::reset()
852{
853 d_state = first_fcch_search;
854}
piotr437f5462014-02-04 17:57:25 +0100855
piotrd0bf1492014-02-05 17:27:32 +0100856} /* namespace gsm */
piotr437f5462014-02-04 17:57:25 +0100857} /* namespace gr */
858