hci_dump_posix_fs: provide summary of ISO packets for PacketLogger and bluez dump format

This commit is contained in:
Matthias Ringwald 2022-03-23 11:22:23 +01:00
parent 5a831baef6
commit 997ab207b2

View File

@ -56,6 +56,7 @@
#include "hci_dump_posix_fs.h"
#include "btstack_debug.h"
#include "btstack_util.h"
#include "hci_cmd.h"
#include <time.h>
@ -77,6 +78,25 @@ static void hci_dump_posix_fs_reset(void){
UNUSED(err);
}
// provide summary for ISO Data Packets if not supported by fileformat/viewer yet
static uint16_t hci_dump_iso_summary(uint8_t in, uint8_t *packet, uint16_t len){
uint16_t conn_handle = little_endian_read_16(packet, 0) & 0xfff;
uint8_t pb = (packet[1] >> 4) & 3;
uint8_t ts = (packet[1] >> 6) & 1;
uint16_t pos = 4;
uint32_t time_stamp = 0;
if (ts){
time_stamp = little_endian_read_32(packet, pos);
pos += 4;
}
uint16_t packet_sequence = little_endian_read_16(packet, pos);
pos += 2;
uint16_t iso_sdu_len = little_endian_read_16(packet, pos);
uint8_t packet_status_flag = packet[pos+1] >> 6;
return snprintf(log_message_buffer,sizeof(log_message_buffer), "ISO %s, handle %04x, pb %u, ts 0x%08x, sequence 0x%04x, packet status %u, iso len %u",
in ? "IN" : "OUT", conn_handle, pb, time_stamp, packet_sequence, packet_status_flag, iso_sdu_len);
}
static void hci_dump_posix_fs_log_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len) {
if (dump_file < 0) return;
@ -99,10 +119,22 @@ static void hci_dump_posix_fs_log_packet(uint8_t packet_type, uint8_t in, uint8_
uint16_t header_len = 0;
switch (dump_format){
case HCI_DUMP_BLUEZ:
// ISO packets not supported
if (packet_type == HCI_ISO_DATA_PACKET){
len = hci_dump_iso_summary(in, packet, len);
packet_type = LOG_MESSAGE_PACKET;
packet = (uint8_t*) log_message_buffer;
}
hci_dump_setup_header_bluez(header.header_bluez, tv_sec, tv_us, packet_type, in, len);
header_len = HCI_DUMP_HEADER_SIZE_BLUEZ;
break;
case HCI_DUMP_PACKETLOGGER:
// ISO packets not supported
if (packet_type == HCI_ISO_DATA_PACKET){
len = hci_dump_iso_summary(in, packet, len);
packet_type = LOG_MESSAGE_PACKET;
packet = (uint8_t*) log_message_buffer;
}
hci_dump_setup_header_packetlogger(header.header_packetlogger, tv_sec, tv_us, packet_type, in, len);
header_len = HCI_DUMP_HEADER_SIZE_PACKETLOGGER;
break;