Created
April 4, 2020 11:01
-
-
Save Kongduino/e4050258dde3b63111b21864918b53bc to your computer and use it in GitHub Desktop.
Decoding the RAK811 LoRa packets encoded as HEX.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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