From f905c23a5cfde224a0a7c189a35f6f2aa52bb743 Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Wed, 12 Aug 2020 20:31:14 +1000 Subject: [PATCH] extmod/nimble: Automatically notify subscribed connections on gatts_write(). --- extmod/nimble/modbluetooth_nimble.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c index e3a2f872e5ec..97f40ee107fb 100644 --- a/extmod/nimble/modbluetooth_nimble.c +++ b/extmod/nimble/modbluetooth_nimble.c @@ -1008,10 +1008,14 @@ int mp_bluetooth_gatts_write(uint16_t value_handle, const uint8_t *value, size_t if (!mp_bluetooth_is_active()) { return ERRNO_BLUETOOTH_NOT_ACTIVE; } - return mp_bluetooth_gatts_db_write(MP_STATE_PORT(bluetooth_nimble_root_pointers)->gatts_db, value_handle, value, value_len); -} + int ret = mp_bluetooth_gatts_db_write(MP_STATE_PORT(bluetooth_nimble_root_pointers)->gatts_db, value_handle, value, value_len); + + // Send notification/indication to any connected devices that have + // subscribed to this characteristic. + ble_gatts_chr_updated(value_handle); -// TODO: Could use ble_gatts_chr_updated to send to all subscribed centrals. + return ret; +} int mp_bluetooth_gatts_notify(uint16_t conn_handle, uint16_t value_handle) { if (!mp_bluetooth_is_active()) {