1
votes

I can successfully scan all connectable bluetooth devices:

_manager?.scanForPeripherals(withServices: nil, options: [CBCentralManagerScanOptionAllowDuplicatesKey:true])

But when I try to scan from specific CBUUID my app does not discover the bluetooth device.

 _manager?.scanForPeripherals(withServices: [CBUUID(string: "FFF1")], options: [CBCentralManagerScanOptionAllowDuplicatesKey:true])

I created a virtual device with LightBlue ios app with the same FFF1 service UUID, and 2. code is working as expected. But it does not discover a real bluetooth device having the same service UUID FFF1.

Note: All of the functionality, connection, discovering services, discovering characteristics, read & write working except searhing for specific CBUUID.

1
Is the device actually advertising that service? The set of services offered can be greater than the set of services advertisedPaulw11
+1 on @Paulw11 It's not because a device has a service that it advertises it. When you do ...(withServices: nil..., check in didDiscoverPeripheral what's the advertisement (print it), and if "FFF1" doesn't appear, that's why it fails.Larme
Your are correct, device does not advertise the service.serdar aylanc

1 Answers

0
votes

I have checked your code in iOS13.5 .

You would have got solution. Thanks

//precomputed 128 bit value from the Notification API's 16 bit value: 0xFFF1
//static let serviceUUID = CBUUID(string: "0000FFF1-0000-1000-8000-00805F9B34FB")

 _manager?.scanForPeripherals(withServices: [serviceUUID], options: [CBCentralManagerScanOptionAllowDuplicatesKey:true])