forked from Ursalink-CN/ursalink-decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ug8x_uplink.js
56 lines (49 loc) · 2.53 KB
/
ug8x_uplink.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// LoRaObject is global variable in javascript
// ”applicationID" :1 //application ID
// "applicationName":"cloud", //application name
// "deviceName":"24e1641092176759", // lorawan node device name
// "devEUI":"24e1641092176759", // rx lorawan node deveui
// "time": 2020-0327T12:39:05.547336Z // uplink receive time
// rxInfo": // lorawan gateway information related to lora
// [{
// "mac":"24e124fffef021be", // ID of the receiving gateway
// "rssi":-57, // signal strength (dBm)
// "loRaSNR":10, // signal to noise ratio
// "name":"local_gateway", // name of the receiving gateway
// "latitude":0, // latitude of the receiving gateway
// "longitude":0, // longitude of the receiving gateway
// "altitude":0 // altitude of the receiving gateway
// }],
// "txInfo": //lorawan node tx info
// {
// "frequency":868300000, //frequency used for transmission
// “dataRate":
// {
// "modulation":"LORA", //LORA
// "bandwidth":125, //bandwidth used for transmission
// "spreadFactor":7 //spreadFactor used for transmission
// }
// ,"adr":false, // device ADR status
// "codeRate":"4/5" //codeRate
// },
// "fCnt":0, // frame-counter
// "fPort":85, // FPort
// "data":"AWcAAAJoAA==", // base64 encoded payload (decrypted)
//example Decode function :
function Decode(fPort, bytes) {
var decoder = {};
if (fPort == 85) {
decoder.sensorsId = LoRaObject.devEUI
decoder.flag = "A"
decoder.addTime = LoRaObject.time
decoder.value = bytes[0];
}
return decoder;
}
//Encoded json :
{
"sensorsId":"24e1242191336951",
"addTime":"2020-0327T12:39:05.547336Z",
"flag":"A",
"value":255
}