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

Error in converting EddystoneTLM negative temperatures to float #675

Closed
giovanni-foorban opened this issue Jun 6, 2024 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@giovanni-foorban
Copy link

In NimBLEEddystoneTLM.cpp there is an issue when receiving negative numbers for temperature readings and when setting temperature.

For example: -0,1C is converted to approximately 256C.

On our side we fixed the issue like this:

/**
 * @brief Set the temperature to advertise.
 * @param [in] temp The temperature value.
 */
void NimBLEEddystoneTLM::setTemp(float temp) {
-  m_eddystoneData.temp = (uint16_t)temp;
+  m_eddystoneData.temp = ENDIAN_CHANGE_U16((int16_t)(temp * 256.0f)) ;
} // setTemp
/**
 * @brief Get the temperature being advertised.
 * @return The temperature value.
 */
float NimBLEEddystoneTLM::getTemp() {
-    return ENDIAN_CHANGE_U16(m_eddystoneData.temp) / 256.0f;
+ return (int16_t)ENDIAN_CHANGE_U16(m_eddystoneData.temp) / 256.0f;
} // getTemp
@giovanni-foorban giovanni-foorban changed the title Error in converting EddystoneTLM negative temperatures Error in converting EddystoneTLM negative temperatures to float Jun 6, 2024
@h2zero h2zero added the bug Something isn't working label Jun 6, 2024
@h2zero
Copy link
Owner

h2zero commented Jun 6, 2024

Thanks! would you mind making a PR for this?

@Max93
Copy link
Contributor

Max93 commented Jun 6, 2024

Hello @h2zero

I am a colleague of Giovanni (@giovanni-foorban), who opened this issue. I have created a pull request to address the problem with negative temperature readings #677.

You can find the pull request here.

Thank you for your attention.

@Max93
Copy link
Contributor

Max93 commented Jun 9, 2024

Hi @h2zero, when are you planning the next release ? Was it right to open the pr to release 1.4 ?

@h2zero
Copy link
Owner

h2zero commented Jun 9, 2024

I'll look to make a new release soon, hard to say when exactly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants