CBPeripheral name not updating
I have a bluetooth device that can update its advertised name. Then I use this code to read the new name in my application:
NSString *localName = [advertisementData objectForKey:CBAdvertisementDataLocalNameKey];
When I do this, the variable localName
then contains the updated name. However, when calling this function:
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
peripheral.name
retains the old name. I tried several things to get it to grab the new name (for example, I tried to reset the bluetooth device, reset iPad, uninstall / reinstall my app), but none of those things worked. After leaving it alone for a couple of hours, I went back and peripheral.name
finally updated to reflect the value in localName
.
I thought there might have been a way for a Bluetooth device to advertise one name and then advertise as another, but I found a scenario that convinced me that the problem was with the iOS app. The Bluetooth device was advertised as "Name A". I found a device with my iPod and my iPad. Both devices saw "Name A". I have updated the device name to "Name B". I discovered the device with my iPod and it still reported the device as "Name A". After a while, it finally updated to Title B. I changed the device name to "Name C". The iPod reports "Name B" and the iPad still reports "Name A".
Has anyone seen this issue? Is there a way to update the value CBPeripheral.name
?
(EDIT: I just noticed that the iPad started reporting "Name C" after I first connected to the device. Is there a way to update the name before connecting it?)
source to share
No one has answered this question yet
Check out similar questions: