Android Question BLE extended and password connection

freedom2000

Well-Known Member
Licensed User
Longtime User
Hi,

I am using a HM10 BLE device together with BLE extended and BLE2 librares.

BLE2 is used to scan the devices
BLE ext to connect to them and send AT commands to the beacon

Everything is working very fine but when I use the "password protected" mode of the beacon, I get the "connected event" before I enter the PIN code.

B4X:
Sub BLE_Connected (Services As Map)
   If ConnectState = cstatePreConnect Then
           ConnectState = cstateConnect       
           'Log("BLE Connected")
           bleService = Services.GetValueAt(2)                           
           readCharacteristic = bleService.GetCharacteristics.GetValueAt(0)
           Manager.ReadCharacteristic(readCharacteristic)
           Manager.SetCharacteristicNotification(readCharacteristic, True)   
           writeCharacteristic = bleService.GetCharacteristics.GetValueAt(0) 
        ToastMessageShow(Locale("connected to " &TheConnectingBeacon.name), True)
    End If      
End Sub

So the input password wndows appears but as I can't trap it, my code fails as no actual connection is indeed achieved.

Do you know if there is a way to trap the "pairing in progress" event to wait for pairing completed before exiting this sub ?

Thank you in advance
 

freedom2000

Well-Known Member
Licensed User
Longtime User
I've investigated this issue.

On Nexus 5 running Android 6 the BLE bonding fails. There are several related open bugs in Android. This is one of them: https://code.google.com/p/android/issues/detail?id=80560

Note that it does work on iOS. A dialog appears and once you enter the pin it connects.
That's strange ... I don't have an error and the pairing seems ok. But no event triggered... (Samsung S5 Lollipop)

BLE stuff Still in beta :)
 
Upvote 0
Top