GoodGuyOnWeb
Member
Hi,
I am trying to send alert to smart band (Mi Band 5).
I am sending this alert message : “pollutant_idM10 Max:314”
For sms/mms alert, the alert message has to be preceded by 0x05 and 0x01
so if I convert the alert message to Hex, the following code works :
However I do not want to convert the alert message to Hex manually. Is there a way to convert the message to array of hex bytes and add it after the 0x05 and 0x01 hex bytes?
Thanks
I am trying to send alert to smart band (Mi Band 5).
I am sending this alert message : “pollutant_idM10 Max:314”
For sms/mms alert, the alert message has to be preceded by 0x05 and 0x01
so if I convert the alert message to Hex, the following code works :
However I do not want to convert the alert message to Hex manually. Is there a way to convert the message to array of hex bytes and add it after the 0x05 and 0x01 hex bytes?
B4X:
Sub send_hex_alert(str As String)
Dim bc As ByteConverter
pollutant= bc.HexFromBytes(str.GetBytes("UTF8"))
Log(pollutant)
Try
manager.WriteData(s1, misms,Array As Byte(0x05,0x01,0x70,0x6f,0x6c,0x6c,0x75,0x74,0x61,0x6e,0x74,0x5f,0x69,0x64,0x3a,0x50,0x4d,0x31,0x30,0x20,0x4d,0x61,0x78,0x3a,0x33,0x31,0x34))
'manager.WriteData(s1, misms,Array As Byte(0x05,0x01,pollutant) - this doesn't work. Need a way to convert pollutant variable to array of bytes as shown above[B][/B]
Catch
FailedToSend
Return
End Try
End Sub