l2cap: don't forwared HCI Events to L2CAP Connectionless Packet Handler

This commit is contained in:
Matthias Ringwald 2016-02-03 20:10:26 +01:00
parent 1a389cdc72
commit bb4c225d53
3 changed files with 16 additions and 11 deletions

View File

@ -905,9 +905,6 @@ static void l2cap_event_handler(uint8_t *packet, uint16_t size){
if (!channel->packet_handler) continue; if (!channel->packet_handler) continue;
(* (channel->packet_handler))(HCI_EVENT_PACKET, channel->local_cid, packet, size); (* (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; break;
case HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE: case HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE:
@ -964,11 +961,8 @@ static void l2cap_event_handler(uint8_t *packet, uint16_t size){
break; break;
} }
// pass on: main packet handler, att and sm packet handlers // pass on: main packet handler
(*packet_handler)(HCI_EVENT_PACKET, 0, packet, size); (*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(); l2cap_run();
} }

View File

@ -3,7 +3,7 @@ BTSTACK_ROOT = ../..
CORE += main.c stdin_support.c 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 include ${BTSTACK_ROOT}/example/embedded/Makefile.inc

View File

@ -55,6 +55,7 @@
#include "hci.h" #include "hci.h"
#include "gap.h" #include "gap.h"
#include "btstack_memory.h" #include "btstack_memory.h"
#include "btstack_event.h"
#include "hci_dump.h" #include "hci_dump.h"
#include "l2cap.h" #include "l2cap.h"
#include "classic/rfcomm.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 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 uint16_t mtu;
static btstack_packet_callback_registration_t hci_event_callback_registration;
// GAP INQUIRY // GAP INQUIRY
#define MAX_DEVICES 10 #define MAX_DEVICES 10
@ -390,12 +393,12 @@ static void update_auth_req(void){
hci_ssp_set_authentication_requirement(gap_auth_req); 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); printf("SDP: Service name: '%s', RFCOMM port %u\n", name, port);
rfcomm_channel_nr = 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]){ switch (packet[0]){
case SDP_EVENT_QUERY_RFCOMM_SERVICE: case SDP_EVENT_QUERY_RFCOMM_SERVICE:
handle_found_service(sdp_event_query_rfcomm_service_get_name(packet), 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); 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[]);
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); hci_ssp_set_auto_accept(0);
update_auth_req(); 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_init();
l2cap_register_packet_handler(&packet_handler); l2cap_register_packet_handler(&packet_handler);
l2cap_register_fixed_channel(&packet_handler, L2CAP_CID_CONNECTIONLESS_CHANNEL); 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)); 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_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_discoverable_control(0);
hci_connectable_control(0); hci_connectable_control(0);