net: lwm2m: fix float32/64 handling
During the initial work on LwM2M, the float32/64 code was basically stubbed out. Float32 sent only whole values and float64 was completely broken. Let's clean up the OMA TLV formatting code by moving the float processing code into a separate file: lwm2m_util.c. Then using public definitions for binary32 and binary64, let's fix the processing code to correctly fill the float32_value_t and float64_value_t types. Signed-off-by: Michael Scott <mike@foundries.io>
This commit is contained in:
parent
90d1e6f6c6
commit
d53a0855a1
5 changed files with 380 additions and 89 deletions
20
subsys/net/lib/lwm2m/lwm2m_util.h
Normal file
20
subsys/net/lib/lwm2m/lwm2m_util.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2019 Foundries.io
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef LWM2M_UTIL_H_
|
||||
#define LWM2M_UTIL_H_
|
||||
|
||||
#include <net/lwm2m.h>
|
||||
|
||||
/* convert float struct to binary format */
|
||||
int lwm2m_f32_to_b32(float32_value_t *f32, u8_t *b32, size_t len);
|
||||
int lwm2m_f64_to_b64(float64_value_t *f64, u8_t *b64, size_t len);
|
||||
|
||||
/* convert binary format to float struct */
|
||||
int lwm2m_b32_to_f32(u8_t *b32, size_t len, float32_value_t *f32);
|
||||
int lwm2m_b64_to_f64(u8_t *b64, size_t len, float64_value_t *f64);
|
||||
|
||||
#endif /* LWM2M_UTIL_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue