From bbb8e69815883cdbeeb10c482d4c4d155bf1af29 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 28 Oct 2024 12:19:49 +0100 Subject: [PATCH] gatt_client: allow to ignore EATT bearer --- src/ble/gatt_client.c | 12 +++++++++++- src/ble/gatt_client.h | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ble/gatt_client.c b/src/ble/gatt_client.c index 5df94a187..d18213edb 100644 --- a/src/ble/gatt_client.c +++ b/src/ble/gatt_client.c @@ -100,6 +100,7 @@ static void gatt_client_classic_retry(btstack_timer_source_t * ts); #endif #ifdef ENABLE_GATT_OVER_EATT +static bool gatt_client_eatt_enabled; static bool gatt_client_le_enhanced_handle_can_send_query(gatt_client_t * gatt_client); static void gatt_client_le_enhanced_retry(btstack_timer_source_t * ts); #endif @@ -125,6 +126,10 @@ void gatt_client_init(void){ // and ATT Client PDUs att_dispatch_register_client(gatt_client_att_packet_handler); + +#ifdef ENABLE_GATT_OVER_EATT + gatt_client_eatt_enabled = true; +#endif } void gatt_client_set_required_security_level(gap_security_level_t level){ @@ -246,7 +251,7 @@ static uint8_t gatt_client_provide_context_for_request(hci_con_handle_t con_hand } #ifdef ENABLE_GATT_OVER_EATT - if (gatt_client->eatt_state == GATT_CLIENT_EATT_READY){ + if ((gatt_client->eatt_state == GATT_CLIENT_EATT_READY) && gatt_client_eatt_enabled){ btstack_linked_list_iterator_t it; gatt_client_t * eatt_client = NULL; // find free eatt client @@ -3892,6 +3897,11 @@ uint8_t gatt_client_le_enhanced_connect(btstack_packet_handler_t callback, hci_c return ERROR_CODE_SUCCESS; } +void gatt_client_le_enhanced_enable(bool enable){ + gatt_client_eatt_enabled = enable; +} + + #endif #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION diff --git a/src/ble/gatt_client.h b/src/ble/gatt_client.h index b8a4fa2f7..894d5a46f 100644 --- a/src/ble/gatt_client.h +++ b/src/ble/gatt_client.h @@ -1288,6 +1288,9 @@ void gatt_client_att_packet_handler_fuzz(uint8_t packet_type, uint16_t handle, u uint8_t gatt_client_get_client(hci_con_handle_t con_handle, gatt_client_t ** gatt_client); #endif +// used for testing, default is ON +void gatt_client_le_enhanced_enable(bool enable); + #if defined __cplusplus } #endif