net: lwm2m: Add shell commands
Add shell commands to read and write native time_t value. Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
This commit is contained in:
parent
e1b860815e
commit
7dfa2c8a2b
1 changed files with 19 additions and 6 deletions
|
@ -31,13 +31,15 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
||||||
"-b \tRead value as bool (1/0)\n" \
|
"-b \tRead value as bool (1/0)\n" \
|
||||||
"-uX\tRead value as uintX_t\n" \
|
"-uX\tRead value as uintX_t\n" \
|
||||||
"-sX\tRead value as intX_t\n" \
|
"-sX\tRead value as intX_t\n" \
|
||||||
"-f \tRead value as float\n"
|
"-f \tRead value as float\n" \
|
||||||
|
"-t \tRead value as time_t\n"
|
||||||
#define LWM2M_HELP_WRITE "Write into LwM2M resource\nwrite PATH [OPTIONS] VALUE\n" \
|
#define LWM2M_HELP_WRITE "Write into LwM2M resource\nwrite PATH [OPTIONS] VALUE\n" \
|
||||||
"-s \tValue as string (default)\n" \
|
"-s \tWrite value as string (default)\n" \
|
||||||
"-b \tValue as bool\n" \
|
"-b \tWrite value as bool\n" \
|
||||||
"-uX\tValue as uintX_t\n" \
|
"-uX\tWrite value as uintX_t\n" \
|
||||||
"-sX\tValue as intX_t\n" \
|
"-sX\tWrite value as intX_t\n" \
|
||||||
"-f \tValue as float\n"
|
"-f \tWrite value as float\n" \
|
||||||
|
"-t \tWrite value as time_t\n"
|
||||||
#define LWM2M_HELP_START "Start the LwM2M RD (Registration / Discovery) Client\n" \
|
#define LWM2M_HELP_START "Start the LwM2M RD (Registration / Discovery) Client\n" \
|
||||||
"start EP_NAME [BOOTSTRAP FLAG]\n" \
|
"start EP_NAME [BOOTSTRAP FLAG]\n" \
|
||||||
"-b \tSet the bootstrap flag (default 0)\n"
|
"-b \tSet the bootstrap flag (default 0)\n"
|
||||||
|
@ -245,6 +247,14 @@ static int cmd_read(const struct shell *sh, size_t argc, char **argv)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
shell_print(sh, "%d\n", temp);
|
shell_print(sh, "%d\n", temp);
|
||||||
|
} else if (strcmp(dtype, "-t") == 0) {
|
||||||
|
time_t temp;
|
||||||
|
|
||||||
|
ret = lwm2m_engine_get_time(pathstr, &temp);
|
||||||
|
if (ret != 0) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
shell_print(sh, "%lld\n", temp);
|
||||||
} else {
|
} else {
|
||||||
shell_error(sh, "can't recognize data type %s\n", dtype);
|
shell_error(sh, "can't recognize data type %s\n", dtype);
|
||||||
shell_help(sh);
|
shell_help(sh);
|
||||||
|
@ -321,6 +331,9 @@ static int cmd_write(const struct shell *sh, size_t argc, char **argv)
|
||||||
} else if (strcmp(dtype, "-b") == 0) {
|
} else if (strcmp(dtype, "-b") == 0) {
|
||||||
ret = lwm2m_engine_set_bool(pathstr,
|
ret = lwm2m_engine_set_bool(pathstr,
|
||||||
strtoul(value, &e, 10));
|
strtoul(value, &e, 10));
|
||||||
|
} else if (strcmp(dtype, "-t") == 0) {
|
||||||
|
ret = lwm2m_engine_set_time(pathstr,
|
||||||
|
strtoll(value, &e, 10));
|
||||||
} else {
|
} else {
|
||||||
shell_error(sh, "can't recognize data type %s\n",
|
shell_error(sh, "can't recognize data type %s\n",
|
||||||
dtype);
|
dtype);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue