I have a question that I got by reading Apple's documentation. When it comes to CBCentralManagerScanOptionSolicitedServiceUUIDsKey
Apple's documentation states:
An array (an instance of NSArray) of service UUIDs (represented by CBUUID objects) that you want to scan for.
Specifying this scan option causes the central manager to also scan for peripherals soliciting any of the services contained in the array.
On regard of scanForPeripheralsWithServices:options:
's first argument, however:
An array of CBUUID objects that the app is interested in. In this case, each CBUUID object represents the UUID of a service that a peripheral is advertising.
So what's the difference? Why use one or the other?
Typically the Bluetooth peripheral advertises services and the central scans for those services. This is the case covered by the first parameter.
In some cases, however, the behaviour is reversed - the central offers the service and the peripheral looks for it. This is called service solicitation. When you supply an array of service identifiers using CBCentralManagerScanOptionSolicitedServiceUUIDsKey
you are providing the list of services that the central will 'advertise' to peripherals.
It is still the responsibility of the central to initiate the connection, so once a peripheral is identified that is soliciting for one of those services, you will receive a call to the didDiscoverPeripheral
method as per usual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With