function decodeUplink(input) {
var obj = {};
var warnings = [];
var len = input.bytes?input.bytes.length:0;
var offset = 0;
var dtype;
offset++;
/* Battery voltage level: Battery voltage is from 0-31, 31 means battery is 100% left. */
obj.battery = (input.bytes[offset++]&0x1F);
/* This field is reserved. Generally, the voltage value of the memory chip is 0.1V. For
example, the value of 33 is 3.3V */
obj.vol = (input.bytes[offset++]);
do {
dtype = input.bytes[offset++]; /* dtype: Sensor type */
if(0x01 == dtype){
/**
* dtype 01
:
3D
(
G sensor
)
sensor data
evt
:
Event type
:
0x00
:
Static, 0x01
:
Vibration
,
0x04: Strike
acceX
:
X-axis acceleration, Unit:mg
acceY
:
Y-axis acceleration, Unit:mg
acceZ
:
Z-axis acceleration, Unit:mg
angle
:
Rotation angel
*/
obj.evt = input.bytes[offset++];
obj.acceX = (((input.bytes[offset] & 0x80 ? input.bytes[offset] - 0x100 :
input.bytes[offset]) << 8) + input.bytes[offset+1])
offset += 2;
obj.acceY = (((input.bytes[offset] & 0x80 ? input.bytes[offset] - 0x100 :
input.bytes[offset]) << 8) + input.bytes[offset+1])
offset += 2;
obj.acceZ = (((input.bytes[offset] & 0x80 ? input.bytes[offset] - 0x100 :
input.bytes[offset]) << 8) + input.bytes[offset+1])
offset += 2;
obj.angle = input.bytes[offset++];
}
len = len - offset;
} while(len > 0)
return {
data: obj,