How to use service soliciting with IOBluetooth/CoreBluetooth?

前端 未结 1 625
逝去的感伤
逝去的感伤 2021-02-11 09:28

What I\'m trying to do is use the Apple Notification Center Service (ANCS) from my iPhone on my Mac. To make my Mac show up on in my iPhone\'s Bluetooth settings, I apparently n

1条回答
  •  既然无缘
    2021-02-11 10:14

    When a Bluetooth LE device advertises, it contains certain data in its advertising packet. This can overflow into what is known as Extended Inquiry Response (EIR) data, which the scanning device can request.

    To use service solicitation, one has to include the key 0x15 (marking "List of 128-bit Service Solicitation UUIDs, see here) and the ANCS UUID 7905F431-B5CE-4E99-A40F-4B1E122D00D0.

    I have been able to get this to work on embedded platforms and iOS but have not tried it on OSX. However, you should be able to request the system to add the advertising data in by using the key you mentioned above:

    CBCentralManager *manager = [[CBCentralManager alloc] initWithDelegate:self 
                                                                     queue:nil];
    [manager scanForPeripheralsWithServices:nil
                                    options:@{
        CBCentralManagerScanOptionSolicitedServiceUUIDsKey:@[
            [CBUUID UUIDWithString:@"7905F431-B5CE-4E99-A40F-4B1E122D00D0"]]}];
    

    This passes a dictionary containing that key paired with an array of a single CBUUID object for the ANCS UUID.

    0 讨论(0)
提交回复
热议问题