Our peripheral firmware is in development so we've been changing the device address and device name (which we're using for the ID) often. We've noticed that the name reported by iOS can be out of date, since it's caching it against the device address? I've tried switching Bluetooth off and on, even switching the phone off and on, but to no avail.
Also, the 'name' is not matching up to 'kCBAdvDataLocalName' in the advertising data.
For example, our peripheral is currently set to (and we've verified this with CySmart on the laptop):
Address: ...:00:00:27
Shortened Local Name: 000027 (This is set in the Scan Response Data)
But iOS is reporting the device data as follows. 'kCBAdvDataLocalName' is up to date, but 'name' isn't...
{
advertising = {
kCBAdvDataIsConnectable = 1;
kCBAdvDataLocalName = 000027;
};
id = "379E9807-8F94-6397-CECE-E63F027FA614";
name = 000025;
rssi = "-65";
}
So, two questions please:
- Anyone know why 'name' doesn't match up to 'kCBAdvDataLocalName'?
- Is there a way to (preferably non-programmatically) clear the cache?
Thanks in advance!
There are 2 names to consider. The advertising name and the GAP (Generic Access Profile) name.
For a peripheral which iOS has never connected before, the 'name' property reported is the advertising name. Once it is connected, the GAP name is cached, and is reported as the peripheral's name. GAP name is considered a "better" name due to the size restrictions on the advertising name.
There is no rule that says both names must match. That depends on your use case and implementation. Some people will consider the GAP name as the fixed name, but the advertising name more of an "alias", as it can easily be changed.
If you want both names in sync, you should change the GAP name as well along with the advertised name. Implemented properly, your CB manager delegate will receive a call to - peripheralDidUpdateName:
If you want to manually clear the cache, you need to reset the iOS device.