diff --git a/src/l2cap.c b/src/l2cap.c index 48582d14e..25d648ab4 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -905,9 +905,6 @@ static void l2cap_event_handler(uint8_t *packet, uint16_t size){ if (!channel->packet_handler) continue; (* (channel->packet_handler))(HCI_EVENT_PACKET, channel->local_cid, packet, size); } - if (connectionless_channel_packet_handler) { - (*connectionless_channel_packet_handler)(HCI_EVENT_PACKET, 0, packet, size); - } break; case HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE: @@ -964,11 +961,8 @@ static void l2cap_event_handler(uint8_t *packet, uint16_t size){ break; } - // pass on: main packet handler, att and sm packet handlers + // pass on: main packet handler (*packet_handler)(HCI_EVENT_PACKET, 0, packet, size); - if (connectionless_channel_packet_handler) { - (*connectionless_channel_packet_handler)(HCI_EVENT_PACKET, 0, packet, size); - } l2cap_run(); } diff --git a/test/pts/Makefile b/test/pts/Makefile index a64c97973..a1b0cf057 100644 --- a/test/pts/Makefile +++ b/test/pts/Makefile @@ -3,7 +3,7 @@ BTSTACK_ROOT = ../.. CORE += main.c stdin_support.c -COMMON += hci_transport_h2_libusb.c btstack_run_loop_posix.c remote_device_db_fs.c +COMMON += hci_transport_h2_libusb.c btstack_run_loop_posix.c btstack_link_key_db_fs.c include ${BTSTACK_ROOT}/example/embedded/Makefile.inc diff --git a/test/pts/classic_test.c b/test/pts/classic_test.c index c292f445c..68556b983 100644 --- a/test/pts/classic_test.c +++ b/test/pts/classic_test.c @@ -55,6 +55,7 @@ #include "hci.h" #include "gap.h" #include "btstack_memory.h" +#include "btstack_event.h" #include "hci_dump.h" #include "l2cap.h" #include "classic/rfcomm.h" @@ -99,6 +100,8 @@ static uint32_t dummy_service_buffer[150/4]; // implicit alignment to 4-byte m static uint8_t dummy_uuid128[] = { 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1}; static uint16_t mtu; +static btstack_packet_callback_registration_t hci_event_callback_registration; + // GAP INQUIRY #define MAX_DEVICES 10 @@ -390,12 +393,12 @@ static void update_auth_req(void){ hci_ssp_set_authentication_requirement(gap_auth_req); } -static void handle_found_service(char * name, uint8_t port){ +static void handle_found_service(const char * name, uint8_t port){ printf("SDP: Service name: '%s', RFCOMM port %u\n", name, port); rfcomm_channel_nr = port; } -static void handle_query_rfcomm_event(uint8_t packet_type, uint8_t *packet, uint16_t size, void * context){ +static void handle_query_rfcomm_event(uint8_t packet_type, uint8_t *packet, uint16_t size){ switch (packet[0]){ case SDP_EVENT_QUERY_RFCOMM_SERVICE: handle_found_service(sdp_event_query_rfcomm_service_get_name(packet), @@ -752,6 +755,10 @@ static void sdp_create_dummy_service(uint8_t *service, const char *name){ de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name); } +static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){ + packet_handler(packet_type, 0, packet, size); +} + int btstack_main(int argc, const char * argv[]); int btstack_main(int argc, const char * argv[]){ @@ -765,6 +772,10 @@ int btstack_main(int argc, const char * argv[]){ hci_ssp_set_auto_accept(0); update_auth_req(); + // register for HCI events + hci_event_callback_registration.callback = &hci_event_handler; + hci_add_event_handler(&hci_event_callback_registration); + l2cap_init(); l2cap_register_packet_handler(&packet_handler); l2cap_register_fixed_channel(&packet_handler, L2CAP_CID_CONNECTIONLESS_CHANNEL); @@ -786,7 +797,7 @@ int btstack_main(int argc, const char * argv[]){ printf("Dummy service record size: %u\n\r", de_get_len((uint8_t*)dummy_service_buffer)); sdp_register_service((uint8_t*)dummy_service_buffer); - sdp_query_rfcomm_register_callback(handle_query_rfcomm_event, NULL); + sdp_query_rfcomm_register_callback(handle_query_rfcomm_event); hci_discoverable_control(0); hci_connectable_control(0);