27 #ifndef INCLUDED_GR_BLUETOOTH_PACKET_H 28 #define INCLUDED_GR_BLUETOOTH_PACKET_H 31 #include <gnuradio/sync_block.h> 52 typedef boost::shared_ptr<packet>
sptr;
59 static const int MAX_SYMBOLS = 3125;
64 char d_symbols[MAX_SYMBOLS];
95 packet(
char *stream,
int length,
double freq=0.0);
101 static const uint8_t WHITENING_DATA[127];
103 static int sniff_packet(
char *stream,
int stream_length,
double freq,
air_format& fmt);
106 static uint8_t reverse(
char byte);
109 static void convert_to_grformat(uint8_t input, uint8_t *output);
112 static uint8_t air_to_host8(
char *air_order,
int bits);
113 static uint16_t air_to_host16(
char *air_order,
int bits);
114 static uint32_t air_to_host32(
char *air_order,
int bits);
118 static void host_to_air(uint8_t host_order,
char *air_order,
int bits);
126 void set_whitened(
bool whitened);
129 int get_payload_length();
142 virtual bool decode_header() = 0;
145 virtual void decode_payload() = 0;
148 virtual void print() = 0;
151 virtual char *tun_format() = 0;
154 virtual bool header_present() = 0;
156 virtual int get_channel() = 0;
169 typedef boost::shared_ptr<classic_packet>
sptr;
179 static sptr make(
char *stream,
int length);
182 static sptr make(
char *stream,
int length, uint32_t clkn,
double freq);
185 static const int ID_THRESHOLD = 5;
187 static const int SYMBOLS_PER_BASIC_RATE_ACCESS_CODE = 68;
190 static const uint8_t INDICES[64];
193 static const uint8_t PREAMBLE_DISTANCE[32];
196 static const uint8_t BARKER_DISTANCE[128];
199 static const std::string TYPE_NAMES[16];
205 static int sniff_ac(
char *stream,
int stream_length);
208 static uint8_t *lfsr(uint8_t *data,
int length,
int k, uint8_t *g);
211 static uint8_t *acgen(
int LAP);
214 static bool unfec13(
char *input,
char *output,
int length);
217 static char *unfec23(
char *input,
int length);
223 static bool check_ac(
char *stream,
int LAP);
226 static uint16_t crcgen(
char *payload,
int length,
int UAP);
229 static int UAP_from_hec(uint16_t data, uint8_t hec);
232 virtual int crc_check(
int clock) = 0;
235 virtual bool decode_header() = 0;
238 virtual void decode_payload() = 0;
241 virtual void print() = 0;
244 virtual char *tun_format() = 0;
247 virtual uint32_t get_LAP() = 0;
250 virtual uint8_t get_UAP() = 0;
253 virtual void set_UAP(uint8_t UAP) = 0;
256 virtual void set_NAP(uint16_t NAP) = 0;
259 virtual uint32_t get_clock() = 0;
262 virtual void set_clock(uint32_t clk6,
bool have27) = 0;
267 virtual uint8_t try_clock(
int clock) = 0;
270 virtual bool header_present() = 0;
273 virtual uint32_t lap_from_fhs() = 0;
276 virtual uint8_t uap_from_fhs() = 0;
279 virtual uint16_t nap_from_fhs() = 0;
282 virtual uint32_t clock_from_fhs() = 0;
287 #define LE_MAX_PDU_OCTETS 39 288 #define LE_MAX_OCTETS (1+4+LE_MAX_PDU_OCTETS+3) 289 #define LE_MAX_SYMBOLS (8*LE_MAX_OCTETS) 298 typedef boost::shared_ptr<le_packet>
sptr;
300 static sptr make(
char *stream,
int length,
double freq=0.0);
301 static int freq2chan(
const double freq);
302 static int chan2index(
const int chan);
303 static int freq2index(
const double freq);
306 static const uint8_t INDICES[40];
309 static const uint8_t PREAMBLE_DISTANCE[512];
312 static const uint8_t ACCESS_ADDRESS_DISTANCE_0[256];
313 static const uint8_t ACCESS_ADDRESS_DISTANCE_1[256];
314 static const uint8_t ACCESS_ADDRESS_DISTANCE_2[256];
315 static const uint8_t ACCESS_ADDRESS_DISTANCE_3[256];
318 static const uint8_t ACCESS_HEADER_DISTANCE_LSB[256];
319 static const uint8_t ACCESS_HEADER_DISTANCE_MSB[256];
320 static const uint8_t DATA_HEADER_DISTANCE_LSB[256];
321 static const uint8_t DATA_HEADER_DISTANCE_MSB[256];
323 static int sniff_aa(
char *stream,
int stream_length,
double freq);
326 virtual bool decode_header() = 0;
329 virtual void decode_payload() = 0;
332 virtual void print() = 0;
335 virtual char *tun_format() = 0;
338 virtual bool header_present() = 0;
341 virtual uint32_t get_AA() = 0;
343 virtual int get_channel( ) = 0;
Definition: packet_impl.h:151
boost::shared_ptr< classic_packet > sptr
Definition: packet.h:169
Definition: packet_impl.h:35
air_format
Definition: packet.h:45
#define GR_BLUETOOTH_API
Definition: api.h:30
#define LE_MAX_SYMBOLS
Definition: packet.h:289
Definition: multi_block.h:33
#define LE_MAX_OCTETS
Definition: packet.h:288
uint32_t d_clkn
Definition: packet.h:202
boost::shared_ptr< le_packet > sptr
Definition: packet.h:298
boost::shared_ptr< packet > sptr
Definition: packet.h:52
virtual ~packet()
Definition: packet.h:96
packet()
Definition: packet.h:94
#define LE_MAX_PDU_OCTETS
Definition: packet.h:287
<+description of block+>
Definition: packet.h:163
int get_channel()
Definition: packet.h:284