Skip to content

Commit 50e1c7e

Browse files
authored
Adds MACROs to convert beacon temperature
2 Macros EDDYSTONE_TEMP_U16_TO_FLOAT(tempU16) - takes the TLM BigEndian 8.8 fixed point representation and returns its float value EDDYSTONE_TEMP_FLOAT_TO_U16(tempFloat) - takes a float (temperature) and returns its BigEndian 8.8 fixed point representation
1 parent f677580 commit 50e1c7e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libraries/BLE/src/BLEEddystoneTLM.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
static const char LOG_TAG[] = "BLEEddystoneTLM";
2020
#define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00)>>8) + (((x)&0xFF)<<8))
2121
#define ENDIAN_CHANGE_U32(x) ((((x)&0xFF000000)>>24) + (((x)&0x00FF0000)>>8)) + ((((x)&0xFF00)<<8) + (((x)&0xFF)<<24))
22+
#define EDDYSTONE_TEMP_U16_TO_FLOAT(tempU16) (((int16_t)ENDIAN_CHANGE_U16(tempU16)) / 256.0f)
23+
#define EDDYSTONE_TEMP_FLOAT_TO_U16(tempFloat) (ENDIAN_CHANGE_U16(((int)(tempFloat * 256))))
2224

2325
BLEEddystoneTLM::BLEEddystoneTLM() {
2426
beaconUUID = 0xFEAA;

0 commit comments

Comments
 (0)