Commit graph

829 commits

Author SHA1 Message Date
Yong Cong Sin 3c0aae8415 net: lwm2m: replace deprecated lwm2m_engine_get_resource
`lwm2m_engine_get_resource()` has been mark for deprecation for
more than 2 releases, but we are still using it in tree now,
because the `__deprecated` marker was probably forgotten in the
initial deprecation commit.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-18 14:32:56 -04:00
Yong Cong Sin 94e12d595e net: lwm2m: remove deprecated functions & definition
These functions have been deprecated for more than 2 releases,
remove them:

- lwm2m_engine_update_observer_min_period
- lwm2m_engine_update_observer_max_period
- lwm2m_engine_create_obj_inst
- lwm2m_engine_delete_obj_inst
- lwm2m_engine_set_opaque
- lwm2m_engine_set_string
- lwm2m_engine_set_u8
- lwm2m_engine_set_u16
- lwm2m_engine_set_u32
- lwm2m_engine_set_u64
- lwm2m_engine_set_s8
- lwm2m_engine_set_s16
- lwm2m_engine_set_s32
- lwm2m_engine_set_s64
- lwm2m_engine_set_bool
- lwm2m_engine_set_float
- lwm2m_engine_set_objlnk
- lwm2m_engine_set_time
- lwm2m_engine_get_opaque
- lwm2m_engine_get_string
- lwm2m_engine_get_u8
- lwm2m_engine_get_u16
- lwm2m_engine_get_u32
- lwm2m_engine_get_u64
- lwm2m_engine_get_s8
- lwm2m_engine_get_s16
- lwm2m_engine_get_s32
- lwm2m_engine_get_s64
- lwm2m_engine_get_bool
- lwm2m_engine_get_float
- lwm2m_engine_get_objlnk
- lwm2m_engine_get_time
- lwm2m_engine_register_read_callback
- lwm2m_engine_register_pre_write_callback
- lwm2m_engine_register_validate_callback
- lwm2m_engine_register_post_write_callback
- lwm2m_engine_register_exec_callback
- lwm2m_engine_register_create_callback
- lwm2m_engine_register_delete_callback
- lwm2m_engine_set_res_buf
- lwm2m_engine_set_res_data
- lwm2m_engine_set_res_data_len
- lwm2m_engine_get_res_buf
- lwm2m_engine_get_res_data
- lwm2m_engine_create_res_inst
- lwm2m_engine_delete_res_inst
- lwm2m_engine_path_is_observed
- lwm2m_engine_send
- lwm2m_send
- lwm2m_engine_enable_cache

And additionally, the following definition:
- LWM2M_RD_CLIENT_EVENT_REG_UPDATE_FAILURE

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-18 14:32:56 -04:00
Seppo Takalo 35cc774aa5 net: lwm2m: Retry DTLS handshake before dropping to bootstrap
Allow DTLS handshake to be retried before the engine
drops into bootstrap. Otherwise any termporary failure,
for example DNS failure might drop us into bootstrap
without retrying.

Now all the retry logic should be in sm_do_network_error().
sm_do_registration() should only fall back to bootstrap
if there is configuration error.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-14 15:34:39 +02:00
Seppo Takalo 441d970417 net: lwm2m: Bypass send_queue when sending empty Ack
In case we want to immediately send empty Ack to server,
we should bypass all send queues.

This is required when we try to send Ack from callbacks
that happen from socket-loop context. On those cases
the Ack would have not been send because the callback
might be blocking the socket-loop while processing
a request (like write callbacks).

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-12 12:50:46 -04:00
Seppo Takalo d3081e2f30 net: lwm2m: On write, use server selected block size
When we receive CoAP packets, it is in input buffer
that is size of NET_IPV6_MTU.
So in reality, we can handle bigger Block-Wise writes
than CONFIG_LWM2M_COAP_BLOCK_SIZE.

So if parsing of CoAP packet has passed, continue
with the same block-size instead of going to default.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-05 14:43:14 +01:00
Chris Friedt 4a5c4e5f73 posix: timers: deprecate CONFIG_POSIX_CLOCK and TIMER
The POSIX_CLOCK option does not correspond to any standard
option. It was used to active features of several distinct
POSIX Options and Option Groups, which complicated API and
application configuration as a result.

POSIX_CLOCK is being deprecated in order to ensure that Zephyr's
POSIX Kconfig variables correspond to those defined in the
specification, as of IEEE 1003.1-2017.

Additionally, CONFIG_TIMER is being deprecated because it does
not match the corresponding POSIX Option (_POSIX_TIMERS).

With this deprecation, we introduce the following Kconfig
options that map directly to standard POSIX Option Groups by
simply removing "CONFIG_":

* CONFIG_POSIX_TIMERS

Similarly, we introduce the following Kconfig options that
map directly to standard POSIX Options by simply removing
"CONFIG":

* CONFIG_POSIX_CLOCK_SELECTION
* CONFIG_POSIX_CPUTIME
* CONFIG_POSIX_DELAYTIMER_MAX
* CONFIG_POSIX_MONOTONIC_CLOCK
* CONFIG_POSIX_TIMEOUTS
* CONFIG_POSIX_TIMER_MAX

In order to maintain parity with the current feature set, we
introduce the following Kconfig options that map directly to
standard POSIX Option Groups by simply removing "CONFIG_":

* CONFIG_POSIX_MULTI_PROCESS - sleep()

Similarly, in order to maintain parity with the current feature
set, we introduce the following additional Kconfig options that
map directly to standard POSIX Options by simply removing
"CONFIG":

* CONFIG_XSI_SINGLE_PROCESS - gettimeofday()

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Seppo Takalo 9e615429d5 net: lwm2m: Block-Wise response NUM field fix
When calculating the offset for blockwise writes,
we should not advance the block_ctx->current field
past the block boundary.
It causes CoAP layer to reply with the next NUM field
instead of the current one being processed.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-03 15:37:21 +02:00
Seppo Takalo b76683e4cb net: lwm2m: Allow setting RD context without starting
When tests control the LwM2M client entirely through
shell, we should be able to set the RD client context
from the application without causing RD client to
start registration.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-29 10:47:57 -07:00
Seppo Takalo 4049e17c62 net: lwm2m: Fix null dereference when post-write cb is set
When opaque resources have post-write callback set, but
the write is not a Block-Wise write, there is no block_ctx
and the code causes null pointer dereference when calculating
the offset of the data.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-28 18:54:31 +02:00
Seppo Takalo 37f6803833 net: lwm2m: Allow Block-Wise write without callbacks
Allow Block-Wise writes to resources that have enough buffer for
the whole content. Calculate the offset before calling the
content specific write handlers when callback is not set.

Previously only resources with post-write callback were able to
assemble the content.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Seppo Takalo a9e91af375 test: lwm2m: Add tests for Block-Wise transfers
Block-Wise GET, PUT and SEND

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Seppo Takalo 01b57b4999 net: lwm2m: Add offset to post-write callback
When Block-Wise transfer restarts, the post-write callback should
receive some indication that the block is actually a beginning of new,
instead of part of previous transfer.

Fixes #71351

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Jordan Yates 23ca74b756 convert: use k_uptime_seconds
Replace usage of `k_uptime_get() / MSEC_PER_SEC` and
`k_uptime_get() / 1000` with dedicated function.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-14 09:32:01 +02:00
Philippe Schumacher 67db6f69f3 net: lwm2m: efficent cbor record data structure
The record data structure is better aligned. Each record saves
24 bytes.

Signed-off-by: Philippe Schumacher <philippe.schumacher@husqvarnagroup.com>
2024-05-08 12:00:57 +02:00
Seppo Takalo e2ab41b625 net: lwm2m: Fix pull-context on queue mode
Two issues fixed:
When pull-context is created, it does not have to wake up the RD
client context. Ignore the EPERM warning.

When new pull-context creates a new socket, sometimes socket-loop
gets to recvfrom() before we have set O_NONBLOCK on the socket.
So use ZSOCK_MSG_DONTWAIT on zsock_recvfrom() so it does not
block the socket loop.

Fixes #71450

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-07 15:10:09 -05:00
Seppo Takalo 553e5d2e0c net: lwm2m: Move one Kconfig to engine features submenu
Kconfig option to enable object version reporting should
be moved into sub section "Engine features" so
it does not clutter up the main LwM2M menu.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-06 14:55:42 +01:00
Andreas Rudolf f531afbd2c net: lwm2m: Add config to always report obj version
Adds a config that enables sending the object version for all objects.

According to LwM2M specification v1.0 and v1.1, non-core object versions
other than 1.0 'must' be provided, while all other versions 'may' be
provided. With specification v1.2, a client 'can always attach Object
Version Information'. Or in other words, it is OK to always report the
object version with all specifications.

Signed-off-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>
2024-04-23 21:26:39 +00:00
Peter Mitsis 02cc127475 linker: subsys: Use Z_LINK_ITERABLE_SUBALIGN
Updates the linker script fragments under 'subsys' to use
Z_LINK_ITERABLE_SUBALIGN for the subalignment instead of
a hardcoded value of 4.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-04-20 13:45:25 -04:00
Seppo Takalo 51d80a9838 net: lwm2m: Allow CoAP block size to be changed
Allow changing the CoAP Block-wise transfers block-size
for subsequent GET requests.

It looks like Leshan switches block size back to its
configured value, if it is smaller.
So even when we send block N=0 with size of 512, Leshan
seem to handle that properly but still asks N=2 with
block size 256(if that is configured).

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-04-12 09:14:36 -04:00
Marco Argiolas f0212367dc net: lib: lwm2m: fix formula for expected next block
Block size is a 3-bit value mapping values [0, 6] to powers of 2 in the
range [16, 1024]. Value 7 is invalid.
The previous formula was not working in case the client's preferred size
was 4 (or more) times bigger than the server's.
This commit takes into account also the case the client's preferred size
is smaller than the server's.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2024-04-11 14:40:44 +02:00
Reto Schneider ccc58b8ce5 net: lwm2m: device object: Fix coverage compatibility
Starting with b1d24e425c (net: lwm2m:
device object: optionally store error list in settings), it was no
longer possible to build the code with coverage enabled when the
settings subsystem was disabled.

The build would fail with an error like this:

> subsys/net/lib/lwm2m/lwm2m_obj_device.c:262: undefined reference to
> `settings_name_steq'

This fixes #70923.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2024-04-03 15:39:49 +01:00
Seppo Takalo c62dd778cd net: lwm2m: Fix socket hints for block transfer
Outgoing block-transfers now set the socket hint
to ONGOING as long as the BLOCK1/BLOCK2 header has
MORE flag set to true.
This means as only the last packet in the block-transfer
set the socket hint to LAST or ONE_RESPONSE.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-03-28 16:02:34 -05:00
Jukka Rissanen d7c9d67a9c net: Use always zephyr/posix/fcntl.h
Changing remaining users of fcntl.h to use the include from our own
POSIX file so that the values in there are consistent in all parts
of the sources.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-27 13:40:13 -05:00
Marco Argiolas 2f35d11bfe net: lib: lwm2m: block 0 resets prev block transfer for same resource
As stated in "[RFC7959], Section 2.5":
   "The Block1 Option provides no way for a single endpoint to perform
   multiple concurrently proceeding block-wise request payload transfer
   (e.g., PUT or POST) operations to the same resource.  Starting a new
   block-wise sequence of requests to the same resource (before an old
   sequence from the same endpoint was finished) simply overwrites the
   context the server may still be keeping."

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2024-03-26 09:38:55 +00:00
Marco Argiolas 215782aa5c net: lib: lwm2m: fix function parameter for SW management object
Fix build error.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2024-03-26 09:38:55 +00:00
Stefan Schwendeler 947d4a13c3 net: lwm2m: removes redundant newline for log and shell calls
All the shell and logger calls here already add a newline.

Signed-off-by: Stefan Schwendeler <Stefan.Schwendeler@husqvarnagroup.com>
2024-03-14 11:04:59 -05:00
Seppo Takalo 8a38ff7161 net: lwm2m: Handle empty URI
On some content-types, it might be impossible to
send strings with size of zero.
Therefore empty URI should also allow cases
where strlen() is zero.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-03-13 11:37:54 -05:00
Juha Ylinen f38ecb7a09 net: lwm2m: Add API to set multiple resource values
Add new API lwm2m_set_bulk() to set multiple resource values in
one function call.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2024-02-26 11:53:29 +00:00
Øyvind Rønningstad 3ad47d214a lwm2m: Regenerate zcbor files
with zcbor 0.8.1

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2024-01-30 13:38:51 +01:00
Seppo Takalo 992936300b net: lwm2m: Use CID_SUPPORTED instead of CID_ENABLED
When ENABLED flag is used, we generate 32 byte DTLS
Connection Identifier and include that in our
DTLS Client HELO. This has no benefit as client only
has one connection toward the server, it does not need
any identification.

When SUPPORTED flag is used, we just include
zero length Connection Identifier in the handshake,
which tell server that we support Connection Identifier
and server can generate one for it.
We then use the CID in the packets that we send towards
server, but response packets don't contain any CID.
This gives all the benefit of CID as server is able to
identify us even when NAT mapping have changed.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-01-26 12:00:51 -06:00
Alberto Escolar Piedras 4ff79cb74a subsys/net/lib/lwm2m: Define required source standard macros
Instead of relaying on those macros having been defined
somewhere else let's define them for this file.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-26 07:48:55 -05:00
Øyvind Rønningstad 1bbb0a9ddb lwm2m: Adapt to zcbor 0.8.0
Regenerate from CDDL, update patch, fix references in code.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2024-01-25 15:09:16 +00:00
Seppo Takalo ec3ec8cd2a net: lwm2m: Add LWM2M_ON_INIT() macro
Add macro that allows registration of initialization functions that
are called when LwM2M engine starts.

On LwM2M engine starts up, it first executes all initialization
functions in following priority order:
1. LWM2M_PRIO_ENGINE
2. LWM2M_PRIO_CORE, this is where all LwM2M core objects are initialized
3. LWM2M_PRIO_OBJ, this is where all other objects are initialized
4. LwM2M_PRIO_APP, application initialization.

Now on the initialization phase, we could rely that certain objects have
already been registered.
For example custom objects can register callbacks to core objects.
On application phase, we can initialize sensor objects and register
their callbacks because objects have already been initialized.

This LWM2M_ON_INIT() should replace all use of SYS_INIT()
with the default CONFIG_KERNEL_INIT_PRIORITY_DEFAULT.

Priority order is actually just alphabetical order of names, so
the order is set on a linkin phase, and we don't need any
runtime checking for it.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-01-24 10:44:28 +01:00
Seppo Takalo bf872870ea net: lwm2m: Fix segfault on failed bootstrap
If bootstrap fails, RD client will call lwm2m_engine_stop()
which will close the context.
The socket loop, however still contains a call to
hint_socket_state(context, NULL) which has a null pointer now.

Fix the segfault by allowing nullpointer on hint_socket_state().

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-01-22 17:25:02 +00:00
Juha Ylinen 9eee8d2be5 net: lwm2m: Allow send operations when sleeping
Add new kconfig CONFIG_LWM2M_QUEUE_MODE_NO_MSG_BUFFERING.

When enabled and device is sleeping, Reqistration Update
message is skipped and messages from send operation and
notifications are sent right away.

Reqistration update message is also skipped when
lwm2m_engine resumes from pause state.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2024-01-19 09:48:46 +01:00
Simon Walz 38aa4d5169 net: lwm2m: add gateway callback to handle prefixed messages
Adding a callback for handling lwm2m messages with prefixed paths defined
by the gateway object. If CONFIG_LWM2M_GATEWAY_OBJ_SUPPORT is set,
each path is checked for the prefix stored in the object instances of the
gateway object 25. If prefixes match the msg is passed to the gw_msg_cb.

Signed-off-by: Simon Walz <simon.walz@autosen.com>
2024-01-10 18:22:21 +00:00
Juha Ylinen 7c53fa86ff net: lwm2m: Fix deadlock when calling lwm2m_engine_pause()
lwm2m_engine_pause() caused deadlock if it was called within
engine thread.

Remove while loop from lwm2m_engine_resume().

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2024-01-05 09:06:27 +01:00
Juha Ylinen 85dfe3df14 net: lwm2m: Delay triggering registration update
Add short delay before triggering registration update. This allows
postponing the update from application side if needed.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2024-01-05 09:06:27 +01:00
Seppo Takalo dc6e7aa4b1 net: lwm2m: Add transmission state indicator to RX as well
Refactored the socket state indication into its own function
that checks the state of TX queues as well as number of
pending CoAP responses.
Check the state after receiving a packet, as it might
have been a last Ack packet we have been waiting.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-27 16:07:59 +00:00
Seppo Takalo 071cad2e76 net: lwm2m: Deprecate lwm2m_get/set_u64
Deprecate lwm2m_set_u64() and lwm2m_get_u64 as only
LWM2M_RES_TYPE_S64 exist. Unsigned variant is not defined.

Technically these might have worked OK, but it is undefined
what happens to large unsigned values when those are
converted to various payload formats (like CBOR) that might
decode numbers differently depending of their signedness.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-22 09:54:07 +01:00
Seppo Takalo 6161fbdf21 net: lwm2m: Transmission state indications
Allow engine to give hints about ongoing CoAP transmissions.
This information can be used to control various power saving
modes for network interfaces. For example cellular networks might
support release assist indicator.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-20 11:57:48 +00:00
Seppo Takalo 0d650ffd26 net: lwm2m: Update TX timestamp on zsock_send()
In slow networks, like Nb-IOT, when using queue mode,
there might be significant delay between the time we
put the packet into a transmission queue and the time
we actually start transmitting.
This might cause QUEUE_RX_OFF state to be triggered earlier
than expected. Remedy the issue by updating the timestamp on the
moment where packet is accepted by zsock_send().

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-20 11:57:48 +00:00
Johan Hedberg 3fbf12487c kernel: Introduce a way to specify minimum system heap size
There are several subsystems and boards which require a relatively large
system heap (used by k_malloc()) to function properly. This became even
more notable with the recent introduction of the ACPICA library, which
causes ACPI-using boards to require a system heap of up to several
megabytes in size.

Until now, subsystems and boards have tried to solve this by having
Kconfig overlays which modify the default value of HEAP_MEM_POOL_SIZE.
This works ok, except when applications start explicitly setting values
in their prj.conf files:

$ git grep CONFIG_HEAP_MEM_POOL_SIZE= tests samples|wc -l
     157

The vast majority of values set by current sample or test applications
is much too small for subsystems like ACPI, which results in the
application not being able to run on such boards.

To solve this situation, we introduce support for subsystems to specify
their own custom system heap size requirement. Subsystems do
this by defining Kconfig options with the prefix HEAP_MEM_POOL_ADD_SIZE_.
The final value of the system heap is the sum of the custom
minimum requirements, or the value existing HEAP_MEM_POOL_SIZE option,
whichever is greater.

We also introduce a new HEAP_MEM_POOL_IGNORE_MIN Kconfig option which
applications can use to force a lower value than what subsystems have
specficied, however this behavior is disabled by default.

Whenever the minimum is greater than the requested value a CMake warning
will be issued in the build output.

This patch ends up modifying several places outside of kernel code,
since the presence of the system heap is no longer detected using a
non-zero CONFIG_HEAP_MEM_POOL_SIZE value, rather it's now detected using
a new K_HEAP_MEM_POOL_SIZE value that's evaluated at build.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2023-12-20 11:01:42 +01:00
Juha Ylinen d09d3d82ef net: lib: coap: Change coap_pending_init()
Replace function parameter 'retries' with pointer to structure
holding coap transmission parameters. This allows setting the
retransmission parameters individually for each pending request.

Add coap transmission parameters to coap_pending structure.

Update migration guide and release notes.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-12-15 11:41:27 +00:00
Daniel DeGrasse 3091ddc4fe net: lib: lwm2m: use correct format specifier for LOG_ERR
Use correct format specifier for LOG_ERR in lwm2m_obj_device.c. The
previously used format specifier of %u was correct for 32 bit systems
but would produce a build warning for 64 bit systems.

Fixes #66441

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-12-14 09:32:43 +01:00
Seppo Takalo 005dc60d24 net: lwm2m: Fix pmin handling on tickless
If observed resource was written during the pMin period, it did
not schedule any wake-up event into the future. Notify message would
then only be generated as a result of any other (like Update) event.

Refactor check_notifications() to follow same pattern as retransmit_req().
Return the next event timestamp, which could be now.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-11 09:57:09 +01:00
Nick Ward b1d24e425c net: lwm2m: device object: optionally store error list in settings
A device can be reset before the error code list is communicated
to a LwM2M server so optionally store error list in settings so it
can restored after reset.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-12-06 17:55:22 +00:00
Nick Ward b75a3f691d net: lwm2m: device object: use LWM2M_DEVICE_ERROR_NONE
Use LWM2M_DEVICE_ERROR_NONE macro.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-12-06 17:55:22 +00:00
Seppo Takalo dc8f6da53c net: lwm2m: Implement fallback mechanism and support for diable
If server registration fails, allow fallback to secondary server,
or fallback to bootstrap.
Also allow fallback to different bootstrap server.

Add API to tell RD client when server have been disabled by
executable command.

Changes to RD state machine:
* All retry logic should be handled in NETWORK_ERROR state.
* New state SERVER_DISABLED.
* Internally disable servers that reject registration
* Temporary disable server on network error.
* Clean up all "disable timers" on start.
* Select server first, then find security object for it.
* State functions return void, error handling is done using states.
* DISCONNECT event will only come when client is requested to stop.
* NETWORK_ERROR will stop engine. This is generic error for all kinds
  of registration or network failures.
* BOOTSTRAP_REG_FAILURE also stops engine. This is fatal, and we cannot
  recover.

Refactoring:
* Server selection logic is inside server object.
* sm_handle_timeout_state() does not require msg parameter. Unused.
* When bootstrap fail, we should NOT back off to registration.
  This is a fatal error, and it stops the engine and informs application.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-05 16:40:06 -06:00
Seppo Takalo ec962246e9 net: lwm2m: Allow disabling server for a period of time
React to disable executable, as well as add callback that allows
disabling server for a period of time.

Also add API that would find a next server candidate based on the
priority and server being not-disabled.

Move all server related functions into its own header.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-05 16:40:06 -06:00