Convert all canbus related API/samples/tests/subsys
to the new timeout API with k_timeout_t.
Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
If we have removed first net_buf, then we must not restore the
original cursor as that will point to wrong head net_buf.
Add also unit test to check that the packets are removed
properly.
Clarify the documentation that we are removing data from
beginning of the function, also document that the cursor
is reset after this call.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Replace:
DT_FLASH_ERASE_BLOCK_SIZE ->
DT_PROP(DT_CHOSEN(zephyr_flash), erase_block_size)
DT_FLASH_WRITE_BLOCK_SIZE ->
DT_PROP(DT_CHOSEN(zephyr_flash), write_block_size)
As this allows us to phase out the old generator.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Adding RFC1350 compliant support for TFTP Client in Zephyr. The
current implementation is minimal and only supports the ability
to get a file from the server.
Things for the future include support for putting files to
server and adding support for RFC2347.
Signed-off-by: Bilal Wasim <bilalwasim676@gmail.com>
In order to avoid retransmissions from the peer's side
on full-close, handle states properly.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
If net_pkt_pull() would cause an empty net_buf, then unref
those empty buffers from the list.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
So far socket errors reported by poll/recvfrom were ignored, which could
lead to an unexpected behavior when socket was left in an undefined
state.
Fix this, by requesting a re-registration in the LWM2M state machine,
which will close the faulty socket and open a new one. Note, that simply
closing and re-opening a socket in the lwm2m engine would not work,
since this would silently invalidate any open observations on the
lwm2m server side (due to port number change). Triggering a fresh
registration will notify the server to update its observations.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
SNTP implementation defined symbols like "MODE_MASK", which can easily
conflict with similary laxly defined symbols in other modules, and
indeed, we hit a case like that (below). So, prefix these symbols
consistently with "SNTP_", until more clear private namespacing
convention are made pervasive in Zephyr.
subsys/net/lib/sntp/sntp_pkt.h:14: error: "MODE_MASK" redefined
include/arch/arm/aarch32/cortex_a_r/cpu.h:17: note: this is the
location of the previous definition
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
On OT network with poor coverage, very often request/observe packets
doesn't get it's ACK and consumes from pendings/replies/message stacks.
In such cases when LWM2M engine tries to recover by resetting its state,
it fails because of lack of free messages.
Signed-off-by: Kiril Petrov <retfie@gmail.com>
In networks with high latencies (like NB-IoT), it's quite common to
recieve duplicated response. It's not an error condition, a correct way
to handle it is to simply ignore the duplicate. Lower the log level for
this event, not to disturb users.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The retaransmission logic was not correct in the lwm2m_engine, and could
lead to faulty behavior in case multiple messages were pending for
retransmission in the queue.
1. Since there is a singe delayed work item for entire retransmission
queue, `coap_pending_next_to_expire` should be called before
scheduling next timeout, to identify which message is going to expire
next (and when). Currently, the engine always set next timeout, based
on timeout from the message being currently re-transmitted.
2. In case the message was re-transmitted several times, and is removed
from the retansmission queue due to a timeout, next retransmission
should be scheduled, in case there are other messages on the queue.
3. Verify the timeout of the earliest message to expire in the
retransmission handler. In case messages from the beginning of the
queue were removed, we might need to schedule the retransmission
again, instead of sending message rightaway.
4. `lwm2m_send_message` is not handling retransmissions anyway, so
there's no need to check send attempts. Instead, verify
retransmission work item is already pending, and update its timeout
if needed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
So far, coap_pending structure kept track only of the timeout interval
between two consecutive retransmissions. Calculations inside
`coap_pending_next_to_expire` relied only on this value. This approach
gives incorrect results though, in case multiple messages are pending
for retransmission.
For instance, assuming initial retransmission timeout is set to 2
seconds. If some message had been retransmitted already, its timeout
would be increased to 4 seconds. Any new message added to the pending
list would have a retransmission timeout set to 2 seconds, and will be
returned as a first message to expire, no matter how long the initial
message was already on the list.
To resolve this, add a `t0` field to the coap_pending structure. This
field is initialized to the initial transmission time, and is increased
on each retransmission by the retransmission timeout.
`coap_pending_next_to_expire` uses this value to calculate absolute
time, when the next retransmission should take place, and based on this
information returns correctly first pending message to expire.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Replace DT_FLASH_DEV_NAME with DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL.
We now set zephyr,flash-controller in the chosen node of the device
tree to the flash controller device.
NOTE: For a SoCs with on die flash, this points to the controller and
not the 'soc-nv-flash' node. Typically the controller is the
parent of the 'soc-nv-flash' node).
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit renames the Kconfig `FLOAT` symbol to `FPU`, since this
symbol only indicates that the hardware Floating Point Unit (FPU) is
used and does not imply and/or indicate the general availability of
toolchain-level floating point support (i.e. this symbol is not
selected when building for an FPU-less platform that supports floating
point operations through the toolchain-provided software floating point
library).
Moreover, given that the symbol that indicates the availability of FPU
is named `CPU_HAS_FPU`, it only makes sense to use "FPU" in the name of
the symbol that enables the FPU.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
In order to fix the line tracking of the TCP packet allocation
with the test protocol enabled, refactor tcp_pkt_alloc(),
so the line of the allocation can be tracked properly.
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
The LwM2M stack would previously ignore all OPAQUE resources when
reading them. This meant that it was impossible to read them, even if
there was a custom read callback.
Signed-off-by: Göran Weinholt <goran.weinholt@endian.se>
Some services like DHCHPv4 directly send raw packets to the iface.
This causes issue when the iface does not implement l2, e.g.
because it is a socket offload interface. fix that.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Make sure we only parse the received TCP options only once. Store
the options to tcp conn struct for later use.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This patch fixes an issue with TCP options reading. Previous approach
was accessing the options with pointers (th + 1). This does not work if
TCP options span multiple net_pkt buffer fragments. Instead net_pkt
functions must be used.
Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
During registration, first thing LWM2M does is trying to close a socket
indicated by sock_fd stored in its context. In case it is not
initialized to some invalid value (-1 in this case), LWM2M may close an
ambigous socket.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In order to avoid retransmissions from the peer's side
on active connection close, acknowledge the incoming FIN+ACK
in FIN_WAIT_1 state.
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
We cannot directly use the local address in net_context when
registering the connection as it is not proper type. So create
temp address variable for that purposes.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Avoid dynamic allocations and all the issues if we run out of
memory, by placing the connection endpoint directly to TCP
connection struct.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Bug fix and improved `payload` handling in `http_client_req`.
Changes to `http_client_req` behaviour:
If the user provides `payload_len` it is used to generate the
`Content-Length` header. This is done even if `payload_cb` is used to
provide the actual data. If no `payload_len` is specified then no
`Content-Length` is generated.
If `payload_cb` is provided it is called to send the payload data.
Otherwise `payload` is used as the payload buffer and sent. If
`payload_len` is not zero, it is used as the size of `payload`.
Otherwise `payload` is assumed to be a string and `strlen` is used to
determine its size. This is to maintain current behaviour and not break
existing samples.
Fixes#24431
Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
In tcp_endpoint_cmd() we allocate and then almost immediately
destroy the allocated endpoint. This is quite inefficient so
use a endpoint from stack in the compare.
Separate endpoint allocation from value setting so the caller
can decide how the endpoint union values are set.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Cell ID resource was not initialized properly in the Connectivity
Monitoring object, making it unusable from the application.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Some other part of Zephyr has similar defines (SRC)
causing build failures.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Assigning the allocated IPv4 endpoint as struct sockaddr
leads to the memory overwrite, assign the correct structure,
i.e. struct sockaddr_in.
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
There was no way to use Openthread CoAP api in zephyr application so
far. These changes enable the feature. Now you can fully use CoAP
communication in an application working in Thread network.
Signed-off-by: Lukasz Maciejonczyk <Lukasz.Maciejonczyk@nordicsemi.no>
Set information about Frame Pending Bit from the ACK response in the
frame passed to OpenThread.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In order to implement active connection close with the
TIME_WAIT state, send FIN and enter FIN_WAIT_1 state.
We actually send FIN+ACK as most of the implementations do.
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
In order to support TIME_WAIT state during the TCP connection
termination, add a TIME_WAIT timer and the corresponding state.
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
In order to improve readability, rename TCP_FIN_WAIT
states into TCP_FIN_WAIT_1, TCP_FIN_WAIT_2.
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
Replace CONFIG_ENTROPY_NAME with DT_CHOSEN_ZEPHYR_ENTROPY_LABEL. We now
set zephyr,entropy in the chosen node of the device tree to the entropy
device.
This allows us to remove CONFIG_ENTROPY_NAME from dts_fixup.h. Also
remove any other stale ENTROPY related defines in dts_fixup.h files.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Fill the mTimestamp filed in OpenThread frame based on the net_pkt
timestamp value (only if NET_PKT_TIMESTAMP is enabled).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>