I am trying to write a decoder for a device that is reporting position in Cayenne LPP format. The basic conversion
decode.lat = (bytes[2] << 16) | (bytes[3] << 8 | bytes[4] ) ;
decode.lat = decode.lat / 10000 ;
decode.lon = (bytes[5] << 16) | (bytes[6] << 8) | bytes[7];
decode.lon = decode.lon / 10000;
works, but does not take into consideration negative values. Given the following test payload
01 88 07 31 1E F0 C8 29 00 DA 5C 02 02 01 8E 03 67 01 40
I think there needs to be logic that looks at the high bit of the first byte of the lat/log triplet to determine whether it is negative, but I haven’t been able to write anything that works. Can someone offer a suggestion?