I am trying to get a list of all connected Peripherals to an iPhone. I have a Bose Soundlink connected but it doesn't show up in my app. I don't know the UUID so am passing [] as this should get all I think?
func centralManagerDidUpdateState(_ central: CBCentralManager) {
var message = ""
switch central.state {
case .poweredOn:
message = "Bluetooth LE is turned on and ready for communication."
// scan for ALL devices
centralManager.scanForPeripherals(withServices: nil, options: nil)
let connectedPeripherals = self.centralManager.retrieveConnectedPeripherals(withServices: [])
// WILL [] RETURN ALL CONNECTED PERIPHERALS?
print("connectedPeripherals are \(connectedPeripherals)")
}
}
If you want to get all connected peripherals, my suggestion is: add string 180A as a parameter to retrieveConnectedPeripherals. All Bluetooth Smart devices implement the DEVICE INFORMATION (180A) service (at least this one).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With