Cannot find BLE peripheral when scanning for specific services
Cannot find BLE peripheral when scanning for specific services
- Subject: Cannot find BLE peripheral when scanning for specific services
- From: "Mosher, Ben" <email@hidden>
- Date: Tue, 26 Jun 2012 17:26:41 -0400
- Acceptlanguage: en-US
- Thread-topic: Cannot find BLE peripheral when scanning for specific services
When I use:
CBUUID * uuid = [CBUUID UUIDWithString:@"1800"]; // GAP
DEBUG_LOG(@"CBUUID: %@",uuid); // CBUUID: Generic Access Profile
_centralMan = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[_centralMan scanForPeripheralsWithServices:[NSArray arrayWithObject:uuid]
options:nil];
I cannot find my peripheral, but when I use:
_centralMan = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[_centralMan scanForPeripheralsWithServices:nil
options:nil];
…it shows up immediately.
When I connect, I am able to discover/read/write to all the services I am expecting. My understanding is that GAP makes this possible. I have also tried CBUUID's for other services that I know are running (specifically "1804", TX power service), to no avail; the scan never discovers anything.
Even though the services are running (I can communicate w/ them upon connecting), when I scan passing the service UUID array as `nil` and this delegate method is called...
-(void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
DEBUG_LOG(@"Found peripheral w/ UUID: %@ RSSI: %@ \n AdvData: %@",peripheral.UUID,RSSI,advertisementData);
DEBUG_LOG(@"Services found: %d",peripheral.services.count);
for (CBService * service in peripheral.services) {
DEBUG_LOG(@"Found service: %@ w/ UUID %@",service, service.UUID);
}
}
…it always reports "Services found: 0". Should I expect the `services` array to be populated w/ services found during the scan? (I assume this is at least partially possible, based on `scanForPeripheralsWithServices:[NSArray arrayWithObject:uuid]
options:nil`.)
Could this be a problem w/ my peripheral's service advertisements? Am I using the API incorrectly? Any guidance is much appreciated! :-)
--Ben Mosher
PS: I'm pretty green w/ Bluetooth.
PPS: I control the source to the peripheral (it's a CC2540DK). So I'd be as likely to believe the problem is there as it is here.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden