GNU Radio's DECT2 Package
packet_receiver_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2015 Pavel Yazev <pyazev@gmail.com>
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_DECT2_PACKET_RECEIVER_IMPL_H
22 #define INCLUDED_DECT2_PACKET_RECEIVER_IMPL_H
23 
24 #include <dect2/packet_receiver.h>
25 
26 
27 #define MAX_PARTS 8 // Maximum number of DECT parts to be tracked
28 #define SMPL_BUF_LEN (32 * 4)
29 #define TIME_TOL 10 // Time tolerance
30 #define INTER_SLOT_TIME (480 * 4)
31 #define INTER_FRAME_TIME (INTER_SLOT_TIME * 24)
32 #define S_FIELD_BITS 32
33 #define P32_D_FIELD_BITS 388
34 #define RFP_SYNC_FIELD 0xAAAAE98A
35 
36 
37 namespace gr {
38  namespace dect2 {
39 
41  {
42  private:
43  typedef enum {_RFP_, _PP_} part_type;
44 
45  part_type d_part_type;
46 
47  uint32_t d_rx_bits_buf[4]; // Buffer to save demodulated bits. Input signal has four samples per bits.
48  // We save bits related to null sample in null element, bits related to first sample in firts element
49  // and so on. Each element in this array should be considered as circular buffer.
50  unsigned d_rx_bits_buf_index;
51  enum {_WAIT_BEGIN_, _WAIT_END_, _POST_WAIT_} d_sync_state;
52 
53  uint32_t d_begin_pos;
54  uint32_t d_end_pos;
55  uint32_t d_post_wait_cnt;
56 
57  float d_smpl_buf[SMPL_BUF_LEN];
58  uint32_t d_smpl_buf_index;
59 
60 
61  uint32_t d_smpl_cnt;
62  uint32_t d_out_bit_cnt;
63  uint64_t d_inc_smpl_cnt; // Incomming samples counter
64 
65 
66  uint64_t d_part_time[MAX_PARTS];
67  uint32_t d_part_seq[MAX_PARTS];
68  uint32_t d_part_activity;
69 
70  int32_t d_cur_part_rx_id;
71 
72 
73 
74  int d_decimation;
75  int decimation () const { return d_decimation; }
76  void set_decimation (int decimation)
77  {
78  d_decimation = decimation;
79  set_relative_rate (1.0 / decimation);
80  }
81 
82  int fixed_rate_ninput_to_noutput(int ninput);
83  int fixed_rate_noutput_to_ninput(int noutput);
84 
85  int check_part_activity(void);
86  int register_part(void);
87  int find_best_smpl_point(void);
88 
89  public:
92 
93  // Where all the action really happens
94  void forecast (int noutput_items, gr_vector_int &ninput_items_required);
95 
96  int general_work(int noutput_items,
97  gr_vector_int &ninput_items,
98  gr_vector_const_void_star &input_items,
99  gr_vector_void_star &output_items);
100  };
101 
102  } // namespace dect2
103 } // namespace gr
104 
105 #endif /* INCLUDED_DECT2_PACKET_RECEIVER_IMPL_H */
106 
<+description of block+>
Definition: packet_receiver.h:36
Definition: packet_receiver_impl.h:40
#define MAX_PARTS
Definition: packet_receiver_impl.h:27
Definition: packet_decoder.h:28
#define SMPL_BUF_LEN
Definition: packet_receiver_impl.h:28
void forecast(int noutput_items, gr_vector_int &ninput_items_required)
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)