Skip to content

Commit b78dd24

Browse files
Veijo Pesonencarlescufi
authored andcommitted
net: lwm2m: Sets ct to registration msg
Tells the server which content format is preferred in a registration message. Signed-off-by: Veijo Pesonen <[email protected]>
1 parent 4f76b19 commit b78dd24

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

subsys/net/lib/lwm2m/lwm2m_rw_link_format.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ LOG_MODULE_REGISTER(net_lwm2m_link_format, CONFIG_LWM2M_LOG_LEVEL);
2828
* missing.
2929
*/
3030

31-
#if defined(CONFIG_LWM2M_RW_JSON_SUPPORT)
32-
#define RESOURCE_TYPE ";rt=\"oma.lwm2m\""
3331

34-
#define REG_PREFACE "</>" RESOURCE_TYPE \
32+
#if defined(CONFIG_LWM2M_RW_SENML_CBOR_SUPPORT)
33+
#define REG_PREFACE "</>;ct=" STRINGIFY(LWM2M_FORMAT_APP_SENML_CBOR)
34+
#elif defined(CONFIG_LWM2M_RW_SENML_JSON_SUPPORT)
35+
#define REG_PREFACE "</>;ct=" STRINGIFY(LWM2M_FORMAT_APP_SEML_JSON)
36+
#elif defined(CONFIG_LWM2M_RW_JSON_SUPPORT)
37+
#define REG_PREFACE "</>;rt=\"oma.lwm2m\"" \
3538
";ct=" STRINGIFY(LWM2M_FORMAT_OMA_JSON)
3639
#else
3740
#define REG_PREFACE ""
@@ -61,8 +64,8 @@ static int put_begin(struct lwm2m_output_context *out,
6164
break;
6265

6366
case LINK_FORMAT_MODE_REGISTER:
64-
/* Only indicate content type if json is enabled. */
65-
if (!IS_ENABLED(CONFIG_LWM2M_RW_JSON_SUPPORT)) {
67+
/* No need to append content type */
68+
if (strlen(REG_PREFACE) == 0) {
6669
return 0;
6770
}
6871

0 commit comments

Comments
 (0)