sandeepmistry / node-bleacon

A Node.js library for creating, discovering, and configuring iBeacons
MIT License
497 stars 88 forks source link

Estimote sticker battery level #51

Closed xiptos closed 7 years ago

xiptos commented 8 years ago

Hi! When looking at the way battery level is calculated, I get the impression that there is something not right... On line 88 (estimate-sticker.js), the first byte is rotated 8 bits and added to the second byte, after it is left rotated 4 bits, in which the first 6 bit (in 16) are cleared. Is this ok? The last part is irrelevant, right?

Cheers, /rp

sandeepmistry commented 8 years ago

@xiptos something might be off, unfortunately I don't have any stickers to test anything with now.

var rawBatteryLevel = (manufacturerData.readUInt8(15) << 8) + ((manufacturerData.readUInt8(14) >> 4) & 0x3ff);

do you think it should be:

var rawBatteryLevel = (manufacturerData.readUInt8(15) << 4) + ((manufacturerData.readUInt8(14) >> 4) & 0x3ff);

If you have time to try this out and compare to the Estimote app, I can change it ...

sandeepmistry commented 7 years ago

Closing this due to lack of activity.