define HCI_INCOMING_PRE_BUFFER_SIZE and reserve space in posix libusb and h4 transport

This commit is contained in:
matthias.ringwald@gmail.com 2014-10-31 21:17:58 +00:00
parent 7b472d9ff8
commit b34233c302
3 changed files with 9 additions and 4 deletions

View File

@ -104,7 +104,7 @@ static struct libusb_transfer *command_out_transfer;
static uint8_t hci_event_in_buffer[ASYNC_BUFFERS][HCI_ACL_BUFFER_SIZE]; // bigger than largest packet
static uint8_t hci_bulk_in_buffer[ASYNC_BUFFERS][HCI_ACL_BUFFER_SIZE]; // bigger than largest packet
static uint8_t hci_bulk_in_buffer[ASYNC_BUFFERS][HCI_INCOMING_PRE_BUFFER_SIZE + HCI_ACL_BUFFER_SIZE];
static uint8_t hci_control_buffer[3 + 256 + LIBUSB_CONTROL_SETUP_SIZE];
// For (ab)use as a linked list of received packets
@ -295,7 +295,7 @@ static void handle_completed_transfer(struct libusb_transfer *transfer){
// log_info("command done, size %u", transfer->actual_length);
usb_command_active = 0;
// notify upper stack that iit might be possible to send again
// notify upper stack that it might be possible to send again
uint8_t event[] = { DAEMON_EVENT_HCI_PACKET_SENT, 0};
packet_handler(HCI_EVENT_PACKET, &event[0], sizeof(event));
@ -513,7 +513,7 @@ static int usb_open(void *transport_config){
// configure bulk_in handlers
libusb_fill_bulk_transfer(bulk_in_transfer[c], handle, acl_in_addr,
hci_bulk_in_buffer[c], HCI_ACL_BUFFER_SIZE, async_callback, NULL, 0) ;
hci_bulk_in_buffer[c] + HCI_INCOMING_PRE_BUFFER_SIZE, HCI_ACL_BUFFER_SIZE, async_callback, NULL, 0) ;
r = libusb_submit_transfer(bulk_in_transfer[c]);
if (r) {

View File

@ -86,7 +86,8 @@ static H4_STATE h4_state;
static int bytes_to_read;
static int read_pos;
static uint8_t hci_packet[1+HCI_PACKET_BUFFER_SIZE]; // packet type + max(acl header + acl payload, event header + event data)
static uint8_t hci_packet_with_pre_buffer[HCI_INCOMING_PRE_BUFFER_SIZE + 1 + HCI_PACKET_BUFFER_SIZE]; // packet type + max(acl header + acl payload, event header + event data)
static uint8_t * hci_packet = &hci_packet_with_pre_buffer[HCI_INCOMING_PRE_BUFFER_SIZE];
static int h4_open(void *transport_config){
hci_uart_config = (hci_uart_config_t*) transport_config;

View File

@ -110,6 +110,10 @@ 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
#ifndef HCI_INCOMING_PRE_BUFFER_SIZE
#define HCI_INCOMING_PRE_BUFFER_SIZE 0
#endif
// OGFs
#define OGF_LINK_CONTROL 0x01
#define OGF_LINK_POLICY 0x02