Peripheral device cannot be found while scanning for a specific CBUUID service

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 can not find my peripherals, but when I use:

 _centralMan = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; [_centralMan scanForPeripheralsWithServices:nil options:nil]; 

... he appears immediately.

When I connect, I can open / read / write for all the services that I expect. I understand that GAP makes this possible. I also tried CBUUID for other services that I know work (in particular, "1804", TX data service), to no avail; scanning does not detect anything.

Despite the fact that the services work (I can communicate with them when connected), when I look at the transfer of the UUID array of the service 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); } } 

... he always reports "Services found: 0". Should I expect the services array to be populated with w / services detected during the scan? (I assume this is at least partially possible based on scanForPeripheralsWithServices:[NSArray arrayWithObject:uuid] options:nil .)

Maybe this is a problem with my peripheral service advertisements? Am I using the API incorrectly? Any guidance is much appreciated !:-)

PS: I'm pretty green with bluetooth.

PPS: I control the source peripheral (this is CC2540DK). Therefore, I would be sure that the problem would be what it is.

+3
source share
1 answer

It turns out that our peripheral code did not advertise UUID a la this Bluetooth specification .

As soon as we fell into the proposal, iOS did not lose them.

+2
source

Source: https://habr.com/ru/post/1212445/


All Articles