net: lwm2m: plain text: fix float formatting
Formatting a float32/64 value for plain text is broken. Example for 32bit: val1=0 and val2=500000 is equivalent to 0.5 Current formatter was using %d.%d (%lld.%lld for 64bit) so exported value was 0.500000 (or 0.5) To fix this, for val2 use a zero-padded formatter for the maximum length of each bit length (6 for 32bit and 9 for 64bit), and then remove the zero characters at the end of the string. Notes re: handling of val1/val2 signs: - eliminate potential negative sign when converting val2 to avoid: a value like: 0.-5 - use negative val2 when val1 is 0 to fix small negative handling such as -0.5 Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/16154 Signed-off-by:Michael Scott <mike@foundries.io>
Loading
Please sign in to comment