Skip to content

Commit 6d8eb8a

Browse files
Max93h2zero
authored andcommitted
Fix Error in converting EddystoneTLM negative temperatures to float | resolves #675
1 parent 098a989 commit 6d8eb8a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/NimBLEEddystoneTLM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ uint16_t NimBLEEddystoneTLM::getVolt() {
8181
* @return The temperature value.
8282
*/
8383
float NimBLEEddystoneTLM::getTemp() {
84-
return ENDIAN_CHANGE_U16(m_eddystoneData.temp) / 256.0f;
84+
return (int16_t)ENDIAN_CHANGE_U16(m_eddystoneData.temp) / 256.0f;
8585
} // getTemp
8686

8787
/**
@@ -203,7 +203,7 @@ void NimBLEEddystoneTLM::setVolt(uint16_t volt) {
203203
* @param [in] temp The temperature value.
204204
*/
205205
void NimBLEEddystoneTLM::setTemp(float temp) {
206-
m_eddystoneData.temp = (uint16_t)temp;
206+
m_eddystoneData.temp = ENDIAN_CHANGE_U16((int16_t)(temp * 256.0f));
207207
} // setTemp
208208

209209

0 commit comments

Comments
 (0)