From c55a6388a2c1d5984e3e7c489de5d0908af4d97c 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 | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nimble/host/src/ble_gatt_priv.h b/nimble/host/src/ble_gatt_priv.h index 34c10ed16..86a52ee25 100644 --- a/nimble/host/src/ble_gatt_priv.h +++ b/nimble/host/src/ble_gatt_priv.h @@ -222,6 +222,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); #if MYNEWT_VAL(BLE_GATT_CACHING) struct ble_gatts_aware_state { diff --git a/nimble/host/src/ble_gatts.c b/nimble/host/src/ble_gatts.c index bec30c4e2..8e308efdc 100644 --- a/nimble/host/src/ble_gatts.c +++ b/nimble/host/src/ble_gatts.c @@ -26,6 +26,9 @@ #include "host/ble_store.h" #include "ble_hs_priv.h" #include "esp_nimble_mem.h" + +static uint8_t perm_flags = BLE_ATT_F_READ | BLE_ATT_F_WRITE ; + #if MYNEWT_VAL(BLE_DYNAMIC_SERVICE) #include "services/gatt/ble_svc_gatt.h" #endif @@ -175,6 +178,11 @@ ble_gatts_clt_cfg_free(struct ble_gatts_clt_cfg *cfg) } #endif +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, @@ -1000,8 +1008,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;