Hello All,
I am building an App that sends data over BLE
I am using the following code
Problem:
When i = 255
255 -> 00FF
(I need to interchange the order while sending)
BYTE_0 = 0xFF
BYTE_1 = 0x00
When i = 256
256 -> 0100
I want the following
BYTE_0 = 01
BYTE_1 = 00
I found a code where I can generate the following
Output
How can I separate the 2 bytes that are strings and convert them into BYTE_0 and BYTE_1
Thank you!
I am building an App that sends data over BLE
I am using the following code
B4X:
Dim bc As ByteConverter
Dim setting_ID As Byte
For i = 0 To 999
'setting_ID = bc.IntsToBytes(Array As Int(i))
'Log(i & " Dec = " & setting_ID & " Hex")
setting_ID = i
Log(i & " Dec = " & setting_ID & " Hex")
Dim DataToSend() As Byte = Array As Byte(0x00,0x00,0x0E,0x00,[B]BYTE_1,BYTE_0[/B],0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00)
manager.WriteData(BLE_SERVICE_UUID,SETTINGS_UUID, DataToSend)
Problem:
When i = 255
255 -> 00FF
(I need to interchange the order while sending)
BYTE_0 = 0xFF
BYTE_1 = 0x00
When i = 256
256 -> 0100
I want the following
BYTE_0 = 01
BYTE_1 = 00
I found a code where I can generate the following
B4X:
For i = 254 To 300
Log(bc.HexFromBytes(bc.IntsToBytes(Array As Int(i))))
hex = bc.HexFromBytes(bc.IntsToBytes(Array As Int(i)))
hex = hex.SubString(4)
Log(hex)
Output
B4X:
00FE
00FF
0100
0101
...
How can I separate the 2 bytes that are strings and convert them into BYTE_0 and BYTE_1
Thank you!