LwM2M SEND functionality is defined in LwM2M v1.1
So quard the condition with protocol version, not
server object version.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Add name to choice symbol, so that default value can be changed
downstream.
Developed-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
- Remove the `strlen`, as it is unnecessary for safe copying.
- Limit the `strncpy` to `sizeof(fsm->terminate_reason) - 1`
to ensure the last byte is reserved for null-termination.
- Add an explicit null terminator to guarantee correct string termination.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Cloning a packet for a capture may fail due to insufficient memory.
In such a case, the networking statistics should be updated
to reflect this processing error. This commit updates the processing
error count on the capture tunnel network interface because this is
the interface that the captured packet would have been assigned to.
Signed-off-by: Tom Finet <tomfinet@outlook.com>
Refactor (1 << xyz) to use the BIT(xyz) macro.
The change aims to enhance code readability.
Signed-off-by: Muhammad Haziq <muhammad.haziq@zintechnologies.com>
http1_headers_sent flag has to be cleared when entering
HTTP_SERVER_REQUEST_STATE and not only on the client init. Otherwise,
serving multiple HTTP1 POST requests over the same connection does not
work as intended (headers were not sent for the second and further
requests).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Introduce `wifi_utils_get_next_chan_6g` to get the next
valid Wi-Fi 6GHz channel.
This commit addresses the proper handling of cases when
`chan_start` is not 1.
Fix#74063
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Enhancing code consistency provides cognitive leverage with
the following changes:
- Unified the order of declaration for `opt`, `opt_index`,
`state`, and `long_options`.
- Unified the wrapping of `getopt_long` calls, regardless of
the length of the `options` string.
- Renamed `option_index` to `opt_index` for consistency.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Using `getopt_state` to access `optarg` and also `optopt` offers
a better alternative to direct global access.
See e145eb9201 for the previous change related to this.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
This change marks the remaining instance of the `struct option` as
`static const`.
The rationale is that `struct option` is a read-only variable.
By using `static const`, we ensure immutability, leading to usage of only
the `.rodata` section and a reduction in the `.data` area.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Various manual code formatting adjustments, including:
- Wrapping lines in the `long_options` declaration to prevent them
from extending too far to the right.
- Adding missing `{` and `}` in the `if` statement in
`cmd_wifi_set_rts_threshold`.
- Aligning `SHELL_CMD_ARG` in `wifi_commands` with previous declarations.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
SenML is technically a JSON based format which can
be encoded as a CBOR. SenML-CBOR specification in
RFC 8428 section 6 states that numbers can be decoded
as an integer.
Also RFC 7049 section 4.2 states that JSON numbers
without fractional part can be decoded as an integer.
I have seen with one commercial LwM2M platform that
the decoder they use, sends floating point values as
integers, if there is no fractional part.
So LwM2M engine cannot assume from the path that
the incomming number is either float or int. Accept both.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This commit moves reading nexthop's LL address only if it's supported
by a given neighbor and can be used for routing between interfaces.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
Current PHY rate
It represents the current PHY rate of transfer
of data in bits per second. It will a TX data rate.
Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
Over run count
It represents the number of packets dropped either at
received and sent due to lack of buffer memory to retain
all packets on the network interface.
Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
This commit fixes an issue where deprecated IPv6 addresses were not
being correctly marked. In some cases, deprecated addresses might have
been used as source addresses.
Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
On a successful update we should reset the retry counter, similarly
like we do on successful registration.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When socket errors call sm_handle_timeout_state() we might be
in a state where application assumes we are in registered state
but we are dropping it.
Therefore we must ensure that all registration states emit either
REGISTRATION_TIMEOUT event for application to indicate that
we have lost the connection to server.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Revise data type declarations to avoid implicit/explicit casts:
- Changed `unsigned char` to `uint8_t` for `zeros` array
to match with `longest`.
- Declared variables `i`, `j`, and `pos` as `int` to use the same type.
- Cast `value` to `uint16_t` instead of `uint32_t` since
`value` is `uint16_t`.
- Moved `bh` and `bl` declarations to narrow the scope of variables.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Simplify high and low byte conversion by removing redundant checks,
since `net_byte_to_hex` already takes care of zero padding.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Replace the loop with direct high and low nibble extraction,
and ensure the padding and zero suppression logic is simplified.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Some offloaded ifaces have an L2, but lack support for
net_l2->send. This edge case is not handled by
net_if_send_data, resulting in a NULL dereference under
rare circumstances.
This patch expands the offloaded iface guard in
net_if_send_data to handle this edge case.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Fixes issues with net_ptp_time arithmetic where second
overflow/underflow would not be handled properly.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Offset should be *subtracted* from current clock value, not added.
This was causing clock to accumulate error instead of actually
"converging".
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
For 2.4GHz and 6GHz bands, while counting the channels in configured
range, start of the range is being counted twice. Correct this
by advancing the index by 1 while counting channels in range.
Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
Parse the more flag in coap_get_block2_option(), so that the function
can be used not only with requests but also with replies (where the more
flag should not be ignored).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The block number in block1/2 options can be encoded on up to 20 bits
according to RFC 7959, therefore the underlying type used in helper
functions to retrieve the block number should be large enough to hold
the result. Therefore, replace the container for block number with
uint32_t instead of uint8_t.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This is related to change in commit dacb3dbfeb
("iterable_sections: move to specific header")
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When LwM2M engine is requested to stop,
emit the disconnected event unconditionally.
There is really no reason to skip the event
on network error, or if we have never been registered.
Fixes#76422
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Allow an application to add a Block2 option to an initial request for a
resource. For any subsequent requests as part of a blockwise transfer,
drop the application-added Block2 option since the coap_client must
append a Block2 option with updated NUM and SZX fields based on the
server response.
Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
Improve buffer handling logic to use local variables extensively.
This change reduces the number of pointer dereferences, which leads
to more efficient runtime and helps reduce the code size.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Improve buffer handling logic to use local variables extensively.
This change reduces the number of pointer dereferences, which leads
to more efficient runtime and helps reduce the code size.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Windows TCP stack has a peculiar behavior - when running iperf, it will
fill out the RX window almost entirely, but will not set PSH flag on
packets. In result, our stack would delay the ACK and thus window
update, affecting throughputs heavily.
In order to avoid that, keep track of the most recent window size
reported to the peer, and reduce it when receiving new data. In case the
RX window, as seen from the peer perspective, drops below certain
threshold, and the real RX window is currently empty, send an ACK
immediately when updating window, so that peer can continue
with sending data.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If IPv6 is not enabled for a given network interface, then there
is no need to try to join IPv6 multicast groups as it will just
cause an error print which is pointless in this case.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
While routing between interfaces source Link-Local L2 address is set
for a packet. However, it should not be done for some of the interfaces.
This commit adds helper function to check this condition in runtime.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
When packet is routed between interfaces new routing entry is added
to the table. This should not be done for interfaces that do not
support Neighbor Discovery protocol as they are not keep potential
neighbors in the common table.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
adds filesystem as a resource for the http_server which serves static
(gzipped) files from a filesystem to the client.
Signed-off-by: Gerhard Jörges <joerges@metratec.com>
The Association permit bit shall be set to zero if the coordinator does
not accept association requests.
Not accepting association request ist not a reason to filter the
beacons from this coordinator during network scan. It is still a
network, just one you cannot associate with.
Signed-off-by: Fabian Pflug <fabian.pflug@grandcentrix.net>
Limit the coap payload size passed up to the application callback to the
block size, when a block transfer is in progress and the current payload
is not the final block.
If the current payload is not part of a block transfer, or is the final
block of a transfer, then the full payload can be passed to the
application to avoid having to make another request over the network for
data that has already been received.
This avoids a problem raised in issue #76089, where a payload longer
than CONFIG_COAP_CLIENT_MESSAGE_SIZE causes the same data to be passed
to the application callback twice (once in the large packet, and once in
the next block which must have an offset that is a multiple of the block
size).
Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
Use the MSG_TRUNC flag to check the total length of UDP packets
receieved by the coap_client, and hence check if the receive buffer
contains the whole message, or if it is truncated.
If the message is truncated, then use a blockwise transfer to fetch the
rest of the data.
This is related to issue #76089.
Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
Due to the introduction of `shell_xxx_impl` wrapper functions in
PR #75340, we can minimize caller overhead by eliminating direct
`color` parameter passing.
This is achieved by using `shell_print_impl`, `shell_error_impl`,
`shell_info_impl` and `shell_warn_impl` instead of `shell_fprintf`.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>