Connecting to a specific BLE device

Hi Evan!
I am trying to simplify multiple bluetooth connections so that the user doesn't have to click to connect a device twice. I want the app to connect to a particular device immediately upon clicking connect, without having to travel to a separate listpicker to select which bluetooth they want. Will the ConnectToDeviceType extension help with this?
Thanks!

Hi Brianna,
Next time start a new subject for your question to allow others to find answers.
This one was intended to announce a release.
Anyway, if you know the address from your device already, you could use connect with address
component_method
No need to use a listpicker then.
Cheers.

2 Likes

Hi @brianna,

The ConnectToDeviceType method is really aimed more at extensions that build on the BLE functionality. The extension can expose some additional functionality that the BLE extension will use to filter the results.

As Ghica says, you can use ConnectWithAddress to connect to the same device once you know its MAC address, which you can extract from the device list the first time you scan & connect.

Alternatively, you can use ConnectToDeviceWithServiceAndName, which provides similar functionality to ConnectToDeviceType but lets the programmer specify the information. You need to provide the name and service that the device broadcasts in its advertising packet for this to work, so it may not work with all devices if they don't include this info.

In either case, you will likely want to look at the AutoReconnect option, which will instruct the Android BLE subsystem to try and reconnect to the device if it leaves/reenters range, turns off or on, and requires no additional logic in the blocks to manage reconnecting.

Regards,
Evan

1 Like

Ghica, which block (with HEX value of BLE MAC address eg. 01:85:12:DD:EF:01) should be connected to the "call CLuetoothLE1.ConnectWIthAddress" -> Address?

BR,
Jakub

Maybe look at the documentation: http://iot.appinventor.mit.edu/#/bluetoothle/bluetoothleintro
And then try it.