Mesh Generic Location Server -Not configured state values +C-type implicit conversions

Mesh 1.1 Generic Location Server defines special values for long/lat and north/east when unconfigured.
Current code doesn't appear to support/use these special values, instead using zero as defaults. This looks like a bug.

When attempting to fix the code in gen_loc_internal.h, the functions  *_encode() and *_decode() for local and global state
use type conversions int -> uint, uint -> int, and float -> uint that I am having some difficulty understanding if they will always
work correctly across all Nordic platforms and compilers, or rely on potentially unspecified integer/float promotion behavior.

https://github.com/nrfconnect/sdk-nrf/blob/9abba2029b75e5b4f8990f7b55b28817ed01a0e1/subsys/bluetooth/mesh/gen_loc_internal.h#L25-L32

Idea for at least a temporary fix is to use value outside of defined WGS84 ranges [-90,90] and -180,180] to represent an unconfigured global state and
then add test for these in above functions. If want to read/write these values directly to the net_buf_simple struct, is it safe to first read out and test the
value from the buffer and then conditionally perform the float calc, or is there more going on and this could result in a different value?

Similarly the local state struct decoding casts a uint16 to an int16. Will this always correctly work for negative target int values?

Getting a full fix would of course also work.

Related