Commit graph

831 commits

Author SHA1 Message Date
Daniel Leung 5bc08ae3c6 net: rename shadow variables
Renames shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:43 +00:00
Seppo Takalo 321db8561d net: lwm2m: Restructure LwM2M Kconfig menu
* Create submenu for protocol versions.
  Like LwM2M 1.0 vs 1.1. Object versions.
* Create submenu for engine features.
  Containing all engine tweaks that are not directly from
  protocol specification.
* Create submenu for all memory tuning options.
  For example maximum number of certain objects, buffer
  sizes, etc.
* Order all objects by object ID and show the ID in
  title.
* When multiple options depend on same feature, group
  them under if <option> ... endif. Preferably directly
  after the selection itself.
* Move IPSO and uCIFI menuentries one sublevel up.
* Drop deprecated entries to bottom.

No functional changes, just clean up of Kconfig menu.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-07 11:26:47 +02:00
Seppo Takalo 838ab80bca net: coap: Use 64bit timestamps
Use 64bit timestamps from k_uptime_get() so they don't
roll over during the expected device lifetime.

Fixes #60826

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-01 15:40:04 +02:00
Seppo Takalo 518bbc1303 net: lwm2m: Refactor RD client to be tickless
Call RD client service only when there is state transitioning.
Remove periodic 500 ms timer.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-01 12:07:12 +02:00
Seppo Takalo 2da8844d19 net: lwm2m: Add support for non-periodic services
Engine now allows registering service callbacks that are
called only once on a given timestamp.
This allows tickless services to be developed.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-01 12:07:12 +02:00
Seppo Takalo 1dfa711167 net: lwm2m: Create socketpair that can wake up zsock_poll()
Allow socket-loop to wake up immediately, if there are changes,
instead of waiting for zsock_poll() to timeout.
This change makes engine more reactive and removes
hard coded timeout from zsock_poll().

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-01 12:07:12 +02:00
Seppo Takalo aaa9cedf18 net: lwm2m: Update next event timestamp on PMAX change
When PMAX value is changed, it should update all events.
I believe there is a bug that caused the code only to update
events that are ongoing (to be send).

Now if PMAX changes, next event timestamp is recalculated.

Fixes #59397

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-07-05 11:16:06 +02:00
Jarno Lämsä 7ae4e24728 net: lib: lwm2m: Use int16_t for signal strength
The signal strength for the connectivity monitor was
defined as int8_t, however this was too small for
LTE RSRP values, which has range [-140,-44].

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-06-29 10:04:14 +00:00
Seppo Takalo 6050a10f8b net: lwm2m: Allow setting string to zero length
Lwm2m firmware object have defined a write of zero length
string as a cancel operation.
So allow lwm2m_set_opaque(path, NULL, 0);

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-27 12:18:35 +00:00
Seppo Takalo dc7fbc5d2e net: lwm2m: Fix pause and resume on non-closed sockets
Pause and resume functionality was written into assumption
that sockets are closed before resuming.

With use new options CONFIG_LWM2M_RD_CLIENT_STOP_POLLING_AT_IDLE
or CONFIG_LWM2M_RD_CLIENT_LISTEN_AT_IDLE this is not always true.
Fix the state machine, so that on those cases, sockets are not
closed and resume is always similar like from the QUEUE mode.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-26 12:37:13 +00:00
Seppo Takalo 5c1228770e net: lwm2m: Add support for X509 certificates
Add support for using X509 certificates.
Default settings use ECDSA certificates with SHA256 hash.

When different settings are required clients should overwrite
struct lwm2m_ctx->load_credentials() and
struct lwm2m_ctx->set_socketoptions()

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-26 12:35:29 +00:00
Seppo Takalo 95cef5f3ab net: lwm2m: Ensure string termination
When writing string data to resources which are string types,
we should count in the terminating character into the data length.

Corner cases exist where LwM2M resource type is opaque but
lwm2m_get_string() or lwm2m_set_string() are used to read/write
the data. We must ensure string termination on those case, but
terminating character must not be stored in the engine buffer
or counted in the data length as this might be considered
as part of the binary data.

Fixes #59196

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-21 10:42:31 +02:00
Robert Lubos e5aa433f87 net: lwm2m: Fix pointless variable assignment
Coverity reported that assigning ret = 0 is pointless, as in any
scenario (loop continues or ends) the ret variable is overwritten
anyway, w/o using the assigned value. Therefore remove the needless
assignment.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:07:09 -04:00
Robert Lubos 479036165c net: lwm2m: Fix possible out-of-bound access when creating FW object
obj_inst_id should not be used directly to index the instance array, as
the instance ID is not tightly bound to the maximum instance count and
can exceed this value, causing out-of-bound access.

Therefore, perform some extra validation when choosing the array index
for the object instance to make sure we stay in the array bounds, or
return an error if there's no more room for more object instances, in a
similar way it's done for Security object.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-07 10:06:52 -04:00
Seppo Takalo a1cfe983b6 net: lwm2m: Allow overiding of default socket behaviour
In order to support external IP stacks that might have Connection
ID support, the LwM2M engine should allow client to bypass default
behaviour.

New set_socketoptions() callback added into client context
that allows overriding all socket opetions. This is called
after a socket is opened, but before the connect() is
called. This cannot be combined with load_credentials() callback
on all platforms as for example nRF91 requires modem offline
when credentials are written. This would cause socket to be closed
as well.

Second change is that we allow fine tuning of what we do with
socket handle when QUEUE mode is enabled and engine enters idle
state.

First option would be to close the socket. That would cause
TLS Alert(Close Notify) to be send. This is a band choice if
LTE modem was already in PSM or eDRX power saving mode.

Second option would be to delay socket closing until we
are going to send LwM2M update. There TLS Alert is also send,
but most probably lost due to NAT mapping timed out. This
is a best choice for LTE modem with DTL session cache enabled.

Two new options are to keep socket open, and either stop listening
or just keep listening. Both of these options work fine when
we have DTLS Connection ID support.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-06 09:40:16 -04:00
Robert Lubos 2e0b0af44e net: lwm2m: Fix lwm2m_socket_start() error handling
In case lwm2m_socket_start() internal error, it should only do cleanup
on the socket, i. e. call lwm2m_socket_close(), not lwm2m_engine_stop().
The latter resets the entire lwm2m_context, which results in removal of
active observations.

This should not be done, as it collides with the RD client logic, where
connection resumption may skip the full registration phase, in result
not notifying the server that it should restart the observations.

At the same time, the RD client should clean the lwm2m_context when it's
done trying to update the registration and proceeds with regular
registration/bootstrap in the network error handler. In that case, only
the socket was closed, so the lwm2m_context needs to be reset
separately.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-06-06 06:51:34 -04:00
Marco Argiolas 49436dc453 net: lib: lwm2m: add missing #include to lwm2m_rd_client.h
Definition for 'struct lwm2m_ctx' was missing and build warnings were
generated.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-05-29 04:57:18 -04:00
Lukas Woodtli fb924e2b62 net: lwm2m: Handle CONTINUE in registration message
The continue code is not considered an error in case of
block-wise transfer.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli 73fb4e73a8 net: lwm2m: Handle CONTINUE response and send new block
After sending a CoAP block and receiving the CONTINUE response
code the next block is sent.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli 49f8d08f98 net: lwm2m: Split message into blocks for sending
Add functionality that creates blocks from a big payload body.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Lukas Woodtli 3707a0d229 net: lwm2m: Provide buffer for block transfer
Allow to use a buffer for the complete message body if block transfer is
enabled. This buffer is used when serializing the message. For sending
the message the body is split into blocks.

Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
2023-05-15 09:18:09 +02:00
Flavio Ceolin 9b1da61d6a lwm2m: kconfig: Fix experimental feature
select EXPERIMENTAL for experimental option.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-05-10 11:41:50 +02:00
romain pelletant 75dd2c9904 net: lwm2m: use path as block context retrieval
Replace block context retrieval using object path instead of token.
Update block context structure
Fix issue #57165

Signed-off-by: romain pelletant <romain.pelletant@fullfreqs.com>
2023-05-03 10:01:37 +02:00
Øyvind Rønningstad 31c10f5fe1 lwm2m_senml_cbor_encode.c: Manually edit whitespace
since it crossed the 100 column cutoff, even after clang-format.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
Øyvind Rønningstad d0c278af78 lwm2m_senml_cbor: Regenerate code files using zcbor 0.7.0
and the _regenerate.sh script.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
Øyvind Rønningstad e9eb61bd14 lwm2m_senml_cbor: Update the regenerate script and the patch file
Do patch file application before clang-format.
Add copyright to generated files using the --file-header option in zcbor.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2023-04-18 15:22:02 +02:00
romain pelletant eab19663a9 net: lwm2m: add callback for send confirmation
Issue #52328

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2023-04-17 11:29:14 +02:00
Seppo Takalo 1dd9d514f1 net: lwm2m: Move utility functions from engine
Some utility functions belong to lwm2m_util.c.
Block contexts belong to lwm2m_message_handling.c

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-12 17:44:37 +02:00
Gerard Marull-Paretas a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Seppo Takalo 1c6a853528 net: lwm2m: Default lifetime is also a minimum accepted lifetime
If server or bootstrap writes a lifetime value less than
configured default lifetime, client will automatically overwrite
the value with default one.

This gives better control for the application where client
behaviour is fine tuned on the Kconfig, but default values
from bootstrap server cannot be fine-tuned.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 14:15:04 -05:00
Seppo Takalo 3a241592b5 net: lwm2m: Remove lwm2m_path_to_string
This function had only one use in SenML CBOR formatter and it
contained some specific tweaks, so move the function to be a
static member of that module.

Fixes #53674

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 15:37:21 +02:00
Seppo Takalo 567b2510b8 net: lwm2m: Allow stopping while paused
When LwM2M engine is paused, stop functionality just
marks the intent and when we resume, it will send the
de-registration if that was requested.
Otherwise it will stay in SUSPENDED state until resumed
and then goes into ENGINE_DEREGISTERED -> IDLE.

This also removes the blocking loop from lwm2m_rd_client_stop().
It does not need to block because lwm2m_rd_client_start()
is already checking if client is in IDLE.

Fixes #56254

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-04-06 14:21:49 +02:00
Kumar Gala b9a63b805e lwm2m: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-31 14:01:24 +02:00
Andreas Chmielewski 357181be23 net: lwm2m: Add is_suspended() routine
Add is_suspended() routine to have control over the rd client from the
outside whether it is suspended.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2023-03-28 15:06:15 +02:00
Michal Ciesielski 43c08d5c3f lwm2m: Fix multi res inst, create flags and post write callback for SWMGMT
The multi resource and create flags were reversed, meaning that resources
were defined as multi resource but weren't being created by default. That
doesn't reflect the LWM2M Software Management, which specifies which
objects can be multi resource and which are mandatory.

The post write callbacks were assigned to the validate callbacks.

Signed-off-by: Michal Ciesielski <michal.m.ciesielski@voiapp.io>
2023-03-13 11:58:29 +01:00
Julien Vermillard a9349fe74d net: lwm2m: Typo in LWM2M_IPSO_TIMER description
Changed description to "IPSO Timer Support" in place of "Light Control
Support"

Signed-off-by: Julien Vermillard <julien@vermillard.com>
2023-03-11 08:46:22 +02:00
Dave Lacerte 96c8d16986 net: lwm2m: Add IPSO voltage sensor object
Add support fot the IPSO voltage sensor object

Signed-off-by: Dave Lacerte <lacerte.dave@hydroquebec.com>
2023-03-06 12:34:22 +01:00
Marc Lasch 072a5da433 net: lwm2m: Register callback for firmware update cancel
Allow to register a callback function which is called when a firmware
update is canceled by the cancel command.

Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
2023-03-06 12:33:12 +01:00
Stefan Schwendeler 596a3bd996 net: lwm2m: bugfix lwm2m shell exec command with optional parameter
Actually `execute_cb` is fed with an array of char* and the size of
that array, instead of a single char* buffer and its byte size.

This fix expects a single, already joined, optional shell argument and
feeds `execute_cb` with proper arguments.

Signed-off-by: Stefan Schwendeler <Stefan.Schwendeler@husqvarnagroup.com>
2023-02-27 11:34:42 +01:00
Seppo Takalo abb3163d82 net: lwm2m: Clear out the timestamp when we start registration
There was a corner case that last registration timestamp was used
to detect if we can try UPDATE instead of full registration.

When timestamp was not cleared and DNS resolving failed, it might
cause engine to skip the resolving and continue retrying an UPDATE
message until timeout.

Fixes #54504

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo d8b8d53f5f net: lwm2m: Drop observations when falling back to registration
When we have establised an DTLS handshake and try LwM2M Update,
if the server rejects it, we fall back to sending full registration
but when doing so, we should also clear out any observations.

It was intentional that we don't go to ENGINE_DO_REGISTRATION
state as that would close the socket and cause DTLS handshake.

Fixes #54974

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo 96a4bedd30 net: lwm2m: Don't ignore socket errors when sending
Only socket error that we should ignore is EAGAIN (EWOULDBLOCK),
others might be indicating that there are some serious errors
in network layer.
When network stack would block us, just drop the packet and
let CoAP layer handle the retrying.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:31 +01:00
Seppo Takalo ea1eb28135 net: lwm2m: Fix build issue on time-series cache
This was only missing a variable declaration.

Fixes #55031

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:20 +01:00
Seppo Takalo bf49540a8d net: lwm2m: Add const qualifier to many pointers
Various functions, mostly concerning time-series cache, were not
using const pointer while they still did not modify the content.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-22 14:26:20 +01:00
Stefan Schwendeler 4662c40888 net: lwm2m: read command uses hexdump as default print format
A default format that does always print something useful.

Signed-off-by: Stefan Schwendeler <Stefan.Schwendeler@husqvarnagroup.com>
2023-02-22 08:50:56 +01:00
Juha Ylinen fdffdedc41 net: lwm2m: Add event LWM2M_RD_CLIENT_EVENT_REG_UPDATE
New event LWM2M_RD_CLIENT_EVENT_REG_UPDATE to indicate
application that engine starts registration update.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-02-19 20:44:02 -05:00
Seppo Takalo 437bfc58d9 net: lwm2m: Fix deregistration timeout state handling
Socket faults or timeouts in CoAP deregistration messages
caused RD client state machine to restart registration.

Fixes #54136

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-08 11:20:00 +01:00
Seppo Takalo d0dc67a72d net: lwm2m: Fix native_posix fcntl() calls
Native POSIX target still needs to use the <fcntl.h> header
instead of <zephyr/posix/fcntl.h>

Also removed the include from various files that did not use it.

Also changed fcntl() calls to zsock_fcntl() because we directly
use zsock_* calls elsewhere.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-02-02 20:05:08 +09:00
Seppo Takalo ec8884d58f net: lwm2m: lwm2m_client: Fix fcntl header path
We don't default to POSIX_API so use Zephyr's
path for fcntl.h

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-01-27 10:41:19 -06:00
Juha Heiskanen 1f84409b48 net: lwm2m: Trace clean
Cleaned Trace message print.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-25 15:08:07 +00:00
Andreas Chmielewski 022ff636da net: lwm2m: rd_client: added init function
To write tests it is necessary to offer init function for the RDClient
to define custom fakes before.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2023-01-25 14:55:02 +00:00
Veijo Pesonen f0258dbe4d net: lwm2m: Sufficient memory for resource names
Full resource names aren't as long as combined basename- and name-buffer
sizes but the compiler doesn't know it. Increasing the buffer size to
avoid the compiler warning.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2023-01-19 12:03:27 +01:00
Jarno Lämsä abafd7e810 net: lib: lwm2m: Replace deprecated function calls
Replace calls to deprecated functions with new ones.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä 3b3463ecba net: lib: lwm2m: Deprecate string based enable cache
Deprecate the old API and replace with new one which uses
the lwm2m_obj_path struct instead of a string.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä 460dd6530f net: lib: lwm2m: Deprecate string based send
Deprecate send API using the string references as paths.
Replace it with one using path structs.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä 49cf96858f net: lib: lwm2m: Deprecate buffer set get API
Deprecate old API and make new API using path structs
instead of using old string reference based paths.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä bca0550413 net: lib: lwm2m: Deprecate callback registration API
Deprecate old API and create new API using path structs
instead of string references to paths.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä a2e52c5607 net: lib: lwm2m: Deprecate observation API
Add new APIs using the lwm2m path structs instead of
string references to paths.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä 5c80be9379 net: lib: lwm2m: Deprecate object and resource API
Deprecate old API and offer a new API for object and resource
creation and deletion. The new API uses path struct instead
of using a string as a reference to a path.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Jarno Lämsä 15d81a8914 net: lib: lwm2m: Deprecate string based set get API
Use the lwm2m_obj_path struct instead and deprecate old.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-01-19 10:16:22 +01:00
Pascal Brogle 6ac281887c net: lwm2m: fix observation path list ordering
under certain conditions the current implementation did not maintain
the desired sort order.

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 13:47:27 +01:00
Pascal Brogle cc40bc33ba net: lwm2m: fix senml max name size
base name or name can contain up to two shorts.
(object id & object intstance or resource id & resource instance id)

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 12:02:07 +00:00
Pascal Brogle b6bc324a1d net: lwm2m: rename path size define
Rename max path constant to prevent string length vs data size confusion

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 12:02:07 +00:00
Pascal Brogle b178ff5246 net: lwm2m: fix senml cbor compiler warning
use size_t instead of assuming uint32_t

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-13 12:00:13 +00:00
Juha Ylinen 5e4eeb104d net: lwm2m: Verify data buffer size in lwm2m_engine_set()
Check data buffer size and return error if
     * buffer size is too small for opaque or string data type
     * buffer size is not equal to res data length when data type
       is fixed size

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-05 14:39:01 +00:00
Pascal Brogle 60bf310aae net: lwm2m: fix senml cbor object link encoding
use text format instead of tlv format

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-05 12:43:24 +01:00
Juha Heiskanen a70f420b2b net: lib: Patch file for generated code fix
Patch for generated lwm2m senml-cbor.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-05 12:43:24 +01:00
Juha Heiskanen d939c79af1 net: lib: LwM2M SenML-Cbor regenrated files update
Patched and fixed regenerated code.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-05 12:43:24 +01:00
Juha Heiskanen 637c9bbf95 net: lib: regenerate cbor code using zcbor
with the updated cddl for object links.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-05 12:43:24 +01:00
Pascal Brogle 547c3063b9 net: lwm2m: support senml cbor object link
use "vlo" map key

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2023-01-05 12:43:24 +01:00
Juha Ylinen eb914f45d1 net: lwm2m: Check return value from lwm2m_rd_client_pause/resume
Check return values from lwm2m_rd_client_pause() and
lwm2m_rd_client_resume() when engine thread suspend is requested.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-05 12:43:00 +01:00
Juha Ylinen c7a5f7fda7 net: lwm2m: Deprecate Kconfig for LwM2M RD Client
RD-Client is essential part of LwM2M specification and it can't
be disabled from LwM2M engine. This commit deprecates Kconfig
variable CONFIG_LWM2M_RD_CLIENT_SUPPORT and removes
all usages if it.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-03 13:23:46 +01:00
Juha Ylinen 7dfa2c8a2b 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>
2023-01-03 11:03:16 +01:00
Seppo Takalo a33f3b6abb net: lwm2m: Add shell command to enable timeseries cache
Add shell command

  cache   :Enable data cache for resource
           cache PATH NUM
           PATH is LwM2M path
           NUM how many elements to cache

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-01-03 11:02:54 +01:00
Juha Heiskanen 1800e629e6 net: lwm2m: LwM2M times series data update
Fixed problem for matching path url with or without '/'
by change time series data structure to use struct lwm2m_obj_path.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-03 11:02:54 +01:00
Juha Heiskanen 3abd9c364a net: lwm2m: LwM2M Object path equal API
Added new API for check is 2 object path equal.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2023-01-03 11:02:54 +01:00
Juha Ylinen 16b6892294 net: lwm2m: Refactor lwm2m_information_interface_send()
Call lwm2m_send_message_async() from function
lwm2m_information_interface_send() and remove duplicate code.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-03 11:02:44 +01:00
Juha Ylinen 1111184b74 net: lwm2m: Remove lwm2m_send_message() from public API
lwm2m_send_message() sends a message directly to the socket. Remove
the function from public API and combine the code with
socket_send_message().

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-01-03 11:02:44 +01:00
romain pelletant 5c14c56f2c net: lwm2m: add binaryappdatacontainer obj support
OMA LwM2M object 19 support for application specific binary data
Related issue #53340

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2023-01-03 11:02:09 +01:00
Juha Heiskanen 4a50f9362f net: lib: LwM2M rd client fix
Fix LwM2M rd client stop call hang when Queue client is at
RX_ON_IDLE_STATE. Added miossing connection resume for
de-register functionality.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-12-22 15:50:31 +00:00
Juha Ylinen 1827636ab6 net: lwm2m: Verify receiving buffer size in lwm2m_engine_get()
Check receiving buffer size and return error if
 * buffer size is too small for opaque or string data type
 * buffer size is not equal to data lenght when data type is
   fixed size

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2022-12-22 13:44:27 +01:00
Erwan Gouriou 66d4c64966 all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences
Clean up occurrences of "#if IS_ENABLED(CONFIG_FOO)" an replace
with classical "#if defined(CONFIG_FOO)".

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-12-21 10:09:23 +01:00
Marco Argiolas f8f3629efd net: lib: lwm2m: add uCIFI LPWAN object
Add support for Low Power Wide Area Network (LPWAN) Object (ID 3412)

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2022-12-14 09:51:38 +01:00
Veijo Pesonen f467410088 net: lwm2m: shell - allow leading slash
Paths should start from root.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-11-11 08:49:25 +00:00
Ryan Erickson 12b4187092 lwm2m: swmgmt: fix observations not working for resources
The pointers to resource values should not be used
directly to update the values.
This will break observations if the server is trying to
observe changes during a software update.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2022-11-10 09:27:54 +01:00
Juha Heiskanen efa75b5a76 net: lwm2m: Send operation registry lock update
Secured Message allocation, init and rebuild process for secure
timeseries ring buffer.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-11-04 09:59:51 +01:00
Juha Heiskanen 05a92f9258 net: lwm2m: Timeseries data cache read update
Added support for handle case when all data is not possible to
add in 1 message for Send and Observed Notification.

Notification continuous pending timeseries data is triggred
by iMIN attribute.

Send Operation generate continuous message in multiple lwm2m
message.

Normal Read by server only report back latest stored data.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-11-04 09:59:51 +01:00
Tommi Kangas 75b5eaac0f net: lwm2m: fix hanging deregistration
Fixed a deadlock in deregistration by moving mutex unlocking.

Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
2022-11-04 08:56:05 +00:00
Christoph Schnetzler 0dd14404e1 net: lwm2m: Prevent wundef warnings
If -Werror is used compilation fails due to wundef warning.

Signed-off-by: Christoph Schnetzler <christoph.schnetzler@husqvarnagroup.com>
2022-10-28 22:06:09 +09:00
Veijo Pesonen 8c68e01e55 doc: lwm2m: LwM2M Shell
Describes a possible scenario where to use the LwM2M shell
and how to enable it.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-10-27 11:05:05 +02:00
Juha Heiskanen a66970a6b8 net: lwm2m: Fix connection resume without DTLS
LwM2M connection resume was missing socket connection when
DTLS is disabled.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-27 11:00:46 +02:00
Marc Lasch df68307121 net: lwm2m: Rename timer object instance create function
Rename timer object instance create funciton `timer_create` to fix a
name collision regression with a POSIX function in `timer.h`. The issue
was introduced with commit 73a637eda0 when
first including`timer.h` into `lwm2ms.h`.

Signed-off-by: Marc Lasch <mlasch@mailbox.org>
2022-10-26 12:01:27 +02:00
Tommi Kangas c3ad5efa19 net: lwm2m: use zsock_ functions
Use Zephyr internal zsock_ calls to remove dependency
to NET_SOCKETS_POSIX_NAMES.

Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
2022-10-26 12:01:14 +02:00
Robert Lubos caab8cb1b3 net: lwm2m: Don't assume time_t data type size
sizeof(time_t) can vary depending on architecture/libc being in use,
therefore LwM2M should not assume time_t data type size. Instead of
using magic numbers, use a proper sizeof.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-24 16:13:40 +03:00
Juha Heiskanen 4bcc880670 net: lwm2m: LwM2M engine time API update
Updated lwm2m_enigen_set/get_time API for support time_t.

Updated LwM2M engine set/get resource time to time resource support
time_t and uint32_t input.

LwM2M engine put and get time API update to use time_t.

Time series data cache entry have own type for time resource.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-24 10:39:03 +02:00
Juha Heiskanen e1e2228e9c net: lwm2m: LwM2M object time resource update
Updated Timestamp resource default buffer type to time_t.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-24 10:39:03 +02:00
Øyvind Rønningstad 1e88e7cc9b lwm2m_senml_cbor.patch: Update patch file to match current changes
File created by commiting changes and running

  git diff HEAD~1.. > lwm2m_senml_cbor.patch

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Øyvind Rønningstad 8b295bc58c lwm2m_senml: Regenerate cbor code using zcbor
Also do clang-format and apply patch.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Øyvind Rønningstad 7b05569d49 lwm2m_senml_cbor_regenerate.sh: Fix argument order in zcbor call
zcbor 0.6.0 has changed the argument order to put code/convert/validate
first.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Øyvind Rønningstad f8d0c8a43f lwm2m_senml_cbor_regenerate.sh: Use git am instead of git apply
Since it's better at resolving conflicts.
Commit regenerated files before applying patch.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-10-19 16:04:56 +02:00
Veijo Pesonen 33453e1135 lwm2m: fails if incorrect registration reply
No need to proceed if registration reply parsing fails.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-10-17 20:06:32 +02:00
Peter Tönz 46a59124dc net: lwm2m: Fix seg-faults if a socket was closed in the meantime
Our application (posix-naive/debug) ran into segmentaion faults,
because the socket was closed between the "wait for sockets" and the
second if in the first loop. Added the check also to line 690
and 720.
The other uses of sock_ctx[i] are already checked against NULL

Signed-off-by: Peter Tönz <peter.tonz@husqvarnagroup.com>
2022-10-12 18:42:41 +02:00
Christopher Friedt dbe2c0d59e include: net: http: rename http_x.h http/x.h
Some minor housekeeping prior to adding an http server
implementation. There are already a number of http headers
and that number will likely increase with subsequent work.
Moving them into a common directory cleans up the
`include/net` directory a bit.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2022-10-12 09:02:21 -04:00
Peter Tönz a868da8568 net: lwm2m: Fix buffer overflow by using CONFIG_LWM2M_VERSION_1_0
By using CONFIG_LWM2M_VERSION_1_0, the function
lwm2m_engine_get_binding() returns the binding
and the queue mode bytes. Therefore the buffer
must be tree bytes long.
The issue is caused by the two inconsistent defines:

lwm2m_registry.c:
    #define BINDING_OPT_MAX_LEN 3 /* "UQ" */
lwm2m_rd_client.c:
    #define CLIENT_BINDING_LEN sizeof("U")

Signed-off-by: Peter Tönz <peter.tonz@husqvarnagroup.com>
2022-10-12 18:45:50 +09:00
Seppo Takalo d454cc946e net: lwm2m: Add helper macro for filling lwm2m_obj_path structs
Allows filling up struct lwm2m_obj_path by a macro.
For example:
  struct lwm2m_obj_path p1 = LWM2M_OBJ(MY_OBJ);
  struct lwm2m_obj_path p2 = LWM2M_OBJ(MY_OBJ, 0, RESOURCE);

Similarly, some function calls accept the structure, so it can
be initialized from stack and given by a pointer
  lwm2m_notify_observer_path(&LWM2M_OBJ(obj_id, 0, RESOURCE_ID));

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:14:31 +02:00
Seppo Takalo 65c084f9e5 net: lwm2m: Don't close the socket context on callbacks
I need to register a service for the pull-context so I can
safely close the socket context. Otherwise the socket loop
would crash, because context would be closed while going through
the list where it was located.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo d49219aede net: lwm2m: Block on semaphose waiting
Minor change, the semaphore is freed by a caller so it was always
free, but just for being correct, it should be a blocking call,
so any errors would clearly block.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo b72fde1f54 net: lwm2m: Remove second layer or rettrying from pull handler
CoAP layer handles retrying so having a second layer of retry
in the pull-context does not make sense. If we need more retrying
it should be done in CoAP layer.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo 4ec698004c net: lwm2m: Set FOTA state correctly on URI write
When URI is written, we must first set the state to DOWNLOADING
so when any error happens on the initialization phase, the
result written on a callbacks are correctly reflected and the state
changes correctly IDLE -> DOWNLOADING -> IDLE (result written).

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:13:56 +02:00
Seppo Takalo 99ebcefc71 net: lib: lwm2m: Add shell commands for lock and unlock
Allowing locking the registry from commandline allows
us to test composite observation and observation of
object instances, etc. where multiple values are changed
before the notify message triggers.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-10-11 11:12:20 +02:00
Juha Ylinen c8a409d7d3 net: lwm2m: Use const data pointers in lwm2m_engine_set functions
lwm2m_engine_set functions use void data pointers. Change those to
to const void

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2022-10-07 16:43:51 +00:00
Juha Heiskanen 8e1ade2663 net: lwm2m: Fixed cached readtime
Added missing typecast for time read.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-05 14:23:32 +00:00
Juha Heiskanen 17b60d0fce net: lwm2m: LwM2M engine send operation update.
Added mutex lock for message build operation.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-05 14:23:32 +00:00
Juha Heiskanen 87dc170fed net: lwm2m: SenML-JSON support for Historical data
Extend SenML-JSON content format for handle cached data
timestamp API for basetime and timestamp label's.

Added support for write historical data for static resource
size's: Float (v) and Boolean (vb).

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-05 14:23:32 +00:00
Juha Heiskanen 60d9948b67 net: lwm2m: SenML-CBOR Encoder and CDDL update
Added support for historical data encode by adding base time (bt)
and time (t) label. New labels are needed for Encoder so Decoder
is not regenerated.

Added support for SenML-CBOR to write time series data.
Use "bt" base time and "t" timestamp labels for data cache.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-05 14:23:32 +00:00
Juha Heiskanen 73a637eda0 net: lwm2m: Historical data cache API update
New API for enable Historical data storage for LwM2M resource.
Data cache is only supported at resource which resource size is
static and well known.

Extend output writer for write cached data timestamp.

Enable cache support for Resource set and Read operation.

Added possibility for for drop latest or oldest data from cache.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-05 14:23:32 +00:00
Juha Heiskanen 8c2f5d3296 net: lwm2m: RD Client bootstrap trigger update
Accept now from bootstrap trigger from any state expect ongoing
bootstrap process.
Free also possible on going RD client message. There was a chance
that update message response change state and bootstrap proces
not started.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-03 10:20:13 +02:00
Juha Heiskanen 7cee4cf80c net: lwm2m: LwM2M RD client message allocate update
Updated message handler that it free possible old allocated
message. Added message free also to RD stop and idle state.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-03 10:20:13 +02:00
Juha Heiskanen 8279489aee net: lwm2m: RD Client update registration timeout
Renamed LWM2M_RD_CLIENT_EVENT_REG_UPDATE_FAILURE to
LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT.

Changed reported event type for registration timeout to
LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT from
LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE.
LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE should be only
reported case when server reject by response registration.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-10-03 10:20:13 +02:00
Juha Heiskanen b559bd818c net: lwm2m: Fix LwM2M pause and resume
Fixed unstable thread state read for detetect engine thread
state.
Fixed engine missing socket conrext add.
lwm2m resume now do update also from network error state

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-09-26 15:17:37 +00:00
Juha Heiskanen 8364715998 net: lwm2m: Fix LwM2M resume from Update registration state
If LwM2M engine was paused at ENGINE_UPDATE_SENT it was not
able to resume lwm2m engine properly. There was also missing
RD client Pending message free which could also affect a issue.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-09-26 10:55:03 +00:00
Juha Heiskanen c9c8c467b5 net: lwm2m: LwM2M rd client Update registration Timeout fix
RD client was not closing socket socket when Update registration
timeout. It fail new connection open. There is added a flag for
detect a case when Registration state need to be re-open a socket
for new connection.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-09-26 10:55:03 +00:00
Henrico Brom bde8c6d24f net: lwm2m: Fixed missing _CONFIG prefix
Fixed missing '_CONFIG' prefix when enabling
LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT_MULTIPLE and
CONFIG_LWM2M_FIRMWARE_UPDATE_OBJ_INSTANCE_COUNT through prj.conf

Signed-off-by: Henrico Brom <henrico.brom@vention.nl>
2022-09-21 08:56:58 +00:00
Jarno Lämsä 05b17356e2 net: lib: lwm2m: Fix lwm2m exec
The lwm2m exec erroneously checked the previous return value
instead of checking if the resource existed. This caused exec
to try to get and execute the execute callback from NULL and caused
a reboot.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2022-09-19 10:33:04 +00:00
Ola Tangen Kulseng 1df3de4e98 net: lwm2m: API for multiple resource writing
Used the registry lock in the functions lwm2m_registry_lock() and
lwm2m_registry_unlock() to make the registry lockable through a public
API. If writing to multiple resources that are composite-observed,
locking will halt the main thread until every resource is written to,
ensuring that only one notify message will be sent. Updated
the documentation in lwm2m to include this addition.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-09-12 10:52:18 +00:00
Ola Tangen Kulseng 00aa80bb8c net: lwm2m: thread safety in the rd client
Used the mutex in the client to protect the state transitions of
client.state.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-08-31 10:42:02 +02:00
Ola Tangen Kulseng 0a87c2d0d0 net: lwm2m: Thread safe lwm2m registry
Created the mutex registry_lock to:
- protect read and write operations
- protect the registry.
Only partially finished as the functions like lwm2m_engine_get_obj
warrants a larger refactoring to completely thread safe the registry.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-08-31 10:42:02 +02:00
Juha Heiskanen 534c7f2246 net: lwm2m: Fixed LwM2M message wrong error response
LwM2M was not reported properly case when message "Accept"
coap option was not not supported. In that case LwM2M transport
specification define 4.06 "Not Accepted"

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-31 10:41:49 +02:00
Ola Tangen Kulseng 24a84ae743 net: lwm2m: Documentation of the lwm2m engine
I've provided documentation for the API's
- lwm2m_registry.h
- lwm2m_engine.h

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-08-30 14:19:05 +00:00
Veijo Pesonen 862cabc48c net: lwm2m: Fixes FOTA update result code
The update result is supposed to indicate success only after a firmware
update has been applied. The bug here was that the success was reported
already when the update image download was done.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-08-29 11:38:53 +02:00
Juha Heiskanen b0c794305c net: lwm2m: Fix to Queue update process triggering
Fix that broken Queue client for stop looping
"ENGINE_REGISTRATION_DONE_RX_OFF" state.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-18 10:19:11 +02:00
Juha Heiskanen cec0ea0dce net: lwm2m: Fix Update registration issue
Client Registration update process may be reject by server
and this commit fix a case that it will jump to new state
which send registration message. Earlier RD client try
allocate message before only possible one was released.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-11 12:16:56 +02:00
Juha Heiskanen 6bfebe5fc3 net: lwm2m: Fix Queued data buffer send at wakeup from idle
Queue mode without TLS cache was loosing buffered messages at
wake-up process from idle state. Now client context linked list
are initialized at rd client start process only 1 time.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-11 12:16:56 +02:00
Seppo Takalo eafc4f875b net: lwm2m: Allow string and opaque data types to be empty
When string and opaque types are uninitialized, we should
allow their data length to be zero. However, most content
formatters seem to calculate the string length separately
so replace the pointer of empty data into a static string
that is guaranteed to be empty.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-08-08 11:27:16 +02:00
Andreas Chmielewski 7532a23dc9 net: lwm2m: Try to reuse registration in case of a network error
For most of the times it is not necessary to do a full registration
once a connection is established after a network error. This is in
particular not needed if lifetime is not yet expired and the server
does not refuse a registration update.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2022-08-08 06:55:49 +01:00
Andreas Chmielewski 74a56b05a9 net: lwm2m: separate closing context from closing socket
Separate closing lwm2m context from closing socket. This patch is required
for the rd client to take more control over lwm2m context and the socket.
The goal is to close the socket and to keep the lwm2m context if this is
needed.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2022-08-08 06:55:49 +01:00
Andreas Chmielewski 3cdff65eb0 net: lwm2m: Update registration only in good path
Registration should only be updated if update of the registration was
succesful.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2022-08-08 06:55:49 +01:00
Juha Heiskanen ca20462bcc net: lwm2m: Shell helper for pause and resume
Helper commit for test pause and resume.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-04 13:42:55 +02:00
Juha Heiskanen ed5f3cdf06 net: lwm2m: LwM2M Pause and resume support
New API for suspend and resume LwM2M engine.
New event LWM2M_RD_CLIENT_EVENT_ENGINE_SUSPENDED for indicate
application that engine is suspended.

Simplify stack suspend and resume state same time for queue mode.

New CONFIG_LWM2M_RD_CLIENT_SUSPEND_SOCKET_AT_IDLE for enable skip socket
close at RX_OFF_IDDLE state that socket is only suspended and close is
called only when connection is resumed.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-08-04 13:42:55 +02:00
Veijo Pesonen 0b57ba8dcb net: lwm2m: remove EXPERIMENTAL-label from v1.1
Version 1.1 support is not experimental anymore.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-08-03 11:20:50 +02:00
Seppo Takalo c3302d5f41 net: lwm2m: Allow observing of object instances and objects
Code was limiting observations to resources and
resource instances without any reason.
Also if resource is written, and the whole object is observer
it should trigger. Path does not have to be matching on the
same level, if parent is observed.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-08-01 18:12:33 +01:00
Seppo Takalo b10f2c13ed net: lwm2m: Remove two useless macros
These two macros just change the name of function call
* NOTIFY_OBSERVER
* NOTIFY_OBSERVER_PATH

I don't see any benefit of those, so I dropped them.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-07-26 23:23:34 +00:00
Ola Tangen Kulseng 1563d4a0c3 net: lwm2m: Default ssid
Created the variable CONFIG_LWM2M_SERVER_DEFAULT_SSID to be
the default ssid when not using bootstrap. Needed for access control.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-07-15 10:10:16 +02:00
Ola Tangen Kulseng e05bcefedb net: lwm2m: Access control object
Implementation of the access control object. Core object (obj_id 2).
If used without bootstrap, the default value in
CONFIG_LWM2M_SERVER_DEFAULT_SSID will be used as access control owner.
Enable/disable ac control with CONFIG_LWM2M_ACCESS_CONTROL_ENABLE.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-07-15 10:10:16 +02:00
romain pelletant 3908b9dc74 net: lwm2m: Add Event Log object
Event Log object (ID:20) from OMA LwM2M support added

Signed-off-by: romain pelletant <romainp@kickmaker.net>
2022-07-13 10:19:26 +02:00
Kiril Petrov a4557a46b8 net: lwm2m: Pass client_ctx to observe callback
In case LWM2M cient wants to change attrs of observed obj,
it needs pointer to client_ctx.

For example:
On observer add, wants to change pmin for some obj path to 1s:

static void observe_cb(enum lwm2m_observe_event event,
		struct lwm2m_obj_path *path, void *user_data)
{
	struct lwm2m_ctx *ctx = (struct lwm2m_ctx *) user_data;

	switch (event) {
	case LWM2M_OBSERVE_EVENT_OBSERVER_ADDED:
		lwm2m_engine_update_observer_min_period(ctx, "3347", 1);
	...
}

Signed-off-by: Kiril Petrov <retfie@gmail.com>
2022-07-11 09:32:18 +00:00
Simen S. Røstad 92eb309918 net: lib: lwm2m: Give Kconfig choices symbol names
Give Kconfig choices symbols names so that they can be redefined in
applications that wants to alter the choice's default value without
setting it in the project configuration.

Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
2022-07-11 11:03:41 +02:00
Anas Nashif 0aefa654da net: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
Juha Heiskanen d4bf2ad6cc net: lwm2m: Fix socket offload and native TLS conflict
Removed auto select from LWM2M_DTLS_SUPPORT
* TLS_CREDENTIALS
* NET_SOCKETS_SOCKOPT_TLS
* NET_SOCKETS_ENABLE_DTLS

LwM2M stack shouldn't enforce these options as they
are not needed with socket offloading.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-07-06 11:28:19 +02:00
Andreas Chmielewski 363e2f3014 net: coap: make coap vars configurable
COAP_DEFAULT_MAX_RETRANSMIT and COAP_DEFAULT_ACK_RANDOM_FACTOR
should be configurable to determine the max transmission
timeout of a CoAP packet.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
2022-07-05 21:56:34 +00:00