Skip to content

Commit 81595ed

Browse files
rluboscfriedt
authored andcommitted
net: lwm2m: Fix binary to float32_value_t conversion
The helper function to conver 32-bit binary float value to float32_value_t incorrectly identified the "hidden" bit, resulting in invalid conversion when TLV encoding was used to write a resource (the output value was divided by 2). Signed-off-by: Robert Lubos <[email protected]>
1 parent 36a72dd commit 81595ed

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

subsys/net/lib/lwm2m/lwm2m_util.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ int lwm2m_b32_to_f32(uint8_t *b32, size_t len, float32_value_t *f32)
197197
/* remove bias */
198198
e -= 127;
199199

200-
/* enable "hidden" fraction bit 23 which is always 1 */
201-
f = ((int32_t)1 << 22);
200+
/* enable "hidden" fraction bit 24 which is always 1 */
201+
f = ((int32_t)1 << 23);
202202
/* calc fraction: bits 22-0 */
203203
f += ((int32_t)(b32[1] & 0x7F) << 16);
204204
f += ((int32_t)b32[2] << 8);

0 commit comments

Comments
 (0)