piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 1 | /* -*- c++ -*- */ |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 2 | /* |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 3 | * @file |
Piotr Krysik | a6268a5 | 2017-08-23 16:02:19 +0200 | [diff] [blame] | 4 | * @author (C) 2009-2017 by Piotr Krysik <ptrkrysik@gmail.com> |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 5 | * @section LICENSE |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 6 | * |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 7 | * Gr-gsm is free software; you can redistribute it and/or modify |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3, or (at your option) |
| 10 | * any later version. |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 11 | * |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 12 | * Gr-gsm is distributed in the hope that it will be useful, |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 16 | * |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 17 | * You should have received a copy of the GNU General Public License |
ptrkrysik | 529895b | 2014-12-02 18:07:38 +0100 | [diff] [blame] | 18 | * along with gr-gsm; see the file COPYING. If not, write to |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 19 | * the Free Software Foundation, Inc., 51 Franklin Street, |
| 20 | * Boston, MA 02110-1301, USA. |
| 21 | */ |
| 22 | |
| 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include "config.h" |
| 25 | #endif |
| 26 | |
| 27 | #include <gnuradio/io_signature.h> |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 28 | #include <gnuradio/math.h> |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 29 | |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 30 | #include <algorithm> |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 31 | #include <string.h> |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 32 | #include <iostream> |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 33 | #include <numeric> |
| 34 | #include <math.h> |
| 35 | #include <vector> |
ptrkrysik | 3be74a7 | 2014-12-13 10:11:00 +0100 | [diff] [blame] | 36 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 37 | #include <boost/circular_buffer.hpp> |
| 38 | #include <boost/scoped_ptr.hpp> |
ptrkrysik | 3be74a7 | 2014-12-13 10:11:00 +0100 | [diff] [blame] | 39 | #include <grgsm/endian.h> |
ptrkrysik | 5821379 | 2014-10-30 09:05:15 +0100 | [diff] [blame] | 40 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 41 | #include "receiver_impl.h" |
| 42 | #include "viterbi_detector.h" |
| 43 | #include "sch.h" |
| 44 | |
| 45 | #if 0 |
| 46 | /* Files included for debuging */ |
| 47 | #include "plotting/plotting.hpp" |
| 48 | #include <pthread.h> |
| 49 | #include <iomanip> |
| 50 | #endif |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 51 | |
| 52 | #define SYNC_SEARCH_RANGE 30 |
| 53 | |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 54 | namespace gr |
| 55 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 56 | namespace gsm |
| 57 | { |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 58 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 59 | /* The public constructor */ |
| 60 | receiver::sptr |
| 61 | receiver::make( |
| 62 | int osr, const std::vector<int> &cell_allocation, |
| 63 | const std::vector<int> &tseq_nums, bool process_uplink) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 64 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 65 | return gnuradio::get_initial_sptr |
| 66 | (new receiver_impl(osr, cell_allocation, |
| 67 | tseq_nums, process_uplink)); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 68 | } |
| 69 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 70 | /* The private constructor */ |
| 71 | receiver_impl::receiver_impl( |
| 72 | int osr, const std::vector<int> &cell_allocation, |
| 73 | const std::vector<int> &tseq_nums, bool process_uplink |
| 74 | ) : gr::sync_block("receiver", |
| 75 | gr::io_signature::make(1, -1, sizeof(gr_complex)), |
| 76 | gr::io_signature::make(0, 0, 0)), |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 77 | d_rx_time_received(false), |
| 78 | d_time_samp_ref(GSM_SYMBOL_RATE * osr), |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 79 | d_OSR(osr), |
| 80 | d_process_uplink(process_uplink), |
| 81 | d_chan_imp_length(CHAN_IMP_RESP_LENGTH), |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 82 | d_counter(0), //TODO: use nitems_read instead of d_counter |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 83 | d_fcch_start_pos(0), |
| 84 | d_freq_offset_setting(0), |
| 85 | d_state(fcch_search), |
| 86 | d_burst_nr(osr), |
| 87 | d_failed_sch(0), |
| 88 | d_signal_dbm(-120), |
| 89 | d_tseq_nums(tseq_nums), |
| 90 | d_cell_allocation(cell_allocation), |
| 91 | d_last_time(0.0) |
ptrkrysik | 32c2116 | 2015-04-04 14:01:52 +0200 | [diff] [blame] | 92 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 93 | /** |
| 94 | * Don't send samples to the receiver |
| 95 | * until there are at least samples for one |
| 96 | */ |
| 97 | set_output_multiple(floor((TS_BITS + 2 * GUARD_PERIOD) * d_OSR)); |
| 98 | |
| 99 | /** |
| 100 | * Prepare SCH sequence bits |
| 101 | * |
| 102 | * (TS_BITS + 2 * GUARD_PERIOD) |
| 103 | * Burst and two guard periods |
| 104 | * (one guard period is an arbitrary overlap) |
| 105 | */ |
| 106 | gmsk_mapper(SYNC_BITS, N_SYNC_BITS, |
| 107 | d_sch_training_seq, gr_complex(0.0, -1.0)); |
| 108 | |
| 109 | /* Prepare bits of training sequences */ |
| 110 | for (int i = 0; i < TRAIN_SEQ_NUM; i++) { |
| 111 | /** |
| 112 | * If first bit of the sequence is 0 |
| 113 | * => first symbol is 1, else -1 |
| 114 | */ |
| 115 | gr_complex startpoint = train_seq[i][0] == 0 ? |
| 116 | gr_complex(1.0, 0.0) : gr_complex(-1.0, 0.0); |
| 117 | gmsk_mapper(train_seq[i], N_TRAIN_BITS, |
| 118 | d_norm_training_seq[i], startpoint); |
| 119 | } |
| 120 | |
| 121 | /* Register output ports */ |
| 122 | message_port_register_out(pmt::mp("C0")); |
| 123 | message_port_register_out(pmt::mp("CX")); |
| 124 | message_port_register_out(pmt::mp("measurements")); |
| 125 | |
| 126 | /** |
| 127 | * Configure the receiver, |
| 128 | * i.e. tell it where to find which burst type |
| 129 | */ |
| 130 | configure_receiver(); |
| 131 | } |
| 132 | |
| 133 | /* Our virtual destructor */ |
| 134 | receiver_impl::~receiver_impl() {} |
| 135 | |
| 136 | int |
| 137 | receiver_impl::work( |
| 138 | int noutput_items, |
| 139 | gr_vector_const_void_star &input_items, |
| 140 | gr_vector_void_star &output_items) |
| 141 | { |
| 142 | gr_complex *input = (gr_complex *) input_items[0]; |
| 143 | uint64_t start = nitems_read(0); |
| 144 | uint64_t stop = start + noutput_items; |
| 145 | d_freq_offset_tag_in_fcch = false; |
| 146 | |
| 147 | #if 0 |
| 148 | /* FIXME: jak zrobić to rzutowanie poprawnie */ |
| 149 | std::vector<const gr_complex *> iii = |
| 150 | (std::vector<const gr_complex *>) input_items; |
| 151 | #endif |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 152 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 153 | |
| 154 | /* Time synchronization loop */ |
| 155 | float current_time = |
| 156 | static_cast<float>(start / (GSM_SYMBOL_RATE * d_OSR)); |
| 157 | if ((current_time - d_last_time) > 0.1) { |
| 158 | pmt::pmt_t msg = pmt::make_tuple(pmt::mp("current_time"), |
| 159 | pmt::from_double(current_time)); |
ptrkrysik | 32c2116 | 2015-04-04 14:01:52 +0200 | [diff] [blame] | 160 | message_port_pub(pmt::mp("measurements"), msg); |
| 161 | d_last_time = current_time; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 162 | } |
ptrkrysik | 32c2116 | 2015-04-04 14:01:52 +0200 | [diff] [blame] | 163 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 164 | /* Frequency correction loop */ |
| 165 | std::vector<tag_t> freq_offset_tags; |
| 166 | pmt::pmt_t key = pmt::string_to_symbol("setting_freq_offset"); |
| 167 | get_tags_in_range(freq_offset_tags, 0, start, stop, key); |
| 168 | |
| 169 | if (!freq_offset_tags.empty()) { |
piotr | 4089c1a | 2014-08-06 14:10:56 +0200 | [diff] [blame] | 170 | tag_t freq_offset_tag = freq_offset_tags[0]; |
Piotr Krysik | 43af70d | 2016-07-20 21:37:24 +0200 | [diff] [blame] | 171 | uint64_t tag_offset = freq_offset_tag.offset - start; |
Piotr Krysik | 43af70d | 2016-07-20 21:37:24 +0200 | [diff] [blame] | 172 | d_freq_offset_setting = pmt::to_double(freq_offset_tag.value); |
piotr | 4089c1a | 2014-08-06 14:10:56 +0200 | [diff] [blame] | 173 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 174 | burst_type b_type = d_channel_conf.get_burst_type(d_burst_nr); |
| 175 | if (d_state == synchronized && b_type == fcch_burst){ |
| 176 | uint64_t last_sample_nr = |
| 177 | ceil((GUARD_PERIOD + 2.0 * TAIL_BITS + 156.25) * d_OSR) + 1; |
| 178 | d_freq_offset_tag_in_fcch = tag_offset < last_sample_nr; |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 179 | } |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 180 | } |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 181 | |
| 182 | /* Obtaining current time with use of rx_time tag provided i.e. by UHD devices */ |
| 183 | /* And storing it in time_sample_ref for sample number to time conversion */ |
| 184 | std::vector<tag_t> rx_time_tags; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 185 | |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 186 | get_tags_in_window(rx_time_tags, 0, 0, noutput_items, pmt::string_to_symbol("rx_time")); |
| 187 | if(!rx_time_tags.empty()){ |
| 188 | d_rx_time_received = true; |
| 189 | tag_t rx_time_tag = *(rx_time_tags.begin()); |
| 190 | |
| 191 | uint64_t rx_time_full_part = to_uint64(tuple_ref(rx_time_tag.value,0)); |
| 192 | double rx_time_frac_part = to_double(tuple_ref(rx_time_tag.value,1)); |
| 193 | |
| 194 | time_spec_t current_rx_time = time_spec_t(rx_time_full_part, rx_time_frac_part); |
| 195 | uint64_t current_start_offset = rx_time_tag.offset; |
| 196 | d_time_samp_ref.update(current_rx_time, current_start_offset); |
| 197 | // std::cout << "Mam rx_time: " << current_rx_time.get_real_secs() << std::endl; |
| 198 | } |
| 199 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 200 | /* Main state machine */ |
| 201 | switch (d_state) { |
| 202 | case fcch_search: |
| 203 | fcch_search_handler(input, noutput_items); |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 204 | break; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 205 | case sch_search: |
| 206 | sch_search_handler(input, noutput_items); |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 207 | break; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 208 | case synchronized: |
| 209 | synchronized_handler(input, input_items, noutput_items); |
| 210 | break; |
| 211 | } |
| 212 | |
| 213 | return 0; |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 214 | } |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 215 | |
| 216 | void |
| 217 | receiver_impl::fcch_search_handler(gr_complex *input, int noutput_items) |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 218 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 219 | double freq_offset_tmp; |
ptrkrysik | 5821379 | 2014-10-30 09:05:15 +0100 | [diff] [blame] | 220 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 221 | /* Check if received samples is a FCCN burst */ |
| 222 | if (!find_fcch_burst(input, noutput_items, freq_offset_tmp)) |
| 223 | return; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 224 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 225 | /* We found it, compose a message */ |
| 226 | pmt::pmt_t msg = pmt::make_tuple( |
| 227 | pmt::mp("freq_offset"), |
| 228 | pmt::from_double(freq_offset_tmp - d_freq_offset_setting), |
| 229 | pmt::mp("fcch_search") |
| 230 | ); |
Piotr Krysik | 9bc0fc0 | 2017-01-18 21:53:17 +0100 | [diff] [blame] | 231 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 232 | /* Notify FCCH loop */ |
| 233 | message_port_pub(pmt::mp("measurements"), msg); |
| 234 | |
| 235 | /* Update current state */ |
| 236 | d_state = sch_search; |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 237 | } |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 238 | |
| 239 | void |
| 240 | receiver_impl::sch_search_handler(gr_complex *input, int noutput_items) |
| 241 | { |
| 242 | std::vector<gr_complex> channel_imp_resp(CHAN_IMP_RESP_LENGTH * d_OSR); |
| 243 | unsigned char burst_buf[BURST_SIZE]; |
| 244 | int rc, t1, t2, t3; |
| 245 | int burst_start; |
| 246 | |
| 247 | /* Wait until we get a SCH burst */ |
| 248 | if (!reach_sch_burst(noutput_items)) |
| 249 | return; |
| 250 | |
| 251 | /* Get channel impulse response from it */ |
| 252 | burst_start = get_sch_chan_imp_resp(input, &channel_imp_resp[0]); |
| 253 | |
| 254 | /* Detect bits using MLSE detection */ |
| 255 | detect_burst(input, &channel_imp_resp[0], burst_start, burst_buf); |
| 256 | |
| 257 | /* Attempt to decode BSIC and frame number */ |
| 258 | rc = decode_sch(&burst_buf[3], &t1, &t2, &t3, &d_ncc, &d_bcc); |
| 259 | if (rc) { |
| 260 | /** |
| 261 | * There is error in the SCH burst, |
| 262 | * go back to the FCCH search state |
| 263 | */ |
| 264 | d_state = fcch_search; |
| 265 | return; |
| 266 | } |
| 267 | |
| 268 | /* Set counter of bursts value */ |
| 269 | d_burst_nr.set(t1, t2, t3, 0); |
| 270 | d_burst_nr++; |
| 271 | |
| 272 | /* Consume samples up to the next guard period */ |
| 273 | consume_each(burst_start + BURST_SIZE * d_OSR + 4 * d_OSR); |
| 274 | |
| 275 | /* Update current state */ |
| 276 | d_state = synchronized; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 277 | } |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 278 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 279 | void |
| 280 | receiver_impl::synchronized_handler(gr_complex *input, |
| 281 | gr_vector_const_void_star &input_items, int noutput_items) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 282 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 283 | /** |
| 284 | * In this state receiver is synchronized and it processes |
| 285 | * bursts according to burst type for given burst number |
| 286 | */ |
| 287 | std::vector<gr_complex> channel_imp_resp(CHAN_IMP_RESP_LENGTH * d_OSR); |
| 288 | unsigned int inputs_to_process = d_cell_allocation.size(); |
| 289 | unsigned char output_binary[BURST_SIZE]; |
| 290 | burst_type b_type; |
| 291 | int to_consume = 0; |
| 292 | int offset = 0; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 293 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 294 | if (d_process_uplink) |
| 295 | inputs_to_process *= 2; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 296 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 297 | /* Process all connected inputs */ |
| 298 | for (int input_nr = 0; input_nr < inputs_to_process; input_nr++) { |
| 299 | input = (gr_complex *) input_items[input_nr]; |
| 300 | double signal_pwr = 0; |
| 301 | |
| 302 | for (int ii = GUARD_PERIOD; ii < TS_BITS; ii++) |
| 303 | signal_pwr += abs(input[ii]) * abs(input[ii]); |
| 304 | |
| 305 | signal_pwr = signal_pwr / (TS_BITS); |
| 306 | d_signal_dbm = round(10 * log10(signal_pwr / 50)); |
| 307 | |
| 308 | if (input_nr == 0) |
| 309 | d_c0_signal_dbm = d_signal_dbm; |
| 310 | |
| 311 | /* Get burst type for given burst number */ |
| 312 | b_type = input_nr == 0 ? |
| 313 | d_channel_conf.get_burst_type(d_burst_nr) : normal_or_noise; |
| 314 | |
| 315 | /* Process burst according to its type */ |
| 316 | switch (b_type) { |
| 317 | case fcch_burst: |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 318 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 319 | if (d_freq_offset_tag_in_fcch) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 320 | break; |
| 321 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 322 | /* Send all-zero sequence message */ |
| 323 | send_burst(d_burst_nr, fc_fb, GSMTAP_BURST_FCCH, input_nr); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 324 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 325 | /* Extract frequency offset */ |
| 326 | const unsigned first_sample = |
| 327 | ceil((GUARD_PERIOD + 2 * TAIL_BITS) * d_OSR) + 1; |
| 328 | const unsigned last_sample = |
| 329 | first_sample + USEFUL_BITS * d_OSR - TAIL_BITS * d_OSR; |
| 330 | double freq_offset_tmp = |
| 331 | compute_freq_offset(input, first_sample, last_sample); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 332 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 333 | /* Frequency correction loop */ |
| 334 | pmt::pmt_t msg = pmt::make_tuple( |
| 335 | pmt::mp("freq_offset"), |
| 336 | pmt::from_double(freq_offset_tmp - d_freq_offset_setting), |
| 337 | pmt::mp("synchronized")); |
| 338 | message_port_pub(pmt::mp("measurements"), msg); |
| 339 | |
| 340 | break; |
| 341 | } |
| 342 | |
| 343 | case sch_burst: |
| 344 | { |
| 345 | int d_ncc, d_bcc; |
| 346 | int t1, t2, t3; |
| 347 | int rc; |
| 348 | |
| 349 | /* Get channel impulse response */ |
| 350 | d_c0_burst_start = get_sch_chan_imp_resp(input, |
| 351 | &channel_imp_resp[0]); |
| 352 | |
| 353 | /* Perform MLSE detection */ |
| 354 | detect_burst(input, &channel_imp_resp[0], |
| 355 | d_c0_burst_start, output_binary); |
| 356 | |
| 357 | /* Compose a message with GSMTAP header and bits */ |
| 358 | send_burst(d_burst_nr, output_binary, |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 359 | GSMTAP_BURST_SCH, input_nr, d_c0_burst_start); |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 360 | |
| 361 | /* Attempt to decode SCH burst */ |
| 362 | rc = decode_sch(&output_binary[3], &t1, &t2, &t3, &d_ncc, &d_bcc); |
| 363 | if (rc) { |
| 364 | if (++d_failed_sch >= MAX_SCH_ERRORS) { |
| 365 | /* We have to resynchronize, change state */ |
| 366 | d_state = fcch_search; |
| 367 | |
| 368 | /* Frequency correction loop */ |
| 369 | pmt::pmt_t msg = pmt::make_tuple(pmt::mp("freq_offset"), |
| 370 | pmt::from_double(0.0),pmt::mp("sync_loss")); |
| 371 | message_port_pub(pmt::mp("measurements"), msg); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | break; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 375 | } |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 376 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 377 | /** |
| 378 | * Decoding was successful, now |
| 379 | * compute offset from burst_start, |
| 380 | * burst should start after a guard period. |
| 381 | */ |
| 382 | offset = d_c0_burst_start - floor((GUARD_PERIOD) * d_OSR); |
| 383 | to_consume += offset; |
| 384 | d_failed_sch = 0; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 385 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 386 | break; |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 387 | } |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 388 | |
| 389 | case normal_burst: |
| 390 | { |
| 391 | float normal_corr_max; |
| 392 | /** |
| 393 | * Get channel impulse response for given |
| 394 | * training sequence number - d_bcc |
| 395 | */ |
| 396 | d_c0_burst_start = get_norm_chan_imp_resp(input, |
| 397 | &channel_imp_resp[0], &normal_corr_max, d_bcc); |
| 398 | |
| 399 | /* Perform MLSE detection */ |
| 400 | detect_burst(input, &channel_imp_resp[0], |
| 401 | d_c0_burst_start, output_binary); |
| 402 | |
| 403 | /* Compose a message with GSMTAP header and bits */ |
| 404 | send_burst(d_burst_nr, output_binary, |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 405 | GSMTAP_BURST_NORMAL, input_nr, d_c0_burst_start); |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 406 | |
| 407 | break; |
| 408 | } |
| 409 | |
| 410 | case dummy_or_normal: |
| 411 | { |
| 412 | unsigned int normal_burst_start, dummy_burst_start; |
| 413 | float dummy_corr_max, normal_corr_max; |
| 414 | |
| 415 | dummy_burst_start = get_norm_chan_imp_resp(input, |
| 416 | &channel_imp_resp[0], &dummy_corr_max, TS_DUMMY); |
| 417 | normal_burst_start = get_norm_chan_imp_resp(input, |
| 418 | &channel_imp_resp[0], &normal_corr_max, d_bcc); |
| 419 | |
| 420 | if (normal_corr_max > dummy_corr_max) { |
| 421 | d_c0_burst_start = normal_burst_start; |
| 422 | |
| 423 | /* Perform MLSE detection */ |
| 424 | detect_burst(input, &channel_imp_resp[0], |
| 425 | normal_burst_start, output_binary); |
| 426 | |
| 427 | /* Compose a message with GSMTAP header and bits */ |
| 428 | send_burst(d_burst_nr, output_binary, |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 429 | GSMTAP_BURST_NORMAL, input_nr, normal_burst_start); |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 430 | } else { |
| 431 | d_c0_burst_start = dummy_burst_start; |
| 432 | |
| 433 | /* Compose a message with GSMTAP header and bits */ |
| 434 | send_burst(d_burst_nr, dummy_burst, |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 435 | GSMTAP_BURST_DUMMY, input_nr, dummy_burst_start); |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | break; |
| 439 | } |
| 440 | |
| 441 | case normal_or_noise: |
| 442 | { |
| 443 | std::vector<gr_complex> v(input, input + noutput_items); |
| 444 | float normal_corr_max = -1e6; |
| 445 | float normal_corr_max_tmp; |
| 446 | unsigned int burst_start; |
| 447 | int max_tn, tseq_num; |
| 448 | |
| 449 | if (d_tseq_nums.size() == 0) { |
| 450 | /** |
| 451 | * There is no information about training sequence, |
| 452 | * however the receiver can detect it with use of a |
| 453 | * very simple algorithm based on finding |
| 454 | */ |
| 455 | get_norm_chan_imp_resp(input, &channel_imp_resp[0], |
| 456 | &normal_corr_max, 0); |
| 457 | |
| 458 | float ts_max = normal_corr_max; |
| 459 | int ts_max_num = 0; |
| 460 | |
| 461 | for (int ss = 1; ss <= 7; ss++) { |
| 462 | get_norm_chan_imp_resp(input, &channel_imp_resp[0], |
| 463 | &normal_corr_max, ss); |
| 464 | |
| 465 | if (ts_max < normal_corr_max) { |
| 466 | ts_max = normal_corr_max; |
| 467 | ts_max_num = ss; |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | d_tseq_nums.push_back(ts_max_num); |
| 472 | } |
| 473 | |
| 474 | /* Choose proper training sequence number */ |
| 475 | tseq_num = input_nr <= d_tseq_nums.size() ? |
| 476 | d_tseq_nums[input_nr - 1] : d_tseq_nums.back(); |
| 477 | |
| 478 | /* Get channel impulse response */ |
| 479 | burst_start = get_norm_chan_imp_resp(input, &channel_imp_resp[0], |
| 480 | &normal_corr_max, tseq_num); |
| 481 | |
| 482 | /* Perform MLSE detection */ |
| 483 | detect_burst(input, &channel_imp_resp[0], |
| 484 | burst_start, output_binary); |
| 485 | |
| 486 | /* Compose a message with GSMTAP header and bits */ |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 487 | send_burst(d_burst_nr, output_binary, GSMTAP_BURST_NORMAL, input_nr, burst_start); |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 488 | |
| 489 | break; |
| 490 | } |
| 491 | |
| 492 | case dummy: |
| 493 | send_burst(d_burst_nr, dummy_burst, GSMTAP_BURST_DUMMY, input_nr); |
| 494 | break; |
| 495 | |
| 496 | case rach_burst: |
| 497 | case empty: |
| 498 | /* Do nothing */ |
| 499 | break; |
| 500 | } |
| 501 | |
| 502 | if (input_nr == input_items.size() - 1) { |
| 503 | /* Go to the next burst */ |
| 504 | d_burst_nr++; |
| 505 | |
| 506 | /* Consume samples of the burst up to next guard period */ |
| 507 | to_consume += TS_BITS * d_OSR + d_burst_nr.get_offset(); |
| 508 | consume_each(to_consume); |
| 509 | } |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | bool |
| 514 | receiver_impl::find_fcch_burst(const gr_complex *input, |
| 515 | const int nitems, double &computed_freq_offset) |
| 516 | { |
| 517 | /* Circular buffer used to scan through signal to find */ |
| 518 | boost::circular_buffer<float> |
| 519 | phase_diff_buffer(FCCH_HITS_NEEDED * d_OSR); |
| 520 | boost::circular_buffer<float>::iterator buffer_iter; |
| 521 | |
| 522 | float lowest_max_min_diff; |
| 523 | float phase_diff; /* Best match for FCCH burst */ |
| 524 | float min_phase_diff; |
| 525 | float max_phase_diff; |
| 526 | double best_sum = 0; |
| 527 | gr_complex conjprod; |
| 528 | int start_pos; |
| 529 | int hit_count; |
| 530 | int miss_count; |
| 531 | |
| 532 | int sample_number = 0; |
| 533 | int to_consume = 0; |
| 534 | bool result = false; |
| 535 | bool end = false; |
| 536 | |
| 537 | /* Possible states of FCCH search algorithm */ |
| 538 | enum states |
| 539 | { |
| 540 | init, /* initialize variables */ |
| 541 | search, /* search for positive samples */ |
| 542 | found_something, /* search for FCCH and the best position of it */ |
| 543 | fcch_found, /* when FCCH was found */ |
| 544 | search_fail /* when there is no FCCH in the input vector */ |
| 545 | } fcch_search_state; |
| 546 | |
| 547 | /* Set initial state */ |
| 548 | fcch_search_state = init; |
| 549 | |
| 550 | while (!end) |
| 551 | { |
| 552 | switch (fcch_search_state) { |
| 553 | case init: |
| 554 | { |
| 555 | hit_count = 0; |
| 556 | miss_count = 0; |
| 557 | start_pos = -1; |
| 558 | lowest_max_min_diff = 99999; |
| 559 | phase_diff_buffer.clear(); |
| 560 | |
| 561 | /* Change current state */ |
| 562 | fcch_search_state = search; |
| 563 | |
| 564 | break; |
| 565 | } |
| 566 | |
| 567 | case search: |
| 568 | { |
| 569 | sample_number++; |
| 570 | |
| 571 | if (sample_number > nitems - FCCH_HITS_NEEDED * d_OSR) { |
| 572 | /** |
| 573 | * If it isn't possible to find FCCH, because |
| 574 | * there is too few samples left to look into, |
| 575 | * don't do anything with those samples which are left |
| 576 | * and consume only those which were checked |
| 577 | */ |
| 578 | to_consume = sample_number; |
| 579 | fcch_search_state = search_fail; |
| 580 | break; |
| 581 | } |
| 582 | |
| 583 | phase_diff = compute_phase_diff(input[sample_number], |
| 584 | input[sample_number - 1]); |
| 585 | |
| 586 | /** |
| 587 | * If a positive phase difference was found |
| 588 | * switch to state in which searches for FCCH |
| 589 | */ |
| 590 | if (phase_diff > 0) { |
| 591 | to_consume = sample_number; |
| 592 | fcch_search_state = found_something; |
| 593 | } else { |
| 594 | fcch_search_state = search; |
| 595 | } |
| 596 | |
| 597 | break; |
| 598 | } |
| 599 | |
| 600 | case found_something: |
| 601 | { |
| 602 | if (phase_diff > 0) |
| 603 | hit_count++; |
| 604 | else |
| 605 | miss_count++; |
| 606 | |
| 607 | if ((miss_count >= FCCH_MAX_MISSES * d_OSR) |
| 608 | && (hit_count <= FCCH_HITS_NEEDED * d_OSR)) |
| 609 | { |
| 610 | /* If miss_count exceeds limit before hit_count */ |
| 611 | fcch_search_state = init; |
| 612 | continue; |
| 613 | } |
| 614 | |
| 615 | if (((miss_count >= FCCH_MAX_MISSES * d_OSR) |
| 616 | && (hit_count > FCCH_HITS_NEEDED * d_OSR)) |
| 617 | || (hit_count > 2 * FCCH_HITS_NEEDED * d_OSR)) |
| 618 | { |
| 619 | /** |
| 620 | * If hit_count and miss_count exceeds |
| 621 | * limit then FCCH was found |
| 622 | */ |
| 623 | fcch_search_state = fcch_found; |
| 624 | continue; |
| 625 | } |
| 626 | |
| 627 | if ((miss_count < FCCH_MAX_MISSES * d_OSR) |
| 628 | && (hit_count > FCCH_HITS_NEEDED * d_OSR)) |
| 629 | { |
| 630 | /** |
| 631 | * Find difference between minimal and maximal |
| 632 | * element in the buffer. For FCCH this value |
| 633 | * should be low. This part is searching for |
| 634 | * a region where this value is lowest. |
| 635 | */ |
| 636 | min_phase_diff = *(min_element(phase_diff_buffer.begin(), |
| 637 | phase_diff_buffer.end())); |
| 638 | max_phase_diff = *(max_element(phase_diff_buffer.begin(), |
| 639 | phase_diff_buffer.end())); |
| 640 | |
| 641 | if (lowest_max_min_diff > max_phase_diff - min_phase_diff) { |
| 642 | lowest_max_min_diff = max_phase_diff - min_phase_diff; |
| 643 | start_pos = sample_number - FCCH_HITS_NEEDED |
| 644 | * d_OSR - FCCH_MAX_MISSES * d_OSR; |
| 645 | best_sum = 0; |
| 646 | |
| 647 | for (buffer_iter = phase_diff_buffer.begin(); |
| 648 | buffer_iter != (phase_diff_buffer.end()); |
| 649 | buffer_iter++) { |
| 650 | /* Store best value of phase offset sum */ |
| 651 | best_sum += *buffer_iter - (M_PI / 2) / d_OSR; |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | /* If there is no single sample left to check */ |
| 657 | if (++sample_number >= nitems) { |
| 658 | fcch_search_state = search_fail; |
| 659 | continue; |
| 660 | } |
| 661 | |
| 662 | phase_diff = compute_phase_diff(input[sample_number], |
| 663 | input[sample_number-1]); |
| 664 | phase_diff_buffer.push_back(phase_diff); |
| 665 | fcch_search_state = found_something; |
| 666 | |
| 667 | break; |
| 668 | } |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 669 | |
| 670 | case fcch_found: |
| 671 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 672 | /* Consume one FCCH burst */ |
| 673 | to_consume = start_pos + FCCH_HITS_NEEDED * d_OSR + 1; |
| 674 | d_fcch_start_pos = d_counter + start_pos; |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 675 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 676 | /** |
| 677 | * Compute frequency offset |
| 678 | * |
| 679 | * 1625000.0 / 6 - GMSK symbol rate in GSM |
| 680 | */ |
| 681 | double phase_offset = best_sum / FCCH_HITS_NEEDED; |
| 682 | double freq_offset = phase_offset * 1625000.0 / 6 / (2 * M_PI); |
| 683 | computed_freq_offset = freq_offset; |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 684 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 685 | end = true; |
| 686 | result = true; |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 687 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 688 | break; |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 689 | } |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 690 | |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 691 | case search_fail: |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 692 | end = true; |
| 693 | result = false; |
| 694 | break; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 695 | } |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 696 | } |
| 697 | |
| 698 | d_counter += to_consume; |
| 699 | consume_each(to_consume); |
| 700 | |
| 701 | return result; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 702 | } |
| 703 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 704 | double |
| 705 | receiver_impl::compute_freq_offset(const gr_complex * input, |
| 706 | unsigned first_sample, unsigned last_sample) |
Piotr Krysik | 654d652 | 2017-01-23 21:53:48 +0100 | [diff] [blame] | 707 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 708 | double phase_sum = 0; |
| 709 | unsigned ii; |
| 710 | |
| 711 | for (ii = first_sample; ii < last_sample; ii++) |
| 712 | { |
| 713 | double phase_diff = compute_phase_diff(input[ii], |
| 714 | input[ii-1]) - (M_PI / 2) / d_OSR; |
Piotr Krysik | 654d652 | 2017-01-23 21:53:48 +0100 | [diff] [blame] | 715 | phase_sum += phase_diff; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | double phase_offset = phase_sum / (last_sample - first_sample); |
| 719 | double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI); |
| 720 | |
| 721 | return freq_offset; |
Piotr Krysik | 654d652 | 2017-01-23 21:53:48 +0100 | [diff] [blame] | 722 | } |
| 723 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 724 | inline float |
| 725 | receiver_impl::compute_phase_diff(gr_complex val1, gr_complex val2) |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 726 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 727 | gr_complex conjprod = val1 * conj(val2); |
| 728 | return fast_atan2f(imag(conjprod), real(conjprod)); |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 729 | } |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 730 | |
| 731 | bool |
| 732 | receiver_impl::reach_sch_burst(const int nitems) |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 733 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 734 | /* It just consumes samples to get near to a SCH burst */ |
| 735 | int to_consume = 0; |
| 736 | bool result = false; |
| 737 | unsigned sample_nr = d_fcch_start_pos |
| 738 | + (FRAME_BITS - SAFETY_MARGIN) * d_OSR; |
| 739 | |
| 740 | /* Consume samples until d_counter will be equal to sample_nr */ |
| 741 | if (d_counter < sample_nr) { |
| 742 | to_consume = d_counter + nitems >= sample_nr ? |
| 743 | sample_nr - d_counter : nitems; |
| 744 | } else { |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 745 | to_consume = 0; |
| 746 | result = true; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | d_counter += to_consume; |
| 750 | consume_each(to_consume); |
| 751 | |
| 752 | return result; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 753 | } |
| 754 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 755 | int |
| 756 | receiver_impl::get_sch_chan_imp_resp(const gr_complex *input, |
| 757 | gr_complex * chan_imp_resp) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 758 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 759 | std::vector<gr_complex> correlation_buffer; |
| 760 | std::vector<float> window_energy_buffer; |
| 761 | std::vector<float> power_buffer; |
| 762 | |
| 763 | int chan_imp_resp_center = 0; |
| 764 | int strongest_window_nr; |
| 765 | int burst_start; |
| 766 | float energy = 0; |
| 767 | |
| 768 | int len = (SYNC_POS + SYNC_SEARCH_RANGE) * d_OSR; |
| 769 | for (int ii = SYNC_POS * d_OSR; ii < len; ii++) { |
| 770 | gr_complex correlation = correlate_sequence(&d_sch_training_seq[5], |
| 771 | N_SYNC_BITS - 10, &input[ii]); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 772 | correlation_buffer.push_back(correlation); |
| 773 | power_buffer.push_back(std::pow(abs(correlation), 2)); |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 774 | } |
| 775 | |
| 776 | /* Compute window energies */ |
| 777 | std::vector<float>::iterator iter = power_buffer.begin(); |
| 778 | while (iter != power_buffer.end()) { |
ptrkrysik | ef5e2db | 2015-01-03 12:10:14 +0100 | [diff] [blame] | 779 | std::vector<float>::iterator iter_ii = iter; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 780 | bool loop_end = false; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 781 | energy = 0; |
| 782 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 783 | for (int ii = 0; ii < (d_chan_imp_length) * d_OSR; ii++, iter_ii++) { |
| 784 | if (iter_ii == power_buffer.end()) { |
| 785 | loop_end = true; |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 786 | break; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | energy += (*iter_ii); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 790 | } |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 791 | |
| 792 | if (loop_end) |
| 793 | break; |
| 794 | |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 795 | window_energy_buffer.push_back(energy); |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 796 | iter++; |
| 797 | } |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 798 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 799 | strongest_window_nr = max_element(window_energy_buffer.begin(), |
| 800 | window_energy_buffer.end()) - window_energy_buffer.begin(); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 801 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 802 | #if 0 |
| 803 | d_channel_imp_resp.clear(); |
| 804 | #endif |
| 805 | |
| 806 | float max_correlation = 0; |
| 807 | for (int ii = 0; ii < (d_chan_imp_length) * d_OSR; ii++) { |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 808 | gr_complex correlation = correlation_buffer[strongest_window_nr + ii]; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 809 | if (abs(correlation) > max_correlation) { |
| 810 | chan_imp_resp_center = ii; |
| 811 | max_correlation = abs(correlation); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 812 | } |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 813 | |
| 814 | #if 0 |
| 815 | d_channel_imp_resp.push_back(correlation); |
| 816 | #endif |
| 817 | |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 818 | chan_imp_resp[ii] = correlation; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | burst_start = strongest_window_nr + chan_imp_resp_center |
| 822 | - 48 * d_OSR - 2 * d_OSR + 2 + SYNC_POS * d_OSR; |
| 823 | return burst_start; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 827 | void |
| 828 | receiver_impl::detect_burst(const gr_complex * input, |
| 829 | gr_complex * chan_imp_resp, int burst_start, |
| 830 | unsigned char * output_binary) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 831 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 832 | std::vector<gr_complex> rhh_temp(CHAN_IMP_RESP_LENGTH * d_OSR); |
| 833 | unsigned int stop_states[2] = {4, 12}; |
| 834 | gr_complex filtered_burst[BURST_SIZE]; |
| 835 | gr_complex rhh[CHAN_IMP_RESP_LENGTH]; |
| 836 | float output[BURST_SIZE]; |
| 837 | int start_state = 3; |
| 838 | |
| 839 | autocorrelation(chan_imp_resp, &rhh_temp[0], d_chan_imp_length*d_OSR); |
| 840 | for (int ii = 0; ii < d_chan_imp_length; ii++) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 841 | rhh[ii] = conj(rhh_temp[ii*d_OSR]); |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 842 | |
| 843 | mafi(&input[burst_start], BURST_SIZE, chan_imp_resp, |
| 844 | d_chan_imp_length * d_OSR, filtered_burst); |
| 845 | |
| 846 | viterbi_detector(filtered_burst, BURST_SIZE, rhh, |
| 847 | start_state, stop_states, 2, output); |
| 848 | |
| 849 | for (int i = 0; i < BURST_SIZE; i++) |
| 850 | output_binary[i] = output[i] > 0; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 851 | } |
| 852 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 853 | void |
| 854 | receiver_impl::gmsk_mapper(const unsigned char * input, |
| 855 | int nitems, gr_complex * gmsk_output, gr_complex start_point) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 856 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 857 | gr_complex j = gr_complex(0.0, 1.0); |
| 858 | gmsk_output[0] = start_point; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 859 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 860 | int previous_symbol = 2 * input[0] - 1; |
| 861 | int current_symbol; |
| 862 | int encoded_symbol; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 863 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 864 | for (int i = 1; i < nitems; i++) { |
| 865 | /* Change bits representation to NRZ */ |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 866 | current_symbol = 2 * input[i] - 1; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 867 | |
| 868 | /* Differentially encode */ |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 869 | encoded_symbol = current_symbol * previous_symbol; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 870 | |
| 871 | /* And do GMSK mapping */ |
| 872 | gmsk_output[i] = j * gr_complex(encoded_symbol, 0.0) |
| 873 | * gmsk_output[i-1]; |
| 874 | |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 875 | previous_symbol = current_symbol; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 876 | } |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 877 | } |
| 878 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 879 | gr_complex |
| 880 | receiver_impl::correlate_sequence(const gr_complex * sequence, |
| 881 | int length, const gr_complex * input) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 882 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 883 | gr_complex result(0.0, 0.0); |
| 884 | |
| 885 | for (int ii = 0; ii < length; ii++) |
| 886 | result += sequence[ii] * conj(input[ii * d_OSR]); |
| 887 | |
| 888 | return result / gr_complex(length, 0); |
| 889 | } |
| 890 | |
| 891 | /* Computes autocorrelation for positive arguments */ |
| 892 | inline void |
| 893 | receiver_impl::autocorrelation(const gr_complex * input, |
| 894 | gr_complex * out, int nitems) |
| 895 | { |
| 896 | for (int k = nitems - 1; k >= 0; k--) { |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 897 | out[k] = gr_complex(0, 0); |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 898 | for (int i = k; i < nitems; i++) |
| 899 | out[k] += input[i] * conj(input[i - k]); |
| 900 | } |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 901 | } |
| 902 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 903 | inline void |
| 904 | receiver_impl::mafi(const gr_complex * input, int nitems, |
| 905 | gr_complex * filter, int filter_length, gr_complex * output) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 906 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 907 | for (int n = 0; n < nitems; n++) { |
| 908 | int a = n * d_OSR; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 909 | output[n] = 0; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 910 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 911 | for (int ii = 0; ii < filter_length; ii++) { |
| 912 | if ((a + ii) >= nitems * d_OSR) |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 913 | break; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 914 | |
| 915 | output[n] += input[a + ii] * filter[ii]; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 916 | } |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 917 | } |
| 918 | } |
| 919 | |
| 920 | /* Especially computations of strongest_window_nr */ |
| 921 | int |
| 922 | receiver_impl::get_norm_chan_imp_resp(const gr_complex *input, |
| 923 | gr_complex *chan_imp_resp, float *corr_max, int bcc) |
| 924 | { |
| 925 | std::vector<gr_complex> correlation_buffer; |
| 926 | std::vector<float> window_energy_buffer; |
| 927 | std::vector<float> power_buffer; |
| 928 | |
| 929 | int search_center = (int) (TRAIN_POS + GUARD_PERIOD) * d_OSR; |
| 930 | int search_start_pos = search_center + 1 - 5 * d_OSR; |
| 931 | int search_stop_pos = search_center |
| 932 | + d_chan_imp_length * d_OSR + 5 * d_OSR; |
| 933 | |
| 934 | for (int ii = search_start_pos; ii < search_stop_pos; ii++) { |
| 935 | gr_complex correlation = correlate_sequence( |
| 936 | &d_norm_training_seq[bcc][TRAIN_BEGINNING], |
| 937 | N_TRAIN_BITS - 10, &input[ii]); |
| 938 | correlation_buffer.push_back(correlation); |
| 939 | power_buffer.push_back(std::pow(abs(correlation), 2)); |
| 940 | } |
| 941 | |
| 942 | #if 0 |
| 943 | plot(power_buffer); |
| 944 | #endif |
| 945 | |
| 946 | /* Compute window energies */ |
| 947 | std::vector<float>::iterator iter = power_buffer.begin(); |
| 948 | while (iter != power_buffer.end()) { |
| 949 | std::vector<float>::iterator iter_ii = iter; |
| 950 | bool loop_end = false; |
| 951 | float energy = 0; |
| 952 | |
| 953 | int len = d_chan_imp_length * d_OSR; |
| 954 | for (int ii = 0; ii < len; ii++, iter_ii++) { |
| 955 | if (iter_ii == power_buffer.end()) { |
| 956 | loop_end = true; |
| 957 | break; |
| 958 | } |
| 959 | |
| 960 | energy += (*iter_ii); |
| 961 | } |
| 962 | |
| 963 | if (loop_end) |
| 964 | break; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 965 | |
| 966 | window_energy_buffer.push_back(energy); |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 967 | iter++; |
| 968 | } |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 969 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 970 | /* Calculate the strongest window number */ |
| 971 | int strongest_window_nr = max_element(window_energy_buffer.begin(), |
| 972 | window_energy_buffer.end() - d_chan_imp_length * d_OSR) |
| 973 | - window_energy_buffer.begin(); |
| 974 | |
| 975 | if (strongest_window_nr < 0) |
| 976 | strongest_window_nr = 0; |
| 977 | |
| 978 | float max_correlation = 0; |
| 979 | for (int ii = 0; ii < d_chan_imp_length * d_OSR; ii++) { |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 980 | gr_complex correlation = correlation_buffer[strongest_window_nr + ii]; |
piotr | d0bf149 | 2014-02-05 17:27:32 +0100 | [diff] [blame] | 981 | if (abs(correlation) > max_correlation) |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 982 | max_correlation = abs(correlation); |
| 983 | |
| 984 | #if 0 |
| 985 | d_channel_imp_resp.push_back(correlation); |
| 986 | #endif |
| 987 | |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 988 | chan_imp_resp[ii] = correlation; |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | *corr_max = max_correlation; |
| 992 | |
| 993 | /** |
| 994 | * Compute first sample position, which corresponds |
| 995 | * to the first sample of the impulse response |
| 996 | */ |
| 997 | return search_start_pos + strongest_window_nr - TRAIN_POS * d_OSR; |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1001 | void |
| 1002 | receiver_impl::send_burst(burst_counter burst_nr, |
| 1003 | const unsigned char * burst_binary, uint8_t burst_type, |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 1004 | unsigned int input_nr, unsigned int burst_start) |
ptrkrysik | 380dea8 | 2015-08-06 10:11:58 +0200 | [diff] [blame] | 1005 | { |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1006 | /* Buffer for GSMTAP header and burst */ |
| 1007 | uint8_t buf[sizeof(gsmtap_hdr) + BURST_SIZE]; |
| 1008 | uint32_t frame_number; |
| 1009 | uint16_t arfcn; |
| 1010 | uint8_t tn; |
ptrkrysik | 617ba03 | 2014-11-21 10:11:05 +0100 | [diff] [blame] | 1011 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1012 | /* Set pointers to GSMTAP header and burst inside buffer */ |
| 1013 | struct gsmtap_hdr *tap_header = (struct gsmtap_hdr *) buf; |
| 1014 | uint8_t *burst = buf + sizeof(gsmtap_hdr); |
| 1015 | |
| 1016 | tap_header->version = GSMTAP_VERSION; |
| 1017 | tap_header->hdr_len = sizeof(gsmtap_hdr) / 4; |
| 1018 | tap_header->type = GSMTAP_TYPE_UM_BURST; |
| 1019 | tap_header->sub_type = burst_type; |
| 1020 | |
| 1021 | bool dl_burst = !(input_nr >= d_cell_allocation.size()); |
| 1022 | if (dl_burst) { |
| 1023 | tn = static_cast<uint8_t>(d_burst_nr.get_timeslot_nr()); |
| 1024 | frame_number = htobe32(d_burst_nr.get_frame_nr()); |
| 1025 | arfcn = htobe16(d_cell_allocation[input_nr]); |
| 1026 | } else { |
| 1027 | input_nr -= d_cell_allocation.size(); |
| 1028 | tn = static_cast<uint8_t> |
| 1029 | (d_burst_nr.subtract_timeslots(3).get_timeslot_nr()); |
| 1030 | frame_number = htobe32( |
| 1031 | d_burst_nr.subtract_timeslots(3).get_frame_nr()); |
| 1032 | arfcn = htobe16( |
| 1033 | d_cell_allocation[input_nr] | GSMTAP_ARFCN_F_UPLINK); |
| 1034 | } |
| 1035 | |
| 1036 | tap_header->frame_number = frame_number; |
| 1037 | tap_header->timeslot = tn; |
| 1038 | tap_header->arfcn = arfcn; |
| 1039 | |
| 1040 | tap_header->signal_dbm = static_cast<int8_t>(d_signal_dbm); |
| 1041 | tap_header->snr_db = 0; /* FIXME: Can we calculate this? */ |
| 1042 | |
Piotr Krysik | df97869 | 2017-09-27 21:58:24 +0200 | [diff] [blame] | 1043 | pmt::pmt_t pdu_header = pmt::make_dict(); |
| 1044 | |
| 1045 | /* Add timestamp of the first sample - if available */ |
| 1046 | if(d_rx_time_received) { |
| 1047 | time_spec_t time_spec_of_first_sample = d_time_samp_ref.offset_to_time(nitems_read(0)+burst_start); |
| 1048 | uint64_t full = time_spec_of_first_sample.get_full_secs(); |
| 1049 | double frac = time_spec_of_first_sample.get_frac_secs(); |
| 1050 | pdu_header = |
| 1051 | pmt::dict_add(pdu_header, pmt::mp("fn_time"), pmt::cons(pmt::from_uint64(frame_number), pmt::cons(pmt::from_uint64(full), pmt::from_double(frac)))); |
| 1052 | } |
| 1053 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1054 | /* Copy burst to the buffer */ |
| 1055 | memcpy(burst, burst_binary, BURST_SIZE); |
| 1056 | |
| 1057 | /* Allocate a new message */ |
| 1058 | pmt::pmt_t blob = pmt::make_blob(buf, sizeof(gsmtap_hdr) + BURST_SIZE); |
| 1059 | pmt::pmt_t msg = pmt::cons(pmt::PMT_NIL, blob); |
| 1060 | |
| 1061 | /* Send message */ |
| 1062 | if (input_nr == 0) |
ptrkrysik | e518bbf | 2014-11-06 14:50:59 +0100 | [diff] [blame] | 1063 | message_port_pub(pmt::mp("C0"), msg); |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1064 | else |
ptrkrysik | e518bbf | 2014-11-06 14:50:59 +0100 | [diff] [blame] | 1065 | message_port_pub(pmt::mp("CX"), msg); |
| 1066 | } |
piotr | 6d152d9 | 2014-02-21 00:02:44 +0100 | [diff] [blame] | 1067 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1068 | void |
| 1069 | receiver_impl::configure_receiver(void) |
| 1070 | { |
| 1071 | d_channel_conf.set_multiframe_type(TIMESLOT0, multiframe_51); |
| 1072 | d_channel_conf.set_burst_types(TIMESLOT0, TEST51, |
| 1073 | sizeof(TEST51) / sizeof(unsigned), dummy_or_normal); |
| 1074 | d_channel_conf.set_burst_types(TIMESLOT0, TEST_CCH_FRAMES, |
| 1075 | sizeof(TEST_CCH_FRAMES) / sizeof(unsigned), dummy_or_normal); |
| 1076 | d_channel_conf.set_burst_types(TIMESLOT0, FCCH_FRAMES, |
| 1077 | sizeof(FCCH_FRAMES) / sizeof(unsigned), fcch_burst); |
| 1078 | d_channel_conf.set_burst_types(TIMESLOT0, SCH_FRAMES, |
| 1079 | sizeof(SCH_FRAMES) / sizeof(unsigned), sch_burst); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 1080 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1081 | d_channel_conf.set_multiframe_type(TIMESLOT1, multiframe_51); |
| 1082 | d_channel_conf.set_burst_types(TIMESLOT1, TEST51, |
| 1083 | sizeof(TEST51) / sizeof(unsigned), dummy_or_normal); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 1084 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1085 | d_channel_conf.set_multiframe_type(TIMESLOT2, multiframe_51); |
| 1086 | d_channel_conf.set_burst_types(TIMESLOT2, TEST51, |
| 1087 | sizeof(TEST51) / sizeof(unsigned), dummy_or_normal); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 1088 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1089 | d_channel_conf.set_multiframe_type(TIMESLOT3, multiframe_51); |
| 1090 | d_channel_conf.set_burst_types(TIMESLOT3, TEST51, |
| 1091 | sizeof(TEST51) / sizeof(unsigned), dummy_or_normal); |
ptrkrysik | e518bbf | 2014-11-06 14:50:59 +0100 | [diff] [blame] | 1092 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1093 | d_channel_conf.set_multiframe_type(TIMESLOT4, multiframe_51); |
| 1094 | d_channel_conf.set_burst_types(TIMESLOT4, TEST51, |
| 1095 | sizeof(TEST51) / sizeof(unsigned), dummy_or_normal); |
piotr | f2b6a1b | 2014-08-04 11:28:59 +0200 | [diff] [blame] | 1096 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1097 | d_channel_conf.set_multiframe_type(TIMESLOT5, multiframe_51); |
| 1098 | d_channel_conf.set_burst_types(TIMESLOT5, TEST51, |
| 1099 | sizeof(TEST51) / sizeof(unsigned), dummy_or_normal); |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 1100 | |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1101 | d_channel_conf.set_multiframe_type(TIMESLOT6, multiframe_51); |
| 1102 | d_channel_conf.set_burst_types(TIMESLOT6, TEST51, |
| 1103 | sizeof(TEST51) / sizeof(unsigned), dummy_or_normal); |
| 1104 | |
| 1105 | d_channel_conf.set_multiframe_type(TIMESLOT7, multiframe_51); |
| 1106 | d_channel_conf.set_burst_types(TIMESLOT7, TEST51, |
| 1107 | sizeof(TEST51) / sizeof(unsigned), dummy_or_normal); |
| 1108 | } |
| 1109 | |
| 1110 | void |
| 1111 | receiver_impl::set_cell_allocation( |
| 1112 | const std::vector<int> &cell_allocation) |
| 1113 | { |
| 1114 | d_cell_allocation = cell_allocation; |
| 1115 | } |
| 1116 | |
| 1117 | void |
| 1118 | receiver_impl::set_tseq_nums(const std::vector<int> &tseq_nums) |
| 1119 | { |
| 1120 | d_tseq_nums = tseq_nums; |
| 1121 | } |
| 1122 | |
| 1123 | void |
| 1124 | receiver_impl::reset(void) |
| 1125 | { |
| 1126 | d_state = fcch_search; |
| 1127 | } |
Vadim Yanitskiy | cc82cf0 | 2017-07-24 19:21:02 +0700 | [diff] [blame] | 1128 | } /* namespace gsm */ |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 1129 | } /* namespace gr */ |