I'm using the scanForPeripherals method to retrieve UUIDs from devices near me.
I am able to list UUIDs, however, they are not similar with the UUIDs discovered using nRF Connect application. I tried various testing scenarios, in which I've configure a specific UUID for a peripheral (in another app, installed on a different phone) and tried to discover it using my code, but this too proved unsuccessful (yes, the nRF Connect managed to see the right UUID).
Please see this simplified version of the code:
class ViewController: UIViewController {
var centralManager : CBCentralManager!
var peripherals : [CBPeripheral] = []
override func viewDidLoad() {
super.viewDidLoad()
//Initialise CoreBluetooth Central Manager
centralManager = CBCentralManager(delegate: self, queue: DispatchQueue.main)
}
}
extension ViewController: CBCentralManagerDelegate {
func centralManagerDidUpdateState(_ central: CBCentralManager) {
if (central.state == .poweredOn){
self.centralManager?.scanForPeripherals(withServices: nil, options: nil)
}
else {
// do something like alert the user that ble is not on
}
}
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
peripherals.append(peripheral)
print(peripheral.identifier.uuidString)
}
}
I would like to know why the UUID's appear to be different, and what can I do to discover the same UUIDs as nRF Connect.