Android Question Bluetooth pairing

jemajuca

Member
Licensed User
Hello.
I need to pair with a Bluetooth peripheral, from inside my app.
It seems that Android manages the pairing and the storage of credentials.
From inside my app, how can I embed this process?
It is mandatory to call to the Android api to pair and after that return to the app? How?
Thanks in advance for your comments.
 

jemajuca

Member
Licensed User
Hello Erel
Really, what I need is to call to the OS pairing from inside my app.
Please take a look at the attached images from the Nordic Connect app.
I need to do something similar.
Thanks in advance for your comments.
 

Attachments

  • Bond.jpg
    Bond.jpg
    426.8 KB · Views: 563
Upvote 0

jemajuca

Member
Licensed User
Hello Erel

I'm connecting with a BLE peripheral, not an other smartphone.
This works fine between phones, but not between the phone and the BLE peripheral.
When searching for my device, the app lists it, but when I select it the app throws an java read error:

...Error connecting : java.io:IOEException: read failed, socket might closed or timeout, read ret -1...

Between two smatphones works great.
The example does not use the BLE2 library. It is correct?
I tried to adapt the example with the BLE2 library.
It lists, I can select, but I can't throw the Android pairing process.

I think I must use this:

If (Action = "android.bluetooth.device.action.PAIRING_REQUEST") Then
If (intnt.HasExtra("android.bluetooth.device.extra.DEVICE")) Then

But I'm unable to adapt to my app properly.

Thanks in advance for your comments.
 
Upvote 0

jemajuca

Member
Licensed User
In the example there are two buttons: Scan & Connect. They are working correctly.
Then other two buttons appear: Read Data and Disconnect. OK.
What I need is how to open the Android bluetooth manager from my app, as on the Nordic example I attached.

I have tested this code that I found on the example, but no results.

B4X:
If (Action = "android.bluetooth.device.action.PAIRING_REQUEST") Then
If (intnt.HasExtra("android.bluetooth.device.extra.DEVICE")) Then
 
Upvote 0

jemajuca

Member
Licensed User
Hello again;

Thanks for replying so fast Erel.
Yes, the code is from that message ..... I have explained what I'm doing ...

I am using BLE devices, and therefore I use the BLE2 library. I want to implement the pairing of Bluetooth devices, so that I have a device to which another 2 is connected (not at the same time), one of them is a mobile.
Between the 2 BLE devices that are not mobile, they send a one-way password and I have no problem.
When I want to pair the mobile with the BLE device, the following happens to me ......

- If I go to Settings - Bluetooth and search for nearby Bluetooth devices, I locate and when I click on it, I sell the typical Android window where I show the password to match the disconfiguration .....

- If I connect directly without going through the pairing screen, it connects and does not ask me for any passkey .... what I want to avoid .....

So I want to connect with a mobile to the device BLE and I get the Android window where I indicate the passkey that sends me the device BLE ...... tried what you indicate me in the previous posts, but it does not work Hello do not do it

I read post muschos about this but all or almost all refer to classic Bluetooth and I am using BLE with the BLE2 library.

What is the correct way to call the Android pairing window so that it automatically shows my password in my application without the settings - Bluetooth manually?

Thank you and forgive my English.

A greeting; Jemajuca
 
Upvote 0
Top