i am hoping some clever people here would be able to help me , i am new to JavaScript and trying to figure out how to code the following as i get stuck when the payload string is not standard 8 bit 1 byte groups, so i receive 320 bit 40 byte array. the first few values are fine to extract as they are 16 bits , then 8 bits then 32 bits of info but the next value is only 10 bits and i get stuck here. so i should probably be converting the 40 bytes into 320 bits and then shifting right for each number of bit per variable? i am not sure how to do this. This is my payload format and in brackets is the number of bits for that variable. any help would be appreciated.
https://www.iotsoundsensor.com/wp-content/uploads/2021/11/310_payload_parser_manual.html
function Decoder(bytes, port) {
//8 bit single byte values
var messageinfo = bytes[2]>>[2];
var battery = bytes[2]>>[0];
var latitude = bytes[4]>>[4];
var longatude = bytes[4]>>[4];
//now have 10 bit values to decode
var LAfast = bytes[15]>>>[0];
var LAslow = bytes[16]>>>[2];
return {
messageinfo: messageinfo,
battery: battery/10,
LAfast : LAfast/10,
LAslow : LAslow/10,
latitude: latitude,
longatude: longatude
}
}