mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-03 20:54:18 +00:00
GATT Client: allow to register for any notification/indication and/or any connection
This commit is contained in:
parent
7490175edc
commit
b3f03c843f
@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
### Changed
|
||||
|
||||
## Changes March 2020
|
||||
|
||||
### Added
|
||||
GATT Client: allow to register for any notification/indication and/or any connection
|
||||
|
||||
## Changes Februar 2020
|
||||
|
||||
### Fixed
|
||||
|
@ -491,7 +491,11 @@ static void emit_event_new(btstack_packet_handler_t callback, uint8_t * packet,
|
||||
void gatt_client_listen_for_characteristic_value_updates(gatt_client_notification_t * notification, btstack_packet_handler_t packet_handler, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic){
|
||||
notification->callback = packet_handler;
|
||||
notification->con_handle = con_handle;
|
||||
notification->attribute_handle = characteristic->value_handle;
|
||||
if (characteristic == NULL){
|
||||
notification->attribute_handle = GATT_CLIENT_ANY_VALUE_HANDLE;
|
||||
} else {
|
||||
notification->attribute_handle = characteristic->value_handle;
|
||||
}
|
||||
btstack_linked_list_add(&gatt_client_value_listeners, (btstack_linked_item_t*) notification);
|
||||
}
|
||||
|
||||
@ -504,8 +508,8 @@ static void emit_event_to_registered_listeners(hci_con_handle_t con_handle, uint
|
||||
btstack_linked_list_iterator_init(&it, &gatt_client_value_listeners);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
gatt_client_notification_t * notification = (gatt_client_notification_t*) btstack_linked_list_iterator_next(&it);
|
||||
if (notification->con_handle != con_handle) continue;
|
||||
if (notification->attribute_handle != attribute_handle) continue;
|
||||
if ((notification->con_handle != GATT_CLIENT_ANY_CONNECTION) && (notification->con_handle != con_handle)) continue;
|
||||
if ((notification->attribute_handle != GATT_CLIENT_ANY_VALUE_HANDLE) && (notification->attribute_handle != attribute_handle)) continue;
|
||||
(*notification->callback)(HCI_EVENT_PACKET, 0, packet, size);
|
||||
}
|
||||
}
|
||||
|
@ -691,8 +691,8 @@ uint8_t gatt_client_write_client_characteristic_configuration(btstack_packet_han
|
||||
* @brief Register for notifications and indications of a characteristic enabled by gatt_client_write_client_characteristic_configuration
|
||||
* @param notification struct used to store registration
|
||||
* @param callback
|
||||
* @param con_handle
|
||||
* @param characteristic
|
||||
* @param con_handle or GATT_CLIENT_ANY_CONNECTION to receive updates from all connected devices
|
||||
* @param characteristic or NULL to receive updates for all characteristics
|
||||
*/
|
||||
void gatt_client_listen_for_characteristic_value_updates(gatt_client_notification_t * notification, btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic);
|
||||
|
||||
|
@ -632,6 +632,9 @@ typedef enum {
|
||||
#define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION 1
|
||||
#define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION 2
|
||||
|
||||
#define GATT_CLIENT_ANY_CONNECTION 0xffff
|
||||
#define GATT_CLIENT_ANY_VALUE_HANDLE 0x0000
|
||||
|
||||
// GAP Service and Characteristics
|
||||
#define GAP_SERVICE_UUID 0x1800
|
||||
#define GAP_DEVICE_NAME_UUID 0x2a00
|
||||
|
Loading…
x
Reference in New Issue
Block a user