This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

scanForPeripheralsWithServices issue

I am using:

  • DK52
  • SDK 11
  • Softdevice S132 2.0.0

I have initialized my service as follows:

#define BLE_UUID_BASE_UUID              {0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} 
#define BLE_UUID_BOARD_SERVICE_UUID         0x0202


ble_uuid128_t base_uuid = BLE_UUID_BASE_UUID;
ble_uuid.uuid = BLE_UUID_BOARD_SERVICE_UUID;

err_code = sd_ble_uuid_vs_add(&base_uuid, &ble_uuid.type);
if (err_code != NRF_SUCCESS)
{
    return err_code;
}  

err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                    &ble_uuid,
                                    &p_board->service_handle);

nRF Connect shows that the service has the following UUID:

00000202-0000-0000-0000-000000000005

Scanning the device from iOS using:

NSArray *services = @[[CBUUID UUIDWithString:@"00000202-0000-0000-0000-000000000005"]];

[_centralManager scanForPeripheralsWithServices:services options:nil];

The peripheral is not discovered. If I change to:

[_centralManager scanForPeripheralsWithServices:nil options:nil];

the peripheral is discovered and:

- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {

    NSLog(@"Discovered service: %@", service.UUID);
}

shows exactly: 00000202-0000-0000-0000-000000000005

I am aware of this:

https://devzone.nordicsemi.com/question/95431/ios-scanforperipheralswithservices-with-uuid-doesnt-work-for-hrm-etc/

I have tried to reverse the uuid but nothing changes.

Since I am using the same iOS code for other devices without any issue, I think something is wrong in my nRF52 setup.

Where am I wrong?

Tks.

Parents Reply Children
No Data
Related