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}

When click in "read data" I see

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:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…