Re: Cannot find BLE peripheral when scanning for specific services
Re: Cannot find BLE peripheral when scanning for specific services
- Subject: Re: Cannot find BLE peripheral when scanning for specific services
- From: Craig Dooley <email@hidden>
- Date: Tue, 26 Jun 2012 15:13:38 -0700
Hi Ben,
scanForPeripheralsWithServices: applies a filter to the scan response. In other words, your device must advertise this service in it's advertising data to be passed back to the application. We do not connect to each device and perform service discovery. Passing nil in allows all devices to be sent to the app.
- Craig
On Jun 26, 2012, at 2:26 PM, "Mosher, Ben" <email@hidden> wrote:
> 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
_______________________________________________
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