Bluetooth on WatchOS 4 not finding peripherals

Hi,


so i am using my watch series 2 on the latest WatchOS 4 software and i am trying to connect with my perihperal.

I am using swift on XCODE 9 and it never finds any peripheral:


class InterfaceController: WKInterfaceController, CBCentralManagerDelegate,

CBPeripheralDelegate

{

@IBOutlet var StartImage: WKInterfaceImage!

override func awake(withContext context: Any?)

{

super.awake(withContext: context)

manager = CBCentralManager(delegate: self , queue: nil)

}

override func willActivate()

{

super.willActivate()

}

override func didDeactivate()

{

super.didDeactivate()

}

@IBAction func myConnectButton()

{

print("scanning for BLE device");

}

func centralManagerDidUpdateState(_ central: CBCentralManager)

{

if central.state == CBManagerState.poweredOn

{

central.scanForPeripherals(withServices: arrayOfServices, options: [CBCentralManagerScanOptionAllowDuplicatesKey:false])

StartImage.setImage(image)

print("Bluetooth is available.") . <------- It gets here

}

else

{

print("Bluetooth not available.")

}

}

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral,advertisementData: [String : Any], rssi RSSI: NSNumber)

{

let device = (advertisementData as NSDictionary).object(forKey: CBAdvertisementDataLocalNameKey)as? NSString

/

print("Peripheral found!") <--------- Never comes here

if device?.contains(BLE_NAME) == true

{

manager.stopScan()

/

/

print("Bluetooth name found!.")

manager.connect(peripheral, options: nil)

}

else

{

print("device not found!")

}

}

Hi Michael,

that's exactly what I tried today. Unfortunately without success.

The Apple Watch has Bluetooth and has access to the core bluetooth framework, but it does not work.

I can of course communicate via the iPhone with my bluetooth device. But it would be nice to do that directly with the Apple Watch without the iPhone.


Can an Apple engineer please confirm that it is not possible yet? Or are we doing something wrong?

Ok, now i sawthis.

I have only Apple Watch Series 1 here. Maybe that's the reason.

It's also worth setting `nil` for the service UUIDs when scanning, if that starts to make peripherals be discovered then the issue is that it can't find any peripherals with those specific UUIDs. If it _still_ doesn't find anything (and you're running on a Series 2 or newer) then it's highly likely to be a bug with Core Bluetooth.


In all my days of developing apps, Core Bluetooth has been the flakiest API I've ever worked with. Something breaks in every major update.

Thank you kane.codes.


It realy works with Series 2 now. It was a timing problem. I checked the state before centralManagerDidUpdateState was called.

Now the state is CBManagerStatePoweredOn.

Okay no problem. Glad it's working for you now 🙂

The same thing I am working on the peripheral scans by apple watch but not able to connect it. also didn't get any failure message if I am trying to connect it.
so anyone able to connect the peripheral device with apple watch? please help.

thanks.

Bluetooth on WatchOS 4 not finding peripherals
 
 
Q