Skip to content

Instantly share code, notes, and snippets.

@Kongduino
Created April 4, 2020 11:01
Show Gist options
  • Save Kongduino/e4050258dde3b63111b21864918b53bc to your computer and use it in GitHub Desktop.
Save Kongduino/e4050258dde3b63111b21864918b53bc to your computer and use it in GitHub Desktop.
Decoding the RAK811 LoRa packets encoded as HEX.
function hex2txt(packet) {
fields=packet.split("=");
values=fields[1].split(":");
info=values[0].split(",");
console.log(info[2]+" chars received");
console.log("RSSI: "+info[0]);
console.log("SNR: "+info[1]);
text=values[1];
j=text.length;
var res="";
for(i=0; i<j; i+=2) {
s=parseInt(Number("0x"+text.substr(i,2)), 10);
res=res+String.fromCharCode(s);
}
console.log(res);}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment