mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 16:43:28 +00:00
reserve buffer in front of incoming hci_packet buffer for h4 (posix, dma, dma+ehcill) and h2 libusb, and acl recombination buffer
This commit is contained in:
parent
99d8e5fec0
commit
ec6321ee39
@ -570,7 +570,7 @@ static void acl_handler(uint8_t *packet, int size){
|
||||
}
|
||||
|
||||
// append fragment payload (header already stored)
|
||||
memcpy(&conn->acl_recombination_buffer[conn->acl_recombination_pos], &packet[4], acl_length );
|
||||
memcpy(&conn->acl_recombination_buffer[HCI_INCOMING_PRE_BUFFER_SIZE + conn->acl_recombination_pos], &packet[4], acl_length );
|
||||
conn->acl_recombination_pos += acl_length;
|
||||
|
||||
// log_error( "ACL Cont Fragment: acl_len %u, combined_len %u, l2cap_len %u", acl_length,
|
||||
@ -579,7 +579,7 @@ static void acl_handler(uint8_t *packet, int size){
|
||||
// forward complete L2CAP packet if complete.
|
||||
if (conn->acl_recombination_pos >= conn->acl_recombination_length + 4 + 4){ // pos already incl. ACL header
|
||||
|
||||
hci_stack->packet_handler(HCI_ACL_DATA_PACKET, conn->acl_recombination_buffer, conn->acl_recombination_pos);
|
||||
hci_stack->packet_handler(HCI_ACL_DATA_PACKET, &conn->acl_recombination_buffer[HCI_INCOMING_PRE_BUFFER_SIZE], conn->acl_recombination_pos);
|
||||
// reset recombination buffer
|
||||
conn->acl_recombination_length = 0;
|
||||
conn->acl_recombination_pos = 0;
|
||||
@ -607,10 +607,10 @@ static void acl_handler(uint8_t *packet, int size){
|
||||
|
||||
} else {
|
||||
// store first fragment and tweak acl length for complete package
|
||||
memcpy(conn->acl_recombination_buffer, packet, acl_length + 4);
|
||||
memcpy(&conn->acl_recombination_buffer[HCI_INCOMING_PRE_BUFFER_SIZE], packet, acl_length + 4);
|
||||
conn->acl_recombination_pos = acl_length + 4;
|
||||
conn->acl_recombination_length = l2cap_length;
|
||||
bt_store_16(conn->acl_recombination_buffer, 2, l2cap_length +4);
|
||||
bt_store_16(conn->acl_recombination_buffer, HCI_INCOMING_PRE_BUFFER_SIZE + 2, l2cap_length +4);
|
||||
}
|
||||
break;
|
||||
|
||||
|
10
src/hci.h
10
src/hci.h
@ -110,8 +110,12 @@ extern "C" {
|
||||
// additional pre-buffer space for packets to Bluetooth module, for now, used for HCI Transport H4 DMA
|
||||
#define HCI_OUTGOING_PRE_BUFFER_SIZE 1
|
||||
|
||||
// BNEP may uncompress the IP Header by 16 bytes
|
||||
#ifdef HAVE_BNEP
|
||||
#define HCI_INCOMING_PRE_BUFFER_SIZE (16 - HCI_ACL_HEADER_SIZE - 4)
|
||||
#endif
|
||||
#ifndef HCI_INCOMING_PRE_BUFFER_SIZE
|
||||
#define HCI_INCOMING_PRE_BUFFER_SIZE 0
|
||||
#define HCI_INCOMING_PRE_BUFFER_SIZE 0
|
||||
#endif
|
||||
|
||||
// OGFs
|
||||
@ -366,8 +370,8 @@ typedef struct {
|
||||
uint32_t timestamp; // timeout in system ticks
|
||||
#endif
|
||||
|
||||
// ACL packet recombination - ACL Header + ACL payload
|
||||
uint8_t acl_recombination_buffer[4 + HCI_ACL_BUFFER_SIZE];
|
||||
// ACL packet recombination - PRE_BUFFER + ACL Header + ACL payload
|
||||
uint8_t acl_recombination_buffer[HCI_INCOMING_PRE_BUFFER_SIZE + 4 + HCI_ACL_BUFFER_SIZE];
|
||||
uint16_t acl_recombination_pos;
|
||||
uint16_t acl_recombination_length;
|
||||
|
||||
|
@ -90,7 +90,10 @@ static int h4_can_send_packet_now(uint8_t packet_type);
|
||||
static H4_STATE h4_state;
|
||||
static int read_pos;
|
||||
static int bytes_to_read;
|
||||
static uint8_t hci_packet[HCI_PACKET_BUFFER_SIZE]; // bigger than largest packet
|
||||
|
||||
// bigger than largest packet
|
||||
static uint8_t hci_packet_prefixed[HCI_INCOMING_PRE_BUFFER_SIZE + HCI_PACKET_BUFFER_SIZE];
|
||||
static uint8_t * hci_packet = &hci_packet_prefixed[HCI_INCOMING_PRE_BUFFER_SIZE];
|
||||
|
||||
// tx state
|
||||
static TX_STATE tx_state;
|
||||
|
@ -129,7 +129,11 @@ static uint8_t ehcill_command_to_send;
|
||||
static H4_STATE h4_state;
|
||||
static int read_pos;
|
||||
static int bytes_to_read;
|
||||
static uint8_t hci_packet[HCI_PACKET_BUFFER_SIZE]; // bigger than largest packet
|
||||
|
||||
// bigger than largest packet
|
||||
static uint8_t hci_packet_prefixed[HCI_INCOMING_PRE_BUFFER_SIZE + HCI_PACKET_BUFFER_SIZE];
|
||||
static uint8_t * hci_packet = &hci_packet_prefixed[HCI_INCOMING_PRE_BUFFER_SIZE];
|
||||
|
||||
static void (*packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t size) = dummy_handler;
|
||||
|
||||
// H4: tx state
|
||||
|
Loading…
x
Reference in New Issue
Block a user