GNU Radio's LORA_SDR Package
frame_src_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2020 Joachim Tapparel TCL@EPFL.
4 *
5 * 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.
9 *
10 * 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.
14 *
15 * 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#ifndef INCLUDED_LORA_SDR_FRAME_SRC_IMPL_H
22#define INCLUDED_LORA_SDR_FRAME_SRC_IMPL_H
23
24#include <lora_sdr/frame_src.h>
25#include "helpers.h"
26#include <volk/volk.h>
27
28namespace gr {
29namespace lora_sdr {
30
31class frame_src_impl : public frame_src {
32private:
33 /**
34 * @brief Transmission spreading factor
35 *
36 */
37 uint8_t m_sf;
38 /**
39 * @brief Transmission sampling rate
40 *
41 */
42 uint32_t m_samp_rate;
43 /**
44 * @brief Transmission bandwidth (Works only for samp_rate=bw)
45 *
46 */
47 uint32_t m_bw;
48 /**
49 * @brief number of bin per loar symbol
50 *
51 */
52 uint32_t m_N;
53 /**
54 * @brief oversampling factor
55 *
56 */
57 uint8_t m_os_factor;
58 /**
59 * @brief number of zeros between two frames
60 *
61 */
62 int m_delay;
63 /**
64 * @brief number of symbols in a frame payload
65 *
66 */
67 int m_pay_len;
68 /**
69 * @brief number of frames to transmit
70 *
71 */
72 int m_n_frames;
73 /**
74 * @brief the number of zeros sent before the first symbol
75 *
76 */
77 int m_offset;
78 /**
79 * @brief the CFO of the user
80 *
81 */
82 float m_cfo;
83 /**
84 * @brief indicate to use a random STO, uniformly distributed in
85 * [0,2^sf*m_os_factor)
86 *
87 */
88 bool m_rand_sto;
89
90 /**
91 * @brief delay between frame taking a random sto into account
92 *
93 */
94 int m_delay_with_rand_sto;
95 /**
96 * @brief rand_sto val
97 *
98 */
99 int m_sto_val;
100 /**
101 * @brief reference upchirp
102 *
103 */
104 std::vector<gr_complex> m_upchirp;
105 /**
106 * @brief reference downchirp
107 *
108 */
109 std::vector<gr_complex> m_downchirp;
110
111 /**
112 * @brief frame length in samples
113 *
114 */
115 uint32_t m_frame_length;
116
117 /**
118 * @brief contains the whole frame
119 *
120 */
121 std::vector<gr_complex> m_frame;
122
123 /**
124 * @brief variable used to wait before outputing the first frame
125 *
126 */
127 bool is_first;
128
129 /**
130 * @brief number of upchirps in the preamble
131 *
132 */
133 uint m_n_up;
134
135 /**
136 * @brief sample counter
137 *
138 */
139 int m_cnt;
140
141 /**
142 * @brief frame counter
143 *
144 */
145 uint m_frame_cnt;
146
147 /**
148 * @brief return true if this block is responsible for the frame of the
149 * first user. this decision is based on the m_offset value as for the first
150 * user a value bigger than 2^sf*os_factor should not be used.
151 *
152 * @return true
153 * @return false
154 */
155 bool is_first_user();
156
157public:
158 /**
159 * @brief Construct a new frame src impl object
160 *
161 * @param sf
162 * @param pay_len
163 * @param delay
164 * @param offset
165 * @param cfo
166 * @param n_frames
167 * @param os_factor
168 * @param rand_sto
169 */
170 frame_src_impl(uint8_t sf, int pay_len, int delay, int offset, float cfo,
171 int n_frames, int os_factor, bool rand_sto);
172
173 /**
174 * @brief Destroy the frame src impl object
175 *
176 */
178
179 /**
180 * @brief Standard gnuradio function
181 *
182 * @param noutput_items
183 * @param input_items
184 * @param output_items
185 * @return int
186 */
187 int work(int noutput_items, gr_vector_const_void_star &input_items,
188 gr_vector_void_star &output_items);
189};
190
191} // namespace lora_sdr
192} // namespace gr
193
194#endif /* INCLUDED_LORA_SDR_FRAME_SRC_IMPL_H */
Definition: frame_src_impl.h:31
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
Standard gnuradio function.
frame_src_impl(uint8_t sf, int pay_len, int delay, int offset, float cfo, int n_frames, int os_factor, bool rand_sto)
Construct a new frame src impl object.
~frame_src_impl()
Destroy the frame src impl object.
Definition: frame_src.h:36
Definition: add_crc.h:28