1

I am using CBCentralManager to scan for nearby BLE devices. Below is sample code:-

 func centralManagerDidUpdateState(_ central: CBCentralManager) {
    switch central.state {
    case .poweredOff:
        debugPrint("Central manager state is Powered Off")

    case .poweredOn:
        debugPrint("Central manager state is Powered On")
        loggerUtils.log.debug("Central manager state is Powered On")
        centralManager.scanForPeripherals(withServices: nil, options: nil)

    case .resetting:
        debugPrint("Central manager state is resetting")

    case .unauthorized:
        debugPrint("Central manager state is unauthorised")

    case .unknown:
        debugPrint("Central manager state is unknown")

    case .unsupported:
        debugPrint("Central manager state is unsupported")

    default:
        debugPrint("Central Manager state is unrecognised....enum raw value is \(central.state.rawValue)")

    }
}

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
    print("\n****\nPeripheral is \(peripheral.name ?? "No Name")\n*****\nAdvertisement data is \(advertisementData)\n*****\nRSSI is \(RSSI) ")
}

It shows the nearby speakers and other BLE enabled devices. But it is not showing any Android Phone whose bluetooth is powered on from settings option. I can see the android device in device list inSettings->Bluetooth in same iPhone.

Keshav Raj
  • 376
  • 1
  • 7
  • Maybe that answer will help https://stackoverflow.com/questions/21392987/ios-core-bluetooth-cbcentralmanager-scanforperipheralswithservices-no-results – kirander Jul 09 '19 at 14:46
  • 1
    You are using CoreBluetooth, so using BLE devices, that needs to advertise as BLE devices. Usually, a device can having a BLE compatible chip can advertise as BLE or a "classic BT", but they don't always advertise by default as BLE devices. That's why you see them in Settings/Bluetooth, but not with CoreBluetooth. – Larme Jul 10 '19 at 10:34

0 Answers0