blob: f718f99cc3aa3c5ea97961dd4165d72d07504333 [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),
74 d_freq_offset(0),
75 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;
piotr7f3f3662014-07-08 16:47:53 +020082 //set_output_multiple(floor((TS_BITS + 2 * GUARD_PERIOD) * d_OSR)); //don't send samples to the receiver until there are at least samples for one
83 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"));
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{
piotrc7c249a2014-05-02 17:24:08 +0200107 //std::cout << noutput_items << std::endl;
piotrd0bf1492014-02-05 17:27:32 +0100108 const gr_complex *input = (const gr_complex *) input_items[0];
piotr7c82b172014-02-08 14:15:27 +0100109
piotrd0bf1492014-02-05 17:27:32 +0100110 switch (d_state)
piotr437f5462014-02-04 17:57:25 +0100111 {
piotrd0bf1492014-02-05 17:27:32 +0100112 //bootstrapping
113 case first_fcch_search:
piotr7e3b0db2014-02-05 22:44:30 +0100114 DCOUT("FCCH search");
piotrc7c249a2014-05-02 17:24:08 +0200115 if (find_fcch_burst(input, noutput_items)) //find frequency correction burst in the input buffer
piotrd0bf1492014-02-05 17:27:32 +0100116 {
piotr5f1e1d32014-02-05 18:10:05 +0100117 //set_frequency(d_freq_offset); //if fcch search is successful set frequency offset
piotr7f3f3662014-07-08 16:47:53 +0200118 DCOUT("Freq offset " << d_freq_offset);
119 DCOUT("PPM: " << d_freq_offset/940e6);
piotr437f5462014-02-04 17:57:25 +0100120 d_state = next_fcch_search;
piotrd0bf1492014-02-05 17:27:32 +0100121 }
122 else
123 {
piotr437f5462014-02-04 17:57:25 +0100124 d_state = first_fcch_search;
piotrd0bf1492014-02-05 17:27:32 +0100125 }
126 break;
piotr437f5462014-02-04 17:57:25 +0100127
piotrd0bf1492014-02-05 17:27:32 +0100128 case next_fcch_search: //this state is used because it takes some time (a bunch of buffered samples)
129 {
piotr7e3b0db2014-02-05 22:44:30 +0100130 DCOUT("NEXT FCCH search");
piotr7f3f3662014-07-08 16:47:53 +0200131 d_prev_freq_offset = d_freq_offset; //before previous set_frequqency cause change
piotrc7c249a2014-05-02 17:24:08 +0200132 if (find_fcch_burst(input, noutput_items))
piotrd0bf1492014-02-05 17:27:32 +0100133 {
piotr7f3f3662014-07-08 16:47:53 +0200134 if (abs(d_prev_freq_offset - d_freq_offset) > FCCH_MAX_FREQ_OFFSET)
piotrd0bf1492014-02-05 17:27:32 +0100135 {
piotr5f1e1d32014-02-05 18:10:05 +0100136 //set_frequency(d_freq_offset); //call set_frequncy only frequency offset change is greater than some value
piotr7f3f3662014-07-08 16:47:53 +0200137 //COUT("Freq offset " << d_freq_offset);
138 DCOUT("PPM: " << d_freq_offset/940);
piotr437f5462014-02-04 17:57:25 +0100139 }
piotrd0bf1492014-02-05 17:27:32 +0100140 d_state = sch_search;
141 }
142 else
143 {
piotrd0bf1492014-02-05 17:27:32 +0100144 d_state = next_fcch_search;
145 }
146 break;
147 }
piotr437f5462014-02-04 17:57:25 +0100148
149
piotrd0bf1492014-02-05 17:27:32 +0100150 case sch_search:
151 {
piotr7c82b172014-02-08 14:15:27 +0100152 DCOUT("SCH search");
piotrd0bf1492014-02-05 17:27:32 +0100153 vector_complex channel_imp_resp(CHAN_IMP_RESP_LENGTH*d_OSR);
154 int t1, t2, t3;
155 int burst_start = 0;
156 unsigned char output_binary[BURST_SIZE];
piotr437f5462014-02-04 17:57:25 +0100157
piotrc7c249a2014-05-02 17:24:08 +0200158 if (reach_sch_burst(noutput_items)) //wait for a SCH burst
piotrd0bf1492014-02-05 17:27:32 +0100159 {
160 burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]); //get channel impulse response from it
161 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //detect bits using MLSE detection
162 if (decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc) == 0) //decode SCH burst
163 {
piotr6d152d92014-02-21 00:02:44 +0100164 DCOUT("sch burst_start: " << burst_start);
165 DCOUT("bcc: " << d_bcc << " ncc: " << d_ncc << " t1: " << t1 << " t2: " << t2 << " t3: " << t3);
piotr437f5462014-02-04 17:57:25 +0100166 d_burst_nr.set(t1, t2, t3, 0); //set counter of bursts value
piotr437f5462014-02-04 17:57:25 +0100167 d_burst_nr++;
168
piotr7f3f3662014-07-08 16:47:53 +0200169 consume_each(burst_start + BURST_SIZE * d_OSR + 4*d_OSR); //consume samples up to next guard period
piotr437f5462014-02-04 17:57:25 +0100170 d_state = synchronized;
piotrd0bf1492014-02-05 17:27:32 +0100171 }
172 else
173 {
piotr437f5462014-02-04 17:57:25 +0100174 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 +0100175 }
piotrd0bf1492014-02-05 17:27:32 +0100176 }
177 else
178 {
179 d_state = sch_search;
180 }
181 break;
182 }
183 //in this state receiver is synchronized and it processes bursts according to burst type for given burst number
184 case synchronized:
185 {
piotr6d152d92014-02-21 00:02:44 +0100186 DCOUT("Synchronized");
piotrd0bf1492014-02-05 17:27:32 +0100187 vector_complex channel_imp_resp(CHAN_IMP_RESP_LENGTH*d_OSR);
188 int burst_start;
189 int offset = 0;
190 int to_consume = 0;
191 unsigned char output_binary[BURST_SIZE];
piotr437f5462014-02-04 17:57:25 +0100192
piotrd0bf1492014-02-05 17:27:32 +0100193 burst_type b_type = d_channel_conf.get_burst_type(d_burst_nr); //get burst type for given burst number
piotr6d152d92014-02-21 00:02:44 +0100194 double signal_pwr=0;
piotrc7c249a2014-05-02 17:24:08 +0200195 for(int ii=0;ii<noutput_items;ii++)
piotr6d152d92014-02-21 00:02:44 +0100196 {
197 signal_pwr += abs(input[ii])*abs(input[ii]);
198 }
199 d_signal_dbm=static_cast<int8_t>(round(20*log10(signal_pwr)));
200
piotrd0bf1492014-02-05 17:27:32 +0100201 switch (b_type)
202 {
203 case fcch_burst: //if it's FCCH burst
204 {
205 const unsigned first_sample = ceil((GUARD_PERIOD + 2 * TAIL_BITS) * d_OSR) + 1;
206 const unsigned last_sample = first_sample + USEFUL_BITS * d_OSR - TAIL_BITS * d_OSR;
207 double freq_offset = compute_freq_offset(input, first_sample, last_sample); //extract frequency offset from it
piotr437f5462014-02-04 17:57:25 +0100208
piotrd0bf1492014-02-05 17:27:32 +0100209 d_freq_offset_vals.push_front(freq_offset);
piotr6d152d92014-02-21 00:02:44 +0100210 send_burst(d_burst_nr, fc_fb, b_type);
211
piotrd0bf1492014-02-05 17:27:32 +0100212 if (d_freq_offset_vals.size() >= 10)
213 {
214 double sum = std::accumulate(d_freq_offset_vals.begin(), d_freq_offset_vals.end(), 0);
215 double mean_offset = sum / d_freq_offset_vals.size(); //compute mean
216 d_freq_offset_vals.clear();
piotr7f3f3662014-07-08 16:47:53 +0200217 DCOUT("mean offset" << mean_offset/940);
piotrd0bf1492014-02-05 17:27:32 +0100218 if (abs(mean_offset) > FCCH_MAX_FREQ_OFFSET)
219 {
piotr7c82b172014-02-08 14:15:27 +0100220 //d_freq_offset -= mean_offset; //and adjust frequency if it have changed beyond
piotr5f1e1d32014-02-05 18:10:05 +0100221 //set_frequency(d_freq_offset); //some limit
piotr7e3b0db2014-02-05 22:44:30 +0100222 DCOUT("Adjusting frequency, new frequency offset: " << d_freq_offset << "\n");
piotrd0bf1492014-02-05 17:27:32 +0100223 }
224 }
225 }
226 break;
227 case sch_burst: //if it's SCH burst
228 {
229 int t1, t2, t3, d_ncc, d_bcc;
230 burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]); //get channel impulse response
231 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //MLSE detection of bits
piotr6d152d92014-02-21 00:02:44 +0100232 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100233 if (decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc) == 0) //and decode SCH data
234 {
235 // d_burst_nr.set(t1, t2, t3, 0); //but only to check if burst_start value is correct
236 d_failed_sch = 0;
237 DCOUT("bcc: " << d_bcc << " ncc: " << d_ncc << " t1: " << t1 << " t2: " << t2 << " t3: " << t3);
238 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 +0100239 DCOUT("offset: "<<offset);
piotrd0bf1492014-02-05 17:27:32 +0100240 to_consume += offset; //adjust with offset number of samples to be consumed
241 }
242 else
243 {
244 d_failed_sch++;
245 if (d_failed_sch >= MAX_SCH_ERRORS)
246 {
piotr54624012014-04-17 23:36:27 +0200247 d_state = next_fcch_search;
piotr437f5462014-02-04 17:57:25 +0100248 d_freq_offset_vals.clear();
piotrd0bf1492014-02-05 17:27:32 +0100249 d_freq_offset=0;
piotr7c82b172014-02-08 14:15:27 +0100250 //set_frequency(0);
piotr7f3f3662014-07-08 16:47:53 +0200251 DCOUT("Re-Synchronization!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
piotr437f5462014-02-04 17:57:25 +0100252 }
piotr437f5462014-02-04 17:57:25 +0100253 }
piotrd0bf1492014-02-05 17:27:32 +0100254 }
255 break;
piotr437f5462014-02-04 17:57:25 +0100256
piotr7e3b0db2014-02-05 22:44:30 +0100257 case normal_burst:
258 {
259 float normal_corr_max; //if it's normal burst
260 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 +0100261 detect_burst(input, &channel_imp_resp[0], burst_start, output_binary); //MLSE detection of bits
piotr8dc74a42014-04-17 09:48:46 +0200262 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100263 break;
piotr7e3b0db2014-02-05 22:44:30 +0100264 }
piotrd0bf1492014-02-05 17:27:32 +0100265 case dummy_or_normal:
266 {
piotr7e3b0db2014-02-05 22:44:30 +0100267 unsigned int normal_burst_start;
268 float dummy_corr_max, normal_corr_max;
piotr7c82b172014-02-08 14:15:27 +0100269 DCOUT("Dummy");
piotr7e3b0db2014-02-05 22:44:30 +0100270 get_norm_chan_imp_resp(input, &channel_imp_resp[0], &dummy_corr_max, TS_DUMMY);
piotr7c82b172014-02-08 14:15:27 +0100271 DCOUT("Normal");
piotr7e3b0db2014-02-05 22:44:30 +0100272 normal_burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], &normal_corr_max, d_bcc);
273
piotr7c82b172014-02-08 14:15:27 +0100274 DCOUT("normal_corr_max: " << normal_corr_max << " dummy_corr_max:" << dummy_corr_max);
piotr7e3b0db2014-02-05 22:44:30 +0100275 if (normal_corr_max > dummy_corr_max)
piotrd0bf1492014-02-05 17:27:32 +0100276 {
piotr7e3b0db2014-02-05 22:44:30 +0100277 detect_burst(input, &channel_imp_resp[0], normal_burst_start, output_binary);
piotr8dc74a42014-04-17 09:48:46 +0200278 send_burst(d_burst_nr, output_binary, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100279 }
280 else
281 {
piotr6d152d92014-02-21 00:02:44 +0100282 send_burst(d_burst_nr, dummy_burst, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100283 }
284 }
285 case rach_burst:
piotrd0bf1492014-02-05 17:27:32 +0100286 break;
piotr7e3b0db2014-02-05 22:44:30 +0100287 case dummy:
piotr6d152d92014-02-21 00:02:44 +0100288 send_burst(d_burst_nr, dummy_burst, b_type);
piotrd0bf1492014-02-05 17:27:32 +0100289 break;
290 case empty: //if it's empty burst
291 break; //do nothing
292 }
293
294 d_burst_nr++; //go to next burst
piotrd0bf1492014-02-05 17:27:32 +0100295 to_consume += TS_BITS * d_OSR + d_burst_nr.get_offset(); //consume samples of the burst up to next guard period
296 //and add offset which is introduced by
297 //0.25 fractional part of a guard period
piotrd0bf1492014-02-05 17:27:32 +0100298 consume_each(to_consume);
299 }
300 break;
piotr437f5462014-02-04 17:57:25 +0100301 }
302
piotr6d152d92014-02-21 00:02:44 +0100303 return 0;
piotrd0bf1492014-02-05 17:27:32 +0100304}
piotr437f5462014-02-04 17:57:25 +0100305
piotrd0bf1492014-02-05 17:27:32 +0100306
307bool receiver_impl::find_fcch_burst(const gr_complex *input, const int nitems)
308{
309 circular_buffer_float phase_diff_buffer(FCCH_HITS_NEEDED * d_OSR); //circular buffer used to scan throug signal to find
310 //best match for FCCH burst
311 float phase_diff = 0;
312 gr_complex conjprod;
313 int start_pos = -1;
314 int hit_count = 0;
315 int miss_count = 0;
316 float min_phase_diff;
317 float max_phase_diff;
318 double best_sum = 0;
319 float lowest_max_min_diff = 99999;
320
321 int to_consume = 0;
322 int sample_number = 0;
323 bool end = false;
324 bool result = false;
325 circular_buffer_float::iterator buffer_iter;
piotr6d152d92014-02-21 00:02:44 +0100326
piotrd0bf1492014-02-05 17:27:32 +0100327 /**@name Possible states of FCCH search algorithm*/
328 //@{
329 enum states
piotr437f5462014-02-04 17:57:25 +0100330 {
piotr437f5462014-02-04 17:57:25 +0100331 init, ///< initialize variables
332 search, ///< search for positive samples
333 found_something, ///< search for FCCH and the best position of it
334 fcch_found, ///< when FCCH was found
335 search_fail ///< when there is no FCCH in the input vector
piotrd0bf1492014-02-05 17:27:32 +0100336 } fcch_search_state;
337 //@}
piotr437f5462014-02-04 17:57:25 +0100338
piotrd0bf1492014-02-05 17:27:32 +0100339 fcch_search_state = init;
piotr437f5462014-02-04 17:57:25 +0100340
piotrd0bf1492014-02-05 17:27:32 +0100341 while (!end)
342 {
343 switch (fcch_search_state)
344 {
piotr437f5462014-02-04 17:57:25 +0100345
piotrd0bf1492014-02-05 17:27:32 +0100346 case init: //initialize variables
piotr437f5462014-02-04 17:57:25 +0100347 hit_count = 0;
348 miss_count = 0;
349 start_pos = -1;
350 lowest_max_min_diff = 99999;
351 phase_diff_buffer.clear();
352 fcch_search_state = search;
353
354 break;
355
piotr7c82b172014-02-08 14:15:27 +0100356 case search: // search for positive samples
piotr437f5462014-02-04 17:57:25 +0100357 sample_number++;
358
piotrd0bf1492014-02-05 17:27:32 +0100359 if (sample_number > nitems - FCCH_HITS_NEEDED * d_OSR) //if it isn't possible to find FCCH because
360 {
piotr7c82b172014-02-08 14:15:27 +0100361 //there's too few samples left to look into,
piotrd0bf1492014-02-05 17:27:32 +0100362 to_consume = sample_number; //don't do anything with those samples which are left
piotr7c82b172014-02-08 14:15:27 +0100363 //and consume only those which were checked
piotrd0bf1492014-02-05 17:27:32 +0100364 fcch_search_state = search_fail;
365 }
366 else
367 {
368 phase_diff = compute_phase_diff(input[sample_number], input[sample_number-1]);
piotr437f5462014-02-04 17:57:25 +0100369
piotrd0bf1492014-02-05 17:27:32 +0100370 if (phase_diff > 0) //if a positive phase difference was found
371 {
372 to_consume = sample_number;
373 fcch_search_state = found_something; //switch to state in which searches for FCCH
374 }
375 else
376 {
377 fcch_search_state = search;
378 }
piotr437f5462014-02-04 17:57:25 +0100379 }
380
381 break;
382
piotrd0bf1492014-02-05 17:27:32 +0100383 case found_something: // search for FCCH and the best position of it
384 {
385 if (phase_diff > 0)
386 {
piotr437f5462014-02-04 17:57:25 +0100387 hit_count++; //positive phase differencies increases hits_count
piotrd0bf1492014-02-05 17:27:32 +0100388 }
389 else
390 {
piotr437f5462014-02-04 17:57:25 +0100391 miss_count++; //negative increases miss_count
piotrd0bf1492014-02-05 17:27:32 +0100392 }
piotr437f5462014-02-04 17:57:25 +0100393
piotrd0bf1492014-02-05 17:27:32 +0100394 if ((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count <= FCCH_HITS_NEEDED * d_OSR))
395 {
piotr437f5462014-02-04 17:57:25 +0100396 //if miss_count exceeds limit before hit_count
397 fcch_search_state = init; //go to init
398 continue;
piotrd0bf1492014-02-05 17:27:32 +0100399 }
400 else if (((miss_count >= FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR)) || (hit_count > 2 * FCCH_HITS_NEEDED * d_OSR))
401 {
piotr437f5462014-02-04 17:57:25 +0100402 //if hit_count and miss_count exceeds limit then FCCH was found
403 fcch_search_state = fcch_found;
404 continue;
piotrd0bf1492014-02-05 17:27:32 +0100405 }
406 else if ((miss_count < FCCH_MAX_MISSES * d_OSR) && (hit_count > FCCH_HITS_NEEDED * d_OSR))
407 {
piotr437f5462014-02-04 17:57:25 +0100408 //find difference between minimal and maximal element in the buffer
409 //for FCCH this value should be low
410 //this part is searching for a region where this value is lowest
411 min_phase_diff = * (min_element(phase_diff_buffer.begin(), phase_diff_buffer.end()));
412 max_phase_diff = * (max_element(phase_diff_buffer.begin(), phase_diff_buffer.end()));
413
piotrd0bf1492014-02-05 17:27:32 +0100414 if (lowest_max_min_diff > max_phase_diff - min_phase_diff)
415 {
416 lowest_max_min_diff = max_phase_diff - min_phase_diff;
417 start_pos = sample_number - FCCH_HITS_NEEDED * d_OSR - FCCH_MAX_MISSES * d_OSR; //store start pos
418 best_sum = 0;
piotr437f5462014-02-04 17:57:25 +0100419
piotrd0bf1492014-02-05 17:27:32 +0100420 for (buffer_iter = phase_diff_buffer.begin();
421 buffer_iter != (phase_diff_buffer.end());
422 buffer_iter++)
423 {
424 best_sum += *buffer_iter - (M_PI / 2) / d_OSR; //store best value of phase offset sum
425 }
piotr437f5462014-02-04 17:57:25 +0100426 }
piotrd0bf1492014-02-05 17:27:32 +0100427 }
piotr437f5462014-02-04 17:57:25 +0100428
piotrd0bf1492014-02-05 17:27:32 +0100429 sample_number++;
piotr437f5462014-02-04 17:57:25 +0100430
piotrd0bf1492014-02-05 17:27:32 +0100431 if (sample_number >= nitems) //if there's no single sample left to check
432 {
piotr437f5462014-02-04 17:57:25 +0100433 fcch_search_state = search_fail;//FCCH search failed
434 continue;
piotr437f5462014-02-04 17:57:25 +0100435 }
piotrd0bf1492014-02-05 17:27:32 +0100436
437 phase_diff = compute_phase_diff(input[sample_number], input[sample_number-1]);
438 phase_diff_buffer.push_back(phase_diff);
439 fcch_search_state = found_something;
440 }
441 break;
442
443 case fcch_found:
444 {
445 DCOUT("fcch found on position: " << d_counter + start_pos);
446 to_consume = start_pos + FCCH_HITS_NEEDED * d_OSR + 1; //consume one FCCH burst
447
448 d_fcch_start_pos = d_counter + start_pos;
449
450 //compute frequency offset
451 double phase_offset = best_sum / FCCH_HITS_NEEDED;
452 double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI);
piotr7f3f3662014-07-08 16:47:53 +0200453 //d_freq_offset -= freq_offset;
454 d_freq_offset = freq_offset;
piotrd0bf1492014-02-05 17:27:32 +0100455 DCOUT("freq_offset: " << d_freq_offset);
456
457 end = true;
458 result = true;
piotr437f5462014-02-04 17:57:25 +0100459 break;
piotrd0bf1492014-02-05 17:27:32 +0100460 }
piotr437f5462014-02-04 17:57:25 +0100461
piotrd0bf1492014-02-05 17:27:32 +0100462 case search_fail:
piotr437f5462014-02-04 17:57:25 +0100463 end = true;
464 result = false;
465 break;
466 }
piotr437f5462014-02-04 17:57:25 +0100467 }
468
piotrd0bf1492014-02-05 17:27:32 +0100469 d_counter += to_consume;
470 consume_each(to_consume);
piotr437f5462014-02-04 17:57:25 +0100471
piotrd0bf1492014-02-05 17:27:32 +0100472 return result;
473}
474
piotrd0bf1492014-02-05 17:27:32 +0100475double receiver_impl::compute_freq_offset(const gr_complex * input, unsigned first_sample, unsigned last_sample)
476{
477 double phase_sum = 0;
478 unsigned ii;
479
480 for (ii = first_sample; ii < last_sample; ii++)
piotr437f5462014-02-04 17:57:25 +0100481 {
piotr437f5462014-02-04 17:57:25 +0100482 double phase_diff = compute_phase_diff(input[ii], input[ii-1]) - (M_PI / 2) / d_OSR;
483 phase_sum += phase_diff;
piotr437f5462014-02-04 17:57:25 +0100484 }
485
piotrd0bf1492014-02-05 17:27:32 +0100486 double phase_offset = phase_sum / (last_sample - first_sample);
487 double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI);
488 return freq_offset;
489}
piotr437f5462014-02-04 17:57:25 +0100490
piotrd0bf1492014-02-05 17:27:32 +0100491void receiver_impl::set_frequency(double freq_offset)
492{
493 d_tuner->calleval(freq_offset);
494}
piotr437f5462014-02-04 17:57:25 +0100495
piotrd0bf1492014-02-05 17:27:32 +0100496inline float receiver_impl::compute_phase_diff(gr_complex val1, gr_complex val2)
497{
498 gr_complex conjprod = val1 * conj(val2);
499 return fast_atan2f(imag(conjprod), real(conjprod));
500}
piotr437f5462014-02-04 17:57:25 +0100501
piotrd0bf1492014-02-05 17:27:32 +0100502bool receiver_impl::reach_sch_burst(const int nitems)
503{
504 //it just consumes samples to get near to a SCH burst
505 int to_consume = 0;
506 bool result = false;
507 unsigned sample_nr_near_sch_start = d_fcch_start_pos + (FRAME_BITS - SAFETY_MARGIN) * d_OSR;
508
509 //consume samples until d_counter will be equal to sample_nr_near_sch_start
510 if (d_counter < sample_nr_near_sch_start)
511 {
512 if (d_counter + nitems >= sample_nr_near_sch_start)
513 {
514 to_consume = sample_nr_near_sch_start - d_counter;
515 }
516 else
517 {
518 to_consume = nitems;
piotr437f5462014-02-04 17:57:25 +0100519 }
520 result = false;
piotrd0bf1492014-02-05 17:27:32 +0100521 }
522 else
523 {
piotr437f5462014-02-04 17:57:25 +0100524 to_consume = 0;
525 result = true;
piotr437f5462014-02-04 17:57:25 +0100526 }
527
piotrd0bf1492014-02-05 17:27:32 +0100528 d_counter += to_consume;
529 consume_each(to_consume);
530 return result;
531}
532
533int receiver_impl::get_sch_chan_imp_resp(const gr_complex *input, gr_complex * chan_imp_resp)
534{
535 vector_complex correlation_buffer;
536 vector_float power_buffer;
537 vector_float window_energy_buffer;
538
539 int strongest_window_nr;
540 int burst_start = 0;
541 int chan_imp_resp_center = 0;
542 float max_correlation = 0;
543 float energy = 0;
544
545 for (int ii = SYNC_POS * d_OSR; ii < (SYNC_POS + SYNC_SEARCH_RANGE) *d_OSR; ii++)
piotr437f5462014-02-04 17:57:25 +0100546 {
piotr437f5462014-02-04 17:57:25 +0100547 gr_complex correlation = correlate_sequence(&d_sch_training_seq[5], N_SYNC_BITS - 10, &input[ii]);
548 correlation_buffer.push_back(correlation);
549 power_buffer.push_back(std::pow(abs(correlation), 2));
piotrd0bf1492014-02-05 17:27:32 +0100550 }
piotr7f3f3662014-07-08 16:47:53 +0200551 //plot(power_buffer);
piotrd0bf1492014-02-05 17:27:32 +0100552 //compute window energies
553 vector_float::iterator iter = power_buffer.begin();
554 bool loop_end = false;
555 while (iter != power_buffer.end())
556 {
piotr437f5462014-02-04 17:57:25 +0100557 vector_float::iterator iter_ii = iter;
558 energy = 0;
559
piotrd0bf1492014-02-05 17:27:32 +0100560 for (int ii = 0; ii < (d_chan_imp_length) *d_OSR; ii++, iter_ii++)
561 {
562 if (iter_ii == power_buffer.end())
563 {
564 loop_end = true;
565 break;
566 }
567 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100568 }
piotrd0bf1492014-02-05 17:27:32 +0100569 if (loop_end)
570 {
571 break;
piotr437f5462014-02-04 17:57:25 +0100572 }
573 iter++;
574 window_energy_buffer.push_back(energy);
piotrd0bf1492014-02-05 17:27:32 +0100575 }
piotr437f5462014-02-04 17:57:25 +0100576
piotrd0bf1492014-02-05 17:27:32 +0100577 strongest_window_nr = max_element(window_energy_buffer.begin(), window_energy_buffer.end()) - window_energy_buffer.begin();
piotr437f5462014-02-04 17:57:25 +0100578 // d_channel_imp_resp.clear();
579
piotrd0bf1492014-02-05 17:27:32 +0100580 max_correlation = 0;
581 for (int ii = 0; ii < (d_chan_imp_length) *d_OSR; ii++)
582 {
piotr437f5462014-02-04 17:57:25 +0100583 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100584 if (abs(correlation) > max_correlation)
585 {
586 chan_imp_resp_center = ii;
587 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100588 }
piotrd0bf1492014-02-05 17:27:32 +0100589 // d_channel_imp_resp.push_back(correlation);
piotr437f5462014-02-04 17:57:25 +0100590 chan_imp_resp[ii] = correlation;
piotr437f5462014-02-04 17:57:25 +0100591 }
592
piotrd0bf1492014-02-05 17:27:32 +0100593 burst_start = strongest_window_nr + chan_imp_resp_center - 48 * d_OSR - 2 * d_OSR + 2 + SYNC_POS * d_OSR;
594 return burst_start;
595}
piotr437f5462014-02-04 17:57:25 +0100596
597
piotrd0bf1492014-02-05 17:27:32 +0100598
599void receiver_impl::detect_burst(const gr_complex * input, gr_complex * chan_imp_resp, int burst_start, unsigned char * output_binary)
600{
601 float output[BURST_SIZE];
602 gr_complex rhh_temp[CHAN_IMP_RESP_LENGTH*d_OSR];
603 gr_complex rhh[CHAN_IMP_RESP_LENGTH];
604 gr_complex filtered_burst[BURST_SIZE];
605 int start_state = 3;
606 unsigned int stop_states[2] = {4, 12};
607
608 autocorrelation(chan_imp_resp, rhh_temp, d_chan_imp_length*d_OSR);
609 for (int ii = 0; ii < (d_chan_imp_length); ii++)
piotr437f5462014-02-04 17:57:25 +0100610 {
piotr437f5462014-02-04 17:57:25 +0100611 rhh[ii] = conj(rhh_temp[ii*d_OSR]);
piotr437f5462014-02-04 17:57:25 +0100612 }
613
piotrd0bf1492014-02-05 17:27:32 +0100614 mafi(&input[burst_start], BURST_SIZE, chan_imp_resp, d_chan_imp_length*d_OSR, filtered_burst);
615
616 viterbi_detector(filtered_burst, BURST_SIZE, rhh, start_state, stop_states, 2, output);
617
618 for (int i = 0; i < BURST_SIZE ; i++)
piotr437f5462014-02-04 17:57:25 +0100619 {
piotrd0bf1492014-02-05 17:27:32 +0100620 output_binary[i] = (output[i] > 0);
621 }
622}
piotr437f5462014-02-04 17:57:25 +0100623
piotrd0bf1492014-02-05 17:27:32 +0100624//TODO consider placing this funtion in a separate class for signal processing
625void receiver_impl::gmsk_mapper(const unsigned char * input, int nitems, gr_complex * gmsk_output, gr_complex start_point)
626{
627 gr_complex j = gr_complex(0.0, 1.0);
piotr437f5462014-02-04 17:57:25 +0100628
piotrd0bf1492014-02-05 17:27:32 +0100629 int current_symbol;
630 int encoded_symbol;
631 int previous_symbol = 2 * input[0] - 1;
632 gmsk_output[0] = start_point;
633
634 for (int i = 1; i < nitems; i++)
635 {
piotr437f5462014-02-04 17:57:25 +0100636 //change bits representation to NRZ
637 current_symbol = 2 * input[i] - 1;
638 //differentially encode
639 encoded_symbol = current_symbol * previous_symbol;
640 //and do gmsk mapping
641 gmsk_output[i] = j * gr_complex(encoded_symbol, 0.0) * gmsk_output[i-1];
642 previous_symbol = current_symbol;
piotr437f5462014-02-04 17:57:25 +0100643 }
piotrd0bf1492014-02-05 17:27:32 +0100644}
piotr437f5462014-02-04 17:57:25 +0100645
piotrd0bf1492014-02-05 17:27:32 +0100646//TODO consider use of some generalized function for correlation and placing it in a separate class for signal processing
647gr_complex receiver_impl::correlate_sequence(const gr_complex * sequence, int length, const gr_complex * input)
648{
649 gr_complex result(0.0, 0.0);
650 int sample_number = 0;
651
652 for (int ii = 0; ii < length; ii++)
piotr437f5462014-02-04 17:57:25 +0100653 {
piotr437f5462014-02-04 17:57:25 +0100654 sample_number = (ii * d_OSR) ;
655 result += sequence[ii] * conj(input[sample_number]);
piotr437f5462014-02-04 17:57:25 +0100656 }
657
piotrd0bf1492014-02-05 17:27:32 +0100658 result = result / gr_complex(length, 0);
659 return result;
660}
661
662//computes autocorrelation for positive arguments
663//TODO consider placing this funtion in a separate class for signal processing
664inline void receiver_impl::autocorrelation(const gr_complex * input, gr_complex * out, int nitems)
665{
666 int i, k;
667 for (k = nitems - 1; k >= 0; k--)
piotr437f5462014-02-04 17:57:25 +0100668 {
piotr437f5462014-02-04 17:57:25 +0100669 out[k] = gr_complex(0, 0);
piotrd0bf1492014-02-05 17:27:32 +0100670 for (i = k; i < nitems; i++)
671 {
672 out[k] += input[i] * conj(input[i-k]);
piotr437f5462014-02-04 17:57:25 +0100673 }
piotr437f5462014-02-04 17:57:25 +0100674 }
piotrd0bf1492014-02-05 17:27:32 +0100675}
piotr437f5462014-02-04 17:57:25 +0100676
piotrd0bf1492014-02-05 17:27:32 +0100677//TODO consider use of some generalized function for filtering and placing it in a separate class for signal processing
678inline void receiver_impl::mafi(const gr_complex * input, int nitems, gr_complex * filter, int filter_length, gr_complex * output)
679{
680 int ii = 0, n, a;
681
682 for (n = 0; n < nitems; n++)
piotr437f5462014-02-04 17:57:25 +0100683 {
piotr437f5462014-02-04 17:57:25 +0100684 a = n * d_OSR;
685 output[n] = 0;
686 ii = 0;
687
piotrd0bf1492014-02-05 17:27:32 +0100688 while (ii < filter_length)
689 {
piotrda8a0662014-04-24 10:29:38 +0200690 if ((a + ii) >= nitems*d_OSR){
piotrd0bf1492014-02-05 17:27:32 +0100691 break;
piotrda8a0662014-04-24 10:29:38 +0200692 }
piotrd0bf1492014-02-05 17:27:32 +0100693 output[n] += input[a+ii] * filter[ii];
694 ii++;
piotr437f5462014-02-04 17:57:25 +0100695 }
piotr437f5462014-02-04 17:57:25 +0100696 }
piotrd0bf1492014-02-05 17:27:32 +0100697}
piotr437f5462014-02-04 17:57:25 +0100698
piotrd0bf1492014-02-05 17:27:32 +0100699//TODO: get_norm_chan_imp_resp is similar to get_sch_chan_imp_resp - consider joining this two functions
piotrd0bf1492014-02-05 17:27:32 +0100700//especially computations of strongest_window_nr
piotr7e3b0db2014-02-05 22:44:30 +0100701int 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 +0100702{
703 vector_complex correlation_buffer;
704 vector_float power_buffer;
705 vector_float window_energy_buffer;
piotr437f5462014-02-04 17:57:25 +0100706
piotrd0bf1492014-02-05 17:27:32 +0100707 int strongest_window_nr;
708 int burst_start = 0;
709 int chan_imp_resp_center = 0;
710 float max_correlation = 0;
711 float energy = 0;
piotr5c820252014-04-17 09:43:02 +0200712
piotrd0bf1492014-02-05 17:27:32 +0100713 int search_center = (int)((TRAIN_POS + GUARD_PERIOD) * d_OSR);
piotr7c82b172014-02-08 14:15:27 +0100714 int search_start_pos = search_center + 1 - 5*d_OSR;
piotr437f5462014-02-04 17:57:25 +0100715 // int search_start_pos = search_center - d_chan_imp_length * d_OSR;
piotr5c820252014-04-17 09:43:02 +0200716 int search_stop_pos = search_center + d_chan_imp_length * d_OSR + 5 * d_OSR;
piotr437f5462014-02-04 17:57:25 +0100717
piotrd0bf1492014-02-05 17:27:32 +0100718 for (int ii = search_start_pos; ii < search_stop_pos; ii++)
719 {
piotr437f5462014-02-04 17:57:25 +0100720 gr_complex correlation = correlate_sequence(&d_norm_training_seq[bcc][TRAIN_BEGINNING], N_TRAIN_BITS - 10, &input[ii]);
721
722 correlation_buffer.push_back(correlation);
723 power_buffer.push_back(std::pow(abs(correlation), 2));
piotrd0bf1492014-02-05 17:27:32 +0100724 }
piotr437f5462014-02-04 17:57:25 +0100725
piotrd0bf1492014-02-05 17:27:32 +0100726 //compute window energies
727 vector_float::iterator iter = power_buffer.begin();
728 bool loop_end = false;
729 while (iter != power_buffer.end())
730 {
piotr437f5462014-02-04 17:57:25 +0100731 vector_float::iterator iter_ii = iter;
732 energy = 0;
733
piotrd0bf1492014-02-05 17:27:32 +0100734 for (int ii = 0; ii < (d_chan_imp_length - 2)*d_OSR; ii++, iter_ii++)
735 {
piotrd0bf1492014-02-05 17:27:32 +0100736 if (iter_ii == power_buffer.end())
737 {
738 loop_end = true;
739 break;
740 }
741 energy += (*iter_ii);
piotr437f5462014-02-04 17:57:25 +0100742 }
piotrd0bf1492014-02-05 17:27:32 +0100743 if (loop_end)
744 {
745 break;
piotr437f5462014-02-04 17:57:25 +0100746 }
747 iter++;
748
749 window_energy_buffer.push_back(energy);
piotrd0bf1492014-02-05 17:27:32 +0100750 }
piotr437f5462014-02-04 17:57:25 +0100751
piotr5c820252014-04-17 09:43:02 +0200752 strongest_window_nr = max_element(window_energy_buffer.begin(), window_energy_buffer.end()-((d_chan_imp_length)*d_OSR)) - window_energy_buffer.begin();
753 //strongest_window_nr = strongest_window_nr-d_OSR;
754 if(strongest_window_nr<0){
755 strongest_window_nr = 0;
756 }
piotr6d152d92014-02-21 00:02:44 +0100757
piotrd0bf1492014-02-05 17:27:32 +0100758 max_correlation = 0;
759 for (int ii = 0; ii < (d_chan_imp_length)*d_OSR; ii++)
760 {
piotr437f5462014-02-04 17:57:25 +0100761 gr_complex correlation = correlation_buffer[strongest_window_nr + ii];
piotrd0bf1492014-02-05 17:27:32 +0100762 if (abs(correlation) > max_correlation)
763 {
764 chan_imp_resp_center = ii;
765 max_correlation = abs(correlation);
piotr437f5462014-02-04 17:57:25 +0100766 }
piotrd0bf1492014-02-05 17:27:32 +0100767 // d_channel_imp_resp.push_back(correlation);
piotr437f5462014-02-04 17:57:25 +0100768 chan_imp_resp[ii] = correlation;
piotr437f5462014-02-04 17:57:25 +0100769 }
piotr7c82b172014-02-08 14:15:27 +0100770
piotr7e3b0db2014-02-05 22:44:30 +0100771 *corr_max = max_correlation;
piotrd0bf1492014-02-05 17:27:32 +0100772
piotr7c82b172014-02-08 14:15:27 +0100773 DCOUT("strongest_window_nr_new: " << strongest_window_nr);
piotrc7c249a2014-05-02 17:24:08 +0200774 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
775 //TRAIN_POS=3+57+1+6
776 //TODO: describe this part in detail in documentation as this is crucial part for synchronization
piotr7c82b172014-02-08 14:15:27 +0100777
778 DCOUT("burst_start: " << burst_start);
piotrd0bf1492014-02-05 17:27:32 +0100779 return burst_start;
780}
piotr437f5462014-02-04 17:57:25 +0100781
782
piotr6d152d92014-02-21 00:02:44 +0100783void receiver_impl::send_burst(burst_counter burst_nr, const unsigned char * burst_binary, burst_type b_type)
piotrd0bf1492014-02-05 17:27:32 +0100784{
piotr7c82b172014-02-08 14:15:27 +0100785
piotr6d152d92014-02-21 00:02:44 +0100786 boost::scoped_ptr<gsmtap_hdr> tap_header(new gsmtap_hdr());
787
788 tap_header->version = GSMTAP_VERSION;
789 tap_header->hdr_len = BURST_SIZE/4;
790 tap_header->type = GSMTAP_TYPE_UM_BURST;
791 tap_header->timeslot = static_cast<uint8_t>(d_burst_nr.get_timeslot_nr());
792 tap_header->frame_number = d_burst_nr.get_frame_nr();
793 tap_header->sub_type = static_cast<uint8_t>(b_type);
794 tap_header->arfcn = d_arfcn;
795 tap_header->signal_dbm = static_cast<int8_t>(d_signal_dbm);
796 pmt::pmt_t header_blob=pmt::make_blob(tap_header.get(),sizeof(gsmtap_hdr));
797 pmt::pmt_t burst_binary_blob=pmt::make_blob(burst_binary,BURST_SIZE);
798 pmt::pmt_t msg = pmt::cons(header_blob, burst_binary_blob);
799
800 message_port_pub(pmt::mp("bursts"), msg);
piotrd0bf1492014-02-05 17:27:32 +0100801}
piotr6d152d92014-02-21 00:02:44 +0100802
piotrd0bf1492014-02-05 17:27:32 +0100803void receiver_impl::configure_receiver()
804{
piotrce92f982014-04-17 23:37:18 +0200805 d_channel_conf.set_multiframe_type(TIMESLOT0, multiframe_51);
piotrd0bf1492014-02-05 17:27:32 +0100806 d_channel_conf.set_burst_types(TIMESLOT0, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotr437f5462014-02-04 17:57:25 +0100807
piotrce92f982014-04-17 23:37:18 +0200808 d_channel_conf.set_burst_types(TIMESLOT0, TEST_CCH_FRAMES, sizeof(TEST_CCH_FRAMES) / sizeof(unsigned), dummy_or_normal);
809 d_channel_conf.set_burst_types(TIMESLOT0, FCCH_FRAMES, sizeof(FCCH_FRAMES) / sizeof(unsigned), fcch_burst);
810 d_channel_conf.set_burst_types(TIMESLOT0, SCH_FRAMES, sizeof(SCH_FRAMES) / sizeof(unsigned), sch_burst);
piotr437f5462014-02-04 17:57:25 +0100811
812 // d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_26);
813 // d_channel_conf.set_burst_types(TIMESLOT1, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
814 // d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_26);
815 // d_channel_conf.set_burst_types(TIMESLOT2, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
816 // d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_26);
817 // d_channel_conf.set_burst_types(TIMESLOT3, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
818 // d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_26);
819 // d_channel_conf.set_burst_types(TIMESLOT4, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
820 // d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_26);
821 // d_channel_conf.set_burst_types(TIMESLOT5, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
822 // d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_26);
823 // d_channel_conf.set_burst_types(TIMESLOT6, TRAFFIC_CHANNEL_F, sizeof(TRAFFIC_CHANNEL_F) / sizeof(unsigned), dummy_or_normal);
824 // d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_26);
825 // 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 +0100826
piotrd0bf1492014-02-05 17:27:32 +0100827 d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_51);
828 d_channel_conf.set_burst_types(TIMESLOT1, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
829 d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_51);
830 d_channel_conf.set_burst_types(TIMESLOT2, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
831 d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_51);
832 d_channel_conf.set_burst_types(TIMESLOT3, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
833 d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_51);
834 d_channel_conf.set_burst_types(TIMESLOT4, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
835 d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_51);
836 d_channel_conf.set_burst_types(TIMESLOT5, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
837 d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_51);
838 d_channel_conf.set_burst_types(TIMESLOT6, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
839 d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_51);
840 d_channel_conf.set_burst_types(TIMESLOT7, TEST51, sizeof(TEST51) / sizeof(unsigned), dummy_or_normal);
piotrd0bf1492014-02-05 17:27:32 +0100841}
piotr437f5462014-02-04 17:57:25 +0100842
843
piotrd0bf1492014-02-05 17:27:32 +0100844} /* namespace gsm */
piotr437f5462014-02-04 17:57:25 +0100845} /* namespace gr */
846