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

alternativeAdvertisingName or custom peripheralSelector examples

I'm having an issue where I can't reconnect to a device after updating the firmware from the iOS SDK. I believe it's the issue described here in the documentation:

Since SDK 8.0.0, to solve caching problem on a host that is no bonded (in case there is no Service Changed characteristic), the bootloader starts to advertise with an address incremented by 1. The DFU Library has to scan for a peripheral with this new address. However, as iOS does not expose the device address in the public CoreBluetooth API, address matching, used on Android, can not be used. Instead, this selector is used. The DFU Service will start scanning for peripherals with a UUID filter, where the list of required UUID is returned by the filterBy(hint:) method. If your device in the Bootloader mode does not advertise with any service UUIDs, or this is not enough, you may select a target device by their advertising packet or RSSI using this delegate.

In SDK 14.0.0 a new feature was added to the Buttonless DFU for non-bonded devices which allows to send a unique name to the device before it is switched to bootloader mode. After jump, the bootloader will advertise with this name as the Complete Local Name making it easy to select proper device. In this case you don't have to override the default peripheral selector.

Are there any code examples of how to implement an alternativeAdvertisingName or custom peripheralSelector? The default peripheralSelector is not working for me.

  • Hi Drossi, 

    The feature to set the advertising device name is described here

    You can find it in the ble_dfu_buttonless_on_ctrl_pt_write() function in ble_dfu_unbonded.c 

    I'm not sure it's implemented in the iOS DFU library, but you can do this in your app. Simply send a write command to the DFU ctrl point characteristic with DFU_OP_SET_ADV_NAME + device name. And then after that start DFU as normal. 

    You can verify this by checking if the bootloader advertising after you trigger DFU with the name you set. 

Related