diff --git a/example/ancs_client_demo.c b/example/ancs_client_demo.c index 52633a5ac..60a2b8ee5 100644 --- a/example/ancs_client_demo.c +++ b/example/ancs_client_demo.c @@ -87,9 +87,9 @@ static btstack_packet_callback_registration_t sm_event_callback_registration; static void app_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]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: - if (packet[2] == HCI_STATE_WORKING) { + if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING) { printf("ANCS Client Demo ready.\n"); } break; @@ -107,8 +107,8 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t * static void ancs_callback(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ const char * attribute_name; - if (packet[0] != HCI_EVENT_ANCS_META) return; - switch (packet[2]){ + if (hci_event_packet_get_type(packet) != HCI_EVENT_ANCS_META) return; + switch (hci_event_ancs_meta_get_subevent_code(packet)){ case ANCS_SUBEVENT_CLIENT_CONNECTED: printf("ANCS Client: Connected\n"); break; diff --git a/example/gap_dedicated_bonding.c b/example/gap_dedicated_bonding.c index 4cfcd67d8..0aeac71cb 100644 --- a/example/gap_dedicated_bonding.c +++ b/example/gap_dedicated_bonding.c @@ -36,21 +36,13 @@ */ -#include "btstack_config.h" #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> - -#include "hci_cmd.h" -#include "btstack_run_loop.h" - -#include "hci.h" -#include "gap.h" -#include "btstack_memory.h" -#include "hci_dump.h" +#include "btstack.h" static bd_addr_t remote = {0x84, 0x38, 0x35, 0x65, 0xD1, 0x15}; @@ -59,7 +51,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration; 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]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: // bt stack activated, get started if (packet[2] == HCI_STATE_WORKING){ diff --git a/example/gap_inquiry.c b/example/gap_inquiry.c index f17cdbe9f..5dd2f9336 100644 --- a/example/gap_inquiry.c +++ b/example/gap_inquiry.c @@ -53,17 +53,8 @@ #include <stdlib.h> #include <string.h> -#include "btstack_config.h" - -#include "btstack_run_loop.h" - -#include "btstack_debug.h" -#include "btstack_memory.h" -#include "hci.h" -#include "hci_dump.h" - -#include "classic/sdp_util.h" - +#include "btstack.h" + #define MAX_DEVICES 10 enum DEVICE_STATE { REMOTE_NAME_REQUEST, REMOTE_NAME_INQUIRED, REMOTE_NAME_FETCHED }; struct device { @@ -143,10 +134,9 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe int numResponses; int index; - // printf("packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]); if (packet_type != HCI_EVENT_PACKET) return; - uint8_t event = packet[0]; + uint8_t event = hci_event_packet_get_type(packet); switch(state){ /* @text In INIT, an inquiry scan is started, and the application transits to diff --git a/example/gap_inquiry_and_bond.c b/example/gap_inquiry_and_bond.c index 59cef260e..6be1be4fe 100644 --- a/example/gap_inquiry_and_bond.c +++ b/example/gap_inquiry_and_bond.c @@ -46,17 +46,7 @@ #include <stdlib.h> #include <string.h> -#include "btstack_config.h" - -#include "btstack_run_loop.h" - -#include "btstack_debug.h" -#include "btstack_memory.h" -#include "hci.h" -#include "hci_dump.h" -#include "gap.h" - -#include "classic/sdp_util.h" +#include "btstack.h" #define MAX_DEVICES 10 enum DEVICE_STATE { BONDING_REQUEST, BONDING_REQUESTED, BONDING_COMPLETED }; @@ -131,10 +121,9 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack int i; int numResponses; - // printf("packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]); if (packet_type != HCI_EVENT_PACKET) return; - uint8_t event = packet[0]; + uint8_t event = hci_event_packet_get_type(packet); switch(state){ diff --git a/example/gap_le_advertisements.c b/example/gap_le_advertisements.c index aeedac73d..8bdcc0a5c 100644 --- a/example/gap_le_advertisements.c +++ b/example/gap_le_advertisements.c @@ -50,11 +50,7 @@ #include <stdlib.h> #include <string.h> -#include "hci_cmd.h" - -#include "btstack_memory.h" -#include "hci.h" -#include "ble/ad_parser.h" +#include "btstack.h" static btstack_packet_callback_registration_t hci_event_callback_registration; @@ -235,7 +231,7 @@ static void dump_advertisement_data(uint8_t * adv_data, uint8_t adv_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]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: // BTstack activated, get started if (packet[2] == HCI_STATE_WORKING) { diff --git a/example/gatt_battery_query.c b/example/gatt_battery_query.c index c0308748c..4594d3d7f 100644 --- a/example/gatt_battery_query.c +++ b/example/gatt_battery_query.c @@ -131,7 +131,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint switch(state){ case TC_W4_SERVICE_RESULT: - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case GATT_EVENT_SERVICE_QUERY_RESULT: gatt_event_service_query_result_get_service(packet, &battery_service); printf("Battery service found:\n"); @@ -154,7 +154,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint break; case TC_W4_CHARACTERISTIC_RESULT: - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case GATT_EVENT_CHARACTERISTIC_QUERY_RESULT: printf("Battery level characteristic found:\n"); gatt_event_characteristic_query_result_get_characteristic(packet, &config_characteristic); @@ -170,14 +170,14 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint } break; case TC_W4_BATTERY_DATA: - if (packet[0] == GATT_EVENT_QUERY_COMPLETE){ + if (hci_event_packet_get_type(packet) == GATT_EVENT_QUERY_COMPLETE){ if (packet[4] != 0){ printf("\nNotification is not possible: "); error_code(packet[4]); } break; } - if (packet[0] != GATT_EVENT_NOTIFICATION) break; + if (hci_event_packet_get_type(packet) != GATT_EVENT_NOTIFICATION) break; printf("\nBattery Data:\n"); dump_characteristic_value(&packet[8], little_endian_read_16(packet, 6)); break; @@ -205,7 +205,7 @@ static void fill_advertising_report_from_packet(advertising_report_t * report, u 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]; + uint8_t event = hci_event_packet_get_type(packet); switch (event) { case BTSTACK_EVENT_STATE: // BTstack activated, get started diff --git a/example/gatt_browser.c b/example/gatt_browser.c index b95519ee6..659cca048 100644 --- a/example/gatt_browser.c +++ b/example/gatt_browser.c @@ -172,7 +172,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac if (packet_type != HCI_EVENT_PACKET) return; advertising_report_t report; - uint8_t event = packet[0]; + uint8_t event = hci_event_packet_get_type(packet); switch (event) { case BTSTACK_EVENT_STATE: // BTstack activated, get started @@ -226,7 +226,7 @@ static int search_services = 1; static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ gatt_client_service_t service; gatt_client_characteristic_t characteristic; - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case GATT_EVENT_SERVICE_QUERY_RESULT:\ gatt_event_service_query_result_get_service(packet, &service); dump_service(&service); diff --git a/example/le_counter.c b/example/le_counter.c index 01f35f8c5..2d2880261 100644 --- a/example/le_counter.c +++ b/example/le_counter.c @@ -50,25 +50,8 @@ #include <stdlib.h> #include <string.h> -#include "btstack_config.h" - -#include "btstack_run_loop.h" -#include "classic/sdp_util.h" - -#include "btstack_debug.h" -#include "btstack_memory.h" -#include "gap.h" -#include "hci.h" -#include "hci_dump.h" - -#include "l2cap.h" - #include "le_counter.h" - -#include "ble/att_db.h" -#include "ble/att_server.h" -#include "ble/le_device_db.h" -#include "ble/sm.h" +#include "btstack.h" #define HEARTBEAT_PERIOD_MS 1000 @@ -145,7 +128,7 @@ static void le_counter_setup(void){ 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]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: if (packet[2] == HCI_STATE_WORKING) { printf("LE Counter Demo ready.\n"); diff --git a/example/le_streamer.c b/example/le_streamer.c index 437bd25cf..b164a459f 100644 --- a/example/le_streamer.c +++ b/example/le_streamer.c @@ -54,24 +54,9 @@ #include <stdlib.h> #include <string.h> -#include "btstack_config.h" - -#include "btstack_run_loop.h" -#include "classic/sdp_util.h" - -#include "btstack_debug.h" -#include "btstack_memory.h" -#include "hci.h" -#include "hci_dump.h" -#include "l2cap.h" - +#include "btstack.h" #include "le_streamer.h" -#include "ble/att_db.h" -#include "ble/att_server.h" -#include "ble/le_device_db.h" -#include "ble/sm.h" - static int le_notification_enabled; static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); static int att_write_callback(hci_con_handle_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size); @@ -178,7 +163,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack int mtu; switch (packet_type) { case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case HCI_EVENT_DISCONNECTION_COMPLETE: le_notification_enabled = 0; break; diff --git a/example/panu_demo.c b/example/panu_demo.c index bddb7a348..6974e5f89 100644 --- a/example/panu_demo.c +++ b/example/panu_demo.c @@ -322,7 +322,7 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint8_t *packet, des_iterator_t prot_it; char *str; - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case SDP_EVENT_QUERY_ATTRIBUTE_VALUE: // Handle new SDP record if (sdp_event_query_attribute_byte_get_record_id(packet) != record_id) { @@ -436,7 +436,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack /* LISTING_RESUME */ switch (packet_type) { case HCI_EVENT_PACKET: - event = packet[0]; + event = hci_event_packet_get_type(packet); switch (event) { /* @text When BTSTACK_EVENT_STATE with state HCI_STATE_WORKING * is received and the example is started in client mode, the remote SDP BNEP query is started. diff --git a/example/sdp_bnep_query.c b/example/sdp_bnep_query.c index f17b08aa5..24effa14a 100644 --- a/example/sdp_bnep_query.c +++ b/example/sdp_bnep_query.c @@ -113,7 +113,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, uint16_t channel, uint8_t *packet, uint16_t size){ if (packet_type != HCI_EVENT_PACKET) return; - uint8_t event = packet[0]; + uint8_t event = hci_event_packet_get_type(packet); switch (event) { case BTSTACK_EVENT_STATE: @@ -166,7 +166,7 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel des_iterator_t prot_it; char *str; - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case SDP_EVENT_QUERY_ATTRIBUTE_VALUE: // handle new record if (sdp_event_query_attribute_byte_get_record_id(packet) != record_id){ diff --git a/example/sdp_general_query.c b/example/sdp_general_query.c index edacb7a0c..324b8a768 100644 --- a/example/sdp_general_query.c +++ b/example/sdp_general_query.c @@ -107,10 +107,8 @@ static bd_addr_t remote = {0x04,0x0C,0xCE,0xE4,0x85,0xD3}; /* LISTING_START(SDPQueryUUID): Querying a list of service records on a remote device. */ 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; - uint8_t event = packet[0]; + uint8_t event = hci_event_packet_get_type(packet); switch (event) { case BTSTACK_EVENT_STATE: diff --git a/example/sdp_rfcomm_query.c b/example/sdp_rfcomm_query.c index a7a43fd27..047bc1591 100644 --- a/example/sdp_rfcomm_query.c +++ b/example/sdp_rfcomm_query.c @@ -71,10 +71,8 @@ static btstack_packet_callback_registration_t hci_event_callback_registration; 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; - uint8_t event = packet[0]; + uint8_t event = hci_event_packet_get_type(packet); switch (event) { case BTSTACK_EVENT_STATE: diff --git a/example/spp_and_le_counter.c b/example/spp_and_le_counter.c index f8e1ba4e4..230c54925 100644 --- a/example/spp_and_le_counter.c +++ b/example/spp_and_le_counter.c @@ -52,28 +52,9 @@ #include <string.h> #include <inttypes.h> -#include "btstack_config.h" - -#include "btstack_run_loop.h" -#include "classic/sdp_util.h" - -#include "btstack_debug.h" -#include "btstack_memory.h" -#include "hci.h" -#include "hci_dump.h" - -#include "l2cap.h" - -#include "classic/rfcomm.h" - -#include "classic/sdp_server.h" +#include "btstack.h" #include "spp_and_le_counter.h" -#include "ble/att_db.h" -#include "ble/att_server.h" -#include "ble/le_device_db.h" -#include "ble/sm.h" - #define RFCOMM_SERVER_CHANNEL 1 #define HEARTBEAT_PERIOD_MS 1000 @@ -120,7 +101,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack switch (packet_type) { case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case HCI_EVENT_PIN_CODE_REQUEST: // inform about pin code request printf("Pin code request - using '0000'\n"); diff --git a/example/spp_counter.c b/example/spp_counter.c index 8b6adf995..8a5a54c27 100644 --- a/example/spp_counter.c +++ b/example/spp_counter.c @@ -50,21 +50,7 @@ #include <stdlib.h> #include <string.h> -#include "btstack_config.h" - -#include "btstack_run_loop.h" -#include "classic/sdp_util.h" - -#include "btstack_debug.h" -#include "btstack_memory.h" -#include "hci.h" -#include "hci_dump.h" - -#include "l2cap.h" - -#include "classic/rfcomm.h" - -#include "classic/sdp_server.h" +#include "btstack.h" #define RFCOMM_SERVER_CHANNEL 1 #define HEARTBEAT_PERIOD_MS 1000 @@ -191,7 +177,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack switch (packet_type) { case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: // BTstack activated, get started diff --git a/example/spp_flowcontrol.c b/example/spp_flowcontrol.c index d68afea16..e7c9758b6 100644 --- a/example/spp_flowcontrol.c +++ b/example/spp_flowcontrol.c @@ -145,7 +145,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack switch (packet_type) { case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: if (packet[2] == HCI_STATE_WORKING) { diff --git a/example/spp_streamer.c b/example/spp_streamer.c index 350879c6b..bb957772a 100644 --- a/example/spp_streamer.c +++ b/example/spp_streamer.c @@ -117,10 +117,8 @@ static void send_packet(void){ } 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; - uint8_t event = packet[0]; + uint8_t event = hci_event_packet_get_type(packet); switch (event) { case BTSTACK_EVENT_STATE: diff --git a/platform/daemon/example/inquiry.c b/platform/daemon/example/inquiry.c index 37279f5bc..1564812b6 100644 --- a/platform/daemon/example/inquiry.c +++ b/platform/daemon/example/inquiry.c @@ -114,7 +114,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe // printf("packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]); if (packet_type != HCI_EVENT_PACKET) return; - uint8_t event = packet[0]; + uint8_t event = hci_event_packet_get_type(packet); switch(state){ diff --git a/platform/daemon/example/l2cap_server.c b/platform/daemon/example/l2cap_server.c index 21e755d2f..657d6ead8 100644 --- a/platform/daemon/example/l2cap_server.c +++ b/platform/daemon/example/l2cap_server.c @@ -69,7 +69,6 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint int i; uint8_t status; - //printf("packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]); switch (packet_type) { case L2CAP_DATA_PACKET: @@ -80,7 +79,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_POWERON_FAILED: printf("HCI Init failed - make sure you have turned off Bluetooth in the System Settings\n"); diff --git a/platform/daemon/example/l2cap_throughput.c b/platform/daemon/example/l2cap_throughput.c index 2941b644c..98f73d310 100644 --- a/platform/daemon/example/l2cap_throughput.c +++ b/platform/daemon/example/l2cap_throughput.c @@ -94,7 +94,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_POWERON_FAILED: printf("HCI Init failed - make sure you have turned off Bluetooth in the System Settings\n"); diff --git a/platform/daemon/example/le_scan.c b/platform/daemon/example/le_scan.c index 20be7079d..fa084fd4d 100644 --- a/platform/daemon/example/le_scan.c +++ b/platform/daemon/example/le_scan.c @@ -49,10 +49,9 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ - // printf("- packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]); if (packet_type != HCI_EVENT_PACKET) return; - uint8_t event = packet[0]; + uint8_t event = hci_event_packet_get_type(packet); switch (event){ case BTSTACK_EVENT_STATE: diff --git a/platform/daemon/example/rfcomm_cat.c b/platform/daemon/example/rfcomm_cat.c index 34e470010..5572d9119 100644 --- a/platform/daemon/example/rfcomm_cat.c +++ b/platform/daemon/example/rfcomm_cat.c @@ -76,7 +76,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint break; case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_POWERON_FAILED: // handle HCI init failure diff --git a/platform/daemon/example/rfcomm_echo.c b/platform/daemon/example/rfcomm_echo.c index 53fc3ac03..15f72ef3d 100644 --- a/platform/daemon/example/rfcomm_echo.c +++ b/platform/daemon/example/rfcomm_echo.c @@ -76,7 +76,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint break; case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_POWERON_FAILED: // handle HCI init failure diff --git a/platform/daemon/example/rfcomm_test.c b/platform/daemon/example/rfcomm_test.c index 447ab76ae..255e1d718 100644 --- a/platform/daemon/example/rfcomm_test.c +++ b/platform/daemon/example/rfcomm_test.c @@ -91,7 +91,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint break; case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_POWERON_FAILED: // handle HCI init failure diff --git a/platform/daemon/example/test.c b/platform/daemon/example/test.c index 3cdfa24d1..5f953c436 100644 --- a/platform/daemon/example/test.c +++ b/platform/daemon/example/test.c @@ -62,7 +62,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_POWERON_FAILED: printf("HCI Init failed - make sure you have turned off Bluetooth in the System Settings\n"); diff --git a/platform/daemon/src/daemon.c b/platform/daemon/src/daemon.c index 99f91b450..10d5e90a8 100644 --- a/platform/daemon/src/daemon.c +++ b/platform/daemon/src/daemon.c @@ -1399,7 +1399,7 @@ static void deamon_status_event_handler(uint8_t *packet, uint16_t size){ uint8_t update_status = 0; // handle state event - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: hci_state = packet[2]; log_info("New state: %u\n", hci_state); @@ -1502,7 +1502,7 @@ static void daemon_packet_handler(void * connection, uint8_t packet_type, uint16 switch (packet_type) { case HCI_EVENT_PACKET: deamon_status_event_handler(packet, size); - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS: // ACL buffer freed... @@ -1628,7 +1628,7 @@ static void rfcomm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t } static void handle_sdp_rfcomm_service_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case SDP_EVENT_QUERY_RFCOMM_SERVICE: case SDP_EVENT_QUERY_COMPLETE: // already HCI Events, just forward them @@ -1650,7 +1650,7 @@ static void sdp_client_assert_buffer(int size){ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ int event_len; - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case SDP_EVENT_QUERY_ATTRIBUTE_BYTE: sdp_client_assert_buffer(sdp_event_query_attribute_byte_get_attribute_length(packet)); attribute_value[sdp_event_query_attribute_byte_get_data_offset(packet)] = sdp_event_query_attribute_byte_get_data(packet); @@ -1804,7 +1804,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint // hack: handle disconnection_complete_here instead of main hci event packet handler // we receive a HCI event packet in disguise - if (packet[0] == HCI_EVENT_DISCONNECTION_COMPLETE){ + if (hci_event_packet_get_type(packet) == HCI_EVENT_DISCONNECTION_COMPLETE){ log_info("daemon hack: handle disconnection_complete in handle_gatt_client_event instead of main hci event packet handler"); hci_con_handle_t con_handle = little_endian_read_16(packet, 3); daemon_remove_gatt_client_helper(con_handle); @@ -1812,7 +1812,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint } // only handle GATT Events - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case GATT_EVENT_SERVICE_QUERY_RESULT: case GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT: case GATT_EVENT_NOTIFICATION: @@ -1839,7 +1839,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint connection_t *connection = NULL; // daemon doesn't track which connection subscribed to this particular handle, so we just notify all connections - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case GATT_EVENT_NOTIFICATION: case GATT_EVENT_INDICATION:{ hci_dump_packet(HCI_EVENT_PACKET, 0, packet, size); @@ -1862,7 +1862,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint if (!connection) return; - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case GATT_EVENT_SERVICE_QUERY_RESULT: case GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT: @@ -1878,7 +1878,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint case GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT: offset = little_endian_read_16(packet, 6); length = little_endian_read_16(packet, 8); - gatt_client_helper->characteristic_buffer[0] = packet[0]; // store type (characteristic/descriptor) + gatt_client_helper->characteristic_buffer[0] = hci_event_packet_get_type(packet); // store type (characteristic/descriptor) gatt_client_helper->characteristic_handle = little_endian_read_16(packet, 4); // store attribute handle gatt_client_helper->characteristic_length = offset + length; // update length memcpy(&gatt_client_helper->characteristic_buffer[10 + offset], &packet[10], length); diff --git a/port/arduino/BTstack.cpp b/port/arduino/BTstack.cpp index 3ac0b0fd2..897c37d78 100644 --- a/port/arduino/BTstack.cpp +++ b/port/arduino/BTstack.cpp @@ -229,7 +229,7 @@ static void gatt_client_callback(uint8_t packet_type, uint8_t * packet, uint16_t uint16_t value_length; BLEDevice device(con_handle); - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case GATT_EVENT_SERVICE_QUERY_RESULT: if (gattServiceDiscoveredCallback) { gatt_client_service_t service; diff --git a/port/arduino/examples/ANCS/ANCS.ino b/port/arduino/examples/ANCS/ANCS.ino index 26d88e2fc..f299902c6 100644 --- a/port/arduino/examples/ANCS/ANCS.ino +++ b/port/arduino/examples/ANCS/ANCS.ino @@ -74,8 +74,8 @@ void loop(void){ /* LISTING_START(ANCSCallback): ANCS Callback */ void ancs_callback(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ const char * attribute_name; - if (packet[0] != HCI_EVENT_ANCS_META) return; - switch (packet[0]){ + if (hci_event_packet_get_type(packet) != HCI_EVENT_ANCS_META) return; + switch (hci_event_ancs_meta_get_subevent_code()]){ case ANCS_SUBEVENT_CLIENT_CONNECTED: Serial.println("ANCS Client: Connected"); break; diff --git a/port/ez430-rf2560/example/ant_test.c b/port/ez430-rf2560/example/ant_test.c index 16550f30c..b73a07f3c 100644 --- a/port/ez430-rf2560/example/ant_test.c +++ b/port/ez430-rf2560/example/ant_test.c @@ -65,6 +65,7 @@ #include "hci.h" #include "l2cap.h" #include "btstack_memory.h" +#include "btstack_event.h" #include "classic/btstack_link_key_db.h" #include "classic/rfcomm.h" #include "classic/sdp_server.h" @@ -90,7 +91,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack switch (packet_type) { case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: if (packet[2] == HCI_STATE_WORKING) { diff --git a/port/ez430-rf2560/example/spp_accel.c b/port/ez430-rf2560/example/spp_accel.c index 3988f18f4..9f601d651 100644 --- a/port/ez430-rf2560/example/spp_accel.c +++ b/port/ez430-rf2560/example/spp_accel.c @@ -130,7 +130,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack switch (packet_type) { case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: if (packet[2] == HCI_STATE_WORKING) { diff --git a/port/ios/CocoaTouch/src/BTInquiryViewController.m b/port/ios/CocoaTouch/src/BTInquiryViewController.m index 5e5f2cf62..b28bdc15b 100644 --- a/port/ios/CocoaTouch/src/BTInquiryViewController.m +++ b/port/ios/CocoaTouch/src/BTInquiryViewController.m @@ -127,7 +127,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe case HCI_EVENT_PACKET: - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case BTSTACK_EVENT_STATE: // bt stack activated @@ -172,7 +172,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe [dev setAddress:addr]; [dev setPageScanRepetitionMode:packet[offset]]; offset += 1; - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case HCI_EVENT_INQUIRY_RESULT: offset += 2; // Reserved + Reserved [dev setClassOfDevice:little_endian_read_24(packet, 3 + numResponses*(6+1+1+1) + i*3)]; diff --git a/port/ios/CocoaTouch/src/BTstackManager.m b/port/ios/CocoaTouch/src/BTstackManager.m index 56a2b5c92..0b70ef286 100644 --- a/port/ios/CocoaTouch/src/BTstackManager.m +++ b/port/ios/CocoaTouch/src/BTstackManager.m @@ -264,7 +264,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe case kW4SysBTDisabled: // DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED - if ( packet[0] == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED){ + if ( hci_event_packet_get_type(packet) == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED){ if (packet[2]){ // system bt on - first time try to disable it if ( state == kW4SysBTState) { @@ -289,7 +289,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe break; case kW4Activated: - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case BTSTACK_EVENT_STATE: if (packet[2] == HCI_STATE_WORKING) { state = kActivated; @@ -307,21 +307,21 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe break; case kW4Deactivated: - if (packet[0] != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_OFF){ + if (hci_event_packet_get_type(packet) != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_OFF){ state = kDeactivated; [self sendDeactivated]; } break; case kActivated: - if (packet[0] != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_FALLING_ASLEEP){ + if (hci_event_packet_get_type(packet) != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_FALLING_ASLEEP){ state = kSleeping; [self sendSleepEnter]; } break; case kSleeping: - if (packet[0] != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_WORKING){ + if (hci_event_packet_get_type(packet) != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_WORKING){ state = kActivated; [self sendSleepExit]; } @@ -403,7 +403,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe break; case kW4InquiryMode: - if (packet[0] == HCI_EVENT_COMMAND_COMPLETE && COMMAND_COMPLETE_EVENT(packet, hci_write_inquiry_mode) ) { + if (hci_event_packet_get_type(packet) == HCI_EVENT_COMMAND_COMPLETE && COMMAND_COMPLETE_EVENT(packet, hci_write_inquiry_mode) ) { discoveryState = kInquiry; bt_send_cmd(&hci_inquiry, HCI_INQUIRY_LAP, INQUIRY_INTERVAL, 0); [self sendDiscoveryInquiry]; @@ -412,7 +412,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe case kInquiry: - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case HCI_EVENT_INQUIRY_RESULT: numResponses = packet[2]; for (i=0; i<numResponses ; i++){ @@ -472,20 +472,20 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe break; case kRemoteName: - if (packet[0] == HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE){ + if (hci_event_packet_get_type(packet) == HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE){ [self handleRemoteName:packet]; } break; case kW4InquiryModeBeforeStop: - if (packet[0] == HCI_EVENT_COMMAND_COMPLETE && COMMAND_COMPLETE_EVENT(packet, hci_write_inquiry_mode) ) { + if (hci_event_packet_get_type(packet) == HCI_EVENT_COMMAND_COMPLETE && COMMAND_COMPLETE_EVENT(packet, hci_write_inquiry_mode) ) { discoveryState = kInactive; [self sendDiscoveryStoppedEvent]; } break; case kW4InquiryStop: - if (packet[0] == HCI_EVENT_INQUIRY_COMPLETE + if (hci_event_packet_get_type(packet) == HCI_EVENT_INQUIRY_COMPLETE || COMMAND_COMPLETE_EVENT(packet, hci_inquiry_cancel)) { discoveryState = kInactive; [self sendDiscoveryStoppedEvent]; @@ -493,7 +493,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe break; case kW4RemoteNameBeforeStop: - if (packet[0] == HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE + if (hci_event_packet_get_type(packet) == HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE || COMMAND_COMPLETE_EVENT(packet, hci_remote_name_request_cancel)){ discoveryState = kInactive; [self sendDiscoveryStoppedEvent]; diff --git a/port/ios/PrefsBundle/BluetoothController.m b/port/ios/PrefsBundle/BluetoothController.m index 25141e509..06d31222e 100644 --- a/port/ios/PrefsBundle/BluetoothController.m +++ b/port/ios/PrefsBundle/BluetoothController.m @@ -32,6 +32,7 @@ #import "BluetoothController.h" #include "btstack_run_loop.h" #include "btstack_run_loop_cocoa.h" +#include "btstack_event.h" #pragma mark callback handler static void btstackStoppedCallback(CFNotificationCenterRef center, @@ -179,7 +180,7 @@ static BluetoothController* sharedInstance = nil; // NSLog(@"bt_packet_handler event: %u, state %u", packet[0], state); // update state - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case BTSTACK_EVENT_STATE: hci_state = packet[2]; // NSLog(@"new BTSTACK_EVENT_STATE %u", hci_state); @@ -195,7 +196,7 @@ static BluetoothController* sharedInstance = nil; switch(state){ case kIdle: - if (packet[0] == BTSTACK_EVENT_STATE) { + if (hci_event_packet_get_type(packet) == BTSTACK_EVENT_STATE) { if (hci_state == HCI_STATE_OFF) { bt_send_cmd(&btstack_get_system_bluetooth_enabled); } else { @@ -205,7 +206,7 @@ static BluetoothController* sharedInstance = nil; break; case kW4SystemOffToEnableBTstack: - if (packet[0] == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED) { + if (hci_event_packet_get_type(packet) == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED) { if (system_bluetooth == 0){ bt_send_cmd(&btstack_set_power_mode, HCI_POWER_ON); state = kIdle; @@ -214,13 +215,13 @@ static BluetoothController* sharedInstance = nil; break; case kW4BTstackOffToEnableSystem: - if (packet[0] == BTSTACK_EVENT_STATE) { + if (hci_event_packet_get_type(packet) == BTSTACK_EVENT_STATE) { if (hci_state == HCI_STATE_OFF) { // NSLog(@"Sending set system bluetooth enable A"); bt_send_cmd(&btstack_set_system_bluetooth_enabled, 1); } } - if (packet[0] == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED) { + if (hci_event_packet_get_type(packet) == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED) { if (system_bluetooth == 0){ // NSLog(@"Sending set system bluetooth enable B"); bt_send_cmd(&btstack_set_system_bluetooth_enabled, 1); diff --git a/port/ios/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m b/port/ios/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m index faa0783ea..87940f20e 100644 --- a/port/ios/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m +++ b/port/ios/example/WiiMoteOpenGLDemo/Classes/WiiMoteOpenGLDemoAppDelegate.m @@ -157,7 +157,7 @@ static float addToHistory(int history[histSize], int value){ case HCI_EVENT_PACKET: - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case HCI_EVENT_COMMAND_COMPLETE: if ( COMMAND_COMPLETE_EVENT(packet, hci_write_authentication_enable) ) { diff --git a/port/msp-exp430f5438-cc2564b/example/ant_test.c b/port/msp-exp430f5438-cc2564b/example/ant_test.c index dd15fa2a1..5ea6b55c5 100644 --- a/port/msp-exp430f5438-cc2564b/example/ant_test.c +++ b/port/msp-exp430f5438-cc2564b/example/ant_test.c @@ -90,7 +90,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack switch (packet_type) { case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: if (packet[2] == HCI_STATE_WORKING) { diff --git a/port/msp-exp430f5438-cc2564b/example/ble_server.c b/port/msp-exp430f5438-cc2564b/example/ble_server.c index 4ae74600c..c7b46d9ae 100644 --- a/port/msp-exp430f5438-cc2564b/example/ble_server.c +++ b/port/msp-exp430f5438-cc2564b/example/ble_server.c @@ -116,7 +116,7 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t * bd_addr_t addr; uint8_t adv_data[] = { 02, 01, 05, 03, 02, 0xf0, 0xff }; - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: // bt stack activated, get started - set local name if (packet[2] == HCI_STATE_WORKING) { diff --git a/port/msp-exp430f5438-cc2564b/example/hid_demo.c b/port/msp-exp430f5438-cc2564b/example/hid_demo.c index 41982a5a2..535d356ba 100644 --- a/port/msp-exp430f5438-cc2564b/example/hid_demo.c +++ b/port/msp-exp430f5438-cc2564b/example/hid_demo.c @@ -229,7 +229,7 @@ unsigned char hid_process_packet(unsigned char *hid_report, uint16_t *buffer, ui static void l2cap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ - if (packet_type == HCI_EVENT_PACKET && packet[0] == L2CAP_EVENT_CHANNEL_OPENED){ + if (packet_type == HCI_EVENT_PACKET && hci_event_packet_get_type(packet) == L2CAP_EVENT_CHANNEL_OPENED){ if (packet[2]) { printf("Connection failed\n\r"); return; @@ -277,7 +277,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack int i,j; switch (packet_type) { case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: // bt stack activated, get started - set local name diff --git a/port/msp-exp430f5438-cc2564b/example/spp_accel.c b/port/msp-exp430f5438-cc2564b/example/spp_accel.c index c3a7f280f..88fbd15fd 100644 --- a/port/msp-exp430f5438-cc2564b/example/spp_accel.c +++ b/port/msp-exp430f5438-cc2564b/example/spp_accel.c @@ -131,7 +131,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack switch (packet_type) { case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: if (packet[2] == HCI_STATE_WORKING) { diff --git a/port/msp430f5229lp-cc2564b/example/ble_server.c b/port/msp430f5229lp-cc2564b/example/ble_server.c index c36e953ce..3f972dc24 100644 --- a/port/msp430f5229lp-cc2564b/example/ble_server.c +++ b/port/msp430f5229lp-cc2564b/example/ble_server.c @@ -91,7 +91,7 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t * bd_addr_t addr; uint8_t adv_data[] = { 02, 01, 05, 03, 02, 0xf0, 0xff }; - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: // bt stack activated, get started - set local name if (packet[2] == HCI_STATE_WORKING) { diff --git a/src/ble/ancs_client.c b/src/ble/ancs_client.c index 1d9581137..d1729866c 100644 --- a/src/ble/ancs_client.c +++ b/src/ble/ancs_client.c @@ -182,7 +182,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac int connection_encrypted; // handle connect / disconncet events first - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case HCI_EVENT_LE_META: switch (packet[2]) { case HCI_SUBEVENT_LE_CONNECTION_COMPLETE: @@ -226,7 +226,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac switch(tc_state){ case TC_W4_SERVICE_RESULT: - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case GATT_EVENT_SERVICE_QUERY_RESULT: gatt_event_service_query_result_get_service(packet, &ancs_service); ancs_service_found = 1; @@ -247,7 +247,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac break; case TC_W4_CHARACTERISTIC_RESULT: - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case GATT_EVENT_CHARACTERISTIC_QUERY_RESULT: gatt_event_characteristic_query_result_get_characteristic(packet, &characteristic); if (memcmp(characteristic.uuid128, ancs_notification_source_uuid, 16) == 0){ @@ -280,7 +280,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac } break; case TC_W4_NOTIFICATION_SOURCE_SUBSCRIBED: - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case GATT_EVENT_QUERY_COMPLETE: log_info("ANCS Notification Source subscribed"); tc_state = TC_W4_DATA_SOURCE_SUBSCRIBED; @@ -293,7 +293,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac } break; case TC_W4_DATA_SOURCE_SUBSCRIBED: - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ case GATT_EVENT_QUERY_COMPLETE: log_info("ANCS Data Source subscribed"); tc_state = TC_SUBSCRIBED; @@ -304,7 +304,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac } break; case TC_SUBSCRIBED: - if (packet[0] != GATT_EVENT_NOTIFICATION && packet[0] != GATT_EVENT_INDICATION ) break; + if (hci_event_packet_get_type(packet) != GATT_EVENT_NOTIFICATION && hci_event_packet_get_type(packet) != GATT_EVENT_INDICATION ) break; value_handle = little_endian_read_16(packet, 4); value_length = little_endian_read_16(packet, 6); diff --git a/src/ble/att_server.c b/src/ble/att_server.c index 02ceeabd5..7420830fe 100644 --- a/src/ble/att_server.c +++ b/src/ble/att_server.c @@ -48,12 +48,12 @@ #include "btstack_config.h" -#include "btstack_run_loop.h" #include "btstack_debug.h" +#include "btstack_event.h" #include "btstack_memory.h" +#include "btstack_run_loop.h" #include "hci.h" #include "hci_dump.h" - #include "l2cap.h" #include "ble/sm.h" @@ -137,7 +137,7 @@ static void att_event_packet_handler (uint8_t packet_type, uint16_t channel, uin switch (packet_type) { case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case L2CAP_EVENT_CAN_SEND_NOW: att_run(); diff --git a/src/ble/gatt_client.c b/src/ble/gatt_client.c index 47d3c75b7..c703c28e0 100644 --- a/src/ble/gatt_client.c +++ b/src/ble/gatt_client.c @@ -39,25 +39,25 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "btstack_run_loop.h" -#include "hci_cmd.h" -#include "btstack_util.h" -#include "classic/sdp_util.h" #include "btstack_config.h" -#include "ble/gatt_client.h" +#include "att_dispatch.h" #include "ble/ad_parser.h" - +#include "ble/att_db.h" +#include "ble/gatt_client.h" +#include "ble/le_device_db.h" +#include "ble/sm.h" #include "btstack_debug.h" +#include "btstack_event.h" #include "btstack_memory.h" +#include "btstack_run_loop.h" +#include "btstack_util.h" +#include "classic/sdp_util.h" #include "hci.h" +#include "hci_cmd.h" #include "hci_dump.h" #include "l2cap.h" -#include "ble/att_db.h" -#include "att_dispatch.h" -#include "ble/sm.h" -#include "ble/le_device_db.h" static btstack_linked_list_t gatt_client_connections; static btstack_linked_list_t gatt_client_value_listeners; @@ -998,7 +998,7 @@ static void gatt_client_report_error_if_pending(gatt_client_t *peripheral, uint8 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]) { + switch (hci_event_packet_get_type(packet)) { case HCI_EVENT_DISCONNECTION_COMPLETE: { log_info("GATT Client: HCI_EVENT_DISCONNECTION_COMPLETE"); diff --git a/src/ble/sm.c b/src/ble/sm.c index f6c75b7ba..b66687489 100644 --- a/src/ble/sm.c +++ b/src/ble/sm.c @@ -39,15 +39,15 @@ #include <string.h> #include <inttypes.h> -#include "btstack_linked_list.h" - -#include "btstack_memory.h" -#include "btstack_debug.h" -#include "hci.h" -#include "l2cap.h" #include "ble/le_device_db.h" #include "ble/sm.h" +#include "btstack_debug.h" +#include "btstack_event.h" +#include "btstack_linked_list.h" +#include "btstack_memory.h" #include "gap.h" +#include "hci.h" +#include "l2cap.h" // // SM internal types and globals @@ -1834,7 +1834,7 @@ static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint switch (packet_type) { case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case BTSTACK_EVENT_STATE: // bt stack activated, get started diff --git a/src/btstack_event.h b/src/btstack_event.h index e863c28eb..54bb060b4 100644 --- a/src/btstack_event.h +++ b/src/btstack_event.h @@ -60,9 +60,42 @@ extern "C" { /* API_START */ +/** + * @brief Get event type + * @param event + * @return type of event + */ +static inline uint8_t hci_event_packet_get_type(const uint8_t * event){ + return event[0]; +} + +/*** + * @brief Get subevent code for hsp event + * @param event packet + * @return subevent_code + */ +static inline uint8_t hci_event_hsp_meta_get_subevent_code(const uint8_t * event){ + return event[2]; +} +/*** + * @brief Get subevent code for hfp event + * @param event packet + * @return subevent_code + */ +static inline uint8_t hci_event_hfp_meta_get_subevent_code(const uint8_t * event){ + return event[2]; +} +/*** + * @brief Get subevent code for ancs event + * @param event packet + * @return subevent_code + */ +static inline uint8_t hci_event_ancs_meta_get_subevent_code(const uint8_t * event){ + return event[2]; +} /** * @brief Get field status from event hci_event_inquiry_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -72,7 +105,7 @@ static inline uint8_t hci_event_inquiry_complete_get_status(const uint8_t * even /** * @brief Get field num_responses from event hci_event_inquiry_result - * @param Event packet + * @param event packet * @return num_responses * @note: btstack_type 1 */ @@ -81,7 +114,7 @@ static inline uint8_t hci_event_inquiry_result_get_num_responses(const uint8_t * } /** * @brief Get field bd_addr from event hci_event_inquiry_result - * @param Event packet + * @param event packet * @param Pointer to storage for bd_addr * @note: btstack_type B */ @@ -90,7 +123,7 @@ static inline void hci_event_inquiry_result_get_bd_addr(const uint8_t * event, b } /** * @brief Get field page_scan_repetition_mode from event hci_event_inquiry_result - * @param Event packet + * @param event packet * @return page_scan_repetition_mode * @note: btstack_type 1 */ @@ -99,7 +132,7 @@ static inline uint8_t hci_event_inquiry_result_get_page_scan_repetition_mode(con } /** * @brief Get field reserved1 from event hci_event_inquiry_result - * @param Event packet + * @param event packet * @return reserved1 * @note: btstack_type 1 */ @@ -108,7 +141,7 @@ static inline uint8_t hci_event_inquiry_result_get_reserved1(const uint8_t * eve } /** * @brief Get field reserved2 from event hci_event_inquiry_result - * @param Event packet + * @param event packet * @return reserved2 * @note: btstack_type 1 */ @@ -117,7 +150,7 @@ static inline uint8_t hci_event_inquiry_result_get_reserved2(const uint8_t * eve } /** * @brief Get field class_of_device from event hci_event_inquiry_result - * @param Event packet + * @param event packet * @return class_of_device * @note: btstack_type 3 */ @@ -126,7 +159,7 @@ static inline uint32_t hci_event_inquiry_result_get_class_of_device(const uint8_ } /** * @brief Get field clock_offset from event hci_event_inquiry_result - * @param Event packet + * @param event packet * @return clock_offset * @note: btstack_type 2 */ @@ -136,7 +169,7 @@ static inline uint16_t hci_event_inquiry_result_get_clock_offset(const uint8_t * /** * @brief Get field status from event hci_event_connection_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -145,7 +178,7 @@ static inline uint8_t hci_event_connection_complete_get_status(const uint8_t * e } /** * @brief Get field connection_handle from event hci_event_connection_complete - * @param Event packet + * @param event packet * @return connection_handle * @note: btstack_type 2 */ @@ -154,7 +187,7 @@ static inline uint16_t hci_event_connection_complete_get_connection_handle(const } /** * @brief Get field bd_addr from event hci_event_connection_complete - * @param Event packet + * @param event packet * @param Pointer to storage for bd_addr * @note: btstack_type B */ @@ -163,7 +196,7 @@ static inline void hci_event_connection_complete_get_bd_addr(const uint8_t * eve } /** * @brief Get field link_type from event hci_event_connection_complete - * @param Event packet + * @param event packet * @return link_type * @note: btstack_type 1 */ @@ -172,7 +205,7 @@ static inline uint8_t hci_event_connection_complete_get_link_type(const uint8_t } /** * @brief Get field encryption_enabled from event hci_event_connection_complete - * @param Event packet + * @param event packet * @return encryption_enabled * @note: btstack_type 1 */ @@ -182,7 +215,7 @@ static inline uint8_t hci_event_connection_complete_get_encryption_enabled(const /** * @brief Get field bd_addr from event hci_event_connection_request - * @param Event packet + * @param event packet * @param Pointer to storage for bd_addr * @note: btstack_type B */ @@ -191,7 +224,7 @@ static inline void hci_event_connection_request_get_bd_addr(const uint8_t * even } /** * @brief Get field class_of_device from event hci_event_connection_request - * @param Event packet + * @param event packet * @return class_of_device * @note: btstack_type 3 */ @@ -200,7 +233,7 @@ static inline uint32_t hci_event_connection_request_get_class_of_device(const ui } /** * @brief Get field link_type from event hci_event_connection_request - * @param Event packet + * @param event packet * @return link_type * @note: btstack_type 1 */ @@ -210,7 +243,7 @@ static inline uint8_t hci_event_connection_request_get_link_type(const uint8_t * /** * @brief Get field status from event hci_event_disconnection_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -219,7 +252,7 @@ static inline uint8_t hci_event_disconnection_complete_get_status(const uint8_t } /** * @brief Get field connection_handle from event hci_event_disconnection_complete - * @param Event packet + * @param event packet * @return connection_handle * @note: btstack_type 2 */ @@ -228,7 +261,7 @@ static inline uint16_t hci_event_disconnection_complete_get_connection_handle(co } /** * @brief Get field reason from event hci_event_disconnection_complete - * @param Event packet + * @param event packet * @return reason * @note: btstack_type 1 */ @@ -238,7 +271,7 @@ static inline uint8_t hci_event_disconnection_complete_get_reason(const uint8_t /** * @brief Get field status from event hci_event_authentication_complete_event - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -247,7 +280,7 @@ static inline uint8_t hci_event_authentication_complete_event_get_status(const u } /** * @brief Get field connection_handle from event hci_event_authentication_complete_event - * @param Event packet + * @param event packet * @return connection_handle * @note: btstack_type 2 */ @@ -257,7 +290,7 @@ static inline uint16_t hci_event_authentication_complete_event_get_connection_ha /** * @brief Get field status from event hci_event_remote_name_request_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -266,7 +299,7 @@ static inline uint16_t hci_event_authentication_complete_event_get_connection_ha // } /** * @brief Get field bd_addr from event hci_event_remote_name_request_complete - * @param Event packet + * @param event packet * @return bd_addr * @note: btstack_type B */ @@ -275,7 +308,7 @@ static inline uint16_t hci_event_authentication_complete_event_get_connection_ha // } /** * @brief Get field remote_name from event hci_event_remote_name_request_complete - * @param Event packet + * @param event packet * @return remote_name * @note: btstack_type N */ @@ -285,7 +318,7 @@ static inline uint16_t hci_event_authentication_complete_event_get_connection_ha /** * @brief Get field status from event hci_event_encryption_change - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -294,7 +327,7 @@ static inline uint8_t hci_event_encryption_change_get_status(const uint8_t * eve } /** * @brief Get field connection_handle from event hci_event_encryption_change - * @param Event packet + * @param event packet * @return connection_handle * @note: btstack_type 2 */ @@ -303,7 +336,7 @@ static inline uint16_t hci_event_encryption_change_get_connection_handle(const u } /** * @brief Get field encryption_enabled from event hci_event_encryption_change - * @param Event packet + * @param event packet * @return encryption_enabled * @note: btstack_type 1 */ @@ -313,7 +346,7 @@ static inline uint8_t hci_event_encryption_change_get_encryption_enabled(const u /** * @brief Get field status from event hci_event_change_connection_link_key_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -322,7 +355,7 @@ static inline uint8_t hci_event_change_connection_link_key_complete_get_status(c } /** * @brief Get field connection_handle from event hci_event_change_connection_link_key_complete - * @param Event packet + * @param event packet * @return connection_handle * @note: btstack_type 2 */ @@ -332,7 +365,7 @@ static inline uint16_t hci_event_change_connection_link_key_complete_get_connect /** * @brief Get field status from event hci_event_master_link_key_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -341,7 +374,7 @@ static inline uint8_t hci_event_master_link_key_complete_get_status(const uint8_ } /** * @brief Get field connection_handle from event hci_event_master_link_key_complete - * @param Event packet + * @param event packet * @return connection_handle * @note: btstack_type 2 */ @@ -350,7 +383,7 @@ static inline uint16_t hci_event_master_link_key_complete_get_connection_handle( } /** * @brief Get field key_flag from event hci_event_master_link_key_complete - * @param Event packet + * @param event packet * @return key_flag * @note: btstack_type 1 */ @@ -360,7 +393,7 @@ static inline uint8_t hci_event_master_link_key_complete_get_key_flag(const uint /** * @brief Get field num_hci_command_packets from event hci_event_command_complete - * @param Event packet + * @param event packet * @return num_hci_command_packets * @note: btstack_type 1 */ @@ -369,7 +402,7 @@ static inline uint8_t hci_event_command_complete_get_num_hci_command_packets(con } /** * @brief Get field command_opcode from event hci_event_command_complete - * @param Event packet + * @param event packet * @return command_opcode * @note: btstack_type 2 */ @@ -378,7 +411,7 @@ static inline uint16_t hci_event_command_complete_get_command_opcode(const uint8 } /** * @brief Get field return_parameters from event hci_event_command_complete - * @param Event packet + * @param event packet * @return return_parameters * @note: btstack_type R */ @@ -388,7 +421,7 @@ static inline const uint8_t * hci_event_command_complete_get_return_parameters(c /** * @brief Get field status from event hci_event_command_status - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -397,7 +430,7 @@ static inline uint8_t hci_event_command_status_get_status(const uint8_t * event) } /** * @brief Get field num_hci_command_packets from event hci_event_command_status - * @param Event packet + * @param event packet * @return num_hci_command_packets * @note: btstack_type 1 */ @@ -406,7 +439,7 @@ static inline uint8_t hci_event_command_status_get_num_hci_command_packets(const } /** * @brief Get field command_opcode from event hci_event_command_status - * @param Event packet + * @param event packet * @return command_opcode * @note: btstack_type 2 */ @@ -416,7 +449,7 @@ static inline uint16_t hci_event_command_status_get_command_opcode(const uint8_t /** * @brief Get field hardware_code from event hci_event_hardware_error - * @param Event packet + * @param event packet * @return hardware_code * @note: btstack_type 1 */ @@ -426,7 +459,7 @@ static inline uint8_t hci_event_hardware_error_get_hardware_code(const uint8_t * /** * @brief Get field status from event hci_event_role_change - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -435,7 +468,7 @@ static inline uint8_t hci_event_role_change_get_status(const uint8_t * event){ } /** * @brief Get field bd_addr from event hci_event_role_change - * @param Event packet + * @param event packet * @param Pointer to storage for bd_addr * @note: btstack_type B */ @@ -444,7 +477,7 @@ static inline void hci_event_role_change_get_bd_addr(const uint8_t * event, bd_a } /** * @brief Get field role from event hci_event_role_change - * @param Event packet + * @param event packet * @return role * @note: btstack_type 1 */ @@ -454,7 +487,7 @@ static inline uint8_t hci_event_role_change_get_role(const uint8_t * event){ /** * @brief Get field num_responses from event hci_event_inquiry_result_with_rssi - * @param Event packet + * @param event packet * @return num_responses * @note: btstack_type 1 */ @@ -463,7 +496,7 @@ static inline uint8_t hci_event_inquiry_result_with_rssi_get_num_responses(const } /** * @brief Get field bd_addr from event hci_event_inquiry_result_with_rssi - * @param Event packet + * @param event packet * @param Pointer to storage for bd_addr * @note: btstack_type B */ @@ -472,7 +505,7 @@ static inline void hci_event_inquiry_result_with_rssi_get_bd_addr(const uint8_t } /** * @brief Get field page_scan_repetition_mode from event hci_event_inquiry_result_with_rssi - * @param Event packet + * @param event packet * @return page_scan_repetition_mode * @note: btstack_type 1 */ @@ -481,7 +514,7 @@ static inline uint8_t hci_event_inquiry_result_with_rssi_get_page_scan_repetitio } /** * @brief Get field reserved from event hci_event_inquiry_result_with_rssi - * @param Event packet + * @param event packet * @return reserved * @note: btstack_type 1 */ @@ -490,7 +523,7 @@ static inline uint8_t hci_event_inquiry_result_with_rssi_get_reserved(const uint } /** * @brief Get field class_of_device from event hci_event_inquiry_result_with_rssi - * @param Event packet + * @param event packet * @return class_of_device * @note: btstack_type 3 */ @@ -499,7 +532,7 @@ static inline uint32_t hci_event_inquiry_result_with_rssi_get_class_of_device(co } /** * @brief Get field clock_offset from event hci_event_inquiry_result_with_rssi - * @param Event packet + * @param event packet * @return clock_offset * @note: btstack_type 2 */ @@ -508,7 +541,7 @@ static inline uint16_t hci_event_inquiry_result_with_rssi_get_clock_offset(const } /** * @brief Get field rssi from event hci_event_inquiry_result_with_rssi - * @param Event packet + * @param event packet * @return rssi * @note: btstack_type 1 */ @@ -518,7 +551,7 @@ static inline uint8_t hci_event_inquiry_result_with_rssi_get_rssi(const uint8_t /** * @brief Get field status from event hci_event_synchronous_connection_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -527,7 +560,7 @@ static inline uint8_t hci_event_synchronous_connection_complete_get_status(const } /** * @brief Get field handle from event hci_event_synchronous_connection_complete - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -536,7 +569,7 @@ static inline hci_con_handle_t hci_event_synchronous_connection_complete_get_han } /** * @brief Get field bd_addr from event hci_event_synchronous_connection_complete - * @param Event packet + * @param event packet * @param Pointer to storage for bd_addr * @note: btstack_type B */ @@ -545,7 +578,7 @@ static inline void hci_event_synchronous_connection_complete_get_bd_addr(const u } /** * @brief Get field link_type from event hci_event_synchronous_connection_complete - * @param Event packet + * @param event packet * @return link_type * @note: btstack_type 1 */ @@ -554,7 +587,7 @@ static inline uint8_t hci_event_synchronous_connection_complete_get_link_type(co } /** * @brief Get field transmission_interval from event hci_event_synchronous_connection_complete - * @param Event packet + * @param event packet * @return transmission_interval * @note: btstack_type 1 */ @@ -563,7 +596,7 @@ static inline uint8_t hci_event_synchronous_connection_complete_get_transmission } /** * @brief Get field retransmission_interval from event hci_event_synchronous_connection_complete - * @param Event packet + * @param event packet * @return retransmission_interval * @note: btstack_type 1 */ @@ -572,7 +605,7 @@ static inline uint8_t hci_event_synchronous_connection_complete_get_retransmissi } /** * @brief Get field rx_packet_length from event hci_event_synchronous_connection_complete - * @param Event packet + * @param event packet * @return rx_packet_length * @note: btstack_type 2 */ @@ -581,7 +614,7 @@ static inline uint16_t hci_event_synchronous_connection_complete_get_rx_packet_l } /** * @brief Get field tx_packet_length from event hci_event_synchronous_connection_complete - * @param Event packet + * @param event packet * @return tx_packet_length * @note: btstack_type 2 */ @@ -590,7 +623,7 @@ static inline uint16_t hci_event_synchronous_connection_complete_get_tx_packet_l } /** * @brief Get field air_mode from event hci_event_synchronous_connection_complete - * @param Event packet + * @param event packet * @return air_mode * @note: btstack_type 1 */ @@ -600,7 +633,7 @@ static inline uint8_t hci_event_synchronous_connection_complete_get_air_mode(con /** * @brief Get field num_responses from event hci_event_extended_inquiry_response - * @param Event packet + * @param event packet * @return num_responses * @note: btstack_type 1 */ @@ -609,7 +642,7 @@ static inline uint8_t hci_event_extended_inquiry_response_get_num_responses(cons } /** * @brief Get field bd_addr from event hci_event_extended_inquiry_response - * @param Event packet + * @param event packet * @param Pointer to storage for bd_addr * @note: btstack_type B */ @@ -618,7 +651,7 @@ static inline void hci_event_extended_inquiry_response_get_bd_addr(const uint8_t } /** * @brief Get field page_scan_repetition_mode from event hci_event_extended_inquiry_response - * @param Event packet + * @param event packet * @return page_scan_repetition_mode * @note: btstack_type 1 */ @@ -627,7 +660,7 @@ static inline uint8_t hci_event_extended_inquiry_response_get_page_scan_repetiti } /** * @brief Get field reserved from event hci_event_extended_inquiry_response - * @param Event packet + * @param event packet * @return reserved * @note: btstack_type 1 */ @@ -636,7 +669,7 @@ static inline uint8_t hci_event_extended_inquiry_response_get_reserved(const uin } /** * @brief Get field class_of_device from event hci_event_extended_inquiry_response - * @param Event packet + * @param event packet * @return class_of_device * @note: btstack_type 3 */ @@ -645,7 +678,7 @@ static inline uint32_t hci_event_extended_inquiry_response_get_class_of_device(c } /** * @brief Get field clock_offset from event hci_event_extended_inquiry_response - * @param Event packet + * @param event packet * @return clock_offset * @note: btstack_type 2 */ @@ -654,7 +687,7 @@ static inline uint16_t hci_event_extended_inquiry_response_get_clock_offset(cons } /** * @brief Get field rssi from event hci_event_extended_inquiry_response - * @param Event packet + * @param event packet * @return rssi * @note: btstack_type 1 */ @@ -664,7 +697,7 @@ static inline uint8_t hci_event_extended_inquiry_response_get_rssi(const uint8_t /** * @brief Get field status from event hci_event_encryption_key_refresh_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -673,7 +706,7 @@ static inline uint8_t hci_event_encryption_key_refresh_complete_get_status(const } /** * @brief Get field handle from event hci_event_encryption_key_refresh_complete - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -683,7 +716,7 @@ static inline hci_con_handle_t hci_event_encryption_key_refresh_complete_get_han /** * @brief Get field subevent_code from event hci_subevent_le_connection_complete - * @param Event packet + * @param event packet * @return subevent_code * @note: btstack_type 1 */ @@ -692,7 +725,7 @@ static inline uint8_t hci_subevent_le_connection_complete_get_subevent_code(cons } /** * @brief Get field status from event hci_subevent_le_connection_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -701,7 +734,7 @@ static inline uint8_t hci_subevent_le_connection_complete_get_status(const uint8 } /** * @brief Get field connection_handle from event hci_subevent_le_connection_complete - * @param Event packet + * @param event packet * @return connection_handle * @note: btstack_type H */ @@ -710,7 +743,7 @@ static inline hci_con_handle_t hci_subevent_le_connection_complete_get_connectio } /** * @brief Get field role from event hci_subevent_le_connection_complete - * @param Event packet + * @param event packet * @return role * @note: btstack_type 1 */ @@ -719,7 +752,7 @@ static inline uint8_t hci_subevent_le_connection_complete_get_role(const uint8_t } /** * @brief Get field peer_address_type from event hci_subevent_le_connection_complete - * @param Event packet + * @param event packet * @return peer_address_type * @note: btstack_type 1 */ @@ -728,7 +761,7 @@ static inline uint8_t hci_subevent_le_connection_complete_get_peer_address_type( } /** * @brief Get field peer_address from event hci_subevent_le_connection_complete - * @param Event packet + * @param event packet * @param Pointer to storage for peer_address * @note: btstack_type B */ @@ -737,7 +770,7 @@ static inline void hci_subevent_le_connection_complete_get_peer_address(const ui } /** * @brief Get field conn_interval from event hci_subevent_le_connection_complete - * @param Event packet + * @param event packet * @return conn_interval * @note: btstack_type 2 */ @@ -746,7 +779,7 @@ static inline uint16_t hci_subevent_le_connection_complete_get_conn_interval(con } /** * @brief Get field conn_latency from event hci_subevent_le_connection_complete - * @param Event packet + * @param event packet * @return conn_latency * @note: btstack_type 2 */ @@ -755,7 +788,7 @@ static inline uint16_t hci_subevent_le_connection_complete_get_conn_latency(cons } /** * @brief Get field supervision_timeout from event hci_subevent_le_connection_complete - * @param Event packet + * @param event packet * @return supervision_timeout * @note: btstack_type 2 */ @@ -764,7 +797,7 @@ static inline uint16_t hci_subevent_le_connection_complete_get_supervision_timeo } /** * @brief Get field master_clock_accuracy from event hci_subevent_le_connection_complete - * @param Event packet + * @param event packet * @return master_clock_accuracy * @note: btstack_type 1 */ @@ -774,7 +807,7 @@ static inline uint8_t hci_subevent_le_connection_complete_get_master_clock_accur /** * @brief Get field state from event btstack_event_state - * @param Event packet + * @param event packet * @return state * @note: btstack_type 1 */ @@ -785,7 +818,7 @@ static inline uint8_t btstack_event_state_get_state(const uint8_t * event){ /** * @brief Get field discoverable from event btstack_event_discoverable_enabled - * @param Event packet + * @param event packet * @return discoverable * @note: btstack_type 1 */ @@ -795,7 +828,7 @@ static inline uint8_t btstack_event_discoverable_enabled_get_discoverable(const /** * @brief Get field handle from event hci_event_sco_can_send_now - * @param Event packet + * @param event packet * @param Pointer to storage for handle * @note: btstack_type B */ @@ -805,7 +838,7 @@ static inline void hci_event_sco_can_send_now_get_handle(const uint8_t * event, /** * @brief Get field status from event l2cap_event_channel_opened - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -814,7 +847,7 @@ static inline uint8_t l2cap_event_channel_opened_get_status(const uint8_t * even } /** * @brief Get field address from event l2cap_event_channel_opened - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -823,7 +856,7 @@ static inline void l2cap_event_channel_opened_get_address(const uint8_t * event, } /** * @brief Get field handle from event l2cap_event_channel_opened - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -832,7 +865,7 @@ static inline hci_con_handle_t l2cap_event_channel_opened_get_handle(const uint8 } /** * @brief Get field psm from event l2cap_event_channel_opened - * @param Event packet + * @param event packet * @return psm * @note: btstack_type 2 */ @@ -841,7 +874,7 @@ static inline uint16_t l2cap_event_channel_opened_get_psm(const uint8_t * event) } /** * @brief Get field local_cid from event l2cap_event_channel_opened - * @param Event packet + * @param event packet * @return local_cid * @note: btstack_type 2 */ @@ -850,7 +883,7 @@ static inline uint16_t l2cap_event_channel_opened_get_local_cid(const uint8_t * } /** * @brief Get field remote_cid from event l2cap_event_channel_opened - * @param Event packet + * @param event packet * @return remote_cid * @note: btstack_type 2 */ @@ -859,7 +892,7 @@ static inline uint16_t l2cap_event_channel_opened_get_remote_cid(const uint8_t * } /** * @brief Get field local_mtu from event l2cap_event_channel_opened - * @param Event packet + * @param event packet * @return local_mtu * @note: btstack_type 2 */ @@ -868,7 +901,7 @@ static inline uint16_t l2cap_event_channel_opened_get_local_mtu(const uint8_t * } /** * @brief Get field remote_mtu from event l2cap_event_channel_opened - * @param Event packet + * @param event packet * @return remote_mtu * @note: btstack_type 2 */ @@ -877,7 +910,7 @@ static inline uint16_t l2cap_event_channel_opened_get_remote_mtu(const uint8_t * } /** * @brief Get field flush_timeout from event l2cap_event_channel_opened - * @param Event packet + * @param event packet * @return flush_timeout * @note: btstack_type 2 */ @@ -887,7 +920,7 @@ static inline uint16_t l2cap_event_channel_opened_get_flush_timeout(const uint8_ /** * @brief Get field local_cid from event l2cap_event_channel_closed - * @param Event packet + * @param event packet * @return local_cid * @note: btstack_type 2 */ @@ -897,7 +930,7 @@ static inline uint16_t l2cap_event_channel_closed_get_local_cid(const uint8_t * /** * @brief Get field status from event l2cap_event_incoming_connection - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -906,7 +939,7 @@ static inline uint8_t l2cap_event_incoming_connection_get_status(const uint8_t * } /** * @brief Get field address from event l2cap_event_incoming_connection - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -915,7 +948,7 @@ static inline void l2cap_event_incoming_connection_get_address(const uint8_t * e } /** * @brief Get field handle from event l2cap_event_incoming_connection - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -924,7 +957,7 @@ static inline hci_con_handle_t l2cap_event_incoming_connection_get_handle(const } /** * @brief Get field psm from event l2cap_event_incoming_connection - * @param Event packet + * @param event packet * @return psm * @note: btstack_type 2 */ @@ -933,7 +966,7 @@ static inline uint16_t l2cap_event_incoming_connection_get_psm(const uint8_t * e } /** * @brief Get field local_cid from event l2cap_event_incoming_connection - * @param Event packet + * @param event packet * @return local_cid * @note: btstack_type 2 */ @@ -942,7 +975,7 @@ static inline uint16_t l2cap_event_incoming_connection_get_local_cid(const uint8 } /** * @brief Get field remote_cid from event l2cap_event_incoming_connection - * @param Event packet + * @param event packet * @return remote_cid * @note: btstack_type 2 */ @@ -952,7 +985,7 @@ static inline uint16_t l2cap_event_incoming_connection_get_remote_cid(const uint /** * @brief Get field status from event l2cap_event_service_registered - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -961,7 +994,7 @@ static inline uint8_t l2cap_event_service_registered_get_status(const uint8_t * } /** * @brief Get field psm from event l2cap_event_service_registered - * @param Event packet + * @param event packet * @return psm * @note: btstack_type 2 */ @@ -971,7 +1004,7 @@ static inline uint16_t l2cap_event_service_registered_get_psm(const uint8_t * ev /** * @brief Get field handle from event l2cap_event_connection_parameter_update_request - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -980,7 +1013,7 @@ static inline hci_con_handle_t l2cap_event_connection_parameter_update_request_g } /** * @brief Get field interval_min from event l2cap_event_connection_parameter_update_request - * @param Event packet + * @param event packet * @return interval_min * @note: btstack_type 2 */ @@ -989,7 +1022,7 @@ static inline uint16_t l2cap_event_connection_parameter_update_request_get_inter } /** * @brief Get field interval_max from event l2cap_event_connection_parameter_update_request - * @param Event packet + * @param event packet * @return interval_max * @note: btstack_type 2 */ @@ -998,7 +1031,7 @@ static inline uint16_t l2cap_event_connection_parameter_update_request_get_inter } /** * @brief Get field latencey from event l2cap_event_connection_parameter_update_request - * @param Event packet + * @param event packet * @return latencey * @note: btstack_type 2 */ @@ -1007,7 +1040,7 @@ static inline uint16_t l2cap_event_connection_parameter_update_request_get_laten } /** * @brief Get field timeout_multiplier from event l2cap_event_connection_parameter_update_request - * @param Event packet + * @param event packet * @return timeout_multiplier * @note: btstack_type 2 */ @@ -1017,7 +1050,7 @@ static inline uint16_t l2cap_event_connection_parameter_update_request_get_timeo /** * @brief Get field handle from event l2cap_event_connection_parameter_update_response - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1027,7 +1060,7 @@ static inline hci_con_handle_t l2cap_event_connection_parameter_update_response_ /** * @brief Get field local_cid from event l2cap_event_can_send_now - * @param Event packet + * @param event packet * @return local_cid * @note: btstack_type 2 */ @@ -1037,7 +1070,7 @@ static inline uint16_t l2cap_event_can_send_now_get_local_cid(const uint8_t * ev /** * @brief Get field status from event rfcomm_event_open_channel_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -1046,7 +1079,7 @@ static inline uint8_t rfcomm_event_open_channel_complete_get_status(const uint8_ } /** * @brief Get field bd_addr from event rfcomm_event_open_channel_complete - * @param Event packet + * @param event packet * @param Pointer to storage for bd_addr * @note: btstack_type B */ @@ -1055,7 +1088,7 @@ static inline void rfcomm_event_open_channel_complete_get_bd_addr(const uint8_t } /** * @brief Get field con_handle from event rfcomm_event_open_channel_complete - * @param Event packet + * @param event packet * @return con_handle * @note: btstack_type 2 */ @@ -1064,7 +1097,7 @@ static inline uint16_t rfcomm_event_open_channel_complete_get_con_handle(const u } /** * @brief Get field server_channel from event rfcomm_event_open_channel_complete - * @param Event packet + * @param event packet * @return server_channel * @note: btstack_type 1 */ @@ -1073,7 +1106,7 @@ static inline uint8_t rfcomm_event_open_channel_complete_get_server_channel(cons } /** * @brief Get field rfcomm_cid from event rfcomm_event_open_channel_complete - * @param Event packet + * @param event packet * @return rfcomm_cid * @note: btstack_type 2 */ @@ -1082,7 +1115,7 @@ static inline uint16_t rfcomm_event_open_channel_complete_get_rfcomm_cid(const u } /** * @brief Get field max_frame_size from event rfcomm_event_open_channel_complete - * @param Event packet + * @param event packet * @return max_frame_size * @note: btstack_type 2 */ @@ -1092,7 +1125,7 @@ static inline uint16_t rfcomm_event_open_channel_complete_get_max_frame_size(con /** * @brief Get field rfcomm_cid from event rfcomm_event_channel_closed - * @param Event packet + * @param event packet * @return rfcomm_cid * @note: btstack_type 2 */ @@ -1102,7 +1135,7 @@ static inline uint16_t rfcomm_event_channel_closed_get_rfcomm_cid(const uint8_t /** * @brief Get field bd_addr from event rfcomm_event_incoming_connection - * @param Event packet + * @param event packet * @param Pointer to storage for bd_addr * @note: btstack_type B */ @@ -1111,7 +1144,7 @@ static inline void rfcomm_event_incoming_connection_get_bd_addr(const uint8_t * } /** * @brief Get field server_channel from event rfcomm_event_incoming_connection - * @param Event packet + * @param event packet * @return server_channel * @note: btstack_type 1 */ @@ -1120,7 +1153,7 @@ static inline uint8_t rfcomm_event_incoming_connection_get_server_channel(const } /** * @brief Get field rfcomm_cid from event rfcomm_event_incoming_connection - * @param Event packet + * @param event packet * @return rfcomm_cid * @note: btstack_type 2 */ @@ -1130,7 +1163,7 @@ static inline uint16_t rfcomm_event_incoming_connection_get_rfcomm_cid(const uin /** * @brief Get field rfcomm_cid from event rfcomm_event_remote_line_status - * @param Event packet + * @param event packet * @return rfcomm_cid * @note: btstack_type 2 */ @@ -1139,7 +1172,7 @@ static inline uint16_t rfcomm_event_remote_line_status_get_rfcomm_cid(const uint } /** * @brief Get field line_status from event rfcomm_event_remote_line_status - * @param Event packet + * @param event packet * @return line_status * @note: btstack_type 1 */ @@ -1149,7 +1182,7 @@ static inline uint8_t rfcomm_event_remote_line_status_get_line_status(const uint /** * @brief Get field rfcomm_cid from event rfcomm_event_credits - * @param Event packet + * @param event packet * @return rfcomm_cid * @note: btstack_type 2 */ @@ -1158,7 +1191,7 @@ static inline uint16_t rfcomm_event_credits_get_rfcomm_cid(const uint8_t * event } /** * @brief Get field credits from event rfcomm_event_credits - * @param Event packet + * @param event packet * @return credits * @note: btstack_type 1 */ @@ -1168,7 +1201,7 @@ static inline uint8_t rfcomm_event_credits_get_credits(const uint8_t * event){ /** * @brief Get field status from event rfcomm_event_service_registered - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -1177,7 +1210,7 @@ static inline uint8_t rfcomm_event_service_registered_get_status(const uint8_t * } /** * @brief Get field channel_id from event rfcomm_event_service_registered - * @param Event packet + * @param event packet * @return channel_id * @note: btstack_type 1 */ @@ -1187,7 +1220,7 @@ static inline uint8_t rfcomm_event_service_registered_get_channel_id(const uint8 /** * @brief Get field status from event rfcomm_event_persistent_channel - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -1196,7 +1229,7 @@ static inline uint8_t rfcomm_event_persistent_channel_get_status(const uint8_t * } /** * @brief Get field server_channel_id from event rfcomm_event_persistent_channel - * @param Event packet + * @param event packet * @return server_channel_id * @note: btstack_type 1 */ @@ -1206,7 +1239,7 @@ static inline uint8_t rfcomm_event_persistent_channel_get_server_channel_id(cons /** * @brief Get field rfcomm_cid from event rfcomm_event_remote_modem_status - * @param Event packet + * @param event packet * @return rfcomm_cid * @note: btstack_type 2 */ @@ -1215,7 +1248,7 @@ static inline uint16_t rfcomm_event_remote_modem_status_get_rfcomm_cid(const uin } /** * @brief Get field modem_status from event rfcomm_event_remote_modem_status - * @param Event packet + * @param event packet * @return modem_status * @note: btstack_type 1 */ @@ -1225,7 +1258,7 @@ static inline uint8_t rfcomm_event_remote_modem_status_get_modem_status(const ui /** * @brief Get field local_cid from event rfcomm_event_can_send_now - * @param Event packet + * @param event packet * @return local_cid * @note: btstack_type 2 */ @@ -1235,7 +1268,7 @@ static inline uint16_t rfcomm_event_can_send_now_get_local_cid(const uint8_t * e /** * @brief Get field status from event sdp_event_service_registered - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -1244,7 +1277,7 @@ static inline uint8_t sdp_event_service_registered_get_status(const uint8_t * ev } /** * @brief Get field service_record_handle from event sdp_event_service_registered - * @param Event packet + * @param event packet * @return service_record_handle * @note: btstack_type 4 */ @@ -1254,7 +1287,7 @@ static inline uint32_t sdp_event_service_registered_get_service_record_handle(co /** * @brief Get field status from event sdp_event_query_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -1264,7 +1297,7 @@ static inline uint8_t sdp_event_query_complete_get_status(const uint8_t * event) /** * @brief Get field rfcomm_channel from event sdp_event_query_rfcomm_service - * @param Event packet + * @param event packet * @return rfcomm_channel * @note: btstack_type 1 */ @@ -1273,7 +1306,7 @@ static inline uint8_t sdp_event_query_rfcomm_service_get_rfcomm_channel(const ui } /** * @brief Get field name from event sdp_event_query_rfcomm_service - * @param Event packet + * @param event packet * @return name * @note: btstack_type T */ @@ -1283,7 +1316,7 @@ static inline const char * sdp_event_query_rfcomm_service_get_name(const uint8_t /** * @brief Get field record_id from event sdp_event_query_attribute_byte - * @param Event packet + * @param event packet * @return record_id * @note: btstack_type 2 */ @@ -1292,7 +1325,7 @@ static inline uint16_t sdp_event_query_attribute_byte_get_record_id(const uint8_ } /** * @brief Get field attribute_id from event sdp_event_query_attribute_byte - * @param Event packet + * @param event packet * @return attribute_id * @note: btstack_type 2 */ @@ -1301,7 +1334,7 @@ static inline uint16_t sdp_event_query_attribute_byte_get_attribute_id(const uin } /** * @brief Get field attribute_length from event sdp_event_query_attribute_byte - * @param Event packet + * @param event packet * @return attribute_length * @note: btstack_type 2 */ @@ -1310,7 +1343,7 @@ static inline uint16_t sdp_event_query_attribute_byte_get_attribute_length(const } /** * @brief Get field data_offset from event sdp_event_query_attribute_byte - * @param Event packet + * @param event packet * @return data_offset * @note: btstack_type 2 */ @@ -1319,7 +1352,7 @@ static inline uint16_t sdp_event_query_attribute_byte_get_data_offset(const uint } /** * @brief Get field data from event sdp_event_query_attribute_byte - * @param Event packet + * @param event packet * @return data * @note: btstack_type 1 */ @@ -1329,7 +1362,7 @@ static inline uint8_t sdp_event_query_attribute_byte_get_data(const uint8_t * ev /** * @brief Get field record_id from event sdp_event_query_attribute_value - * @param Event packet + * @param event packet * @return record_id * @note: btstack_type 2 */ @@ -1338,7 +1371,7 @@ static inline uint16_t sdp_event_query_attribute_value_get_record_id(const uint8 } /** * @brief Get field attribute_id from event sdp_event_query_attribute_value - * @param Event packet + * @param event packet * @return attribute_id * @note: btstack_type 2 */ @@ -1347,7 +1380,7 @@ static inline uint16_t sdp_event_query_attribute_value_get_attribute_id(const ui } /** * @brief Get field attribute_length from event sdp_event_query_attribute_value - * @param Event packet + * @param event packet * @return attribute_length * @note: btstack_type L */ @@ -1356,7 +1389,7 @@ static inline int sdp_event_query_attribute_value_get_attribute_length(const uin } /** * @brief Get field attribute_value from event sdp_event_query_attribute_value - * @param Event packet + * @param event packet * @return attribute_value * @note: btstack_type V */ @@ -1366,7 +1399,7 @@ static inline const uint8_t * sdp_event_query_attribute_value_get_attribute_valu /** * @brief Get field total_count from event sdp_event_query_service_record_handle - * @param Event packet + * @param event packet * @return total_count * @note: btstack_type 2 */ @@ -1375,7 +1408,7 @@ static inline uint16_t sdp_event_query_service_record_handle_get_total_count(con } /** * @brief Get field record_index from event sdp_event_query_service_record_handle - * @param Event packet + * @param event packet * @return record_index * @note: btstack_type 2 */ @@ -1384,7 +1417,7 @@ static inline uint16_t sdp_event_query_service_record_handle_get_record_index(co } /** * @brief Get field record_handle from event sdp_event_query_service_record_handle - * @param Event packet + * @param event packet * @return record_handle * @note: btstack_type 4 */ @@ -1395,7 +1428,7 @@ static inline uint32_t sdp_event_query_service_record_handle_get_record_handle(c #ifdef ENABLE_BLE /** * @brief Get field handle from event gatt_event_query_complete - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1404,7 +1437,7 @@ static inline hci_con_handle_t gatt_event_query_complete_get_handle(const uint8_ } /** * @brief Get field status from event gatt_event_query_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -1416,7 +1449,7 @@ static inline uint8_t gatt_event_query_complete_get_status(const uint8_t * event #ifdef ENABLE_BLE /** * @brief Get field handle from event gatt_event_service_query_result - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1425,7 +1458,7 @@ static inline hci_con_handle_t gatt_event_service_query_result_get_handle(const } /** * @brief Get field service from event gatt_event_service_query_result - * @param Event packet + * @param event packet * @param Pointer to storage for service * @note: btstack_type X */ @@ -1437,7 +1470,7 @@ static inline void gatt_event_service_query_result_get_service(const uint8_t * e #ifdef ENABLE_BLE /** * @brief Get field handle from event gatt_event_characteristic_query_result - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1446,7 +1479,7 @@ static inline hci_con_handle_t gatt_event_characteristic_query_result_get_handle } /** * @brief Get field characteristic from event gatt_event_characteristic_query_result - * @param Event packet + * @param event packet * @param Pointer to storage for characteristic * @note: btstack_type Y */ @@ -1458,7 +1491,7 @@ static inline void gatt_event_characteristic_query_result_get_characteristic(con #ifdef ENABLE_BLE /** * @brief Get field handle from event gatt_event_included_service_query_result - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1467,7 +1500,7 @@ static inline hci_con_handle_t gatt_event_included_service_query_result_get_hand } /** * @brief Get field include_handle from event gatt_event_included_service_query_result - * @param Event packet + * @param event packet * @return include_handle * @note: btstack_type 2 */ @@ -1476,7 +1509,7 @@ static inline uint16_t gatt_event_included_service_query_result_get_include_hand } /** * @brief Get field service from event gatt_event_included_service_query_result - * @param Event packet + * @param event packet * @param Pointer to storage for service * @note: btstack_type X */ @@ -1488,7 +1521,7 @@ static inline void gatt_event_included_service_query_result_get_service(const ui #ifdef ENABLE_BLE /** * @brief Get field handle from event gatt_event_all_characteristic_descriptors_query_result - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1497,7 +1530,7 @@ static inline hci_con_handle_t gatt_event_all_characteristic_descriptors_query_r } /** * @brief Get field characteristic_descriptor from event gatt_event_all_characteristic_descriptors_query_result - * @param Event packet + * @param event packet * @param Pointer to storage for characteristic_descriptor * @note: btstack_type Z */ @@ -1509,7 +1542,7 @@ static inline void gatt_event_all_characteristic_descriptors_query_result_get_ch #ifdef ENABLE_BLE /** * @brief Get field handle from event gatt_event_characteristic_value_query_result - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1518,7 +1551,7 @@ static inline hci_con_handle_t gatt_event_characteristic_value_query_result_get_ } /** * @brief Get field value_handle from event gatt_event_characteristic_value_query_result - * @param Event packet + * @param event packet * @return value_handle * @note: btstack_type 2 */ @@ -1527,7 +1560,7 @@ static inline uint16_t gatt_event_characteristic_value_query_result_get_value_ha } /** * @brief Get field value_length from event gatt_event_characteristic_value_query_result - * @param Event packet + * @param event packet * @return value_length * @note: btstack_type L */ @@ -1536,7 +1569,7 @@ static inline int gatt_event_characteristic_value_query_result_get_value_length( } /** * @brief Get field value from event gatt_event_characteristic_value_query_result - * @param Event packet + * @param event packet * @return value * @note: btstack_type V */ @@ -1548,7 +1581,7 @@ static inline const uint8_t * gatt_event_characteristic_value_query_result_get_v #ifdef ENABLE_BLE /** * @brief Get field handle from event gatt_event_long_characteristic_value_query_result - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1557,7 +1590,7 @@ static inline hci_con_handle_t gatt_event_long_characteristic_value_query_result } /** * @brief Get field value_handle from event gatt_event_long_characteristic_value_query_result - * @param Event packet + * @param event packet * @return value_handle * @note: btstack_type 2 */ @@ -1566,7 +1599,7 @@ static inline uint16_t gatt_event_long_characteristic_value_query_result_get_val } /** * @brief Get field value_offset from event gatt_event_long_characteristic_value_query_result - * @param Event packet + * @param event packet * @return value_offset * @note: btstack_type 2 */ @@ -1575,7 +1608,7 @@ static inline uint16_t gatt_event_long_characteristic_value_query_result_get_val } /** * @brief Get field value_length from event gatt_event_long_characteristic_value_query_result - * @param Event packet + * @param event packet * @return value_length * @note: btstack_type L */ @@ -1584,7 +1617,7 @@ static inline int gatt_event_long_characteristic_value_query_result_get_value_le } /** * @brief Get field value from event gatt_event_long_characteristic_value_query_result - * @param Event packet + * @param event packet * @return value * @note: btstack_type V */ @@ -1596,7 +1629,7 @@ static inline const uint8_t * gatt_event_long_characteristic_value_query_result_ #ifdef ENABLE_BLE /** * @brief Get field handle from event gatt_event_notification - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1605,7 +1638,7 @@ static inline hci_con_handle_t gatt_event_notification_get_handle(const uint8_t } /** * @brief Get field value_handle from event gatt_event_notification - * @param Event packet + * @param event packet * @return value_handle * @note: btstack_type 2 */ @@ -1614,7 +1647,7 @@ static inline uint16_t gatt_event_notification_get_value_handle(const uint8_t * } /** * @brief Get field value_length from event gatt_event_notification - * @param Event packet + * @param event packet * @return value_length * @note: btstack_type L */ @@ -1623,7 +1656,7 @@ static inline int gatt_event_notification_get_value_length(const uint8_t * event } /** * @brief Get field value from event gatt_event_notification - * @param Event packet + * @param event packet * @return value * @note: btstack_type V */ @@ -1635,7 +1668,7 @@ static inline const uint8_t * gatt_event_notification_get_value(const uint8_t * #ifdef ENABLE_BLE /** * @brief Get field handle from event gatt_event_indication - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1644,7 +1677,7 @@ static inline hci_con_handle_t gatt_event_indication_get_handle(const uint8_t * } /** * @brief Get field value_handle from event gatt_event_indication - * @param Event packet + * @param event packet * @return value_handle * @note: btstack_type 2 */ @@ -1653,7 +1686,7 @@ static inline uint16_t gatt_event_indication_get_value_handle(const uint8_t * ev } /** * @brief Get field value_length from event gatt_event_indication - * @param Event packet + * @param event packet * @return value_length * @note: btstack_type L */ @@ -1662,7 +1695,7 @@ static inline int gatt_event_indication_get_value_length(const uint8_t * event){ } /** * @brief Get field value from event gatt_event_indication - * @param Event packet + * @param event packet * @return value * @note: btstack_type V */ @@ -1674,7 +1707,7 @@ static inline const uint8_t * gatt_event_indication_get_value(const uint8_t * ev #ifdef ENABLE_BLE /** * @brief Get field descriptor_handle from event gatt_event_characteristic_descriptor_query_result - * @param Event packet + * @param event packet * @return descriptor_handle * @note: btstack_type H */ @@ -1683,7 +1716,7 @@ static inline hci_con_handle_t gatt_event_characteristic_descriptor_query_result } /** * @brief Get field descriptor_length from event gatt_event_characteristic_descriptor_query_result - * @param Event packet + * @param event packet * @return descriptor_length * @note: btstack_type 2 */ @@ -1692,7 +1725,7 @@ static inline uint16_t gatt_event_characteristic_descriptor_query_result_get_des } /** * @brief Get field descriptor from event gatt_event_characteristic_descriptor_query_result - * @param Event packet + * @param event packet * @return descriptor * @note: btstack_type L */ @@ -1704,7 +1737,7 @@ static inline int gatt_event_characteristic_descriptor_query_result_get_descript #ifdef ENABLE_BLE /** * @brief Get field handle from event gatt_event_long_characteristic_descriptor_query_result - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1713,7 +1746,7 @@ static inline hci_con_handle_t gatt_event_long_characteristic_descriptor_query_r } /** * @brief Get field descriptor_offset from event gatt_event_long_characteristic_descriptor_query_result - * @param Event packet + * @param event packet * @return descriptor_offset * @note: btstack_type 2 */ @@ -1722,7 +1755,7 @@ static inline uint16_t gatt_event_long_characteristic_descriptor_query_result_ge } /** * @brief Get field descriptor_length from event gatt_event_long_characteristic_descriptor_query_result - * @param Event packet + * @param event packet * @return descriptor_length * @note: btstack_type L */ @@ -1731,7 +1764,7 @@ static inline int gatt_event_long_characteristic_descriptor_query_result_get_des } /** * @brief Get field descriptor from event gatt_event_long_characteristic_descriptor_query_result - * @param Event packet + * @param event packet * @return descriptor * @note: btstack_type V */ @@ -1743,7 +1776,7 @@ static inline const uint8_t * gatt_event_long_characteristic_descriptor_query_re #ifdef ENABLE_BLE /** * @brief Get field handle from event gatt_event_mtu - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1752,7 +1785,7 @@ static inline hci_con_handle_t gatt_event_mtu_get_handle(const uint8_t * event){ } /** * @brief Get field MTU from event gatt_event_mtu - * @param Event packet + * @param event packet * @return MTU * @note: btstack_type 2 */ @@ -1764,7 +1797,7 @@ static inline uint16_t gatt_event_mtu_get_MTU(const uint8_t * event){ #ifdef ENABLE_BLE /** * @brief Get field handle from event sm_event_just_works_request - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1773,7 +1806,7 @@ static inline hci_con_handle_t sm_event_just_works_request_get_handle(const uint } /** * @brief Get field addr_type from event sm_event_just_works_request - * @param Event packet + * @param event packet * @return addr_type * @note: btstack_type 1 */ @@ -1782,7 +1815,7 @@ static inline uint8_t sm_event_just_works_request_get_addr_type(const uint8_t * } /** * @brief Get field address from event sm_event_just_works_request - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -1794,7 +1827,7 @@ static inline void sm_event_just_works_request_get_address(const uint8_t * event #ifdef ENABLE_BLE /** * @brief Get field handle from event sm_event_just_works_cancel - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1803,7 +1836,7 @@ static inline hci_con_handle_t sm_event_just_works_cancel_get_handle(const uint8 } /** * @brief Get field addr_type from event sm_event_just_works_cancel - * @param Event packet + * @param event packet * @return addr_type * @note: btstack_type 1 */ @@ -1812,7 +1845,7 @@ static inline uint8_t sm_event_just_works_cancel_get_addr_type(const uint8_t * e } /** * @brief Get field address from event sm_event_just_works_cancel - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -1824,7 +1857,7 @@ static inline void sm_event_just_works_cancel_get_address(const uint8_t * event, #ifdef ENABLE_BLE /** * @brief Get field handle from event sm_event_passkey_display_number - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1833,7 +1866,7 @@ static inline hci_con_handle_t sm_event_passkey_display_number_get_handle(const } /** * @brief Get field addr_type from event sm_event_passkey_display_number - * @param Event packet + * @param event packet * @return addr_type * @note: btstack_type 1 */ @@ -1842,7 +1875,7 @@ static inline uint8_t sm_event_passkey_display_number_get_addr_type(const uint8_ } /** * @brief Get field address from event sm_event_passkey_display_number - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -1851,7 +1884,7 @@ static inline void sm_event_passkey_display_number_get_address(const uint8_t * e } /** * @brief Get field passkey from event sm_event_passkey_display_number - * @param Event packet + * @param event packet * @return passkey * @note: btstack_type 4 */ @@ -1863,7 +1896,7 @@ static inline uint32_t sm_event_passkey_display_number_get_passkey(const uint8_t #ifdef ENABLE_BLE /** * @brief Get field handle from event sm_event_passkey_display_cancel - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1872,7 +1905,7 @@ static inline hci_con_handle_t sm_event_passkey_display_cancel_get_handle(const } /** * @brief Get field addr_type from event sm_event_passkey_display_cancel - * @param Event packet + * @param event packet * @return addr_type * @note: btstack_type 1 */ @@ -1881,7 +1914,7 @@ static inline uint8_t sm_event_passkey_display_cancel_get_addr_type(const uint8_ } /** * @brief Get field address from event sm_event_passkey_display_cancel - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -1893,7 +1926,7 @@ static inline void sm_event_passkey_display_cancel_get_address(const uint8_t * e #ifdef ENABLE_BLE /** * @brief Get field handle from event sm_event_passkey_input_number - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1902,7 +1935,7 @@ static inline hci_con_handle_t sm_event_passkey_input_number_get_handle(const ui } /** * @brief Get field addr_type from event sm_event_passkey_input_number - * @param Event packet + * @param event packet * @return addr_type * @note: btstack_type 1 */ @@ -1911,7 +1944,7 @@ static inline uint8_t sm_event_passkey_input_number_get_addr_type(const uint8_t } /** * @brief Get field address from event sm_event_passkey_input_number - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -1923,7 +1956,7 @@ static inline void sm_event_passkey_input_number_get_address(const uint8_t * eve #ifdef ENABLE_BLE /** * @brief Get field handle from event sm_event_passkey_input_cancel - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1932,7 +1965,7 @@ static inline hci_con_handle_t sm_event_passkey_input_cancel_get_handle(const ui } /** * @brief Get field addr_type from event sm_event_passkey_input_cancel - * @param Event packet + * @param event packet * @return addr_type * @note: btstack_type 1 */ @@ -1941,7 +1974,7 @@ static inline uint8_t sm_event_passkey_input_cancel_get_addr_type(const uint8_t } /** * @brief Get field address from event sm_event_passkey_input_cancel - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -1953,7 +1986,7 @@ static inline void sm_event_passkey_input_cancel_get_address(const uint8_t * eve #ifdef ENABLE_BLE /** * @brief Get field handle from event sm_event_identity_resolving_started - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1962,7 +1995,7 @@ static inline hci_con_handle_t sm_event_identity_resolving_started_get_handle(co } /** * @brief Get field addr_type from event sm_event_identity_resolving_started - * @param Event packet + * @param event packet * @return addr_type * @note: btstack_type 1 */ @@ -1971,7 +2004,7 @@ static inline uint8_t sm_event_identity_resolving_started_get_addr_type(const ui } /** * @brief Get field address from event sm_event_identity_resolving_started - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -1983,7 +2016,7 @@ static inline void sm_event_identity_resolving_started_get_address(const uint8_t #ifdef ENABLE_BLE /** * @brief Get field handle from event sm_event_identity_resolving_failed - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -1992,7 +2025,7 @@ static inline hci_con_handle_t sm_event_identity_resolving_failed_get_handle(con } /** * @brief Get field addr_type from event sm_event_identity_resolving_failed - * @param Event packet + * @param event packet * @return addr_type * @note: btstack_type 1 */ @@ -2001,7 +2034,7 @@ static inline uint8_t sm_event_identity_resolving_failed_get_addr_type(const uin } /** * @brief Get field address from event sm_event_identity_resolving_failed - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -2013,7 +2046,7 @@ static inline void sm_event_identity_resolving_failed_get_address(const uint8_t #ifdef ENABLE_BLE /** * @brief Get field handle from event sm_event_identity_resolving_succeeded - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -2022,7 +2055,7 @@ static inline hci_con_handle_t sm_event_identity_resolving_succeeded_get_handle( } /** * @brief Get field addr_type from event sm_event_identity_resolving_succeeded - * @param Event packet + * @param event packet * @return addr_type * @note: btstack_type 1 */ @@ -2031,7 +2064,7 @@ static inline uint8_t sm_event_identity_resolving_succeeded_get_addr_type(const } /** * @brief Get field address from event sm_event_identity_resolving_succeeded - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -2040,7 +2073,7 @@ static inline void sm_event_identity_resolving_succeeded_get_address(const uint8 } /** * @brief Get field le_device_db_index from event sm_event_identity_resolving_succeeded - * @param Event packet + * @param event packet * @return le_device_db_index * @note: btstack_type 2 */ @@ -2052,7 +2085,7 @@ static inline uint16_t sm_event_identity_resolving_succeeded_get_le_device_db_in #ifdef ENABLE_BLE /** * @brief Get field handle from event sm_event_authorization_request - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -2061,7 +2094,7 @@ static inline hci_con_handle_t sm_event_authorization_request_get_handle(const u } /** * @brief Get field addr_type from event sm_event_authorization_request - * @param Event packet + * @param event packet * @return addr_type * @note: btstack_type 1 */ @@ -2070,7 +2103,7 @@ static inline uint8_t sm_event_authorization_request_get_addr_type(const uint8_t } /** * @brief Get field address from event sm_event_authorization_request - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -2082,7 +2115,7 @@ static inline void sm_event_authorization_request_get_address(const uint8_t * ev #ifdef ENABLE_BLE /** * @brief Get field handle from event sm_event_authorization_result - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -2091,7 +2124,7 @@ static inline hci_con_handle_t sm_event_authorization_result_get_handle(const ui } /** * @brief Get field addr_type from event sm_event_authorization_result - * @param Event packet + * @param event packet * @return addr_type * @note: btstack_type 1 */ @@ -2100,7 +2133,7 @@ static inline uint8_t sm_event_authorization_result_get_addr_type(const uint8_t } /** * @brief Get field address from event sm_event_authorization_result - * @param Event packet + * @param event packet * @param Pointer to storage for address * @note: btstack_type B */ @@ -2109,7 +2142,7 @@ static inline void sm_event_authorization_result_get_address(const uint8_t * eve } /** * @brief Get field authorization_result from event sm_event_authorization_result - * @param Event packet + * @param event packet * @return authorization_result * @note: btstack_type 1 */ @@ -2118,9 +2151,64 @@ static inline uint8_t sm_event_authorization_result_get_authorization_result(con } #endif +/** + * @brief Get field advertising_event_type from event gap_le_event_advertising_report + * @param event packet + * @return advertising_event_type + * @note: btstack_type 1 + */ +static inline uint8_t gap_le_event_advertising_report_get_advertising_event_type(const uint8_t * event){ + return event[2]; +} +/** + * @brief Get field address_type from event gap_le_event_advertising_report + * @param event packet + * @return address_type + * @note: btstack_type 1 + */ +static inline uint8_t gap_le_event_advertising_report_get_address_type(const uint8_t * event){ + return event[3]; +} +/** + * @brief Get field address from event gap_le_event_advertising_report + * @param event packet + * @param Pointer to storage for address + * @note: btstack_type B + */ +static inline void gap_le_event_advertising_report_get_address(const uint8_t * event, bd_addr_t address){ + reverse_bd_addr(&event[4], address); +} +/** + * @brief Get field rssi from event gap_le_event_advertising_report + * @param event packet + * @return rssi + * @note: btstack_type 1 + */ +static inline uint8_t gap_le_event_advertising_report_get_rssi(const uint8_t * event){ + return event[10]; +} +/** + * @brief Get field data_length from event gap_le_event_advertising_report + * @param event packet + * @return data_length + * @note: btstack_type J + */ +static inline int gap_le_event_advertising_report_get_data_length(const uint8_t * event){ + return event[11]; +} +/** + * @brief Get field data from event gap_le_event_advertising_report + * @param event packet + * @return data + * @note: btstack_type V + */ +static inline const uint8_t * gap_le_event_advertising_report_get_data(const uint8_t * event){ + return &event[12]; +} + /** * @brief Get field subevent_code from event hsp_subevent_audio_connection_complete - * @param Event packet + * @param event packet * @return subevent_code * @note: btstack_type 1 */ @@ -2129,7 +2217,7 @@ static inline uint8_t hsp_subevent_audio_connection_complete_get_subevent_code(c } /** * @brief Get field status from event hsp_subevent_audio_connection_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -2138,7 +2226,7 @@ static inline uint8_t hsp_subevent_audio_connection_complete_get_status(const ui } /** * @brief Get field handle from event hsp_subevent_audio_connection_complete - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -2148,7 +2236,7 @@ static inline hci_con_handle_t hsp_subevent_audio_connection_complete_get_handle /** * @brief Get field subevent_code from event hsp_subevent_audio_disconnection_complete - * @param Event packet + * @param event packet * @return subevent_code * @note: btstack_type 1 */ @@ -2157,7 +2245,7 @@ static inline uint8_t hsp_subevent_audio_disconnection_complete_get_subevent_cod } /** * @brief Get field status from event hsp_subevent_audio_disconnection_complete - * @param Event packet + * @param event packet * @return status * @note: btstack_type 1 */ @@ -2167,7 +2255,7 @@ static inline uint8_t hsp_subevent_audio_disconnection_complete_get_status(const /** * @brief Get field subevent_code from event hsp_subevent_ring - * @param Event packet + * @param event packet * @return subevent_code * @note: btstack_type 1 */ @@ -2177,7 +2265,7 @@ static inline uint8_t hsp_subevent_ring_get_subevent_code(const uint8_t * event) /** * @brief Get field subevent_code from event hsp_subevent_microphone_gain_changed - * @param Event packet + * @param event packet * @return subevent_code * @note: btstack_type 1 */ @@ -2186,7 +2274,7 @@ static inline uint8_t hsp_subevent_microphone_gain_changed_get_subevent_code(con } /** * @brief Get field gain from event hsp_subevent_microphone_gain_changed - * @param Event packet + * @param event packet * @return gain * @note: btstack_type 1 */ @@ -2196,7 +2284,7 @@ static inline uint8_t hsp_subevent_microphone_gain_changed_get_gain(const uint8_ /** * @brief Get field subevent_code from event hsp_subevent_speaker_gain_changed - * @param Event packet + * @param event packet * @return subevent_code * @note: btstack_type 1 */ @@ -2205,7 +2293,7 @@ static inline uint8_t hsp_subevent_speaker_gain_changed_get_subevent_code(const } /** * @brief Get field gain from event hsp_subevent_speaker_gain_changed - * @param Event packet + * @param event packet * @return gain * @note: btstack_type 1 */ @@ -2215,7 +2303,7 @@ static inline uint8_t hsp_subevent_speaker_gain_changed_get_gain(const uint8_t * /** * @brief Get field subevent_code from event hsp_subevent_hs_command - * @param Event packet + * @param event packet * @return subevent_code * @note: btstack_type 1 */ @@ -2224,7 +2312,7 @@ static inline uint8_t hsp_subevent_hs_command_get_subevent_code(const uint8_t * } /** * @brief Get field value_length from event hsp_subevent_hs_command - * @param Event packet + * @param event packet * @return value_length * @note: btstack_type J */ @@ -2233,7 +2321,7 @@ static inline int hsp_subevent_hs_command_get_value_length(const uint8_t * event } /** * @brief Get field value from event hsp_subevent_hs_command - * @param Event packet + * @param event packet * @return value * @note: btstack_type V */ @@ -2243,7 +2331,7 @@ static inline const uint8_t * hsp_subevent_hs_command_get_value(const uint8_t * /** * @brief Get field subevent_code from event hsp_subevent_ag_indication - * @param Event packet + * @param event packet * @return subevent_code * @note: btstack_type 1 */ @@ -2252,7 +2340,7 @@ static inline uint8_t hsp_subevent_ag_indication_get_subevent_code(const uint8_t } /** * @brief Get field value_length from event hsp_subevent_ag_indication - * @param Event packet + * @param event packet * @return value_length * @note: btstack_type J */ @@ -2261,7 +2349,7 @@ static inline int hsp_subevent_ag_indication_get_value_length(const uint8_t * ev } /** * @brief Get field value from event hsp_subevent_ag_indication - * @param Event packet + * @param event packet * @return value * @note: btstack_type V */ @@ -2272,7 +2360,7 @@ static inline const uint8_t * hsp_subevent_ag_indication_get_value(const uint8_t #ifdef ENABLE_BLE /** * @brief Get field subevent_code from event ancs_subevent_client_connected - * @param Event packet + * @param event packet * @return subevent_code * @note: btstack_type 1 */ @@ -2281,7 +2369,7 @@ static inline uint8_t ancs_subevent_client_connected_get_subevent_code(const uin } /** * @brief Get field handle from event ancs_subevent_client_connected - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -2293,7 +2381,7 @@ static inline hci_con_handle_t ancs_subevent_client_connected_get_handle(const u #ifdef ENABLE_BLE /** * @brief Get field subevent_code from event ancs_subevent_client_notification - * @param Event packet + * @param event packet * @return subevent_code * @note: btstack_type 1 */ @@ -2302,7 +2390,7 @@ static inline uint8_t ancs_subevent_client_notification_get_subevent_code(const } /** * @brief Get field handle from event ancs_subevent_client_notification - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ @@ -2311,7 +2399,7 @@ static inline hci_con_handle_t ancs_subevent_client_notification_get_handle(cons } /** * @brief Get field attribute_id from event ancs_subevent_client_notification - * @param Event packet + * @param event packet * @return attribute_id * @note: btstack_type 2 */ @@ -2320,7 +2408,7 @@ static inline uint16_t ancs_subevent_client_notification_get_attribute_id(const } /** * @brief Get field text from event ancs_subevent_client_notification - * @param Event packet + * @param event packet * @return text * @note: btstack_type T */ @@ -2332,7 +2420,7 @@ static inline const char * ancs_subevent_client_notification_get_text(const uint #ifdef ENABLE_BLE /** * @brief Get field subevent_code from event ancs_subevent_client_disconnected - * @param Event packet + * @param event packet * @return subevent_code * @note: btstack_type 1 */ @@ -2341,7 +2429,7 @@ static inline uint8_t ancs_subevent_client_disconnected_get_subevent_code(const } /** * @brief Get field handle from event ancs_subevent_client_disconnected - * @param Event packet + * @param event packet * @return handle * @note: btstack_type H */ diff --git a/src/classic/bnep.c b/src/classic/bnep.c index 3e1c131e5..6ca4dddfa 100644 --- a/src/classic/bnep.c +++ b/src/classic/bnep.c @@ -46,16 +46,15 @@ #include <string.h> // memcpy #include <stdint.h> -#include "hci_cmd.h" +#include "bnep.h" +#include "btstack_debug.h" +#include "btstack_event.h" +#include "btstack_memory.h" #include "btstack_util.h" #include "classic/sdp_util.h" - -#include "btstack_memory.h" #include "hci.h" +#include "hci_cmd.h" #include "hci_dump.h" -#include "btstack_debug.h" -#include "bnep.h" - #include "l2cap.h" #define BNEP_CONNECTION_TIMEOUT_MS 10000 @@ -1157,7 +1156,7 @@ static int bnep_hci_event_handler(uint8_t *packet, uint16_t size) bnep_channel_t *channel = NULL; uint8_t status; - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { /* Accept an incoming L2CAP connection on PSM_BNEP */ case L2CAP_EVENT_INCOMING_CONNECTION: diff --git a/src/classic/bnep.h b/src/classic/bnep.h index 3699aa8be..8a004914e 100644 --- a/src/classic/bnep.h +++ b/src/classic/bnep.h @@ -45,7 +45,9 @@ #define __BNEP_H #include "btstack_util.h" - +#include "btstack_run_loop.h" +#include "gap.h" + #include <stdint.h> #if defined __cplusplus diff --git a/src/classic/hfp.c b/src/classic/hfp.c index ff5ebb258..8f55e3588 100644 --- a/src/classic/hfp.c +++ b/src/classic/hfp.c @@ -430,7 +430,7 @@ static void handle_query_rfcomm_event(uint8_t packet_type, uint16_t channel, uin if ( connection->state != HFP_W4_SDP_EVENT_QUERY_COMPLETE) return; - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case SDP_EVENT_QUERY_RFCOMM_SERVICE: if (!connection) { log_error("handle_query_rfcomm_event alloc connection for RFCOMM port %u failed", sdp_event_query_rfcomm_service_get_rfcomm_channel(packet)); @@ -458,9 +458,9 @@ void hfp_handle_hci_event(uint8_t packet_type, uint8_t *packet, uint16_t size){ uint16_t rfcomm_cid, handle; hfp_connection_t * context = NULL; - // printf("AG packet_handler type %u, packet[0] %x, size %u\n", packet_type, packet[0], size); + // printf("AG packet_handler type %u, event type %x, size %u\n", packet_type, hci_event_packet_get_type(packet), size); - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case RFCOMM_EVENT_INCOMING_CONNECTION: // data: event (8), len(8), address(48), channel (8), rfcomm_cid (16) @@ -477,7 +477,7 @@ void hfp_handle_hci_event(uint8_t packet_type, uint8_t *packet, uint16_t size){ case RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE: // data: event(8), len(8), status (8), address (48), handle(16), server channel(8), rfcomm_cid(16), max frame size(16) - printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE packet_handler type %u, packet[0] %x, size %u\n", packet_type, packet[0], size); + printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE packet_handler type %u, size %u\n", packet_type, size); reverse_bd_addr(&packet[3], event_addr); context = get_hfp_connection_context_for_bd_addr(event_addr); diff --git a/src/classic/hsp_ag.c b/src/classic/hsp_ag.c index c10ae57b5..cdb2781df 100644 --- a/src/classic/hsp_ag.c +++ b/src/classic/hsp_ag.c @@ -443,7 +443,6 @@ static void hsp_run(void){ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ - // log_info("packet_handler type %u, packet[0] %x", packet_type, packet[0]); if (packet_type == RFCOMM_DATA_PACKET){ while (size > 0 && (packet[0] == '\n' || packet[0] == '\r')){ size--; @@ -485,7 +484,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack } if (packet_type != HCI_EVENT_PACKET) return; - uint8_t event = packet[0]; + uint8_t event = hci_event_packet_get_type(packet); bd_addr_t event_addr; uint16_t handle; diff --git a/src/classic/hsp_hs.c b/src/classic/hsp_hs.c index 43acff84a..fb07f69c3 100644 --- a/src/classic/hsp_hs.c +++ b/src/classic/hsp_hs.c @@ -432,7 +432,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack } if (packet_type != HCI_EVENT_PACKET) return; - uint8_t event = packet[0]; + uint8_t event = hci_event_packet_get_type(packet); bd_addr_t event_addr; uint16_t handle; @@ -518,7 +518,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack break; case RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE: - printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE packet_handler type %u, packet[0] %x\n", packet_type, packet[0]); + printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE packet_handler type %u\n", packet_type); // data: event(8), len(8), status (8), address (48), handle(16), server channel(8), rfcomm_cid(16), max frame size(16) if (packet[2]) { printf("RFCOMM channel open failed, status %u\n", packet[2]); @@ -575,7 +575,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack } static void handle_query_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case SDP_EVENT_QUERY_RFCOMM_SERVICE: channel_nr = sdp_event_query_rfcomm_service_get_rfcomm_channel(packet); printf("** Service name: '%s', RFCOMM port %u\n", sdp_event_query_rfcomm_service_get_name(packet), channel_nr); diff --git a/src/classic/rfcomm.c b/src/classic/rfcomm.c index aea38f329..e7e6068d7 100644 --- a/src/classic/rfcomm.c +++ b/src/classic/rfcomm.c @@ -45,6 +45,7 @@ #include <stdint.h> #include "btstack_debug.h" +#include "btstack_event.h" #include "btstack_memory.h" #include "btstack_util.h" #include "classic/rfcomm.h" @@ -841,7 +842,7 @@ static int rfcomm_multiplexer_hci_event_handler(uint8_t *packet, uint16_t size){ rfcomm_multiplexer_t *multiplexer = NULL; uint8_t status; - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { // accept incoming PSM_RFCOMM connection if no multiplexer exists yet case L2CAP_EVENT_INCOMING_CONNECTION: diff --git a/src/classic/sdp_client.c b/src/classic/sdp_client.c index 506ea1550..96297f2ad 100644 --- a/src/classic/sdp_client.c +++ b/src/classic/sdp_client.c @@ -44,6 +44,7 @@ #include "hci_cmd.h" +#include "btstack_event.h" #include "l2cap.h" #include "classic/sdp_server.h" #include "classic/sdp_util.h" @@ -459,10 +460,7 @@ void sdp_client_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p if (packet_type != HCI_EVENT_PACKET) return; - switch(packet[0]){ - case L2CAP_EVENT_TIMEOUT_CHECK: - log_info("sdp client: L2CAP_EVENT_TIMEOUT_CHECK"); - break; + switch(hci_event_packet_get_type(packet)){ case L2CAP_EVENT_CHANNEL_OPENED: if (sdp_client_state != W4_CONNECT) break; // data: event (8), len(8), status (8), address(48), handle (16), psm (16), local_cid(16), remote_cid (16), local_mtu(16), remote_mtu(16) diff --git a/src/classic/sdp_query_rfcomm.c b/src/classic/sdp_query_rfcomm.c index 944de53bf..a5ef8f5b3 100644 --- a/src/classic/sdp_query_rfcomm.c +++ b/src/classic/sdp_query_rfcomm.c @@ -246,7 +246,7 @@ static void handleServiceNameData(uint32_t attribute_value_length, uint32_t data } static void handle_sdp_parser_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ - switch (packet[0]){ + switch (hci_event_packet_get_type(packet)){ case SDP_EVENT_QUERY_SERVICE_RECORD_HANDLE: // handle service without a name if (sdp_rfcomm_channel_nr){ diff --git a/src/classic/sdp_server.c b/src/classic/sdp_server.c index 8ea922b83..3d028dbce 100644 --- a/src/classic/sdp_server.c +++ b/src/classic/sdp_server.c @@ -44,6 +44,7 @@ #include "btstack_memory.h" #include "btstack_debug.h" +#include "btstack_event.h" #include "hci_dump.h" #include "l2cap.h" @@ -491,7 +492,7 @@ static void sdp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p case HCI_EVENT_PACKET: - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case L2CAP_EVENT_INCOMING_CONNECTION: if (l2cap_cid) { diff --git a/src/hci.c b/src/hci.c index c17a329f0..5f01787eb 100644 --- a/src/hci.c +++ b/src/hci.c @@ -63,6 +63,7 @@ #include <inttypes.h> #include "btstack_debug.h" +#include "btstack_event.h" #include "btstack_linked_list.h" #include "btstack_memory.h" #include "gap.h" @@ -1106,7 +1107,7 @@ static void hci_init_done(void){ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){ uint8_t command_completed = 0; - if (packet[0] == HCI_EVENT_COMMAND_COMPLETE){ + if (hci_event_packet_get_type(packet) == HCI_EVENT_COMMAND_COMPLETE){ uint16_t opcode = little_endian_read_16(packet,3); if (opcode == hci_stack->last_cmd_opcode){ command_completed = 1; @@ -1116,7 +1117,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){ } } - if (packet[0] == HCI_EVENT_COMMAND_STATUS){ + if (hci_event_packet_get_type(packet) == HCI_EVENT_COMMAND_STATUS){ uint8_t status = packet[2]; uint16_t opcode = little_endian_read_16(packet,4); if (opcode == hci_stack->last_cmd_opcode){ @@ -1132,13 +1133,13 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){ } // Vendor == CSR - if (hci_stack->substate == HCI_INIT_W4_CUSTOM_INIT && packet[0] == HCI_EVENT_VENDOR_SPECIFIC){ + if (hci_stack->substate == HCI_INIT_W4_CUSTOM_INIT && hci_event_packet_get_type(packet) == HCI_EVENT_VENDOR_SPECIFIC){ // TODO: track actual command command_completed = 1; } // Vendor == Toshiba - if (hci_stack->substate == HCI_INIT_W4_SEND_BAUD_CHANGE && packet[0] == HCI_EVENT_VENDOR_SPECIFIC){ + if (hci_stack->substate == HCI_INIT_W4_SEND_BAUD_CHANGE && hci_event_packet_get_type(packet) == HCI_EVENT_VENDOR_SPECIFIC){ // TODO: track actual command command_completed = 1; } @@ -1156,7 +1157,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){ // // Fix: Command Complete for HCI Reset in HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION trigger resend if (!command_completed - && packet[0] == HCI_EVENT_COMMAND_COMPLETE + && hci_event_packet_get_type(packet) == HCI_EVENT_COMMAND_COMPLETE && hci_stack->substate == HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION){ uint16_t opcode = little_endian_read_16(packet,3); @@ -1327,9 +1328,9 @@ static void event_handler(uint8_t *packet, int size){ hci_connection_t * conn; int i; - // log_info("HCI:EVENT:%02x", packet[0]); + // log_info("HCI:EVENT:%02x", hci_event_packet_get_type(packet)); - switch (packet[0]) { + switch (hci_event_packet_get_type(packet)) { case HCI_EVENT_COMMAND_COMPLETE: // get num cmd packets @@ -1791,7 +1792,7 @@ static void event_handler(uint8_t *packet, int size){ hci_emit_event(packet, size, 0); // don't dump, already happened in packet handler // moved here to give upper stack a chance to close down everything with hci_connection_t intact - if (packet[0] == HCI_EVENT_DISCONNECTION_COMPLETE){ + if (hci_event_packet_get_type(packet) == HCI_EVENT_DISCONNECTION_COMPLETE){ if (!packet[2]){ handle = little_endian_read_16(packet, 3); hci_connection_t * aConn = hci_connection_for_handle(handle); diff --git a/src/l2cap.c b/src/l2cap.c index e0a6fe1f2..10c0261d2 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -47,6 +47,7 @@ #include "hci.h" #include "hci_dump.h" #include "btstack_debug.h" +#include "btstack_event.h" #include "btstack_memory.h" #include <stdarg.h> @@ -919,7 +920,7 @@ static void l2cap_hci_event_handler(uint8_t packet_type, uint16_t cid, uint8_t * btstack_linked_list_iterator_t it; int hci_con_used; - switch(packet[0]){ + switch(hci_event_packet_get_type(packet)){ // handle connection complete events case HCI_EVENT_CONNECTION_COMPLETE: diff --git a/tool/btstack_event_generator.py b/tool/btstack_event_generator.py index 4a63e80e1..23888e590 100755 --- a/tool/btstack_event_generator.py +++ b/tool/btstack_event_generator.py @@ -77,6 +77,15 @@ extern "C" { /* API_START */ +/** + * @brief Get event type + * @param event + * @return type of event + */ +static inline uint8_t hci_event_packet_get_type(const uint8_t * event){ + return event[0]; +} + """ hfile_header_end = """ @@ -92,7 +101,7 @@ hfile_header_end = """ c_prototoype_simple_return = '''/** * @brief {description} - * @param Event packet + * @param event packet * @return {result_name} * @note: btstack_type {format} */ @@ -103,7 +112,7 @@ static inline {result_type} {fn_name}(const uint8_t * event){{ c_prototoype_struct_return = '''/** * @brief {description} - * @param Event packet + * @param event packet * @param Pointer to storage for {result_name} * @note: btstack_type {format} */ @@ -114,7 +123,7 @@ static inline void {fn_name}(const uint8_t * event, {result_type} {result_name}) c_prototoype_unsupported = '''/** * @brief {description} - * @param Event packet + * @param event packet * @return {result_name} * @note: btstack_type {format} */ @@ -123,6 +132,16 @@ c_prototoype_unsupported = '''/** // }} ''' +meta_event_template = '''/*** + * @brief Get subevent code for {meta_event} event + * @param event packet + * @return subevent_code + */ +static inline uint8_t hci_event_{meta_event}_meta_get_subevent_code(const uint8_t * event){{ + return event[2]; +}} +''' + # global variables/defines gen_path = '../src/btstack_event.h' @@ -205,10 +224,16 @@ def create_events(events): global copyright global hfile_header_begin global hfile_header_end + global meta_event_template with open(gen_path, 'wt') as fout: fout.write(copyright) fout.write(hfile_header_begin) + + meta_events = ['HSP', 'HFP', 'ANCS']; + for meta_event in meta_events: + fout.write(meta_event_template.format(meta_event=meta_event.lower())) + for event_type, event_name, format, args in events: parts = event_name.split("_") event_group = parts[0]