From e9c151bc125c2d4ac2b6bbaeef6d20cd9bf21592 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 24 Feb 2017 11:14:37 +0100 Subject: [PATCH] h5: provide 2 byte post buffer for outgoing packets - used for 16-bit data integrity check --- src/hci.h | 7 +++++-- src/hci_transport_h5.c | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hci.h b/src/hci.h index f5884a4ec..f4dde9fbb 100644 --- a/src/hci.h +++ b/src/hci.h @@ -92,8 +92,11 @@ extern "C" { #endif #endif -// additional pre-buffer space for packets to Bluetooth module, for now, used for HCI Transport H4 DMA +// additional pre- and post-packet buffer for packets to Bluetooth module +// - pre-buffer used for HCI Transport H4 variants +// - post-buffer used for HCI Transport H5 #define HCI_OUTGOING_PRE_BUFFER_SIZE 1 +#define HCI_OUTGOING_POST_BUFFER_SIZE 2 // BNEP may uncompress the IP Header by 16 bytes #ifndef HCI_INCOMING_PRE_BUFFER_SIZE @@ -646,7 +649,7 @@ typedef struct { // single buffer for HCI packet assembly + additional prebuffer for H4 drivers uint8_t * hci_packet_buffer; - uint8_t hci_packet_buffer_data[HCI_OUTGOING_PRE_BUFFER_SIZE + HCI_PACKET_BUFFER_SIZE]; + uint8_t hci_packet_buffer_data[HCI_OUTGOING_PRE_BUFFER_SIZE + HCI_PACKET_BUFFER_SIZE + HCI_OUTGOING_POST_BUFFER_SIZE]; uint8_t hci_packet_buffer_reserved; uint16_t acl_fragmentation_pos; uint16_t acl_fragmentation_total_size; diff --git a/src/hci_transport_h5.c b/src/hci_transport_h5.c index 7ef0af1a9..164107be6 100644 --- a/src/hci_transport_h5.c +++ b/src/hci_transport_h5.c @@ -49,6 +49,11 @@ #include "hci_transport.h" #include "btstack_uart_block.h" +// assert post-buffer for 16-bit data integrity check is available +#if !defined(HCI_OUTGOING_POST_BUFFER_SIZE) || (HCI_OUTGOING_POST_BUFFER_SIZE < 2) +#error HCI_OUTGOING_POST_BUFFER_SIZE not defined. Please update hci.h +#endif + typedef enum { LINK_UNINITIALIZED, LINK_INITIALIZED,