Closed delmet closed 8 years ago
The change doesn't work with a command line arg (-t, --defaultContentType) since there no code for the actual arg update handling in core/src/client/lwm2m_client.c
as follows:
diff --git a/core/src/client/lwm2m_client.c b/core/src/client/lwm2m_client.cindex e72e6ef..1d3a472 100644
--- a/core/src/client/lwm2m_client.c
+++ b/core/src/client/lwm2m_client.c
@@ -67,6 +67,7 @@ typedef struct
char * BootStrap;
char * PskIdentity;
char * PskKey;
+ AwaContentType defaultContentType;
const char * FactoryBootstrapFile;
const char * ObjDefsFiles[MAX_OBJDEFS_FILES];
size_t NumObjDefsFiles;
@@ -248,6 +249,8 @@ static int Lwm2mClient_Start(Options * options)
else
coap_SetPSK(pskIdentity, pskKey, sizeof(pskKey));
+ Lwm2mCore_SetDefaultContentType(options->defaultContentType);
+
// if required read the bootstrap information from a file
const BootstrapInfo * factoryBootstrapInfo;
if (options->FactoryBootstrapFile != NULL)
@@ -372,6 +375,7 @@ static void PrintOptions(const Options * options)
printf(" EndPointName (--endPointName) : %s\n", options->EndPointName ? options->EndPointName : "");
printf(" Bootstrap (--bootstrap) : %s\n", options->BootStrap ? options->BootStrap : "");
printf(" FactoryBootstrapFile (--factoryBootstrap) : %s\n", options->FactoryBootstrapFile ? options->FactoryBootstrapFile : "");
+ printf(" defaultContentType (--defaultContentType) : %d\n", options->defaultContentType);
int i;
for (i = 0; i < options->NumObjDefsFiles; ++i)
{
@@ -400,6 +404,9 @@ static int ParseOptions(int argc, char ** argv, struct gengetopt_args_info * ai,
if (ai->pskKey_given)
options->PskKey = ai->pskKey_arg;
+ if (ai->defaultContentType_given)
+ options->defaultContentType = ai->defaultContentType_arg;
+
if (ai->factoryBootstrap_given)
options->FactoryBootstrapFile = ai->factoryBootstrap_arg;
int i;
@@ -440,6 +447,7 @@ int main(int argc, char ** argv)
.BootStrap = NULL,
.PskIdentity = NULL,
.PskKey = NULL,
+ .defaultContentType = AwaContentType_ApplicationPlainText,
.FactoryBootstrapFile = NULL,
.ObjDefsFiles = {0},
.NumObjDefsFiles = 0,
with the above patch all looks good.
Thanks sorry forgot to do that finally step should be fixed now see #262
I guess this is why we typically would have written a test case for this new behaviour ;)
good catch @pstolarz thanks for the patch
Allow setting default content type for client daemon and static client if request does not specify one
see issue #257
Also small change for TinyDTLS and contiki