Hi,
I’m using an arduino that encodes uint16_t variable data and sends it to a lora sensor B-L072Z-LRWAN1 via “at command”,
One of the variable contain negatif number, so when i decode the byte array in the javascript codec, i obaint the wrong value of this variable, but all the other variable are correcte.
my javascrip decode :
function Decode(fPort, bytes) {
var puissance_bat = bytes[0] << 8 | bytes[1] ;
var polo = puissance_bat.valueOf();
var niveau_bat = bytes[2] << 24 | bytes[3] ;
var tension_bat = bytes[4] << 40 | bytes[5] ;
var temperature_bat = bytes[6] << 56 | bytes[7] ;
var temperature_pcb = bytes[8] << 72 | bytes[9] ;
var consigne_courant = bytes[10] << 88 | bytes[11] ;
return {
"puissance_bat": polo ,
"niveau_bat": niveau_bat ,
"tension_bat": tension_bat ,
"temperature_bat": temperature_bat ,
"temperature_pcb": temperature_pcb ,
"consigne_courant": consigne_courant ,
};
}
result
the variable “puissance_bat” should be ecale to "-20 " , maybe there something to do in decoding for signed data ?