Android Question Displaying BLE Characteristics

Bulishor

Member
Licensed User
Longtime User
Hi,

I'm trying to figure out which characteristic I'm looking for in my BT device. It has 17 characteristics in 6 services. I can see all the UUIDs and it seems to be smoother with 4.4 KitKat. However, I'm trying to figure out how to get the actual values. Unfortunately I don't know exactly which characteristic has the info I'm looking for so I was trying them all. I do get values (the length is greater than 0) but they come out as ASCII characters in the Log window.

The is the line I'm running:

Log("Characteristic: " & Characteristic.Uuid & " value = " & Characteristic.GetStringValue(0))

And this is what I see (for one of the characteristics):

Characteristic: 00002a23-0000-1000-8000-00805f9b34fb value = k�����"��

The only one that is displayed properly is the name of the device which is obviously a string. How can I convert that to make it readable?
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
This seems to work. I'm using ble extended library. I previous set this BleCharacteristic as notify (enabled) and every 5 to 10 sec it automatically updates the stats / log file I've got setup for it.

I just needed to know if Characteristic.FORMAT_FLOAT will do the byte to float conversion for me.

B4X:
Sub ble_CharacteristicChanged (Characteristic As BleCharacteristic)

   ' Dim bc As ByteConverter


      If Characteristic.Uuid ="0000fff2-0000-1000-8000-00805f9b34fb" Then
              'precent change
              'Label1.Text = Characteristic.GetStringValue(0)
            Label1.Text = Characteristic.FORMAT_FLOAT
            'Label1.Text = Characteristic.GetValue
            'Label1.Text =  bc.FloatsFromBytes(Characteristic.GetValue)
           
           
            Log(Label1.Text )
            'Test_Click
      End If
End sub
 
Upvote 0
Top