char * str = "Hello, world!";
for(int i = 0 ; i < strlen(str) ; i++ )
printf("%02x", str[i]);
by using the c code above to transfer the âHello, world!â
we will get 48656c6c6f2c20776f726c6421
use the lora module to tranfer this hex
mac tx cnf 1 48656c6c6f2c20776f726c6421
function Decode(fPort, bytes) {
var data = {
"cmd":""
};
for (var i = 0; i < bytes.length; i++) {
data.cmd+= String.fromCharCode(bytes[i]);
}
return data;
}
my appID is 1 we can sub the topic to see into the payload
use mosquitto_sub or any mqtt client like mqtt.fx
mosquitto_sub -t âapplication/1/#â -v
the payload will show the string:
âobjectJSONâ:"{âcmdâ:âHello, world!â}",