This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

what is IS_SRVC_CHANGED_CHARACT_PRESENT for?

Hi, I am just trying to understand the examples properly. This value is mostly set to 0, sometimes set to 1, and used at the call to the soft device initialization.

ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
err_code = sd_ble_enable(&ble_enable_params);

Basically I'm trying to figure out what it means, and the definitions I see throughout the SDK are all cryptic.

uint8_t service_changed:1; /**< Include the Service Changed characteristic in the local attributes. */

Any information would be very helpful. Thanks.

Parents
  • We ran into some problems with iOS regarding this because iOS will under some circumstances cache services and handles for a device, even when not bonding. I've found the guidance from the spec. a little vague, so I wanted to share my experience so that it may help others.

    Here is our use case: we have a device like a Heart Rate monitor. We'd like our customers to be able to update it's firmware. When it is running as a Heart Rate monitor, it is has all of the generic services, as well as the battery and heart rate services. We send it a special command to put it into DFU mode. Once in DFU mode, it has the Nordic DFU service and a different advertising name.

    Here's how iOS treats the Service Changed characteristic:

    1. If the characteristic is not enabled, iOS will cache the services for the device. The only way to get iOS to clear its cache is to turn Bluetooth off and then on again.
    2. If the characteristic is enabled, iOS will not cache the services for the device. It will re-read the services the next time you connect to it. If you want to force iOS to re-read the services while it is connected to the device, your device just needs to send a notification on the Service Changed characteristic.

    We initially were using option 1, but realized that iOS was caching the services. Switching to option 2 fixed almost everything. Some problems we ran into:

    • If you use option 1, iOS will still correctly show any changes to the advertised services, but it will use the cached services once you connect. This means that what is advertised and what iOS "thinks" the device has once you connect are not in agreement. I think this is a bug in iOS.
    • If you use option 2, iOS doesn't re-read the advertising name. It always seemed to have the device name from the last time it connected, so it seemed to be one revision behind.
Reply
  • We ran into some problems with iOS regarding this because iOS will under some circumstances cache services and handles for a device, even when not bonding. I've found the guidance from the spec. a little vague, so I wanted to share my experience so that it may help others.

    Here is our use case: we have a device like a Heart Rate monitor. We'd like our customers to be able to update it's firmware. When it is running as a Heart Rate monitor, it is has all of the generic services, as well as the battery and heart rate services. We send it a special command to put it into DFU mode. Once in DFU mode, it has the Nordic DFU service and a different advertising name.

    Here's how iOS treats the Service Changed characteristic:

    1. If the characteristic is not enabled, iOS will cache the services for the device. The only way to get iOS to clear its cache is to turn Bluetooth off and then on again.
    2. If the characteristic is enabled, iOS will not cache the services for the device. It will re-read the services the next time you connect to it. If you want to force iOS to re-read the services while it is connected to the device, your device just needs to send a notification on the Service Changed characteristic.

    We initially were using option 1, but realized that iOS was caching the services. Switching to option 2 fixed almost everything. Some problems we ran into:

    • If you use option 1, iOS will still correctly show any changes to the advertised services, but it will use the cached services once you connect. This means that what is advertised and what iOS "thinks" the device has once you connect are not in agreement. I think this is a bug in iOS.
    • If you use option 2, iOS doesn't re-read the advertising name. It always seemed to have the device name from the last time it connected, so it seemed to be one revision behind.
Children
No Data
Related