signed integer overflow :,(

A project log for Reading a bunch of BLE sensors with raspberryZero

Reading up to 9 XIaomi Mi Temperature and humidity sensors using nodeRed+Bash+gatttool

Javier MJavier M 01/26/2022 at 17:330 Comments

TODO: review and fix the javascript nodered node, it looks like we have a signed/unsigned problem.
I only noticed because this days temperatures dropped below 0ºC

parseInt()<----yes im talking to you  

Edit: i found out javascript is expecting us to add the "-0001" character for negative hex values (instead of translating the int16_t 2's complement "ffff" so we need to parse it ourselves)

msg.temperatura = parseInt(msg.temperatura, 16);
if ((msg.temperatura & 0x8000) > 0) {
   msg.temperatura = msg.temperatura - 0x10000;