• There is actually 'Service Changed' characteristics that should be used for that and indicate changes.

    I know, but as far as I know it's no use.

    The Service Changed characteristic is designed to enable a GATT server to change its structure during a BLE connection while maintaining synchronicity with the client.

    Basically in order to remove a service, you have to reboot the softdevice, which means being disconnected. And if you're disconnected, nothing is going to be listening to get the notification that the service changed :(

    About the only thing I can think is to have the flag, then if something has changed wait until the connection has initialised and then set service changed?

  • Basically in order to remove a service, you have to reboot the softdevice, which means being disconnected. And if you're disconnected, nothing is going to be listening to get the notification that the service changed :(

    Interesting. I've seen this 'service changed' characteristics working in the buttonless DFU as done in SDK11 - on F07/F10/DK08 watches. Stock firmware has some services including buttonless DFU, then when you click DFU button and start uploading zip in nrfconnect it reboots into bootloader after sending init packet, then upload continues and then after update it reboots back and it still uses same mac address. However I am not sure if services are removed during this. I was thinking yes (since you cannot use the fitness stuff or read battery while in bootloader and updating the firmware) but now I am not sure. Softdevice is not restarted when entering bootloader and possibly even connection is kept open if I understand it correctly. When switching back the connection is closed and SD is restarted. And it seem to work as expected when updating between different versions of original firmware. And true that when I flash espruino via this buttonless DFU I do have issues connecting to espruino nordic uart. Will check in more details. I just know this characterisitics is there and also saw some code related to that in SDK11 bootloader - method static uint32_t service_change_indicate() in SDK11/components/libraries/bootloader_df­u/dfu_transport_ble.c. It calls sd_ble_gatts_service_changed(m_conn_hand­le, DFU_SERVICE_HANDLE, BLE_HANDLE_MAX).

    About the only thing I can think is to have the flag, then if something has changed wait until the connection has initialised and then set service changed?

    Well, yes, that could be solution. Always add this characteristics and signal change on every connection. Either always or when change is detected. Or add method for it so that people could trigger the change after connection themselves(?). But the initial state after waking BT on startup the characteristics should be there so that device would not cache the state without having it (?).

    The practical caching experience with IOS and Android is described in that last link I posted. They mention iOS even does not cache if the 'service changed' is there (?).

About

Avatar for fanoush @fanoush started