1 /* -*- c -*- */ 2 /* 3 * Copyright 2007 - 2012 Mike Ryan, Dominic Spill, Michael Ossmann 4 * Copyright 2005, 2006 Free Software Foundation, Inc. 5 * 6 * This file is part of libbtbb 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2, or (at your option) 11 * any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with libbtbb; see the file COPYING. If not, write to 20 * the Free Software Foundation, Inc., 51 Franklin Street, 21 * Boston, MA 02110-1301, USA. 22 */ 23 #ifndef INCLUDED_BLUETOOTH_LE_PACKET_H 24 #define INCLUDED_BLUETOOTH_LE_PACKET_H 25 26 #include <stdint.h> 27 #include <stdio.h> 28 #include <stdlib.h> 29 30 #define MAX_LE_SYMBOLS 64 31 32 #define ADV_IND 0 33 #define ADV_DIRECT_IND 1 34 #define ADV_NONCONN_IND 2 35 #define SCAN_REQ 3 36 #define SCAN_RSP 4 37 #define CONNECT_REQ 5 38 #define ADV_SCAN_IND 6 39 40 typedef struct _le_packet_t { 41 // raw unwhitened bytes of packet, including access address 42 uint8_t symbols[MAX_LE_SYMBOLS]; 43 44 uint32_t access_address; 45 46 // channel index 47 uint8_t channel_idx; 48 49 // number of symbols 50 int length; 51 52 uint32_t clk100ns; 53 54 // advertising packet header info 55 uint8_t adv_type; 56 int adv_tx_add; 57 int adv_rx_add; 58 } le_packet_t; 59 60 /* decode payload */ 61 void decode_le(uint8_t *stream, uint16_t phys_channel, uint32_t clk100ns, le_packet_t *p); 62 63 /* returns true if this is a data packet, false if advertising */ 64 int le_packet_is_data(le_packet_t *p); 65 66 /* returns the channel index of a physical channel */ 67 uint8_t le_channel_index(uint16_t phys_channel); 68 69 /* returns a string representing advertising packet type */ 70 const char *le_adv_type(le_packet_t *p); 71 72 /* print LE packet information */ 73 void le_print(le_packet_t *p); 74 75 #endif /* INCLUDED_BLUETOOTH_LE_PACKET_H */ 76