From e07074171560f4bc95bbf1ea5d05ceb4cd081d88 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald@gmail.com" Date: Mon, 28 Apr 2014 20:51:11 +0000 Subject: [PATCH] forward HCI Events to att and sm packet handlers, too --- ble/l2cap_le.c | 21 ++++++--------------- src/l2cap.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/ble/l2cap_le.c b/ble/l2cap_le.c index 41c79d456..cf8883bf7 100644 --- a/ble/l2cap_le.c +++ b/ble/l2cap_le.c @@ -141,25 +141,16 @@ int l2cap_send_connectionless(uint16_t handle, uint16_t cid, uint8_t *data, uint void l2cap_event_handler( uint8_t *packet, uint16_t size ){ - switch(packet[0]){ - - case DAEMON_EVENT_HCI_PACKET_SENT: - if (attribute_protocol_packet_handler) { - (*attribute_protocol_packet_handler)(HCI_EVENT_PACKET, 0, packet, size); - } - if (security_protocol_packet_handler) { - (*security_protocol_packet_handler)(HCI_EVENT_PACKET, 0, packet, size); - } - break; - - default: - break; - } - // pass on if (packet_handler) { (*packet_handler)(NULL, HCI_EVENT_PACKET, 0, packet, size); } + if (attribute_protocol_packet_handler){ + (*attribute_protocol_packet_handler)(HCI_EVENT_PACKET, 0, packet, size) + } + if (security_protocol_packet_handler) { + (*security_protocol_packet_handler)(HCI_EVENT_PACKET, 0, packet, size) + } } void l2cap_acl_handler( uint8_t *packet, uint16_t size ){ diff --git a/src/l2cap.c b/src/l2cap.c index 70d289ae8..207fec232 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -779,7 +779,7 @@ static void l2cap_handle_connection_success_for_addr(bd_addr_t address, hci_con_ l2cap_run(); } -void l2cap_event_handler( uint8_t *packet, uint16_t size ){ +void l2cap_event_handler(uint8_t *packet, uint16_t size){ bd_addr_t address; hci_con_handle_t handle; @@ -921,8 +921,14 @@ void l2cap_event_handler( uint8_t *packet, uint16_t size ){ break; } - // pass on + // pass on: main packet handler, att and sm packet handlers (*packet_handler)(NULL, HCI_EVENT_PACKET, 0, packet, size); + if (attribute_protocol_packet_handler){ + (*attribute_protocol_packet_handler)(HCI_EVENT_PACKET, 0, packet, size); + } + if (security_protocol_packet_handler) { + (*security_protocol_packet_handler)(HCI_EVENT_PACKET, 0, packet, size); + } l2cap_run(); }