mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-29 21:32:38 +00:00
gatt_client: require ENABLE_GATT_CLIENT_SERVICE_CHANGED
This commit is contained in:
parent
e2c9844029
commit
842492f0d6
@ -82,63 +82,64 @@ Chipset properties:
|
||||
### ENABLE_* directives {#sec:enableDirectives}
|
||||
BTstack properties:
|
||||
|
||||
| \#define | Description |
|
||||
|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|
|
||||
| ENABLE_CLASSIC | Enable Classic related code in HCI and L2CAP |
|
||||
| ENABLE_BLE | Enable BLE related code in HCI and L2CAP |
|
||||
| ENABLE_EHCILL | Enable eHCILL low power mode on TI CC256x/WL18xx chipsets |
|
||||
| ENABLE_H5 | Enable support for SLIP mode in `btstack_uart.h` drivers for HCI H5 ('Three-Wire Mode') |
|
||||
| ENABLE_LOG_DEBUG | Enable log_debug messages |
|
||||
| ENABLE_LOG_ERROR | Enable log_error messages |
|
||||
| ENABLE_LOG_INFO | Enable log_info messages |
|
||||
| ENABLE_LOG_BTSTACK_EVENTS | Log internal/custom BTstack events |
|
||||
| ENABLE_SCO_OVER_HCI | Enable SCO over HCI for chipsets (if supported) |
|
||||
| ENABLE_SCO_OVER_PCM | Enable SCO ofer PCM/I2S for chipsets (if supported) |
|
||||
| ENABLE_HFP_WIDE_BAND_SPEECH | Enable support for mSBC codec used in HFP profile for Wide-Band Speech |
|
||||
| ENABLE_HFP_AT_MESSAGES | Enable `HFP_SUBEVENT_AT_MESSAGE_SENT` and `HFP_SUBEVENT_AT_MESSAGE_RECEIVED` events |
|
||||
| ENABLE_LE_PERIPHERAL | Enable support for LE Peripheral Role in HCI and Security Manager |
|
||||
| ENABLE_LE_CENTRAL | Enable support for LE Central Role in HCI and Security Manager |
|
||||
| ENABLE_LE_SECURE_CONNECTIONS | Enable LE Secure Connections |
|
||||
| ENABLE_LE_SECURE_CONNECTIONS_DEBUG_KEY | Enable support for LE Secure Connection debug keys for testing |
|
||||
| ENABLE_LE_PROACTIVE_AUTHENTICATION | Enable automatic encryption for bonded devices on re-connect |
|
||||
| ENABLE_GATT_CLIENT_PAIRING | Enable GATT Client to start pairing and retry operation on security error |
|
||||
| ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS | Use [micro-ecc library](https://github.com/kmackay/micro-ecc) for ECC operations |
|
||||
| ENABLE_LE_DATA_LENGTH_EXTENSION | Enable LE Data Length Extension support |
|
||||
| ENABLE_LE_ENHANCED_CONNECTION_COMPLETE_EVENT | Enable LE Enhanced Connection Complete Event v1 & v2 |
|
||||
| ENABLE_LE_EXTENDED_ADVERTISING | Enable extended advertising and scanning |
|
||||
| ENABLE_LE_PERIODIC_ADVERTISING | Enable periodic advertising and scanning |
|
||||
| ENABLE_LE_SIGNED_WRITE | Enable LE Signed Writes in ATT/GATT |
|
||||
| ENABLE_LE_PRIVACY_ADDRESS_RESOLUTION | Enable address resolution for resolvable private addresses in Controller |
|
||||
| ENABLE_CROSS_TRANSPORT_KEY_DERIVATION | Enable Cross-Transport Key Derivation (CTKD) for Secure Connections |
|
||||
| ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE | Enable Enhanced Retransmission Mode for L2CAP Channels. Mandatory for AVRCP Browsing |
|
||||
| ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE | Enable LE credit-based flow-control mode for L2CAP channels |
|
||||
| ENABLE_L2CAP_ENHANCED_CREDIT_BASED_FLOW_CONTROL_MODE | Enable Enhanced credit-based flow-control mode for L2CAP Channels |
|
||||
| ENABLE_HCI_CONTROLLER_TO_HOST_FLOW_CONTROL | Enable HCI Controller to Host Flow Control, see below |
|
||||
| ENABLE_HCI_SERIALIZED_CONTROLLER_OPERATIONS | Serialize Inquiry, Remote Name Request, and Create Connection operations |
|
||||
| ENABLE_ATT_DELAYED_RESPONSE | Enable support for delayed ATT operations, see [GATT Server](profiles/#sec:GATTServerProfile) |
|
||||
| ENABLE_BCM_PCM_WBS | Enable support for Wide-Band Speech codec in BCM controller, requires ENABLE_SCO_OVER_PCM |
|
||||
| ENABLE_CC256X_ASSISTED_HFP | Enable support for Assisted HFP mode in CC256x Controller, requires ENABLE_SCO_OVER_PCM |
|
||||
| ENABLE_RTK_PCM_WBS | Enable support for Wide-Band Speech codec in Realtek controller, requires ENABLE_SCO_OVER_PCM |
|
||||
| ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND | Enable workaround for bug in CC256x Flow Control during baud rate change, see chipset docs. |
|
||||
| ENABLE_CYPRESS_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND | Enable workaround for bug in CYW2070x Flow Control during baud rate change, similar to CC256x. |
|
||||
| ENABLE_LE_LIMIT_ACL_FRAGMENT_BY_MAX_OCTETS | Force HCI to fragment ACL-LE packets to fit into over-the-air packet |
|
||||
| \#define | Description |
|
||||
|-----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
|
||||
| ENABLE_CLASSIC | Enable Classic related code in HCI and L2CAP |
|
||||
| ENABLE_BLE | Enable BLE related code in HCI and L2CAP |
|
||||
| ENABLE_EHCILL | Enable eHCILL low power mode on TI CC256x/WL18xx chipsets |
|
||||
| ENABLE_H5 | Enable support for SLIP mode in `btstack_uart.h` drivers for HCI H5 ('Three-Wire Mode') |
|
||||
| ENABLE_LOG_DEBUG | Enable log_debug messages |
|
||||
| ENABLE_LOG_ERROR | Enable log_error messages |
|
||||
| ENABLE_LOG_INFO | Enable log_info messages |
|
||||
| ENABLE_LOG_BTSTACK_EVENTS | Log internal/custom BTstack events |
|
||||
| ENABLE_SCO_OVER_HCI | Enable SCO over HCI for chipsets (if supported) |
|
||||
| ENABLE_SCO_OVER_PCM | Enable SCO ofer PCM/I2S for chipsets (if supported) |
|
||||
| ENABLE_HFP_WIDE_BAND_SPEECH | Enable support for mSBC codec used in HFP profile for Wide-Band Speech |
|
||||
| ENABLE_HFP_AT_MESSAGES | Enable `HFP_SUBEVENT_AT_MESSAGE_SENT` and `HFP_SUBEVENT_AT_MESSAGE_RECEIVED` events |
|
||||
| ENABLE_LE_PERIPHERAL | Enable support for LE Peripheral Role in HCI and Security Manager |
|
||||
| ENABLE_LE_CENTRAL | Enable support for LE Central Role in HCI and Security Manager |
|
||||
| ENABLE_LE_SECURE_CONNECTIONS | Enable LE Secure Connections |
|
||||
| ENABLE_LE_SECURE_CONNECTIONS_DEBUG_KEY | Enable support for LE Secure Connection debug keys for testing |
|
||||
| ENABLE_LE_PROACTIVE_AUTHENTICATION | Enable automatic encryption for bonded devices on re-connect |
|
||||
| ENABLE_GATT_CLIENT_PAIRING | Enable GATT Client to start pairing and retry operation on security error |
|
||||
| ENABLE_GATT_CLIENT_SERVICE_CHANGED | Enable GATT Client to register for Service Changed and Database Hash indications |
|
||||
| ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS | Use [micro-ecc library](https://github.com/kmackay/micro-ecc) for ECC operations |
|
||||
| ENABLE_LE_DATA_LENGTH_EXTENSION | Enable LE Data Length Extension support |
|
||||
| ENABLE_LE_ENHANCED_CONNECTION_COMPLETE_EVENT | Enable LE Enhanced Connection Complete Event v1 & v2 |
|
||||
| ENABLE_LE_EXTENDED_ADVERTISING | Enable extended advertising and scanning |
|
||||
| ENABLE_LE_PERIODIC_ADVERTISING | Enable periodic advertising and scanning |
|
||||
| ENABLE_LE_SIGNED_WRITE | Enable LE Signed Writes in ATT/GATT |
|
||||
| ENABLE_LE_PRIVACY_ADDRESS_RESOLUTION | Enable address resolution for resolvable private addresses in Controller |
|
||||
| ENABLE_CROSS_TRANSPORT_KEY_DERIVATION | Enable Cross-Transport Key Derivation (CTKD) for Secure Connections |
|
||||
| ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE | Enable Enhanced Retransmission Mode for L2CAP Channels. Mandatory for AVRCP Browsing |
|
||||
| ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE | Enable LE credit-based flow-control mode for L2CAP channels |
|
||||
| ENABLE_L2CAP_ENHANCED_CREDIT_BASED_FLOW_CONTROL_MODE | Enable Enhanced credit-based flow-control mode for L2CAP Channels |
|
||||
| ENABLE_HCI_CONTROLLER_TO_HOST_FLOW_CONTROL | Enable HCI Controller to Host Flow Control, see below |
|
||||
| ENABLE_HCI_SERIALIZED_CONTROLLER_OPERATIONS | Serialize Inquiry, Remote Name Request, and Create Connection operations |
|
||||
| ENABLE_ATT_DELAYED_RESPONSE | Enable support for delayed ATT operations, see [GATT Server](profiles/#sec:GATTServerProfile) |
|
||||
| ENABLE_BCM_PCM_WBS | Enable support for Wide-Band Speech codec in BCM controller, requires ENABLE_SCO_OVER_PCM |
|
||||
| ENABLE_CC256X_ASSISTED_HFP | Enable support for Assisted HFP mode in CC256x Controller, requires ENABLE_SCO_OVER_PCM |
|
||||
| ENABLE_RTK_PCM_WBS | Enable support for Wide-Band Speech codec in Realtek controller, requires ENABLE_SCO_OVER_PCM |
|
||||
| ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND | Enable workaround for bug in CC256x Flow Control during baud rate change, see chipset docs. |
|
||||
| ENABLE_CYPRESS_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND | Enable workaround for bug in CYW2070x Flow Control during baud rate change, similar to CC256x. |
|
||||
| ENABLE_LE_LIMIT_ACL_FRAGMENT_BY_MAX_OCTETS | Force HCI to fragment ACL-LE packets to fit into over-the-air packet |
|
||||
| ENABLE_TLV_FLASH_EXPLICIT_DELETE_FIELD | Enable use of explicit delete field in TLV Flash implementation - required when flash value cannot be overwritten with zero |
|
||||
| ENABLE_TLV_FLASH_WRITE_ONCE | Enable storing of emtpy tag instead of overwriting existing tag - required when flash value cannot be overwritten at all |
|
||||
| ENABLE_CONTROLLER_WARM_BOOT | Enable stack startup without power cycle (if supported/possible) |
|
||||
| ENABLE_SEGGER_RTT | Use SEGGER RTT for console output and packet log, see [additional options](#sec:rttConfiguration) |
|
||||
| ENABLE_EXPLICIT_CONNECTABLE_MODE_CONTROL | Disable calls to control Connectable Mode by L2CAP |
|
||||
| ENABLE_EXPLICIT_IO_CAPABILITIES_REPLY | Let application trigger sending IO Capabilities (Negative) Reply |
|
||||
| ENABLE_EXPLICIT_LINK_KEY_REPLY | Let application trigger sending Link Key (Negative) Response, allows for asynchronous link key lookup |
|
||||
| ENABLE_EXPLICIT_BR_EDR_SECURITY_MANAGER | Report BR/EDR Security Manager support in L2CAP Information Response |
|
||||
| ENABLE_EXPLICIT_DEDICATED_BONDING_DISCONNECT | Keep connection after dedicated bonding is complete |
|
||||
| ENABLE_CLASSIC_OOB_PAIRING | Enable support for classic Out-of-Band (OOB) pairing |
|
||||
| ENABLE_A2DP_EXPLICIT_CONFIG | Let application configure stream endpoint (skip auto-config of SBC endpoint) |
|
||||
| ENABLE_AVDTP_ACCEPTOR_EXPLICIT_START_STREAM_CONFIRMATION | allow accept or reject of stream start on A2DP_SUBEVENT_START_STREAM_REQUESTED |
|
||||
| ENABLE_LE_WHITELIST_TOUCH_AFTER_RESOLVING_LIST_UPDATE | Enable Workaround for Controller bug |
|
||||
| ENABLE_LE_SET_ADV_PARAMS_ON_RANDOM_ADDRESS_CHANGE | Send HCI LE Set Advertising Params after HCI LE Set Random Address - workaround for Controller Bug |
|
||||
| ENABLE_CONTROLLER_DUMP_PACKETS | Dump number of packets in Controller per type for debugging |
|
||||
| ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS WORKAROUND | Track connection handle for HCI Commands and assume command has failed if disonnect event for connection is received |
|
||||
| ENABLE_MUTUAL_AUTHENTICATION_FOR_LEGACY_SECURE_CONNECTIONS | Re-authentication after connection was encrypted to avoid BIAS Attack. Not needed for min encryption key size of 16 |
|
||||
| ENABLE_TLV_FLASH_WRITE_ONCE | Enable storing of emtpy tag instead of overwriting existing tag - required when flash value cannot be overwritten at all |
|
||||
| ENABLE_CONTROLLER_WARM_BOOT | Enable stack startup without power cycle (if supported/possible) |
|
||||
| ENABLE_SEGGER_RTT | Use SEGGER RTT for console output and packet log, see [additional options](#sec:rttConfiguration) |
|
||||
| ENABLE_EXPLICIT_CONNECTABLE_MODE_CONTROL | Disable calls to control Connectable Mode by L2CAP |
|
||||
| ENABLE_EXPLICIT_IO_CAPABILITIES_REPLY | Let application trigger sending IO Capabilities (Negative) Reply |
|
||||
| ENABLE_EXPLICIT_LINK_KEY_REPLY | Let application trigger sending Link Key (Negative) Response, allows for asynchronous link key lookup |
|
||||
| ENABLE_EXPLICIT_BR_EDR_SECURITY_MANAGER | Report BR/EDR Security Manager support in L2CAP Information Response |
|
||||
| ENABLE_EXPLICIT_DEDICATED_BONDING_DISCONNECT | Keep connection after dedicated bonding is complete |
|
||||
| ENABLE_CLASSIC_OOB_PAIRING | Enable support for classic Out-of-Band (OOB) pairing |
|
||||
| ENABLE_A2DP_EXPLICIT_CONFIG | Let application configure stream endpoint (skip auto-config of SBC endpoint) |
|
||||
| ENABLE_AVDTP_ACCEPTOR_EXPLICIT_START_STREAM_CONFIRMATION | allow accept or reject of stream start on A2DP_SUBEVENT_START_STREAM_REQUESTED |
|
||||
| ENABLE_LE_WHITELIST_TOUCH_AFTER_RESOLVING_LIST_UPDATE | Enable Workaround for Controller bug |
|
||||
| ENABLE_LE_SET_ADV_PARAMS_ON_RANDOM_ADDRESS_CHANGE | Send HCI LE Set Advertising Params after HCI LE Set Random Address - workaround for Controller Bug |
|
||||
| ENABLE_CONTROLLER_DUMP_PACKETS | Dump number of packets in Controller per type for debugging |
|
||||
| ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS WORKAROUND | Track connection handle for HCI Commands and assume command has failed if disonnect event for connection is received |
|
||||
| ENABLE_MUTUAL_AUTHENTICATION_FOR_LEGACY_SECURE_CONNECTIONS | Re-authentication after connection was encrypted to avoid BIAS Attack. Not needed for min encryption key size of 16 |
|
||||
|
||||
Notes:
|
||||
|
||||
|
@ -72,7 +72,9 @@
|
||||
|
||||
static btstack_linked_list_t gatt_client_connections;
|
||||
static btstack_linked_list_t gatt_client_value_listeners;
|
||||
#ifdef ENABLE_GATT_CLIENT_SERVICE_CHANGED
|
||||
static btstack_linked_list_t gatt_client_service_changed_handler;
|
||||
#endif
|
||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||
static btstack_packet_callback_registration_t sm_event_callback_registration;
|
||||
static btstack_context_callback_registration_t gatt_client_deferred_event_emit;
|
||||
@ -103,8 +105,9 @@ static void gatt_client_le_enhanced_retry(btstack_timer_source_t * ts);
|
||||
|
||||
void gatt_client_init(void){
|
||||
gatt_client_connections = NULL;
|
||||
#ifdef ENABLE_GATT_CLIENT_SERVICE_CHANGED
|
||||
gatt_client_service_changed_handler = NULL;
|
||||
|
||||
#endif
|
||||
// default configuration
|
||||
gatt_client_mtu_exchange_enabled = true;
|
||||
gatt_client_required_security_level = LEVEL_0;
|
||||
@ -668,6 +671,7 @@ static uint16_t get_last_result_handle_from_included_services_list(uint8_t * pac
|
||||
return little_endian_read_16(packet, size - attr_length);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_GATT_CLIENT_SERVICE_CHANGED
|
||||
static void gatt_client_service_emit_event(gatt_client_t * gatt_client, uint8_t * event, uint16_t size){
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, &gatt_client_service_changed_handler);
|
||||
@ -782,6 +786,7 @@ static void gatt_client_service_packet_handler(uint8_t packet_type, uint16_t cha
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gatt_client_notify_can_send_query(gatt_client_t * gatt_client){
|
||||
|
||||
@ -805,11 +810,14 @@ static void gatt_client_notify_can_send_query(gatt_client_t * gatt_client){
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t status = ERROR_CODE_SUCCESS;
|
||||
gatt_client_service_t gatt_service;
|
||||
gatt_client_characteristic_t characteristic;
|
||||
while (gatt_client->state == P_READY){
|
||||
bool query_sent = false;
|
||||
UNUSED(query_sent);
|
||||
|
||||
#ifdef ENABLE_GATT_CLIENT_SERVICE_CHANGED
|
||||
uint8_t status = ERROR_CODE_SUCCESS;
|
||||
gatt_client_service_t gatt_service;
|
||||
gatt_client_characteristic_t characteristic;
|
||||
switch (gatt_client->gatt_service_state){
|
||||
case GATT_CLIENT_SERVICE_DISCOVER_W2_SEND:
|
||||
gatt_client->gatt_service_state = GATT_CLIENT_SERVICE_DISCOVER_W4_DONE;
|
||||
@ -884,6 +892,7 @@ static void gatt_client_notify_can_send_query(gatt_client_t * gatt_client){
|
||||
if (query_sent){
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_GATT_OVER_EATT
|
||||
query_sent = gatt_client_le_enhanced_handle_can_send_query(gatt_client);
|
||||
@ -1160,6 +1169,7 @@ static void report_gatt_notification(gatt_client_t *gatt_client, uint16_t value_
|
||||
// @note assume that value is part of an l2cap buffer - overwrite parts of the HCI/L2CAP/ATT packet (4/4/3) bytes
|
||||
static void report_gatt_indication(gatt_client_t *gatt_client, uint16_t value_handle, uint8_t *value, int length) {
|
||||
if (!gatt_client_accept_server_message(gatt_client)) return;
|
||||
#ifdef ENABLE_GATT_CLIENT_SERVICE_CHANGED
|
||||
// Directly Handle GATT Service Changed and Database Hash indications
|
||||
if (value_handle == gatt_client->gatt_service_database_hash_value_handle){
|
||||
gatt_client_service_emit_database_hash(gatt_client, value, length);
|
||||
@ -1167,6 +1177,7 @@ static void report_gatt_indication(gatt_client_t *gatt_client, uint16_t value_ha
|
||||
if (value_handle == gatt_client->gatt_service_changed_value_handle){
|
||||
gatt_client_service_emit_service_changed(gatt_client, value, length);
|
||||
}
|
||||
#endif
|
||||
uint8_t * packet = setup_characteristic_value_packet(GATT_EVENT_INDICATION, gatt_client->con_handle, value_handle, value, length);
|
||||
emit_event_to_registered_listeners(gatt_client->con_handle, value_handle, packet, CHARACTERISTIC_VALUE_EVENT_HEADER_SIZE + length);
|
||||
}
|
||||
@ -3085,6 +3096,8 @@ uint8_t gatt_client_request_can_write_without_response_event(btstack_packet_hand
|
||||
att_dispatch_client_request_can_send_now_event(gatt_client->con_handle);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_GATT_CLIENT_SERVICE_CHANGED
|
||||
void gatt_client_add_service_changed_handler(btstack_packet_callback_registration_t * callback) {
|
||||
btstack_linked_list_add_tail(&gatt_client_service_changed_handler, (btstack_linked_item_t*) callback);
|
||||
}
|
||||
@ -3092,6 +3105,7 @@ void gatt_client_add_service_changed_handler(btstack_packet_callback_registratio
|
||||
void gatt_client_remove_service_changed_handler(btstack_packet_callback_registration_t * callback){
|
||||
btstack_linked_list_remove(&gatt_client_service_changed_handler, (btstack_linked_item_t*) callback);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_GATT_OVER_CLASSIC) || defined(ENABLE_GATT_OVER_EATT)
|
||||
|
||||
|
@ -953,15 +953,21 @@ uint8_t gatt_client_write_client_characteristic_configuration(btstack_packet_han
|
||||
|
||||
/**
|
||||
* @brief Register for changes to the Service Changed and Database Hash Characteristics of the remote GATT Service
|
||||
* *
|
||||
* When configured, GATT_EVENT_QUERY_COMPLETE event is emitted
|
||||
* If supported, the Database Hash is read as well
|
||||
*
|
||||
* Requires ENABLE_GATT_CLIENT_SERVICE_CHANGED
|
||||
*
|
||||
* @param callback
|
||||
*/
|
||||
void gatt_client_add_service_changed_handler(btstack_packet_callback_registration_t * callback);
|
||||
|
||||
/**
|
||||
* @brief Remove callback for service changes
|
||||
*
|
||||
* Requires ENABLE_GATT_CLIENT_SERVICE_CHANGED
|
||||
*
|
||||
* @param callback
|
||||
*/
|
||||
void gatt_client_remove_service_changed_handler(btstack_packet_callback_registration_t * callback);
|
||||
|
Loading…
x
Reference in New Issue
Block a user