Question

I have two iOS devices on 7.1, one functioning as a CBCentral and one as a CBPeripheral. Both devices are running software of my own creation, so all UUIDs/CBService/CBCharacteristic are generated by me, and all parameters are fixed and known at all times.

As well, both devices have access to a shared server for storing any arbitrary data I may desire.

Given that I am in control of the entire ecosystem, is there a way to have a CBCentral device connect to the CBPeripheral device without having to first do a scanForPeripheralsWithServices: call? In a sense, I want to "teach" the Central about the existence of the Peripheral before the two devices come into contact with one another.

Perhaps there is there some data or value the CBPeripheralManager unit could post to the server that the CBCentralManager unit could pull, then directly alloc/init its own CBPeripheral object for use with connectPeripheral:options:?

Était-ce utile?

La solution

No, you can't. Core Bluetooth uses internally generated UUIDs to identify the peers. If you don't scan, the system will not identify the peripherals and you will not be able to invoke the retrievePeripheralsWithIdentifiers: method to obtain a CBPeripheral that you can call the connectPeripheral: on.

Since there is no way to inject the UUIDs, you must scan at least once. But depending on many factors, probably many times.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top