Skip to content

Commit

Permalink
examples/lte_lwm2mstub: Support lifetime parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
SPRESENSE committed Dec 2, 2022
2 parents cd2e98b + 21d57fd commit 71a995b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/lte_lwm2mstub/app_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static int setup_parsedvalue(void *user, const char *section,
* security_mode = <Secure mode> ; Select Secure mode from NONE or PSK
* deviceid = <Device ID> ; Set Device ID
* security_key = <Security KeyD> ; Set security key
* lifetime = <Life time> ; Life time [sec] of resource /1/x/1.
*
*/

Expand Down Expand Up @@ -249,6 +250,10 @@ static int setup_parsedvalue(void *user, const char *section,
{
strncpy(param->security_key, value, sizeof(param->security_key));
}
else if (!strcmp(section, "LwM2M") && !strcmp(name, "lifetime"))
{
param->lifetime = atoi(value);
}
else if (!strcmp(section, "LwM2M") && !strcmp(name, "time_period"))
{
printf("Time period.\n");
Expand Down Expand Up @@ -295,6 +300,7 @@ struct app_parameter_s *createparam_from_ini(const char *filename)
{
int ret;
memset(&app_param, 0, sizeof(app_param));
app_param.lifetime = 6000; /* As default */

ret = ini_parse(filename, setup_parsedvalue, &app_param);
if (ret != 0)
Expand Down
1 change: 1 addition & 0 deletions examples/lte_lwm2mstub/app_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct app_parameter_s
char security_key[LWM2MSTUB_MAX_SEQKEY];
bool bootstrap;
int security_mode;
int lifetime;

int time_period;
};
Expand Down
1 change: 1 addition & 0 deletions examples/lte_lwm2mstub/lte_lwm2mstub_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ static int lwm2m_setup(struct app_parameter_s *param)
info.bootstrap = param->bootstrap;
info.security_mode = param->security_mode;
info.nonip = (param->ip_type == LTE_IPTYPE_NON) ? true : false;
info.lifetime = param->lifetime;

ret = lte_setm2m_serverinfo(&info, 0);
if (ret < 0)
Expand Down
3 changes: 3 additions & 0 deletions examples/lte_lwm2mstub/lwm2m.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ deviceid =
; Set security key
security_key =

; LwM2M lifetime
lifetime = 6000

; Timer period in secounds to notice when observation is started.
; Set zero makes no periodic update.
time_period = 10

0 comments on commit 71a995b

Please sign in to comment.