Android Question Get BP measurement using BLE2 libs

ShaiS

Member
Licensed User
Longtime User
I'm using BLE2 lib for connecting BP meter, connection established successfully but I'm not able to retrieve BP readings. Log displays Key "00002a35-0000-1000-8000-00805f9b34fb" and value "[B@21b41a90" but when im converting to string using Byteconverter.HexFromBytes(Characteristics.GetValueAt(i)) no result.

Sub ble_DataAvailable (ServiceId As String, Characteristics As Map)

Dim buffer() As Byte

Dim bc As ByteConverter
For i = 0 To Characteristics.Size - 1
RX.Text =Characteristics.GetValueAt(i)
EditText3.Text = Characteristics.GetKeyAt(i)
EditText4.Text=bc.HexFromBytes(Characteristics.GetValueAt(i))
Next

Offset 1, Label - Blood Pressure Measurement Compound Value - Systolic, Length 16 bit, IEEE-11073 16-bit SFLOAT
Offset 3, Label - Blood Pressure Measurement Compound Value - Diastolic, Length 16 bit, IEEE-11073 16-bit SFLOAT
Offset 5, Label - Blood Pressure, Length 16 bit, IEEE-11073 16-bit SFLOAT
how can i read above values....
 

DonManfred

Expert
Licensed User
Longtime User
Please use code tags when posting code

codetag001.png

codetag002.png

codetag003.png
 
Upvote 0

ShaiS

Member
Licensed User
Longtime User
B4X:
Sub ble_Connected (Services As List)
    ToastMessageShow( "Device Found..." ,True)
    Manager.ReadData(Services.Get(4))
End Sub
Sub ble_DataAvailable (ServiceId As String, Characteristics As Map)
    Dim buffer() As Byte
    Dim bc As ByteConverter
        EditText4.Text=Characteristics.ContainsKey ("00002a35-0000-1000-8000-00805f9b34fb")   'Returns True
        For i = 0 To Characteristics.Size - 1
               Rx.Text = Characteristics.GetValueAt(1)   ' returns [Be21b41a90
               buffer=Characteristics.GetValueAt(1)    'buffer is blank, not receiving the data
               EditText3.Text=bc.HexFromBytes(Characteristics.GetValueAt(1))  'not receiving any data
        Next
End Sub
 
Upvote 0

ShaiS

Member
Licensed User
Longtime User
I tried but here the byte array data() is empty, here we have to transfer large size 72 bytes, includes Diastolic, systolic, Pulse rate, Time stamp, measurement status etc.

B4X:
Sub ble_DataAvailable (ServiceId As String, Characteristics As Map)
   
    Dim buffer() As Byte=Characteristics.Get("00002a35-0000-1000-8000-00805f9b34fb")
    RX.Text = buffer.Length      // RX.Text = 0 ?
End Sub


But if we display directly eg. RX.Text =Characteristics.Get("00002a35-0000-1000-8000-00805f9b34fb") display [Be21b513a0
 
Upvote 0

ShaiS

Member
Licensed User
Longtime User
But I am able to write to randomaccess file using raf.WriteObject, but not able to read

B4X:
Sub ble_DataAvailable (ServiceId As String, Characteristics As Map)
   
    Dim noofbytes As Int
    Dim b As ByteConverter
   
    Dim bu(2) As Byte
   
    Dim buffer() As
    raf.Initialize2(File.DirRootExternal, "1.dat", False,True)
     raf.WriteObject(Characteristics.Get("00002a35-0000-1000-8000-00805f9b34fb"), True, raf.CurrentPosition)
   
       noofbytes=raf.ReadBytes(buffer,0,2,0)   ' display 54
   
    RX.Text = raf.ReadShort(2)
'    EditText4.Text=raf.CurrentPosition
   
    RX.Text = raf.ReadBytes(bu,0,2,1)   'offset 1 ,Blood Pressure systolic  range 25 to 280, 16 bit length
       EditText4.Text = raf.ReadShort(1)   
    EditText3.Text = b.HexFromBytes(bu)  
   
    raf.Close
    End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
But I am able to write to randomaccess file using raf.WriteObject, but not able to read
There is no meaning to this result.

I tried but here the byte array data() is empty
This is the value returned. Maybe you need to read from a different characteristic.
 
Upvote 0
Top