0

In my iOS app I am reading the measured data from BLE blood pressure and weight scale devices. Now I need to make a list of available paired BLE bluetooth devices in the bluetooth section. I am using swift 3.

However I have searched a lot regarding this problem and found the following links Link 1! Link 2! Link 3! Link 4! Link 5! Link 6! Link 7!

I have found a lot of similar questions in Stack Overflow, but I did not found any suitable sollution for this problem. Sorry for the repeated question.

I have tried with the following code to retrieve the paired bluetooth devices in didDiscover function, but it is showing the BLE devices information only when it is connected.

func centralManager(_ central: CBCentralManager,
                    didDiscover peripheral: CBPeripheral,
                    advertisementData: [String : Any],
                    rssi: NSNumber) {

    print("Peripheral Name: \(peripheral.name)")

    if peripheral.name != DashboardViewController.UNKNOWN_DEVICE_NAME{
        self.connectedPeripheral = peripheral
        self.connectedPeripheral?.delegate = self
        centralManager.stopScan()
        centralManager.connect(self.connectedPeripheral!, options: nil)
        let paired = centralManager.retrievePeripherals(withIdentifiers: [(peripheral.identifier)])
        print("Paired Devices:\(paired)")
    }

}

In my case I need the list of all paired bluetooth devices(connected + disconnected)

Please give me some guidelines to solve this issue.

Uzzal Biswas
  • 3
  • 1
  • 5
  • You can't find Bluetooth objects that are away (previously paired/discovered, but no here/connected anymore). In other words, you can't list the devices that you can find in Settings.app/Bluetooth. – Larme May 17 '18 at 07:42
  • Hi Larme, as you know the time for reading the measured values from blood pressure and weight scale BLE devices is very short, so it is quite impossible to get the list of these devices which are connected for this short interval. That's why I was looking for some solution to get all the paired devices list which are connected or not. According to your reply, I can't make the list of all paired devices as like Settings.app/Bluetooth, but is it possible to get the pairing status for a specific BLE device? – Uzzal Biswas May 17 '18 at 08:13
  • 1
    Regarding Apple official documentation, you can only get a list of **Paired and Connected** BLE devices: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipheralswith – Hassan Shahbazi May 17 '18 at 08:50
  • Is that also for connected devices only? (https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1519127-retrieveperipheralswithidentifie?language=objc) @Hassan Shahbazi – Uzzal Biswas May 17 '18 at 09:01
  • How do you want to get all paired devices' identifiers if you had not connected to all of them by your application before? – Hassan Shahbazi May 17 '18 at 09:06
  • Take a look at this thread, it might help you: https://stackoverflow.com/a/38843610/7264553 – Hassan Shahbazi May 17 '18 at 09:08
  • Yes I need the paired list of only those devices, which were connected with my application previously. I don't need those devices which were not connected before. I have checked your recommended link, but nothing changed, they also discussed only about the connected device list, not about the disconnected one. Moreover they discussed how to initiate connection after discovering the devices, but I don't have any connection problem, the data transmission between these devices and my app is okay. I need only the pairing list, if there is any option to get it, please suggest me. – Uzzal Biswas May 18 '18 at 02:55

0 Answers0