From e2522d60d9ffe4fefae1b4a9f8b47ddf02e65f2d Mon Sep 17 00:00:00 2001 From: shreeyash Date: Tue, 20 Aug 2024 17:48:09 +0530 Subject: [PATCH] fix(nimble): Make CCCD flags configurable --- nimble/host/src/ble_gatt_priv.h | 1 + nimble/host/src/ble_gatts.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/nimble/host/src/ble_gatt_priv.h b/nimble/host/src/ble_gatt_priv.h index 2b1705a10..e4b93f5a0 100644 --- a/nimble/host/src/ble_gatt_priv.h +++ b/nimble/host/src/ble_gatt_priv.h @@ -186,6 +186,7 @@ int ble_gatts_register_svcs(const struct ble_gatt_svc_def *svcs, int ble_gatts_clt_cfg_access(uint16_t conn_handle, uint16_t attr_handle, uint8_t op, uint16_t offset, struct os_mbuf **om, void *arg); +void ble_gatts_set_clt_cfg_perm_flags(uint8_t flags); /*** @misc. */ int ble_gatts_conn_can_alloc(void); diff --git a/nimble/host/src/ble_gatts.c b/nimble/host/src/ble_gatts.c index c475b71ad..f387484b5 100644 --- a/nimble/host/src/ble_gatts.c +++ b/nimble/host/src/ble_gatts.c @@ -26,6 +26,8 @@ #include "ble_hs_priv.h" #include "esp_nimble_mem.h" +static uint8_t perm_flags = BLE_ATT_F_READ | BLE_ATT_F_WRITE ; + #define BLE_GATTS_INCLUDE_SZ 6 #define BLE_GATTS_CHR_MAX_SZ 19 @@ -79,6 +81,11 @@ STATS_NAME_START(ble_gatts_stats) STATS_NAME(ble_gatts_stats, dsc_writes) STATS_NAME_END(ble_gatts_stats) +void ble_gatts_set_clt_cfg_perm_flags(uint8_t flags) +{ + perm_flags = flags ; +} + static int ble_gatts_svc_access(uint16_t conn_handle, uint16_t attr_handle, uint8_t op, uint16_t offset, struct os_mbuf **om, @@ -791,8 +798,7 @@ static int ble_gatts_register_clt_cfg_dsc(uint16_t *att_handle) { int rc; - - rc = ble_att_svr_register(uuid_ccc, BLE_ATT_F_READ | BLE_ATT_F_WRITE, 0, + rc = ble_att_svr_register(uuid_ccc, perm_flags, 0, att_handle, ble_gatts_clt_cfg_access, NULL); if (rc != 0) { return rc;