From 7ec5eeaa74e5874c26df0156c1837cf8181fce4e Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Sun, 30 Jan 2011 18:37:02 +0000 Subject: [PATCH] fix exration of num hci cmds allowed from command status packets --- src/hci.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/hci.c b/src/hci.c index 390d227ab..a05960578 100644 --- a/src/hci.c +++ b/src/hci.c @@ -323,16 +323,14 @@ static void event_handler(uint8_t *packet, int size){ hci_connection_t * conn; int i; link_key_t link_key; - - // get num_cmd_packets - if (packet[0] == HCI_EVENT_COMMAND_COMPLETE || packet[0] == HCI_EVENT_COMMAND_STATUS){ - // Get Num_HCI_Command_Packets - hci_stack.num_cmd_packets = packet[2]; - } - + switch (packet[0]) { - + case HCI_EVENT_COMMAND_COMPLETE: + // get num cmd packets + // log_dbg("HCI_EVENT_COMMAND_COMPLETE cmds old %u - new %u\n", hci_stack.num_cmd_packets, packet[2]); + hci_stack.num_cmd_packets = packet[2]; + if (COMMAND_COMPLETE_EVENT(packet, hci_read_buffer_size)){ // from offset 5 // status @@ -349,6 +347,12 @@ static void event_handler(uint8_t *packet, int size){ } break; + case HCI_EVENT_COMMAND_STATUS: + // get num cmd packets + // log_dbg("HCI_EVENT_COMMAND_STATUS cmds - old %u - new %u\n", hci_stack.num_cmd_packets, packet[3]); + hci_stack.num_cmd_packets = packet[3]; + break; + case HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS: for (i=0; i