diff --git a/src/hci.c b/src/hci.c index 4b4a58a43..5480d7eda 100644 --- a/src/hci.c +++ b/src/hci.c @@ -408,7 +408,7 @@ static void event_handler(uint8_t *packet, int size){ hci_stack.acl_data_packet_length = HCI_ACL_BUFFER_SIZE; } // determine usable ACL packet types - hci_stack.packet_types = hci_acl_packet_types_for_buffer_size(max_acl_payload); + hci_stack.packet_types = hci_acl_packet_types_for_buffer_size(hci_stack.acl_data_packet_length); log_error("hci_read_buffer_size: size %u, count %u, packet types %04x\n", hci_stack.acl_data_packet_length, hci_stack.total_num_acl_packets, hci_stack.packet_types); diff --git a/src/hci.h b/src/hci.h index 7358c6fb0..ca03e770a 100644 --- a/src/hci.h +++ b/src/hci.h @@ -71,6 +71,8 @@ extern "C" { #define HCI_ACL_3DH3_SIZE 552 #define HCI_ACL_2DH5_SIZE 679 #define HCI_ACL_3DH5_SIZE 1021 + +#define HCI_EVENT_PKT_SIZE 255 // OGFs #define OGF_LINK_CONTROL 0x01 diff --git a/src/hci_transport_h4.c b/src/hci_transport_h4.c index 387b121dc..0ce560629 100644 --- a/src/hci_transport_h4.c +++ b/src/hci_transport_h4.c @@ -48,6 +48,13 @@ #include "hci_transport.h" #include "hci_dump.h" +// determine sie of receive buffer +#if (HCI_ACL_DATA_PKT_HDR + HCI_ACL_BUFFER_SIZE) > (HCI_EVENT_PKT_HDR + HCI_EVENT_PKT_SIZE) +#define HCI_PACKET_BUFFER_SIZE (HCI_ACL_DATA_PKT_HDR + HCI_ACL_BUFFER_SIZE) +#else +#define HCI_PACKET_BUFFER_SIZE (HCI_EVENT_PKT_HDR + HCI_EVENT_PKT_SIZE) +#endif + // #define USE_HCI_READER_THREAD typedef enum { @@ -90,10 +97,8 @@ static void (*packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t si static H4_STATE h4_state; static int bytes_to_read; static int read_pos; -// static uint8_t hci_event_buffer[255+2]; // maximal payload + 2 bytes header -static uint8_t hci_packet[1+HCI_ACL_BUFFER_SIZE]; // bigger than largest packet - watch out when ACL payload is < 255 - +static uint8_t hci_packet[1+HCI_PACKET_BUFFER_SIZE]; // packet type + max(acl header + acl payload, event header + event data) // prototypes static int h4_open(void *transport_config){