mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-09 21:45:54 +00:00
gatt_client: drop notifications/indications as Central until re-encrypted
This commit is contained in:
parent
7e65711b3f
commit
c90e270f6c
@ -710,15 +710,33 @@ static uint8_t * setup_long_characteristic_value_packet(uint8_t type, hci_con_ha
|
||||
#endif
|
||||
}
|
||||
|
||||
// test if notification/indication should be delivered to application (BLESA)
|
||||
static bool gatt_client_accept_server_message(hci_con_handle_t con_handle){
|
||||
#ifdef ENABLE_LE_CENTRAL_AUTO_ENCRYPTION
|
||||
// only check as Central
|
||||
if (gap_get_role(con_handle) == HCI_ROLE_SLAVE) return true;
|
||||
|
||||
// ignore messages until re-encryption as central is complete
|
||||
if (gap_reconnect_security_setup_active(con_handle)) return false;
|
||||
|
||||
// after that ignore if bonded but not encrypted
|
||||
return !gap_bonded(con_handle) || (gap_encryption_key_size(con_handle) > 0);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// @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_notification(hci_con_handle_t con_handle, uint16_t value_handle, uint8_t * value, int length){
|
||||
if (!gatt_client_accept_server_message(con_handle)) return;
|
||||
uint8_t * packet = setup_characteristic_value_packet(GATT_EVENT_NOTIFICATION, con_handle, value_handle, value, length);
|
||||
emit_event_to_registered_listeners(con_handle, value_handle, packet, characteristic_value_event_header_size + length);
|
||||
}
|
||||
|
||||
// @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(hci_con_handle_t con_handle, uint16_t value_handle, uint8_t * value, int length){
|
||||
if (!gatt_client_accept_server_message(con_handle)) return;
|
||||
uint8_t * packet = setup_characteristic_value_packet(GATT_EVENT_INDICATION, con_handle, value_handle, value, length);
|
||||
emit_event_to_registered_listeners(con_handle, value_handle, packet, characteristic_value_event_header_size + length);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user