Reputation: 9061
I have a fitness app that can connect to Bluetooth LE heart rate monitors. I've had no problem with it for the last few years. Now I'm updating it for iOS 10, and something strange is happening. If I scan for peripherals like this...
- (id)init {
self.heartRateService = @"180D";
self.heartRateKey = @"2A37";
self.allServices = [NSArray arrayWithObjects:[CBUUID UUIDWithString:self.heartRateService], nil];
self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}
- (void)startScanning {
if (self.centralManager.state == CBCentralManagerStatePoweredOn) {
[self.centralManager scanForPeripheralsWithServices:self.allServices options:nil];
}
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
DLog(@"found peripheral: %@", peripheral);
DLog(@"advertisementData: %@", advertisementData);
DLog(@"RSSI: %@", RSSI);
}
...it can't find the heart rate monitor -- the scan starts but didDiscoverPeripheral
is never called. If I try competitor app #1, it finds and displays data from the HRM, but if I quit it and return to my app, my app still can't find the HRM. If I try competitor app #2, it finds and displays data from the HRM, and if I quit it and return to my app, then my app connects immediately and works as expected. It seems like competitor app #1 has a different way to find the HRM, while competitor app #2 does something to not only find the HRM, but let my app find it afterwards. Although this scenario seems strange, it is 100% reproducible.
I can make two guesses about what's happening:
1) Competitor app #2 enables some setting on the HRM that allows it to be found. But I don't think this is possible because I think communication with a BTLE accessory is one way.
2) iOS 10 has some kind of privacy setting that is disabled by default, but competitor app #2 enables it, allowing my app to see the HRM afterwards.
Does this make any sense, or does anyone have a theory about what's wrong?
Upvotes: 1
Views: 42