Android Question [BLE2] How to get the data?

Toley

Active Member
Licensed User
Longtime User
I'm trying to communicate with a BLE device. It's a cheap HM-10 chinese clone known as a CC41-A.

I'm able to connect to it, I'm also able to send data to it from the android app. Once connected is detected in StateChange I call SetNotify with the Service and Characteristic strings as arguments. Everything seems ok but when I type any character in the terminal, I receive a DataAvailable event but I'm unable to decode the data from it.

Here is my DataAvailable code:
B4X:
Sub DataAvailable (Service As String, Characteristics As Map)
    Private Key, Value As String
    Key = Characteristics.GetKeyAt(0)
    Value = Characteristics.GetValueAt(0)
    Log("Key = " & Key)
    Log("Value = " & Value)
   
    For Each id As String In Characteristics.Keys
        Log(Characteristics.Get(id))
    Next
End Sub

and here is what I receive on the Log:
B4X:
** Activity (main) Resume **
Found: CC41-A, 00:15:83:00:51:F0, RSSI = -61, (MyMap) {1=[B@139573d6, 2=[B@d71b657, 9=[B@3d435544}
Discovering services.
Connected
(ArrayList) [00001800-0000-1000-8000-00805f9b34fb, 00001801-0000-1000-8000-00805f9b34fb, 0000180a-0000-1000-8000-00805f9b34fb, 0000ffe0-0000-1000-8000-00805f9b34fb]
Setting descriptor. Success = true
writing descriptor: true
Key = 0000ffe1-0000-1000-8000-00805f9b34fb
Value = [B@103e362d
[B@103e362d
Key = 0000ffe1-0000-1000-8000-00805f9b34fb
Value = [B@32ccf762
[B@32ccf762
Key = 0000ffe1-0000-1000-8000-00805f9b34fb
Value = [B@c7160f3
[B@c7160f3
Key = 0000ffe1-0000-1000-8000-00805f9b34fb
Value = [B@6c281b0
[B@6c281b0
Key = 0000ffe1-0000-1000-8000-00805f9b34fb
Value = [B@22750829
[B@22750829
Key = 0000ffe1-0000-1000-8000-00805f9b34fb
Value = [B@d0727ae
[B@d0727ae
** Activity (main) Pause, UserClosed = true **
Disconnected
 
Top