Android Question BLE Blood Pressure Meter Pairing

ShaiS

Member
Licensed User
Longtime User
I want to connect Blood pressure meter (BLE), but for pairing need to do the following functions
Slave Security Request
upload_2016-4-27_17-45-21.png


Pairing Response
upload_2016-4-27_17-45-10.png

How can i implement this? My code is below, i can see device name in paired list but device not sending data.

B4X:
Sub BroadcastReceiver_OnReceive (Action As String,  i As  Object)
Dim  intnt  As  Intent = i
    Dim BtPairingVariant As  Int
    Dim BtPinBytes() As  Byte
    Dim Bleomronpin As String = "981180"
If (Action = "android.bluetooth.device.action.PAIRING_REQUEST") Then
If (intnt.HasExtra("android.bluetooth.device.extra.DEVICE")) Then
BtPairingVariant = myBtAutoPair.GetPairingVariant(intnt)
            If ((BtPairingVariant=2) OR (BtPairingVariant=3)) Then
                myBtAutoPair.SetPairingConfirmatiion(intnt)
                Diag.Write(1, "BtAutoPair.GetPairingVariant=" & BtPairingVariant & "(confirmation)")
            Else
                '----- Send pin to device. When device accepts pin, pairing dialog closes otherwise dialog remains open
               
                    BtPinBytes = Bleomronpin.GetBytes("UTF8")
                    myBtAutoPair.SetPin(intnt, BtPinBytes)
myBtAutoPair.SetPairingConfirmatiion(intnt)
                   
                End If   
            End If
End Sub
 

leongcc

Member
Licensed User
Longtime User
The codes posted is a hack to do automatic pairing that works for most legacy Bluetooth SPP devices. The effect is when a 'stranger' device comes close to the Android phone, they get paired and start communicating automatically, no user interaction required. May work on BT 4.0 but probably only for a few selected devices.
 
Upvote 0
Top