B4R Question mqtt & "array of bytes" to ULong

Herbert32

Active Member
Licensed User
Longtime User
Hi together,

B4R:

how to convert the received content of Payload (array of bytes) , which shows "244" at Log(Payload) within

Private Sub MQTT_MessageArrived (Topic As String, Payload() As Byte)

Log(Payload) 'shows the expected "244"
Dim MyULongVar as ULong

how can I do:
MyULongVar = ..content_of_Payload().. ?????

End Sub
 

Herbert32

Active Member
Licensed User
Longtime User
Hi & thx for your reply,

B4X:
Log(Payload.length): 3
Log(Payload(0)): 50

I found a way which worked for me by converting Payload to string and then to ULong:

B4X:
        If IsNumber(Payload) = True Then
            Dim ratio As String
            ratio = bc.StringFromBytes(Payload)
            OnTime = ratio
            Log("OnTime: ",OnTime)
        End If
 
Upvote 0
Top