GNU Radio's GSM Package
receiver_config.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * @file
4  * @author (C) 2009-2017 by Piotr Krysik <ptrkrysik@gmail.com>
5  * @section LICENSE
6  *
7  * Gr-gsm is free software; you can redistribute it and/or modify
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.
11  *
12  * Gr-gsm is distributed in the hope that it will be useful,
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.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with gr-gsm; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 #ifndef INCLUDED_GSM_RECEIVER_CONFIG_H
23 #define INCLUDED_GSM_RECEIVER_CONFIG_H
24 
25 #include <vector>
26 #include <algorithm>
27 #include <stdint.h>
28 #include <grgsm/gsm_constants.h>
29 
31 {
32  private:
33  multiframe_type d_type;
34  std::vector<burst_type> d_burst_types;
35  public:
37  d_type = unknown;
38  fill(d_burst_types.begin(), d_burst_types.end(), empty);
39  }
40 
42 
44  if (type == multiframe_26) {
45  d_burst_types.resize(26);
46  } else {
47  d_burst_types.resize(51);
48  }
49 
50  d_type = type;
51  }
52 
53  void set_burst_type(int nr, burst_type type) {
54  d_burst_types[nr] = type;
55  }
56 
58  return d_type;
59  }
60 
62  return d_burst_types[nr];
63  }
64 };
65 
67 {
68  private:
69  const int d_OSR;
70  uint32_t d_t1, d_t2, d_t3, d_timeslot_nr;
71  double d_offset_fractional;
72  double d_offset_integer;
73  public:
74  burst_counter(int osr):
75  d_OSR(osr),
76  d_t1(0),
77  d_t2(0),
78  d_t3(0),
79  d_timeslot_nr(0),
80  d_offset_fractional(0.0),
81  d_offset_integer(0.0) {
82  }
83 
84  burst_counter(int osr, uint32_t t1, uint32_t t2, uint32_t t3, uint32_t timeslot_nr):
85  d_OSR(osr),
86  d_t1(t1),
87  d_t2(t2),
88  d_t3(t3),
89  d_timeslot_nr(timeslot_nr),
90  d_offset_fractional(0.0),
91  d_offset_integer(0.0)
92  {
93  d_offset_integer = 0;
94  d_offset_fractional = 0;
95  }
96 
98  burst_counter subtract_timeslots(unsigned int number_of_timeslots);
99  void set(uint32_t t1, uint32_t t2, uint32_t t3, uint32_t timeslot_nr);
100 
101  uint32_t get_t1() {
102  return d_t1;
103  }
104 
105  uint32_t get_t2() {
106  return d_t2;
107  }
108 
109  uint32_t get_t3() {
110  return d_t3;
111  }
112 
113  uint32_t get_timeslot_nr() {
114  return d_timeslot_nr;
115  }
116 
117  uint32_t get_frame_nr() {
118  return (51 * 26 * d_t1) + (51 * (((d_t3 + 26) - d_t2) % 26)) + d_t3;
119  }
120 
121  uint32_t get_frame_nr_mod() {
122  return (d_t1 << 11) + (d_t3 << 5) + d_t2;
123  }
124 
125  unsigned get_offset() {
126  return (unsigned)d_offset_integer;
127  }
128 };
129 
131 {
132  private:
133  multiframe_configuration d_timeslots_descriptions[TS_PER_FRAME];
134  public:
136  for (int i = 0; i < TS_PER_FRAME; i++) {
137  d_timeslots_descriptions[i].set_type(unknown);
138  }
139  }
140 
141  void set_multiframe_type(int timeslot_nr, multiframe_type type) {
142  d_timeslots_descriptions[timeslot_nr].set_type(type);
143  }
144 
145  void set_burst_types(int timeslot_nr, const unsigned mapping[], unsigned mapping_size, burst_type b_type) {
146  unsigned i;
147  for (i = 0; i < mapping_size; i++) {
148  d_timeslots_descriptions[timeslot_nr].set_burst_type(mapping[i], b_type);
149  }
150  }
151 
152  void set_single_burst_type(int timeslot_nr, int burst_nr, burst_type b_type) {
153  d_timeslots_descriptions[timeslot_nr].set_burst_type(burst_nr, b_type);
154  }
155 
157 };
158 
159 #endif /* INCLUDED_GSM_RECEIVER_CONFIG_H */
burst_counter::burst_counter
burst_counter(int osr, uint32_t t1, uint32_t t2, uint32_t t3, uint32_t timeslot_nr)
Definition: receiver_config.h:84
burst_counter
Definition: receiver_config.h:66
burst_counter::get_frame_nr_mod
uint32_t get_frame_nr_mod()
Definition: receiver_config.h:121
multiframe_type
multiframe_type
Definition: gsm_constants.h:64
burst_counter::set
void set(uint32_t t1, uint32_t t2, uint32_t t3, uint32_t timeslot_nr)
multiframe_configuration::set_type
void set_type(multiframe_type type)
Definition: receiver_config.h:43
gsm_constants.h
multiframe_configuration::get_type
multiframe_type get_type()
Definition: receiver_config.h:57
channel_configuration::set_single_burst_type
void set_single_burst_type(int timeslot_nr, int burst_nr, burst_type b_type)
Definition: receiver_config.h:152
multiframe_configuration::set_burst_type
void set_burst_type(int nr, burst_type type)
Definition: receiver_config.h:53
burst_counter::get_timeslot_nr
uint32_t get_timeslot_nr()
Definition: receiver_config.h:113
channel_configuration::set_burst_types
void set_burst_types(int timeslot_nr, const unsigned mapping[], unsigned mapping_size, burst_type b_type)
Definition: receiver_config.h:145
burst_counter::burst_counter
burst_counter(int osr)
Definition: receiver_config.h:74
burst_counter::get_t2
uint32_t get_t2()
Definition: receiver_config.h:105
burst_counter::get_t3
uint32_t get_t3()
Definition: receiver_config.h:109
burst_counter::operator++
burst_counter & operator++(int)
multiframe_26
@ multiframe_26
Definition: gsm_constants.h:64
burst_counter::subtract_timeslots
burst_counter subtract_timeslots(unsigned int number_of_timeslots)
TS_PER_FRAME
#define TS_PER_FRAME
Definition: gsm_constants.h:46
channel_configuration
Definition: receiver_config.h:130
type
uint8_t type
Definition: gsm_04_08.h:2
channel_configuration::channel_configuration
channel_configuration()
Definition: receiver_config.h:135
multiframe_configuration::get_burst_type
burst_type get_burst_type(int nr)
Definition: receiver_config.h:61
t1
uint8_t t1
Definition: gsm_04_08.h:4
t3
uint8_t t3
Definition: gsm_04_08.h:7
empty
@ empty
Definition: gsm_constants.h:63
t2
uint8_t t2
Definition: gsm_04_08.h:6
burst_type
burst_type
Definition: gsm_constants.h:63
unknown
@ unknown
Definition: gsm_constants.h:64
burst_counter::get_t1
uint32_t get_t1()
Definition: receiver_config.h:101
multiframe_configuration::multiframe_configuration
multiframe_configuration()
Definition: receiver_config.h:36
burst_counter::get_offset
unsigned get_offset()
Definition: receiver_config.h:125
burst_counter::get_frame_nr
uint32_t get_frame_nr()
Definition: receiver_config.h:117
multiframe_configuration
Definition: receiver_config.h:30
channel_configuration::get_burst_type
burst_type get_burst_type(burst_counter burst_nr)
multiframe_configuration::~multiframe_configuration
~multiframe_configuration()
Definition: receiver_config.h:41
channel_configuration::set_multiframe_type
void set_multiframe_type(int timeslot_nr, multiframe_type type)
Definition: receiver_config.h:141