Android Question BLE Receving Data

alienhunter

Active Member
Licensed User
Longtime User
Hi to all
how do i find out what service send this ?
some thing like this as an example "BluetoothService.UUID_HEART_RATE_MEASUREMENT == characteristic.uuid" or something
all works perfect, but i do not know who is send this , in this case i know it is the battery bit nr 7 is the charging procentage
c2e6fba1-e966-1000-8000-bef9c223df6a
Read
Notify
Key: c2e6fba1-e966-1000-8000-bef9c223df6a
Value: [B@c680b83
Array Len :8
��b'��b
0: -82
1: -17
2: 98
3: 39
4: 2
5: 0
6: 2
7: 98
not sure if i ask right just trying this out for the first time this ble .... lol got possessed to get a smartwatch :rolleyes: ..

thank you Alfred
 

alienhunter

Active Member
Licensed User
Longtime User
Hi
thank you for the reply
yes with Read Data and set Notifiers , but the watch sends random values periodicly that i did not subscribe to , it returns one of the characterisctic with those random values, i do not know what hose are , seems cutsom set characteristics /descriptors

B4X:
    pbReadData.Show
    clv.Clear
    For Each s As String In ConnectedServices
        manager.ReadData(s)
    Next
    
    Dim s2 As String ="c2e6fba0-e966-1000-8000-bef9c223df6a"
    Dim c2 As String= "c2e6fba3-e966-1000-8000-bef9c223df6a"

    Dim s As String ="c2e6fba0-e966-1000-8000-bef9c223df6a"
    Dim c As String= "c2e6fba1-e966-1000-8000-bef9c223df6a"
    
    Sleep(2000)
    Try
        manager.SetNotify(s, c, True)
        'manager.SetNotify(s, c2, True)
    Catch
        Log(LastException)
    End Try
    Sleep(2000)
    Try
        manager.SetNotify(s2, c2, True)
    Catch
        Log(LastException)
    End Try

figured it out what i needed over arry length and compared to the watch , seems to work ...

B4X:
For i = 0 To arr.Length - 1
            If arr.Length =13 Then
                If i =12 Then
                    heartrate.Text = arr(i)
                    countx=countx+1
                    Update_Heartrate( arr(i), countx)
                End If
            Else If arr.Length =14 Then
                If i =12 Then
                    Dim s As Short =arr(i)
                    Dim g() As Byte = bc.ShortsToBytes(Array As Short(s))
                    blpressure1.Text = ToUnsigned(g(1))
                Else If i= 13  Then
                    Dim s As Short =arr(i)
                    Dim g() As Byte = bc.ShortsToBytes(Array As Short(s))
                    blpressure2.Text = ToUnsigned(g(1))
                End If
            Else If arr.Length =8  Then
                If i =7 Then
                    Dim s As Short =arr(i)
                    Dim g() As Byte = bc.ShortsToBytes(Array As Short(s))
                    battlbl.Text = ToUnsigned(g(1))  &  "%"
                    Dim battlevel As Int = ToUnsigned(g(1))
                    If battlevel >= 97 Then
                        batticon.Text=Chr(0xF240)
                    Else If battlevel < 97 And battlevel >= 80 Then
                        batticon.Text=Chr(0xF241)
                        batticon.TextColor =Colors.Green
                    Else If battlevel < 80 And battlevel >= 50 Then
                        batticon.Text=Chr(0xF242)
                        batticon.TextColor =Colors.Yellow
                    Else If battlevel < 50 And battlevel >= 10 Then
                        batticon.Text=Chr(0xF243)
                        batticon.TextColor =Colors.Red
                    Else
                        batticon.Text=Chr(0xF244)
                        batticon.TextColor =Colors.Red
                    End If
                    
                End If
            End If
        Next

thank you
 
Upvote 0
Top