Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing iOS BLE cache

I'm currently running on iOS 7. It appears that BLE peripheral device name retrieved during scanning is cached based on the address. Even when the name of the BLE device is flushed with a new value, during iOS 7's peripheral device discovery [myCentralManager scanForPeripheralsWithServices:nil options:nil]; I get the old device name prior to flushing.

  1. Is there a way to programmatically clear the BLE device cache?
  2. Even with manual flushing it seems impossible. Under Setting->Bluetooth, BLE device never seems to be listed, despite being able to programmatically scan and connect. (as instructed here) Why is that?
like image 271
huggie Avatar asked Mar 23 '15 05:03

huggie


People also ask

What is BLE iOS?

Introduction: One of the main features of the Bluetooth 4 specification is Bluetooth Low Energy (BLE). Also called Bluetooth smart, this technology allows peripherals to communicate by consuming much less energy than regular Bluetooth.

Why does my iPhone Bluetooth keep searching for other devices?

When you access Settings > Bluetooth, it is normal for your iPhone to start searching for any Bluetooth devices that have been placed into discovery / pairing mode. Visiting this setting forms part of the process that you would follow when pairing your iPhone with Bluetooth accessories, such as wireless headphones.


1 Answers

I would recommend one of the most effective and violent solutions And my approach worked!!!

RESET YOUR IPHONE

Setting --> General --> Erase All Content and Settings

After that and scan again . It worked.

Other way:

Now let me tell you the correct way to solve the issue:

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.

link(https://forums.developer.apple.com/thread/19381)

In fact, this method (peripheralDidUpdateName) is not called

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *,id> *)advertisementData RSSI:(NSNumber *)RSSI {

    NSString * gapName = peripheral.name;
    NSString * identityName = [advertisementData objectForKey:CBAdvertisementDataLocalNameKey];
}

It is more precisely to use [advertisementData objectForKey:CBAdvertisementDataLocalNameKey] to get peripheral name than peripheral.name

Because peripheral.name get the GAP name but [advertisementData objectForKey:CBAdvertisementDataLocalNameKey] get the updated name.

here is the screenshot

like image 121
刘俊利 Avatar answered Oct 10 '22 07:10

刘俊利