net: lwm2m: Allow changing the protocol version to 1.1

This is a bare minimal changes to tell the server that we are using
LwM2M 1.1 version. Queue-mode parameter has changed between 1.0 and
1.1 so it must be changed in the same time.

Other 1.1 features may follow on separate commits. This is still
an experimental feature that allows developing and testing of
1.1 features.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This commit is contained in:
Seppo Takalo 2021-11-09 12:48:12 +02:00 committed by Anas Nashif
commit f1e0b5413c
4 changed files with 64 additions and 10 deletions

View file

@ -67,6 +67,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define COAP_OPTION_BUF_LEN 13
#endif
#define BINDING_OPT_MAX_LEN 3 /* "UQ" */
#define QUEUE_OPT_MAX_LEN 2 /* "Q" */
#define MAX_TOKEN_LEN 8
struct observe_node {
@ -2011,12 +2013,24 @@ int lwm2m_engine_update_observer_max_period(const char *pathstr, uint32_t period
}
void lwm2m_engine_get_binding(char *binding)
{
/* Defaults to UDP. */
strncpy(binding, "U", BINDING_OPT_MAX_LEN);
#if CONFIG_LWM2M_VERSION_1_0
/* In LwM2M 1.0 binding and queue mode are in same parameter */
char queue[QUEUE_OPT_MAX_LEN];
lwm2m_engine_get_queue_mode(queue);
strncat(binding, queue, QUEUE_OPT_MAX_LEN);
#endif
}
void lwm2m_engine_get_queue_mode(char *queue)
{
if (IS_ENABLED(CONFIG_LWM2M_QUEUE_MODE_ENABLED)) {
strcpy(binding, "UQ");
strncpy(queue, "Q", QUEUE_OPT_MAX_LEN);
} else {
/* Defaults to UDP. */
strcpy(binding, "U");
strncpy(queue, "", QUEUE_OPT_MAX_LEN);
}
}