Service Changed characteristic configuration not being applied
Whilst playing around with the Service Changed characteristic, I noticed that although I enabled the characteristic by calling ble_device.configure(service_changed=True), the subsequent call to ble_device.ble_driver.ble_gatts_service_changed() was failing with NRF_ERROR_NOT_SUPPORTED, suggesting the characteristic was not enabled.
I tracked the problem down to get_service_changed_cfg() in config.py not returning a config object with the self.service_changed_char value applied.
Please see below for a patch that I'm currently applying to v0.4.0 of the library:
--- config.py.ORIG 2022-07-07 21:41:41.000000000 +0100
+++ config.py 2022-07-07 21:42:34.000000000 +0100
@@ -220,8 +220,8 @@
def get_service_changed_cfg(self):
config = driver.ble_cfg_t()
cfg = config.gatts_cfg.service_changed
- cfg = driver.ble_gatts_cfg_service_changed_t()
cfg.service_changed = self.service_changed_char
+ config.gatts_cfg.service_changed = cfg
return driver.BLE_GATTS_CFG_SERVICE_CHANGED, config
Good catch. Should be enough to remove that line you deleted, will test and fix
You're welcome. Note that there are a few other functions in config.py that I think suffer from the same issue.