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

iOS scanForPeripheralsWithServices with UUID doesn't work for HRM etc

I'm trying to write an iOS app that scans for a specific UUID being advertised

e.g.

NSDictionary* options = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithBool:YES], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
CBUUID *hrmUUID = [CBUUID UUIDWithString:@"F5FF81D0-A7EE-367A-1583-B0A44AA94B23"];
CBUUID *watchUUID = [CBUUID UUIDWithString:@"0CC23A32-D8E2-BFFD-093B-B91BCB35E12C"];
            
            
[self.centralManager scanForPeripheralsWithServices:[NSArray arrayWithObjects:hrmUUID,watchUUID,nil] options:options];

However this does not work for the HRM (hrs) example, or the beacon example.

The UUID's I'm using were taken from the UUID's that the callback from scanning with nil passed as the UUID array (hence it finds all UUIDS)

I've checked these iDS in other programs like LightBlue etc on the iPad and the UUIDs are correct.

Both the HRM and the Smart Watch, both have services and are connectable. The Nordic toolbox finds and connects to the HRM

The Smartwatch's proprietary app will connect to it

So at the moment I'm stumpted about what I need to pass to the UUID array or what additional advertising data that the HRM etc need to send, for IOS to be able to scan for them.

I did take a look at the Nordic toolbox, but strangely the UUID is defined as 00001809-0000-1000-8000-00805F9B34FB

But this is not the value reported by iOS and also if I try using that value, it still doesn't work

I also tried searching for just one UUID

[self.centralManager scanForPeripheralsWithServices:[NSArray arrayWithObject:hrmUUID] options:nil];

But that didn't work either ;-(

Parents
  • I have realised that the UUID you can search for is not the UUID that is advertised, its basically the 16 bit Service ID plus some other unknown data

    So you can search for any devices that have the Heart Rate service ID 0x180D and the scan will return all devices that advertise this service ID.

    You can specify a full 128 bit UUID including the 0x180D service ID, and that also works if the whole 128 bits are correct.

    At the moment I have not worked out what the other data in the 128 bit service ID should be, as this ID works

    0000180D-0000-1000-8000-00805F9B34FB
    

    But changing the last digit from FB to F0 stops the scan finding the HRM

    The I'm not sure retainer of the 128 service UUID contains

    0000-1000-8000-00805F9B34FB

    And I found this list

    sviluppomobile.blogspot.com.au/.../bluetooth-services-uuids.html

    But they were all the same for the last 96 bits

    I'm not sure if this data e.g. the 00805F9B34FB can be set in the API, but even if it can, no one seems to change it

    So I'm just going to search for a specific 16 bit Service ID and ignore the remaining 96 bits, as this seems to work

  • Thanks Petter.

    In case its of any use to other forum users...

    If a 128bit service UUID is used, the byte order specified in the 16 byte array, needs to be completely reversed from the value that iOS expects.

    Also using a 128 bit service ID, only leaves room for 8 bytes ( or characters ) of other advertising data.

    So it would be possible to include a Local Name or some Manufacturer Data, but there is not enough room for both ( to include more than 2 chars each)

    In my application, I expect we will not use the Local Name, as we require more spare for Manufacturer data to hold a 16. 24 or 32 bit unique ID code

Reply
  • Thanks Petter.

    In case its of any use to other forum users...

    If a 128bit service UUID is used, the byte order specified in the 16 byte array, needs to be completely reversed from the value that iOS expects.

    Also using a 128 bit service ID, only leaves room for 8 bytes ( or characters ) of other advertising data.

    So it would be possible to include a Local Name or some Manufacturer Data, but there is not enough room for both ( to include more than 2 chars each)

    In my application, I expect we will not use the Local Name, as we require more spare for Manufacturer data to hold a 16. 24 or 32 bit unique ID code

Children
No Data
Related