Created
September 18, 2018 20:45
-
-
Save salfare/189592dd3b4a87abb082a9ea7f0ae09a to your computer and use it in GitHub Desktop.
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
| function Decoder(bytes) { | |
| // Decode an uplink message from a buffer | |
| // (array) of bytes to an object of fields. | |
| // var Lat = ((bytes[2] <<8) | bytes[3] <<16 | bytes[4] <<24 | bytes[5]) /100000; | |
| // var Lon = ((bytes[6] <<8) | bytes[7] <<16 | bytes[8] <<24 | bytes[9]) /100000; | |
| var temp = ((((bytes[0] << 8) | bytes[1])/100 ) -40).toFixed(1); | |
| var batt = (((bytes[2] << 8) | bytes[3])/100).toFixed(2); | |
| var humd = (((bytes[4] << 8) | bytes[5])/100).toFixed(1); | |
| var ldr = (bytes[6]) *4; | |
| if (temp < -20) { | |
| temp =0; | |
| } | |
| if (humd > 100) { | |
| humd = 0; | |
| } | |
| return { | |
| //Number((1.235).toFixed(2)) -> 1.24.sssss | |
| // Lat: Lat, | |
| //Lon: Lon, | |
| Temp : (temp), | |
| Batt : batt, | |
| Humd : (humd), | |
| LDR : (ldr), | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment