Android Question BLE2 read Characteristics

Discussion in 'Android Questions' started by Blueforcer, Dec 22, 2016.

  1. Blueforcer

    Blueforcer Active Member Licensed User

    Hello,

    im trying to read some values from our Pool-Messurement system.
    For testing purpose the system sends every 1sec the same string.

    i have set the notify via
    Code:
    Starter.manager.SetNotify("49535343-fe7d-4ae5-8fa9-9fafd205e455","49535343-1e4d-4bd9-ba61-23c647249616",True)
    after this the DataAvailable event raise every second. So far so good.
    but now i have problems to read the strings.

    in DataAvailable my code is:
    Code:
    Sub DataAvailable (Service As String, Characteristics As Map)
        
    Log("Value: " & Characteristics.GetValueAt(0))
    End Sub
    but there are different values and not the same as it should be
    Code:
    Found: RN42N-A63B, D8:80:39:F0:F6:5B, RSSI = -57, (MyMap) {1=[B@2fa92978, 9=[B@207968510=[B@112048b6}
    Discovering services.
    Connected
    Setting descriptor. Success = true
    writing descriptor: true
    Value: [B@13aa99b7
    Value: [B@35036524
    Value: [B@391b388d
    Value: [B@25e03a42
    Value: [B@3451a53
    Value: [B@21a3af90
    Value: [B@b8fd089
    Value: [B@10bbb88e
    Value: [B@1dfd08af
    Value: [B@3bc34bc
    Value: [B@349bec45
    Value: [B@2abecf9a
    Value: [B@19b80cb
    Value: [B@3875e0a8
    Value: [B@1e9407c1
    Value: [B@1faa4b66
    Value: [B@155f5ea7
    Value: [B@49c5f54
    Value: [B@2a985efd
    Value: [B@47fb7f2
    What is wrong? is there a other way to read the values in this Characteristic as strings?
     
  2. Blueforcer

    Blueforcer Active Member Licensed User

    nevermind :(

    with this code it works!
    Code:
    For i = 0 To Characteristics.Size - 1
            
    Dim data1() As Byte =  Characteristics.GetValueAt(i)
            
    Log(bc.StringFromBytes(data1,"UTF-8"))
        
    Next
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Note that you cannot treat raw bytes as a string unless the data is actually a string (text).

    Otherwise you can print it with bc.HexFromBytes.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice