From 8c68e01e55220c20d22a780c9c0559a7ccd2693c Mon Sep 17 00:00:00 2001 From: Veijo Pesonen Date: Wed, 5 Oct 2022 10:05:19 +0300 Subject: [PATCH] doc: lwm2m: LwM2M Shell Describes a possible scenario where to use the LwM2M shell and how to enable it. Signed-off-by: Veijo Pesonen --- doc/connectivity/networking/api/lwm2m.rst | 51 +++++++++++++++++++++++ subsys/net/lib/lwm2m/lwm2m_shell.c | 6 +-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/doc/connectivity/networking/api/lwm2m.rst b/doc/connectivity/networking/api/lwm2m.rst index ea5cbfdd0b1..9f1bdbc8196 100644 --- a/doc/connectivity/networking/api/lwm2m.rst +++ b/doc/connectivity/networking/api/lwm2m.rst @@ -576,6 +576,57 @@ The events are prefixed with ``LWM2M_RD_CLIENT_EVENT_``. If the retry counter reaches its limits, this event will be triggered. - No actions needed, client will do a re-registrate automatically. +.. _lwm2m_shell: + +LwM2M shell +*********** +For testing the client it is possible to enable Zephyr's shell and LwM2M specific commands which +support changing the state of the client. Operations supported are read, write and execute +resources. Client start, stop, pause and resume are also available. The feature is enabled by +selecting :kconfig:option:`CONFIG_LWM2M_SHELL`. The shell is meant for testing so productions +systems should not enable it. + +One imaginable scenario, where to use the shell, would be executing client side actions over UART +when a server side tests would require those. It is assumed that not all tests are able to trigger +required actions from the server side. + +.. code-block:: console + + uart:~$ lwm2m + lwm2m - LwM2M commands + Subcommands: + exec :Execute a resource + exec PATH + + read :Read value from LwM2M resource + read PATH [OPTIONS] + -s Read value as string (default) + -b Read value as bool (1/0) + -uX Read value as uintX_t + -sX Read value as intX_t + -f Read value as float + + write :Write into LwM2M resource + write PATH [OPTIONS] VALUE + -s Value as string (default) + -b Value as bool + -uX Value as uintX_t + -sX Value as intX_t + -f Value as float + + start :Start the LwM2M RD (Registration / Discovery) Client + start EP_NAME [BOOTSTRAP FLAG] + -b Set the bootstrap flag (default 0) + + stop :Stop the LwM2M RD (De-register) Client + stop [OPTIONS] + -f Force close the connection + + update :Trigger Registration Update of the LwM2M RD Client + + pause :LwM2M engine thread pause + resume :LwM2M engine thread resume + .. _lwm2m_api_reference: diff --git a/subsys/net/lib/lwm2m/lwm2m_shell.c b/subsys/net/lib/lwm2m/lwm2m_shell.c index 419ea91dc03..a96a1df85fe 100644 --- a/subsys/net/lib/lwm2m/lwm2m_shell.c +++ b/subsys/net/lib/lwm2m/lwm2m_shell.c @@ -28,19 +28,19 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); "Root-level operation is unsupported" #define LWM2M_HELP_EXEC "Execute a resource\nexec PATH\n" #define LWM2M_HELP_READ "Read value from LwM2M resource\nread PATH [OPTIONS]\n" \ - "-s \tRead value as string(default)\n" \ + "-s \tRead value as string (default)\n" \ "-b \tRead value as bool (1/0)\n" \ "-uX\tRead value as uintX_t\n" \ "-sX\tRead value as intX_t\n" \ "-f \tRead value as float\n" #define LWM2M_HELP_WRITE "Write into LwM2M resource\nwrite PATH [OPTIONS] VALUE\n" \ - "-s \tValue as string(default)\n" \ + "-s \tValue as string (default)\n" \ "-b \tValue as bool\n" \ "-uX\tValue as uintX_t\n" \ "-sX\tValue as intX_t\n" \ "-f \tValue as float\n" #define LWM2M_HELP_START "Start the LwM2M RD (Registration / Discovery) Client\n" \ - "start EP_NAME [OPTIONS] [BOOTSTRAP FLAG]\n" \ + "start EP_NAME [BOOTSTRAP FLAG]\n" \ "-b \tSet the bootstrap flag (default 0)\n" #define LWM2M_HELP_STOP "Stop the LwM2M RD (De-register) Client\nstop [OPTIONS]\n" \ "-f \tForce close the connection\n"