Android Question BLE

f0raster0

Well-Known Member
Licensed User
Longtime User
Hi

I'm trying to read data using this example:
https://www.b4x.com/android/forum/threads/ble-2-bluetooth-low-energy.59937/

B4X:
Sub Manager_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
    Log("Found: " & Name & ", " & Id & ", RSSI = " & RSSI & ", " & AdvertisingData)
    'print all the advertising data map:
    Dim bc As ByteConverter
    ConnectedName = Name
  
'    If Name = "AntuTech52" Then
'        For Each k As Int In AdvertisingData.Keys
'            Log($"${k}: ${bc.HexFromBytes(AdvertisingData.Get(k))}"$)
'        Next
'
'    End If
  
    If Name = "AntuTech" Then
        For Each k As Int In AdvertisingData.Keys
            Log("This one = " & $"${k}: ${bc.HexFromBytes(AdvertisingData.Get(k))}"$)
        Next
    End If

    manager.StopScan
    manager.Connect2(Id, True) 'disabling auto connect can make the connection quicker
End Sub

I can read a map with 5 items:
Found: AntuTech, FF:B0:19:AF:F0:9F, RSSI = -44, (MyMap) {1=[B@42b578c0, 6=[B@42b57928, 8=[B@42b57978, -1=[B@42b579c0, 0=[B@42b57400}
Found: AntuTech, FF:B0:19:AF:F0:9F, RSSI = -44, (MyMap) {1=[B@42b578c0, 6=[B@42b57928, 8=[B@42b57978, -1=[B@42b579c0, 0=[B@42b57400}
This one = 1: 06
This one = 6: 420074A9FF52109B3349359B000168EF
This one = 8: 416E747554656368
This one = -1: 5900DEE1A0CC
This one = 0: 0201061106420074A9FF52109B3349359B000168EF0908416E74755465636807FF5900DEE1A0CC0000000000000000000000000000000000000000000000

When click in "read data" I see
KeyCode=[B@42b8a4f8
KeyCode=[B@42b8e738
KeyCode=[B@42b94580
416E7475546563683532
KeyCode=[B@42b94e98
0000
KeyCode=[B@42b9ae18
0600180000004001
KeyCode=[B@42b9da28
01
KeyCode=[B@42babde0
416E7475546563683532
KeyCode=[B@42baec48
6002B4
KeyCode=[B@42bb0d00
0600180000004001
KeyCode=[B@42bb1628
03676F6F2E676C2F704957646972
KeyCode=[B@42bb1f30
KeyCode=[B@42bb29f0
020100
KeyCode=[B@42bb32d0
001700
KeyCode=[B@42bc9740
D007D007D007DC0502674E1D
KeyCode=[B@42bca718
KeyCode=[B@42bca8a0
KeyCode=[B@42bcaa28
KeyCode=[B@42bcabb0
KeyCode=[B@42bcad70
KeyCode=[B@42bce798
E803F401F4010A0001
KeyCode=[B@42bcfa00
KeyCode=[B@42bcfc30
KeyCode=[B@42bcfde8
KeyCode=[B@42bcff80
KeyCode=[B@42bd0158
KeyCode=[B@42bd03f0
KeyCode=[B@42bd05c8
KeyCode=[B@42bd07c8
KeyCode=[B@42bd09a0
KeyCode=[B@42bd4d30
020512AC0D
KeyCode=[B@42be6e90
00000000
KeyCode=[B@42be8260
KeyCode=[B@42bf6c58
0101
KeyCode=[B@42bf8148
KeyCode=[B@42bf82d0
KeyCode=[B@42bf8458
KeyCode=[B@42c0a160
20

For example for temperature - Characteristics, the asigned number is 0x2A1C
How can I get that number?

B4X:
Sub DataAvailable (Service As String, Characteristics As Map)
    pbReadData.Visible = False
    clv.Add(CreateServiceItem(Service), "")
    For Each id As String In Characteristics.Keys
        clv.Add(CreateCharacteristicItem(id, Characteristics.Get(id)), "")
    Next
    'Log( Characteristics.Get(1))
End Sub


thanks for any help
 
Last edited:
Top