Connect to BLE Peripheral without scanning?


#1

In my app, I have a page where the user scans and selects a device. I’m saving the peripheral in storage so that later on the app will automatically try to connect to the last used device. However, even though I’m positive the UUIDs are the same both times, a connection is only successful right after scanning.

That is,

BLE.connect("98:4F:EE:0F:C2:DC").subscribe(...)

Only works directly after a scan. Do I have to scan every time I want to auto-connect then, or is there a way to connect without scanning if I already know the peripheral’s ID?


#2

Hey, I know this is old, but have you found a solution to this problem?

I just started using the BLE Ionic native plugin, and have problems with connecting if the devices weren’t scanned prior to connecting, for example if the device address/id was stored in a Database and then used later.


#3

Unfortunately not. In my current code (though the project is old now), I do a scan for devices and if one has a matching id to what is stored in the database I connect to it. But there is always a scan before the connection.


#4

Yes, I did the same thing. I also did some research and found this git discussion helpful.

https://github.com/don/cordova-plugin-ble-central/issues/8

Seems this is the only way for now.

At any case, thanks a lot for the input!