hci_dump: add hci_dump_setup_header_btsnoop

This commit is contained in:
Matthias Ringwald 2021-06-21 22:50:22 +02:00
parent 4ddcd9eabe
commit a9b0ec79f4
2 changed files with 36 additions and 0 deletions

View File

@ -157,3 +157,24 @@ void hci_dump_setup_header_bluez(uint8_t * buffer, uint32_t tv_sec, uint32_t tv_
little_endian_store_32( buffer, 8, tv_us);
buffer[12] = packet_type;
}
// From https://fte.com/webhelpii/hsu/Content/Technical_Information/BT_Snoop_File_Format.htm
void hci_dump_setup_header_btsnoop(uint8_t * buffer, uint32_t ts_usec_high, uint32_t ts_usec_low, uint32_t cumulative_drops, uint8_t packet_type, uint8_t in, uint16_t len) {
uint32_t packet_flags = 0;
if (in){
packet_flags |= 1;
}
switch (packet_type){
case HCI_COMMAND_DATA_PACKET:
case HCI_EVENT_PACKET:
packet_flags |= 2;
default:
break;
}
big_endian_store_32(buffer, 0, len); // Original Length
big_endian_store_32(buffer, 4, len); // Included Length
big_endian_store_32(buffer, 8, packet_flags); // Packet Flags
big_endian_store_32(buffer, 12, cumulative_drops); // Cumulativ Drops
big_endian_store_32(buffer, 16, ts_usec_high); // Timestamp Microseconds High
big_endian_store_32(buffer, 20, ts_usec_low); // Timestamp Microseconds Low
}

View File

@ -63,6 +63,7 @@ extern "C" {
#define HCI_DUMP_HEADER_SIZE_PACKETLOGGER 13
#define HCI_DUMP_HEADER_SIZE_BLUEZ 13
#define HCI_DUMP_HEADER_SIZE_BTSNOOP 24
/* API_START */
@ -70,6 +71,7 @@ typedef enum {
HCI_DUMP_INVALID = 0,
HCI_DUMP_BLUEZ,
HCI_DUMP_PACKETLOGGER,
HCI_DUMP_BTSNOOP,
} hci_dump_format_t;
typedef struct {
@ -150,6 +152,7 @@ __attribute__ ((format (__printf__, 2, 3)))
* @param len
*/
void hci_dump_setup_header_packetlogger(uint8_t * buffer, uint32_t tv_sec, uint32_t tv_us, uint8_t packet_type, uint8_t in, uint16_t len);
/**
* @brief Setup header for BLUEZ (hcidump) format
* @param buffer
@ -161,6 +164,18 @@ void hci_dump_setup_header_packetlogger(uint8_t * buffer, uint32_t tv_sec, uint3
*/
void hci_dump_setup_header_bluez(uint8_t * buffer, uint32_t tv_sec, uint32_t tv_us, uint8_t packet_type, uint8_t in, uint16_t len);
/**
* @brief Setup header for BT Snoop format
* @param buffer
* @param ts_usec_high upper 32-bit of 64-bit microsecond timestamp
* @param ts_usec_low lower 2-bit of 64-bit microsecond timestamp
* @param cumulative_drops since last packet was recorded
* @param packet_type
* @param in
* @param len
*/
void hci_dump_setup_header_btsnoop(uint8_t * buffer, uint32_t ts_usec_high, uint32_t ts_usec_low, uint32_t cumulative_drops, uint8_t packet_type, uint8_t in, uint16_t len);
/* API_END */