Hello,
I need a small help to detect the BOND states of the ble device.
I want to detect if the the ble device is bonded successfully with the device or not
I found few posts on the forums and did the following but unfortunately it does not work as intended
I added the following in the manifest file
I created a service module named "BTPair" and added the following
I do the following
1. Scan for BLE devices
2. The App reads a secure characteristics and the OS generates a popup to pair the device
3. After entering the Pairing KEY I only see the intent log
But no other logs for example " BOND BONDED"
Any idea what is wrong ?
I need a small help to detect the BOND states of the ble device.
I want to detect if the the ble device is bonded successfully with the device or not
I found few posts on the forums and did the following but unfortunately it does not work as intended
I added the following in the manifest file
B4X:
AddReceiverText(BTPair,
<intent-filter>
<action android:name="android.bluetooth.device.action.BOND_STATE_CHANGED"/>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
<action android:name="android.bluetooth.device.action.BOND_BONDING" />
<action android:name="android.bluetooth.device.action.BOND_BONDED" />
</intent-filter>
)
I created a service module named "BTPair" and added the following
B4X:
Sub Service_Start (StartingIntent As Intent)
Log (StartingIntent)
If StartingIntent.Action = "android.bluetooth.device.action.BOND_STATE_CHANGED" Then
Log("BOND STATE CHANGES")
Else If StartingIntent.Action = "android.bluetooth.device.action.PAIRING_REQUEST" Then
Log("PAIRING REQUEST")
Else If StartingIntent.Action = "android.bluetooth.device.action.BOND_BONDING" Then
Log("BONDING")
Else If StartingIntent.Action = "android.bluetooth.device.action.BOND_BONDED" Then
Log("BOND BONDED")
End If
End Sub
I do the following
1. Scan for BLE devices
2. The App reads a secure characteristics and the OS generates a popup to pair the device
B4X:
(Intent) Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) }
Bundle[{android.bluetooth.device.extra.PREVIOUS_BOND_STATE=10, android.bluetooth.device.extra.DEVICE=AC:67:B2:4A:4D:9A, android.bluetooth.device.extra.BOND_STATE=11}]
** Receiver (btpair) OnReceive **
*** Service (btpair) Create ***
** Service (btpair) Start **
(Intent) Intent { act=android.bluetooth.device.action.PAIRING_REQUEST flg=0x11000010 cmp=b4a.example/.btpair$btpair_BR (has extras) }
PAIRING REQUEST
3. After entering the Pairing KEY I only see the intent log
B4X:
(Intent) Intent { act=android.bluetooth.device.action.BOND_STATE_CHANGED flg=0x10 (has extras) }
Bundle[{android.bluetooth.device.extra.PREVIOUS_BOND_STATE=11, android.bluetooth.device.extra.DEVICE=8C:AA:B5:B5:EC:DA, android.bluetooth.device.extra.BOND_STATE=12}]
But no other logs for example " BOND BONDED"
Any idea what is wrong ?