CoreBluetooth not discovering peripherals
rdar://23374935
Summary:
Bluetooth LE devices are never detected by a CBCentralManager when scanning for all devices.
Steps to Reproduce:
- Clone and run a Bluetooth LE peripheral, e.g.
git clone git@github.com:sandeepmistry/osx-ble-peripheral.git
- Clone this example on an Apple TV:
git clone git@github.com:bdotdub/CBExample.git
- Run the example on a tvOS device
Expected Results:
The CBCentralManagerDelegate discovery functions called with Bluetooth LE peripherals nearby
Actual Results:
None of the CBCentralManagerDelegate functions are called
Version:
tvOS 9.0
Notes:
Configuration:
Apple TV
This comment has been minimized.
rcarlsen commentedNov 11, 2015
I believe that you are calling the centralManager too soon in the referenced example project. You must wait until the centralManager calls the delegate method centralManagerDidUpdateState() with a state parameter of .PoweredOn or higher before calling methods on the centralManager.
When I moved the call to scanForPerihperalsWithServices() into the .PoweredOn case in ..didUpdateState() then nearby peripherals were discovered as expected.