2

I'm writing a very basic App that shall scan the environment for peripherals that provide a specific service and displays the device IDs and the RSSI in a table view. Nothing special.

Here is what I'm trying:

extension BLEScanner: CBCentralManagerDelegate {
    func centralManagerDidUpdateState(_ central: CBCentralManager) {
        switch central.state {
        case .poweredOn:
            debug?.debug("Powered on")
            central.scanForPeripherals(withServices: [CBUUID(string: "FD6F")],
                                       options: [
                                        CBCentralManagerScanOptionAllowDuplicatesKey: false
                                       ])
        default:
            break
        }
    }
    
    func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
        let uuid = peripheral.identifier
        
        debug?.debug("UUID: \(uuid) \(peripheral.name) \(RSSI)")
    }
}

This code works as expected on devices running iOS12 and even on MacOSX, but when I run it on iOS13, no peripherals are being discovered.

I also tried other service UUIDs with the same result.

Isn't it possible to discover peripherals with specific services with iOS13 anymore?

Or could it be a device issue? I've installed iOS 13.5 on an iPad Pro (first generation), iOS13.6 on an iPhone 8 and iOS12.4 on an iPhone 6.

vpoltave
  • 1,612
  • 3
  • 14
  • 31
Dimitri
  • 191
  • 2
  • 9
  • Try to restart bluetooth, I have this issue once. Doesn't device already connect to another iPhone while you trying scanForPeripherals(or maybe it's already connected in iPhone settings)? Also try to implement this connection logic: https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/BestPracticesForInteractingWithARemotePeripheralDevice/BestPracticesForInteractingWithARemotePeripheralDevice.html#//apple_ref/doc/uid/TP40013257-CH6-SW1 – vpoltave Jul 05 '20 at 08:02
  • FD6F Is the exposure notification service. iOS will not let you discover that. What other services did you try? What if you specify `nil` for the services, do you discover anything? – Paulw11 Jul 05 '20 at 21:22
  • I tried [1802,1811,1010], all simulated by the BLE Scanner App. When I set services no nil I see a lot of BLE devices around me but none of them offers any service. I tried to restart the iPhone, but still the same result. – Dimitri Jul 06 '20 at 05:11

0 Answers0