Skip to content
Commit 1578e70e authored by Benjamin Lindqvist's avatar Benjamin Lindqvist Committed by Jukka Rissanen
Browse files

net: lwm2m: Add path generation macro



Currently, the Zephyr LwM2M code base is littered with hard-coded
object- and resource IDs, such as

    /* Mark 1st instance of security object as a bootstrap server */
    lwm2m_engine_set_u8("0/0/1", 1);

The purpose of this LoC is extremely opaque without the accompanying
comment. Each use of a resource path requires constantly checking
headers or the object registry to ensure you're not misremembering IDs.

To alleviate this, this commit introduces a variadic LwM2M path
expansion macro which performs preprocessor stringification on each
argument. For instance, "0/0/1" can now be written as

    LWM2M_PATH(LWM2M_OBJECT_SECURITY_ID, 0, SECURITY_BOOTSTRAP_FLAG_ID)

which, while albeit lengthier, avoids the use of hard-coded string
literals, thus making the code much more immediately understandable.

Signed-off-by: default avatarBenjamin Lindqvist <benjamin.lindqvist@endian.se>
parent daa783ae
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment