Android Question Value received on BLE Characteristic

tonga

Member
Licensed User
Longtime User
Hi,
I'm using "BLE_Example" to receive data from a module BLE. The data that interest me is a uint8 byte.
I modified "BLE_Example" with the code of the tread:
https://www.b4x.com/android/forum/t...acteristic-uuid-using-the-ble2-library.97797/
The snipped code is:
B4X:
Sub DataAvailable (Service As String, Characteristics As Map)
    pbReadData.Visible = False
    clv.Add(CreateServiceItem(Service), "")
    For Each id As String In Characteristics.Keys
    Dim dataContent() As Byte = Characteristics.Get(id)
        If id="0000a1b2-0000-1000-8000-00805f9b34fb"  Then  '<--fill with correct values
    ' If the values are string-formatted, convert the bytes to string
    ' Log( "Characteristic:"& id &": "&BytesToString(dataContent, 0, dataContent.Length, "UTF8") )
    ' Or, if we know that each byte has a meaning, just show the bytes
    Dim bc As ByteConverter    '<---- will need the ByteConverter library
    Log( "Characteristic:"& id &": "& bc.HexFromBytes(dataContent) )
    End If
      
    Next
End Sub
But I receive always "00" although the values sended (I'm sure) are others.
Any help?
Thanks!
 
Last edited by a moderator:

tonga

Member
Licensed User
Longtime User
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Found: Blox, 00:A0:50:06:46:2A, RSSI = -25, (MyMap) {1=[B@b4f43ae, 8=[B@3df3054f, 10=[B@163184dc, -1=[B@27b8c9e5, 0=[B@34fecba}
Discovering services.
Connected
Characteristic:0000bf6e-0000-1000-8000-00805f9b34fb: 00
Characteristic:0000bf6e-0000-1000-8000-00805f9b34fb: 00
Characteristic:0000bf6e-0000-1000-8000-00805f9b34fb: 00
** Activity (main) Pause, UserClosed = false **
 
Upvote 0

tonga

Member
Licensed User
Longtime User
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Found: Blox, 00:A0:50:06:46:2A, RSSI = -27, (MyMap) {1=[B@229c1429, 8=[B@b4f43ae, 10=[B@3df3054f, -1=[B@163184dc, 0=[B@27b8c9e5}
Disconnected
Found: Blox, 00:A0:50:06:46:2A, RSSI = -25, (MyMap) {1=[B@2d801a86, 8=[B@31444f47, 10=[B@22279374, -1=[B@197f509d, 0=[B@1c335912}
Discovering services.
Connected
Characteristic:0000ca00-0000-1000-8000-00805f9b34fb:
Characteristic:00002a00-0000-1000-8000-00805f9b34fb: 426C6F78
Characteristic:00002a01-0000-1000-8000-00805f9b34fb: 0000
Characteristic:00002a04-0000-1000-8000-00805f9b34fb: 060030000000E803
Characteristic:00002a05-0000-1000-8000-00805f9b34fb: 00000000
Characteristic:0000cbb1-0000-1000-8000-00805f9b34fb: 00000000
Characteristic:0000bf6e-0000-1000-8000-00805f9b34fb: 00
Characteristic:000009a8-0000-1000-8000-00805f9b34fb: 00
Characteristic:0000cbb3-0001-0008-0000-0805f9b34fb0: 00

The Characteristics interested are the firts and the last four. All this are uint8.

Thanks.
 
Upvote 0

emexes

Expert
Licensed User
Does post #5 mean that this thread is solved? The first characteristic, and the first of the last four characteristics, don't look like they are uint8.

Plus: for the last Characteristic of that post, looks like middle section of UUID has been shifted left by one hex digit (4 bits) - is that correct?
 
Upvote 0

tonga

Member
Licensed User
Longtime User
Hi emexes,
the tread isn't solved.
The first characteristic doesn't send nothing.
The last characteristic has that value.
 
Upvote 0
Top