File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,10 @@ function Decoder(bytes, port) {
33
33
decoded.event = events[port];
34
34
decoded.battery = (bytes[0] << 8) + bytes[1];
35
35
decoded.light = (bytes[2] << 8) + bytes[3];
36
- decoded.temperature = ((bytes[4] << 8) + bytes[5]) / 100;
36
+ if (bytes[4] & 0x80)
37
+ decoded.temperature = ((0xffff << 16) + (bytes[4] << 8) + bytes[5]) / 100;
38
+ else
39
+ decoded.temperature = ((bytes[4] << 8) + bytes[5]) / 100;
37
40
return decoded;
38
41
}
39
42
*/
Original file line number Diff line number Diff line change @@ -24,7 +24,10 @@ function Decoder(bytes, port) {
24
24
decoded . event = events [ port ] ;
25
25
decoded . battery = ( bytes [ 0 ] << 8 ) + bytes [ 1 ] ;
26
26
decoded . light = ( bytes [ 2 ] << 8 ) + bytes [ 3 ] ;
27
- decoded . temperature = ( ( bytes [ 4 ] << 8 ) + bytes [ 5 ] ) / 100 ;
27
+ if ( bytes [ 4 ] & 0x80 )
28
+ decoded . temperature = ( ( 0xffff << 16 ) + ( bytes [ 4 ] << 8 ) + bytes [ 5 ] ) / 100 ;
29
+ else
30
+ decoded . temperature = ( ( bytes [ 4 ] << 8 ) + bytes [ 5 ] ) / 100 ;
28
31
29
32
return decoded ;
30
33
}
You can’t perform that action at this time.
0 commit comments