hci/sm: use btstack_packet_handler instead of (*fn)(type,packet,size) for events

This commit is contained in:
Matthias Ringwald 2016-02-04 17:45:02 +01:00
parent f3abff6765
commit d9a7306a10
37 changed files with 61 additions and 137 deletions

View File

@ -124,17 +124,13 @@ static void ancs_callback(uint8_t packet_type, uint8_t *packet, uint16_t size){
}
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
app_packet_handler(packet_type, 0, packet, size);
}
int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
printf("BTstack ANCS Client starting up...\n");
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &app_packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// set up l2cap_le
@ -149,7 +145,7 @@ int btstack_main(int argc, const char * argv[]){
sm_set_authentication_requirements( SM_AUTHREQ_BONDING );
// register for SM events
sm_event_callback_registration.callback = &hci_event_handler;
sm_event_callback_registration.callback = &app_packet_handler;
hci_add_event_handler(&sm_event_callback_registration);
// setup ATT server

View File

@ -56,7 +56,7 @@ static bd_addr_t remote = {0x84, 0x38, 0x35, 0x65, 0xD1, 0x15};
static btstack_packet_callback_registration_t hci_event_callback_registration;
static void packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
if (packet_type != HCI_EVENT_PACKET) return;
switch (packet[0]) {

View File

@ -137,7 +137,7 @@ static void continue_remote_names(void){
* INIT, and ACTIVE.
*/
static void packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
bd_addr_t addr;
int i;
int numResponses;

View File

@ -126,7 +126,7 @@ static void continue_bonding(void){
start_scan();
}
static void packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size){
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
bd_addr_t addr;
int i;
int numResponses;

View File

@ -66,7 +66,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
*/
/* LISTING_START(GAPLEAdvSetup): Setting up GAP LE client for receiving advertisements */
static void packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size);
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static void gap_le_advertisements_setup(void){
hci_event_callback_registration.callback = &packet_handler;
@ -228,7 +228,7 @@ static void dump_advertisement_data(uint8_t * adv_data, uint8_t adv_size){
/* LISTING_START(GAPLEAdvPacketHandler): Scanning and receiving advertisements */
static void packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
if (packet_type != HCI_EVENT_PACKET) return;
switch (packet[0]) {

View File

@ -235,7 +235,7 @@ static void fill_advertising_report_from_packet(advertising_report_t * report, u
dump_advertising_report(report);
}
static void hci_event_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
if (packet_type != HCI_EVENT_PACKET) return;
advertising_report_t report;
uint8_t event = packet[0];

View File

@ -106,7 +106,7 @@ static uint16_t gc_id;
// Handles connect, disconnect, and advertising report events,
// starts the GATT client, and sends the first query.
static void handle_hci_event(uint8_t packet_type, uint8_t *packet, uint16_t size);
static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
// Handles GATT client query results, sends queries and the
// GAP disconnect command when the querying is done.
@ -185,7 +185,7 @@ static void fill_advertising_report_from_packet(advertising_report_t * report, u
*/
/* LISTING_START(GATTBrowserHCIPacketHandler): Connecting and disconnecting from the GATT client */
static void handle_hci_event(uint8_t packet_type, uint8_t *packet, uint16_t size){
static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
if (packet_type != HCI_EVENT_PACKET) return;
advertising_report_t report;

View File

@ -217,7 +217,8 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
break;
}
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size){
packet_handler(packet, size);
}
@ -233,7 +234,7 @@ int btstack_main(int argc, const char * argv[]){
gap_set_local_name("BTstack HSP HS");
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &handle_hci_event;
hci_add_event_handler(&hci_event_callback_registration);
// register for SCO packets

View File

@ -87,7 +87,7 @@ static int le_notification_enabled;
static btstack_timer_source_t heartbeat;
static btstack_packet_callback_registration_t hci_event_callback_registration;
static void packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size);
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static uint16_t att_read_callback(uint16_t con_handle, uint16_t att_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size);
static int att_write_callback(uint16_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size);
static void heartbeat_handler(struct btstack_timer_source *ts);
@ -142,7 +142,7 @@ static void le_counter_setup(void){
*/
/* LISTING_START(packetHandler): Packet Handler */
static void packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size){
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
switch (packet_type) {
case HCI_EVENT_PACKET:
switch (packet[0]) {

View File

@ -74,7 +74,6 @@
static int le_notification_enabled;
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size);
static int att_write_callback(uint16_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size);
static void streamer(void);
static btstack_packet_callback_registration_t hci_event_callback_registration;
@ -106,7 +105,7 @@ static uint16_t conn_handle;
static void le_streamer_setup(void){
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
l2cap_init();
@ -205,10 +204,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
streamer();
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet_type, 0, packet, size);
}
/* LISTING_END */
/*
* @section Streamer

View File

@ -135,13 +135,12 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
/* LISTING_START(PanuSetup): Panu setup */
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size);
static void handle_sdp_client_query_result(uint8_t packet_type, uint8_t *packet, uint16_t size);
static void panu_setup(void){
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// Initialize L2CAP
@ -421,10 +420,6 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint8_t *packet,
}
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet_type, 0, packet, size);
}
/*
* @section Packet Handler
*

View File

@ -89,7 +89,7 @@ static void assertBuffer(int size){
*/
/* LISTING_START(SDPClientInit): SDP client setup */
static void packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size);
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static void handle_sdp_client_query_result(uint8_t packet_type, uint8_t *packet, uint16_t size);
static void sdp_client_init(void){
@ -116,7 +116,7 @@ static void sdp_client_init(void){
*/
/* LISTING_START(SDPQueryUUID): Querying the a list of service records on a remote device. */
static void packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size){
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
if (packet_type != HCI_EVENT_PACKET) return;
uint8_t event = packet[0];

View File

@ -79,7 +79,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
*/
/* LISTING_START(SDPClientInit): SDP client setup */
static void packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size);
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static void handle_sdp_client_query_result(uint8_t packet_type, uint8_t *packet, uint16_t size);
static void sdp_client_init(void){
@ -111,7 +111,7 @@ static bd_addr_t remote = {0x04,0x0C,0xCE,0xE4,0x85,0xD3};
/* LISTING_END */
/* LISTING_START(SDPQueryUUID): Querying a list of service records on a remote device. */
static void packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size){
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
// printf("packet_handler type %u, packet[0] %x\n", packet_type, packet[0]);
if (packet_type != HCI_EVENT_PACKET) return;

View File

@ -68,7 +68,7 @@ static char* service_name[10];
static btstack_packet_callback_registration_t hci_event_callback_registration;
static void packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size){
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
// printf("packet_handler type %u, packet[0] %x\n", packet_type, packet[0]);
if (packet_type != HCI_EVENT_PACKET) return;

View File

@ -181,10 +181,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
}
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet_type, 0, packet, size);
}
// ATT Client Read Callback for Dynamic Data
// - if buffer == NULL, don't copy data, just return size of value
// - if buffer != NULL, copy data and return number bytes copied
@ -257,7 +253,7 @@ int btstack_main(void)
hci_discoverable_control(1);
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
l2cap_init();

View File

@ -70,7 +70,6 @@
#define HEARTBEAT_PERIOD_MS 1000
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size);
static uint16_t rfcomm_channel_id;
static uint8_t spp_service_buffer[150];
@ -95,7 +94,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
static void spp_service_setup(void){
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
l2cap_init();
@ -258,9 +257,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
}
/* LISTING_RESUME */
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet_type, 0, packet, size);
}
/* LISTING_END */
int btstack_main(int argc, const char * argv[]);

View File

@ -151,9 +151,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
break;
}
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet_type, 0, packet, size);
}
static void handle_found_service(const char * name, uint8_t port){
printf("APP: Service name: '%s', RFCOMM port %u\n", name, port);
@ -194,7 +191,7 @@ int btstack_main(int argc, const char * argv[]){
printf("Client HCI init done\r\n");
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// init L2CAP

View File

@ -1639,9 +1639,6 @@ static void daemon_packet_handler(void * connection, uint8_t packet_type, uint16
daemon_emit_packet(connection, packet_type, channel, packet, size);
}
static void hci_packet_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
daemon_packet_handler(NULL, packet_type, 0, packet, size);
}
static void l2cap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * packet, uint16_t size){
daemon_packet_handler(NULL, packet_type, channel, packet, size);
}
@ -2073,7 +2070,7 @@ int main (int argc, char * const * argv){
#endif
// register for HCI events
hci_event_callback_registration.callback = &hci_packet_handler;
hci_event_callback_registration.callback = &l2cap_packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// init L2CAP

View File

@ -194,10 +194,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
}
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet, size);
}
static void heartbeat_handler(struct btstack_timer_source *ts){
if (rfcomm_channel_id){
@ -221,7 +217,7 @@ int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// init L2CAP

View File

@ -198,10 +198,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
break;
}
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet, size);
}
int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
@ -211,7 +207,7 @@ int btstack_main(int argc, const char * argv[]){
prepare_accel_packet();
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// init L2CAP

View File

@ -193,9 +193,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
break;
}
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet, size);
}
static void heartbeat_handler(struct btstack_timer_source *ts){
@ -220,7 +217,7 @@ int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// init L2CAP

View File

@ -343,9 +343,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
}
}
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet, size);
}
static hci_transport_config_uart_t config = {
HCI_TRANSPORT_CONFIG_UART,
@ -389,7 +386,7 @@ int main(void){
btstack_chipset_cc256x_enable_ehcill(1);
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// init L2CAP

View File

@ -199,9 +199,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
break;
}
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet, size);
}
int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
@ -211,7 +208,7 @@ int btstack_main(int argc, const char * argv[]){
prepare_accel_packet();
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// init L2CAP

View File

@ -196,7 +196,7 @@ static void extract_characteristic(le_characteristic_t * characteristic, uint8_t
}
}
static void handle_gatt_client_event(uint8_t packet_type, uint8_t *packet, uint16_t size){
static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
int connection_encrypted;
@ -353,9 +353,12 @@ static void handle_gatt_client_event(uint8_t packet_type, uint8_t *packet, uint1
}
// app_run();
}
static void handle_gatt_client_event(uint8_t packet_type, uint8_t * packet, uint16_t size){
handle_hci_event(packet_type, 0, packet, size);
}
void ancs_client_init(void){
hci_event_callback_registration.callback = &handle_gatt_client_event;
hci_event_callback_registration.callback = &handle_hci_event;
hci_add_event_handler(&hci_event_callback_registration);
gc_id = gatt_client_register_packet_handler(&handle_gatt_client_event);

View File

@ -354,18 +354,14 @@ static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *pa
att_run();
}
static void att_event_packet_handler2(uint8_t packet_type, uint8_t * packet, uint16_t size){
att_event_packet_handler(packet_type, 0, packet, size);
}
void att_server_init(uint8_t const * db, att_read_callback_t read_callback, att_write_callback_t write_callback){
// register for HCI Events
hci_event_callback_registration.callback = &att_event_packet_handler2;
hci_event_callback_registration.callback = &att_event_packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// register for SM events
sm_event_callback_registration.callback = &att_event_packet_handler2;
sm_event_callback_registration.callback = &att_event_packet_handler;
sm_add_event_handler(&sm_event_callback_registration);
// and L2CAP ATT Server PDUs

View File

@ -66,7 +66,7 @@ static uint8_t pts_suppress_mtu_exchange;
static btstack_packet_callback_registration_t hci_event_callback_registration;
static void gatt_client_att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size);
static void gatt_client_hci_event_packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size);
static void gatt_client_hci_event_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static void gatt_client_report_error_if_pending(gatt_client_t *peripheral, uint8_t error_code);
static void att_signed_write_handle_cmac_result(uint8_t hash[8]);
@ -1034,7 +1034,7 @@ static void gatt_client_report_error_if_pending(gatt_client_t *peripheral, uint8
emit_gatt_complete_event(peripheral, error_code);
}
static void gatt_client_hci_event_packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
static void gatt_client_hci_event_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
if (packet_type != HCI_EVENT_PACKET) return;
switch (packet[0]) {

View File

@ -486,7 +486,7 @@ static void sm_dispatch_event(uint8_t packet_type, uint16_t channel, uint8_t * p
btstack_linked_list_iterator_init(&it, &sm_event_handlers);
while (btstack_linked_list_iterator_has_next(&it)){
btstack_packet_callback_registration_t * entry = (btstack_packet_callback_registration_t*) btstack_linked_list_iterator_next(&it);
entry->callback(packet_type, packet, size);
entry->callback(packet_type, 0, packet, size);
}
}
@ -1826,7 +1826,7 @@ static void sm_handle_random_result(uint8_t * data){
}
}
static void sm_event_packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size){
static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
sm_connection_t * sm_conn;
uint16_t handle;

View File

@ -98,10 +98,10 @@ typedef uint8_t device_name_t[DEVICE_NAME_LEN+1];
// packet handler
typedef void (*btstack_packet_handler_t) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
// new packet callback supporting multiple registration
// packet callback supporting multiple registrations
typedef struct {
btstack_linked_item_t item;
void (*callback)(uint8_t packet_type, uint8_t * packet, uint16_t size);
btstack_linked_item_t item;
btstack_packet_handler_t callback;
} btstack_packet_callback_registration_t;

View File

@ -1975,10 +1975,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
hfp_run();
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet_type, 0, packet, size);
}
static void hfp_ag_set_ag_indicators(hfp_ag_indicator_t * ag_indicators, int ag_indicators_nr){
hfp_ag_indicators_nr = ag_indicators_nr;
memcpy(hfp_ag_indicators, ag_indicators, ag_indicators_nr * sizeof(hfp_ag_indicator_t));
@ -1995,7 +1991,7 @@ void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features,
}
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
l2cap_init();

View File

@ -1024,10 +1024,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
hfp_run();
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet_type, 0, packet, size);
}
void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr){
if (codecs_nr > HFP_MAX_NUM_CODECS){
log_error("hfp_hf_set_codecs: codecs_nr (%d) > HFP_MAX_NUM_CODECS (%d)", codecs_nr, HFP_MAX_NUM_CODECS);
@ -1056,7 +1052,7 @@ void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr){
void hfp_hf_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, uint16_t * indicators, int indicators_nr, uint32_t indicators_status){
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
l2cap_init();

View File

@ -257,13 +257,9 @@ static void hsp_ag_reset_state(void){
ag_speaker_gain = -1;
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet_type, 0, packet, size);
}
void hsp_ag_init(uint8_t rfcomm_channel_nr){
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// init L2CAP

View File

@ -255,13 +255,9 @@ static void hsp_hs_reset_state(void){
hs_support_custom_indications = 0;
}
static void hci_event_handler(uint8_t packet_type, uint8_t * packet, uint16_t size){
packet_handler(packet_type, 0, packet, size);
}
void hsp_hs_init(uint8_t rfcomm_channel_nr){
// register for HCI events
hci_event_callback_registration.callback = &hci_event_handler;
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);
// init L2CAP

View File

@ -2880,7 +2880,7 @@ static void hci_emit_event(uint8_t * event, uint16_t size, int dump){
btstack_linked_list_iterator_init(&it, &hci_stack->event_handlers);
while (btstack_linked_list_iterator_has_next(&it)){
btstack_packet_callback_registration_t * entry = (btstack_packet_callback_registration_t*) btstack_linked_list_iterator_next(&it);
entry->callback(HCI_EVENT_PACKET, event, size);
entry->callback(HCI_EVENT_PACKET, 0, event, size);
}
}

View File

@ -67,7 +67,6 @@
#define L2CAP_SIGNALING_COMMAND_DATA_OFFSET 4
static void null_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static void l2cap_packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size);
// used to cache l2cap rejects, echo, and informational requests
static l2cap_signaling_response_t signaling_responses[NR_PENDING_SIGNALING_RESPONSES];
@ -93,6 +92,8 @@ static void l2cap_emit_channel_opened(l2cap_channel_t *channel, uint8_t status);
static void l2cap_emit_channel_closed(l2cap_channel_t *channel);
static void l2cap_emit_connection_request(l2cap_channel_t *channel);
static int l2cap_channel_ready_for_open(l2cap_channel_t *channel);
static void l2cap_hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static void l2cap_acl_handler(uint8_t packet_type, uint8_t *packet, uint16_t size );
void l2cap_init(void){
@ -113,10 +114,10 @@ void l2cap_init(void){
//
// register callback with HCI
//
hci_event_callback_registration.callback = &l2cap_packet_handler;
hci_event_callback_registration.callback = &l2cap_hci_event_handler;
hci_add_event_handler(&hci_event_callback_registration);
hci_register_acl_packet_handler(&l2cap_packet_handler);
hci_register_acl_packet_handler(&l2cap_acl_handler);
hci_connectable_control(0); // no services yet
}
@ -818,7 +819,7 @@ static void l2cap_handle_connection_success_for_addr(bd_addr_t address, hci_con_
l2cap_run();
}
static void l2cap_event_handler(uint8_t *packet, uint16_t size){
static void l2cap_hci_event_handler(uint8_t packet_type, uint16_t cid, uint8_t *packet, uint16_t size){
bd_addr_t address;
hci_con_handle_t handle;
@ -1296,7 +1297,7 @@ static void l2cap_signaling_handler_dispatch( hci_con_handle_t handle, uint8_t *
}
}
static void l2cap_acl_handler( uint8_t *packet, uint16_t size ){
static void l2cap_acl_handler(uint8_t packet_type, uint8_t *packet, uint16_t size ){
// Get Channel ID
uint16_t channel_id = READ_L2CAP_CHANNEL_ID(packet);
@ -1409,19 +1410,7 @@ static void l2cap_acl_handler( uint8_t *packet, uint16_t size ){
break;
}
}
}
static void l2cap_packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
switch (packet_type) {
case HCI_EVENT_PACKET:
l2cap_event_handler(packet, size);
break;
case HCI_ACL_DATA_PACKET:
l2cap_acl_handler(packet, size);
break;
default:
break;
}
l2cap_run();
}

View File

@ -113,7 +113,7 @@ static hci_transport_t dummy_transport = {
};
void packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
CHECK_EQUAL(0xE2, packet[2]); // event type
CHECK_EQUAL(0x01, packet[3]); // address type
CHECK_EQUAL_ARRAY(expected_bt_addr, &packet[4], 6);

View File

@ -11,7 +11,7 @@
static btstack_packet_handler_t le_data_handler;
static void (*event_packet_handler) (uint8_t packet_type, uint8_t *packet, uint16_t size) = NULL;
static btstack_packet_handler_t event_packet_handler;
static uint8_t packet_buffer[256];
static uint16_t packet_buffer_len = 0;
@ -59,10 +59,10 @@ void aes128_calc_cyphertext(uint8_t key[16], uint8_t plaintext[16], uint8_t cyph
void mock_simulate_hci_event(uint8_t * packet, uint16_t size){
hci_dump_packet(HCI_EVENT_PACKET, 1, packet, size);
if (event_packet_handler){
event_packet_handler(HCI_EVENT_PACKET, packet, size);
event_packet_handler(HCI_EVENT_PACKET, 0, packet, size);
}
if (le_data_handler){
le_data_handler(HCI_EVENT_PACKET, NULL, packet, size);
le_data_handler(HCI_EVENT_PACKET, 0, packet, size);
}
}

View File

@ -159,10 +159,6 @@ void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet,
}
}
static void att_event_packet_handler2(uint8_t packet_type, uint8_t * packet, uint16_t size){
app_packet_handler(packet_type, 0, packet, size);
}
void CHECK_EQUAL_ARRAY(uint8_t * expected, uint8_t * actual, int size){
int i;
for (i=0; i<size; i++){
@ -186,7 +182,7 @@ TEST_GROUP(SecurityManager){
sm_init();
sm_set_io_capabilities(IO_CAPABILITY_NO_INPUT_NO_OUTPUT);
sm_set_authentication_requirements( SM_AUTHREQ_BONDING );
sm_event_callback_registration.callback = &att_event_packet_handler2;
sm_event_callback_registration.callback = &app_packet_handler;
sm_add_event_handler(&sm_event_callback_registration); }
};