3
votes

I am currently creating a simple iOS bluetooth app. I currently have a device with the ability to modify the name. What I am finding is that when I connect to a CBPeripheral device, it seems to be caching the old device name.

  1. Connect to the device via my app.
  2. Disconnect from device via my app.
  3. Change the name of the device.
  4. Rediscover/reconnect to the device via my app (with an existing CBPeripheral object).

By following the procedure above, I was expecting my iOS app to discover the new device name. However, I am finding that it has a tendency of retaining the old name instead. By disconnecting from the CBPeripheral device twice, I find that I can retrieve the new name.

So my question is, is there a way to update or clear CBPeripheral's existing discovered characteristics (or rediscovering new characteristics each time) in order to get the latest device name?

Here is a similar issue: CoreBluetooth: Refreshing local name of an already discovered Peripheral

1

1 Answers

12
votes

I had a similar issue, moreover it wasn't a problem only with the device's name but some characterstics changed in specific modes (like firmware upgrade on a device).

Got the following answer from apple:
"The answer is that the accessory needs to support the GATT Service Changed characteristic - please read the specification, specifically Vol 3, Part G, 2.5.2, and Vol 3, Part G, 7.1."

The name issue has been solved by having the device name advertised as a property in the advertisement data. (This however might need specific firmware as it doesn't always have that property in the adv package)

Otherwise to reset the core-bluetooth cache: you will need to re-start the iOS bluetooth adapter which I couldn't manage to do programatically on iOS.