Skip to content

Instantly share code, notes, and snippets.

@bdotdub
Created November 4, 2015 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdotdub/4d22f4c9e2e5c46ea175 to your computer and use it in GitHub Desktop.
Save bdotdub/4d22f4c9e2e5c46ea175 to your computer and use it in GitHub Desktop.

CoreBluetooth not discovering peripherals

rdar://23374935

Summary:

Bluetooth LE devices are never detected by a CBCentralManager when scanning for all devices.

Steps to Reproduce:

  1. Clone and run a Bluetooth LE peripheral, e.g. git clone git@github.com:sandeepmistry/osx-ble-peripheral.git
  2. Clone this example on an Apple TV: git clone git@github.com:bdotdub/CBExample.git
  3. 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

Attachments:

@rcarlsen
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment