Last active
December 12, 2016 16:22
-
-
Save chrishuan9/e56b58ba3a703cb97b6f0d0133afee86 to your computer and use it in GitHub Desktop.
LoraWAN - xDot Box - NodeJS Function Node
This file contains hidden or 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
var decoded_data = new Buffer(msg.payload.payload,’base64′); | |
var lat_val = decoded_data[3] << 16 | decoded_data[4] << 8 | decoded_data[5]; | |
var lat = !(lat_val&0×800000) ? lat_val : ((0xffffff-lat_val+1)*-1) | |
var latitude = lat/Math.pow(2,23)*90; | |
var lon_val = decoded_data[7] << 16 | decoded_data[8] << 8 | decoded_data[9]; | |
var lon = !(lon_val&0×800000) ? lon_val : ((0xffffff-lon_val+1)*-1); | |
var longitude = lon/Math.pow(2,23)*180; | |
var temperature = decoded_data[1]; | |
return “lat: ” + latitude + ” lon: ” + longitude + ” temp: ” + temperature;� | |
Source1: https://www.thethingsnetwork.org/forum/t/parsing-semtech-loramote-data/938/4 | |
Source2: https://www.multitech.net/developer/forums/topic/mtdot-box/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment