Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect temperature values #213

Closed
spapas opened this issue Apr 19, 2017 · 1 comment
Closed

Incorrect temperature values #213

spapas opened this issue Apr 19, 2017 · 1 comment

Comments

@spapas
Copy link

spapas commented Apr 19, 2017

Hello, the temperature values are not correct when the sensor's temperature is more than 32 degrees celcius (they are negative). I took a look (by decompiling) at the source code and here's what I found for the snippet that parses the temperature:

        byte tempLo = (byte)((uptimeShort & '쀀') >>> 14);
        byte tempMid = buffer.get();
        byte tempAndBatt = buffer.get();
        byte tempHi = (byte)(tempAndBatt & 3);
        int temp = tempLo | tempMid << 2 | tempHi << 10;
        telemetry.temperature = Double.valueOf((double)temp / 16.0D);

This code is very strange and definitely doesn't have anything to do with your specs (https://github.com/Estimote/estimote-specs/blob/master/estimote-telemetry.js):

var temperatureRawValue =
  ((data.readUInt8(17) & 0b00000011) << 10) |
   (data.readUInt8(16)               <<  2) |
  ((data.readUInt8(15) & 0b11000000) >>  6);
if (temperatureRawValue > 2047) {
  // JavaScript way to convert an unsigned integer to a signed one (:
  temperatureRawValue = temperatureRawValue - 4096;
}
temperature = temperatureRawValue / 16.0;

Beyond the latest version is it possible that you provide a patch for this for the version 0.16.1 (for example version 0.16.2)? Unfortunately I have various problems with the new APIs of version 1.0.1 and I would like to stick to 0.16.x for now but I'd really like this bug fixed.

Thanks a lot!

@pawelDylag
Copy link
Contributor

Hello @spapas

Thanks for reporting that. Fix is already live in version 1.0.2 (need some time to appear on Maven) :)
We are not planning to update old SDK 0.16.1 for now :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants