Add new net_pkt checksum, which indicate checksum status on the packet
(i. e. whether it has already been calculated or not).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This change fixes uninitialized RPA values for advertising sets of
non-default Bluetooth identities. The regression has been introduced
in the following commit:
8d6b206064
The follow-up fix for the default Bluetooth identity has been
introduced in a separate commit:
88c20b9cdd
Non-default Bluetooth identities can be loaded from the Settings
subsystem. In this case, RPAs of related advertising sets to these
identities are left uninitialized as the bt_id_create() function
context is not executed. As a result, the RPA is not created for
advertising sets of non-default Bluetooth identities, and the
advertising is started with the 00:00:00:00:00:00 address.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
On-Demand proxy client API has been changed but
usage of this API in shell test was missed.
Commit fixes this API usage.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The ability to send the solicitation PDU doesn't
depend on GATT Client role.
Commit makes independent one functionality from
another.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Remove unnecessary newline characters from shell_print, it already adds
them. Align the table pipe characters better in the list of modules.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
The memory usage shown in the shell was 0 which is obviously incorrect.
At some point the memory allocation tracking was dropped from llext.c
mistakenly. Add it back.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Rename local usbd copy from nrfx_usbd to nrf_usbd_common and use it in
both USB stacks. Renaming header to nrf_usbd_common.h allows breaking
changes in exposed interface. Mark all doxygen comments as internal
because local usbd copy should not be treated as public interface
because we are under refactoring process that aims to arrive at native
driver and therefore drop nrf_usbd_common in the future.
Use Zephyr constructs directly instead of nrfx glue macros.
No functional changes.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
This new API returns the version string corresponding to a given
HCI version.
The API can be used by applications to print out human-readable
information about the controller being used.
Adding this API removes possible code duplication.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Fix tcp.c compilation if user unsets
CONFIG_NET_TCP_CONGESTION_AVOIDANCE config option.
Fixes#64824
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The enum is mainly to print output of band, so, the default value is 0
which means 2.4GHz, which is not correct when using it to configure like
in connect.
Fix the default value to unknown i.e., no user preference. This way we
can use same enum for both set and get.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Implement testcases for Information Reporting Interface [300-399]:
* LightweightM2M-1.1-int-301 - Observation and Notification of parameter
values
* LightweightM2M-1.1-int-302 - Cancel Observations using Reset
* LightweightM2M-1.1-int-304 - Observe-Composite Operation
* LightweightM2M-1.1-int-306 – Send Operation
* LightweightM2M-1.1-int-307 – Muting Send
* LightweightM2M-1.1-int-308 - Observe-Composite and Creating
Object Instance
* LightweightM2M-1.1-int-309 - Observe-Composite and Deleting
Object Instance
* LightweightM2M-1.1-int-310 - Observe-Composite and modification of
parameter values
* LightweightM2M-1.1-int-311 - Send command
303 and 305 cannot be implemented using Leshan as it only support
passive cancelling of observation.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
If the interface is WiFi one, then print information about it.
Also the device information is useful to know so print device
name corresponding to the network interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit names a couple of choices to allow the default
value to be overridden by Kconfig files out of tree
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
If the server has synchronized to the PA and detected that the BIS is
encrypted, the server writes a value of 0x01 (Broadcast_Code
required) to the BIG_Encryption field of the Broadcast Receive State
characteristic to request a client to provide a Broadcast_Code.
In PTS BASS/SR/CP/BV-14-C test case the PTS (client) expects that the
new value of the Broadcast Receive State characteristicstate will be
notified, so the PTS could sent Set Broadcast_Code operation to the
server.
Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
Fixes failing EBQ test LL/DDI/SCN/BV-88-C Extended Scanning,
Active, Properly Ignore RFU Fields
Several minor modifications made to le_ext_adv_report() to
properly ignore any invalid fields present in the received PDUs
Signed-off-by: Troels Nilsson <trnn@demant.com>
There was a conditional compile misssing for the
BT_PER_ADV_SYNC_TRANSFER_SENDER, potentially leading
to build failures
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Many functions return non-zero return codes on errors. I added an assert
for the case, when a function is expected to fail. It is just a
shorthand for `zassert_not_equal(0, ret);`, analogous to
`zassert_ok`, introduced in c5d85e175f.
I also added the corresponding `zassume_nok` and `zexpect_nok`.
Signed-off-by: Greter Raffael <rgreter@baumer.com>
It declares a variable inside a switch statement without brackets to
properly delimit the scope, making clang barf. This patch adds them.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Adding support for echo option if telnet commands are supported. This is
useful when the telnet client is in character mode. It allows to use the
arrow keys, ctrl-c and more. Something to keep in mind is that when
character mode is turned on by the client, network traffic is
considerably increased as each typed character is sent over the wire.
Note: echo mode is only supported if SHELL_TELNET_SUPPORT_COMMAND is
enabled.
Signed-off-by: David Corbeil <david.corbeil@dynon.com>
Do not include the resource type (rt=) in the registration message when
using the OMA JSON format. This was a workaround specifically for the
Wakaama LwM2M server which is no longer needed since the latest master
branch.
Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
Portfolio object created string buffers for Identity resources
that was overlapping on some cases.
Don't calculate pointers by hand, allow compiler to calculate it.
Fixes#64634
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Extend the previous support of creating object instances by allowing
creation of resource instances as well.
Similarly, add support for deleting.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
The existing driver and sample:
- drivers/bluetooth/hci/rpmsg
- samples/bluetooth/hci_rpmsg
are no longer correctly named, since they now use the IPC subsystem to
send and receive data. The IPC subsystem can use RPMsg as a transport,
but that is one of several selectable backends.
I initially wanted to deprecated both the BT_RPMSG Kconfig option as
well as the zephyr,bt-hci-rpmsg-ipc chosen node in Devicetree. However,
this proved to be undoable in the case of the Kconfig option. This is
because it's a choice option, and those have special behavior. In
particular, the only practical way to deprecate would've been to keep
the old Kconfig option outside the choice (much like it's done in this
commit) but then also add a 'depends on !BT_RPMSG' on each of the
remaining choice symbols *except* on the new BT_HCI_IPC one. This, however,
only works correctly for .conf files. If a board instead sets the
default BT_HCI_BUS_TYPE in the Kconfig.defconfig file then the Kconfig
tree parsing would fail, because it'd try to set it to a value
(BT_RPMSG) that is no longer part of the choice.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The mcumgr SMP UDP configs struct was causing a unique tag name
violation (rule 5.7).
The struct name has been changed from configs to smp_udp_configs.
Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
mcumgr's SMP UDP transport was unnecessarily using a potentially large
amount of ROM space due to static initialising fields in a
config struct that also contains buffers/stacks.
This has been changed to instead initialise fields in the start
function, reducing ROM usage by ~5K in the default configuration
with IPv4 and IPv6 enabled.
Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
Unify spelling of CAN Flexible Data-rate abbreviation to "CAN FD" instead
of "CAN-FD". The former aligns with the CAN in Automation (CiA)
recommendation.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
When logging strings are stripped from the binary prevent
performing check of pointers which requires access to the
string.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
radio_pkt_big_ctrl_get() returns a statically allocated
buffer of type pdu_big_ctrl, but the callers expect a
buffer where a whole PDU for a BIG control packet can fit
(not just space for the payload),
and use it as such, overflowing this statically
allocated buffer, and smashing other variables after.
Let's fix it by allocating a buffer of the correct size
to fit a BIG control PDU.
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/64497
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
With very fast HCI interfaces (for ex. in the simulated nrf5340)
the tx_rate calculation can do a division by 0
(if to packets are enqueued in the same 32KHz clock period).
Let's avoid it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Add the len_max rx structure member to indicate maximum number of bytes
possible to receive. It is needed to send information about our protocol
parameters to host.
Also, limit the maximum size of request/responses for backends that uses
buffers provided by the handler.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
When UART dictionary frontend is used strings can be removed
from the binary.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Add option to remove string literals which are constant and
never touched by the firmware. It can save significant amount
of RO memory.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Enabling the core dump via memory window backend only makes sense on
Intel ADSP platform wtih memory windows enabled.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The DEBUG_COREDUMP_BACKEND_LOGGING option should automatically
select LOG Kconfig instead of just depending on it.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
When no parameters are given to the 'bt' command it prints
the help message. The 'iso' command responds with 'missing
subcommand'. This commit updates the behaviour of the iso
command so that it behaves the same as the bt command, i.e.
prints a help message
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
If user adds IPv6 address to the network interface, check
if the address is a multicast one and add it to multicast
group if it is.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If user adds IPv4 address to the network interface, check
if the address is a multicast one and add it to multicast
group if it is.
Fixes#64389
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Default behaviour should only bind to port independent of IP, this
allows even multicast/broadcast L4 traffic to be received.
User can always specify a specific address to bind using shell or
Kconfig or API.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Using a generic IP for address set failures is confusing, esp. two same
prints (one for v4 and the other for v6), so, use explicit version.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This has several advantages:
1. we don't need any hard assumptions about symbol length. The
current hard-coded limit of 32 characters might well be not true.
2. replaces a lot of code for reading those names with a single
call to a 1-line function to calculate string location.
3. eliminates the need to allocate buffers for exported symbol names
by replacing them with a simple pointer assignment.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Instead of first allocating all sections and then copying then,
create a helper function to allocate and copy a single section and
call it for all appropriate sections. We need to call this function
from another location when copying string sections.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Some compilers (e.g. riscv32) does not handle well complex macros
for logging. Generated code is bigger than expected (e.g. riscv32
code is almost twice bigger than cortex-m code). Use of logging can
lead to unexpected code increase.
To handle that an analysis of the zephyr code base was performed and
it shown that 75-80% of logs are simple strings with 0 arguments
(~45%), one 32 bit argument (~26%) or two 32 bit arguments (~6%).
Given that a set of dedicated macro were created which are applied
to those 3 cases which on 32 bit platform create very simple log
messages without padding or alignment needed.
Such dedicated macros save up to 40% of code (riscv32) and also
executes 30% faster (arm cortex and riscv32).
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Extend frontend API with optional set of functions which can
be used when simplified log message handling is enabled. If this
mode is enabled then there are dedicated macros for processing the
most common messages (string + 0-2 word arguments). Using this API
can speed up the processing of messages that are the most common.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
In preparation for new feature which optimizes handling of
the most common log messages (0-2 32 bit word arguments) add
functions dedicated for that purpose.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
The loop in `coredump_flash_backend_buffer_output` might fail without
any alerts. This could be due to e.g. a too small coredump-partion.
Add a LOG_ERR if an error occurs.
Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
ZLP packet has to be read and acknowledged by host just like any other
DATA packet. Do not end transfer until the host actually acknowledged
the trailing ZLP. This fixes the race condition between host and Zephyr
application where the next transfer could be lost if host did not issue
IN token (that would read read ZLP) before the application tried to
start new transfer.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
If CONFIG_BT_ISO_TEST_PARAMS=y then the CIG and BIG
create params was not properly initialized.
Modified the TX for BIS and CIS to be more similar
Added a timeout on the buffer to avoid any potentional
deadlocks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Moving the Zephyr specific config options from
modules/hostap/Kconfig to corresponding Kconfig where the
option is specified.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When no heap has been configured, osMessageQueueNew() will no
longer include a call to k_calloc() (which needs the heap).
In such a configuration, if osMessageQueueNew() indicates that
the buffer must be allocated, it will fail and return NULL.
Fixes#61196
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
CoAP reply structure user_data should be kept between
ongoing blocks, so that callbacks for LwM2M send continue
to work on blockwise transfers.
Fixes#64290
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Ensures correct packing of net idx in Heartbeat Publication Status
messages on the Configuration Server.
Reference to net idx packing format: MshPRTv1.1 section 4.3.1.1
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Fixes incorrect unpacking of Heartbeat Publication status
messages on the Configuration client.
Reference to packing format: MshPRTv1.1 section 4.3.2.63
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Fixes issue where Heartbeat Publication Status message sends
garbage data when destination field is set to the unassigned address.
MshPRTv1.1, section 4.4.1.2.15:
"When the Destination field is set to the unassigned address, the values
of the CountLog, PeriodLog, TTL, and Features fields shall be set to
0x00 and NetKeyIndex field shall be set to 0x0000."
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Updates Bluetooth mesh specification references:
- Change "Profile" to "Protocol" since the main specification has
changed its name.
- Update/align formating of specification references. This will
make it easier to find spec references in the future.
- Change some section references to point to the correct section of the
newest version of the specification (v1.1).
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
The shell name defined with `SHELL_DEFINE` is implicitly
guaranteed to be unique while it is possible that more than one
shell backends can have the same prompt.
Print the name of the shell backend alongside with its prompt
to differentiate between the backends.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Added some new APIs to get the backend instances more easily,
so that dev does not need to rely on `shell_backend_*_get_ptr`,
which looks more like a hack to access a local variable.
These APIs are basically copied from the log backend
implementation.
Added testcase for the APIs.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Rename the shell backend `thread_name` variable to just `name`,
to be used for other things not specific to thread later.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
When there is no buffer for gcov hex data,
dump them directly to console.
This saves RAM which can be used to hold more gcov data.
Reduce number of gcov hex data send by console -
do not send space between every two digits.
Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
This commit reuses the string "Unknown %s frame type" for two
log messages, as suggested by ycsin.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
This commit resets the state of the CMUX receive state
machine when the CMUX instance is attached to a pipe.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
This commit adds logging for CMUX frames and commands and
their data, for both transmit and receive. It also removes
the superseded LOG_DBG() lines like "Received frame".
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
This commit resets the receive ring buffer for each DLCI
pipe when they are opened. They may have old data stored
from last time they where opened.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
This commit adds a check to the async connect and disconnect
functions to validate the CMUX is not already connected
or disconnected respectively. This was already part of the
sync connect and disconnect functions, so the sync functions
now simply wrap the async functions to avoid duplicate code.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
Fix missing Extended Advertising terminate event and
advertising scheduling not being stopped.
Under race conditions, auxiliary event is aborted without
the generation of done extra event which is suppose to
stop the scheduling when max events count is used.
The fix now generates the done extra event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix periodic advertising sync window calculation to include
the scheduling resolution margin, i.e. be double as with
the event jitter value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The new "net sockets" command will utilize the object core
support to track and show information about BSD sockets that
are created in the system. This command is able to show info
for all network sockets (native, offloaded etc) in the system.
Example of the output of the new command:
uart:~$ net sockets
Creator Name Flags FD Lifetime (ms) Sent Received
main af_inet46 6ST 0 3260 819 498
main af_inet46 4ST 1 2110 469 142
main af_inet46 6DU 2 2110 9941 9941
main af_inet46 4DU 3 2110 1375 621
4 active sockets found.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The writefds is typically set if there is an error while
waiting for example the connect() to finish. So check if
the user supplied the writefds and update it accordingly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If we try to connect to a port which no socket is listening to,
we will get a packet with "ACK | RST" flags set. In this case
the errno should be ECONNREFUSED instead of ETIMEDOUT like we
used to return earlier.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Increase reference count already when initial SYN is sent.
This way the tcp pointer in net_context is fully valid for
the duration of the connection.
Fixes#63952
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
According to conditions in the DFU spec section 6.1.3.7 (Sending a
Firmware Update Status message) and in 'Idempotency' part of section
6.1.3.4 (Receiving a Firmware Update Start message), the FU Server
should not update internal state when 'Wrong Phase' error condition
is triggered.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
In case ping is sent to own address, the request is looped back to the
stack and served before ping work had a chance to reschedule. In result,
when the final ping reply has been server, and ping operation finalized
with `ping_done()`, the work was rescheduled one last time, causing the
ping timeout to be reported. Fix this by rescheduling the work before
sending the actual request, so that the reply handler can cancel the
work properly in such case.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case packet is looped back to the stack, set LL address information
on the packet, using the LL address set on the corresponding network
interface, so that the information can be interpreted by the SOCK_DGRAM
packet socket.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If we run network tests under tests/net, then set the
Dummy network interface as a default one so that it will
be picked up first.
This should solve the issue if the DUT is having a real
network interfaces like onboard Ethernet interface which
could cause the test to fail. The test might fail in this
case because the network tests assume that only simulated
network interfaces are used by the tests.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Compiler can't tell that k_thread_abort() won't return and issues a
warning unless we tell it that control never gets this far.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The remote address of the connection is checked whether
it is v4-mapping-to-v6 address in which case we should
print it such.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When a new incoming connection is accepted, do not overwrite
the listening remote address. The remote address for the
listening socket is the any address (like :: for IPv6)
and not the accepted socket remote address.
This only affects the "net conn" shell command which prints
the remote address incorrectly. There is no problem accepting
new connections in this case.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
We should use the NET_CONN_RANK() macro when printing the
current rank value as that macro masks the rank values properly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The socket address passed in accept() call should point
to the new connection address and not the old one.
Fortunately this only affects things after the v4-mapping-to-v6
support so older code than this works fine.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The address length of the accepted socket must reflect the
size of the address struct, so it should either be
sizeof(struct sockaddr_in) for IPv4 or sizeof(struct sockaddr_in6) for
IPv6 socket.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This allows IPv4 and IPv6 share the same port space.
User can still control the behavior of the v4-mapping-to-v6
by using the IPV6_V6ONLY socket option at runtime.
Currently the IPv4 mapping to IPv6 is turned off by
default, and also the IPV6_V6ONLY is true by default which
means that IPv4 and IPv6 do not share the port space.
Only way to use v4-mapping-to-v6 is to enable the Kconfig
option and turn off the v6only socket option.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add support for IPv4 mapped IPv6 addresses when converting
IP address to a string in inet_ntop() function.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Fix two issues with net tcp command:
* The `net tcp` commands are still based on net_context API. For TCP,
the API caller (net shell) should add one extra reference to the
allocated net context, to prevent premature context release in case of
connection teardown. Currently that was not the case, and the context
was released too early, resulting in missing final ACK from the Zephyr
side on connection close.
* The net context API should not be called from the registered connect
callback, as this creates a temporary deadlock situation. The
net_context_connect() function blocks until the connection is
established, or an error or timeout occurs. For that time the
net_context mutex is being locked. In case of connection error (for
example after receiving RST packet) the connect callback is called,
indicating an error. If we try to call net_context API from within, a
deadlock situation takes place, as the context mutex is still locked
by the net_context_connect() (called from the shell thread). This
blocks the further execution of the TCP stack and can result in an
unexpected behavior (like for example retransmitting the SYN packet,
which takes place from yet another thread, TCP work queue).
Fix this, by releasing the net context not from the callback directly,
but based on the return value from net_context_connect().
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Use IN_RANGE instead of explicitly checking that a value is
in between two other values
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
The BT Core Spec v5.4 allows separate SDU_Interval to
be set on C_To_P and P_To_C directions,
but this is not possible with the existing interface.
This PR splits the interval parameter in the call to
bt_iso_sig_create into one for C_To_P
and one for P_To_C
It also splits the latency parameter into one for
C_To_P and one for P_To_C
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Bluetooth: ISO: update UI for extended API
The API for setting the SDU interval and latency have been updated.
This PR also updates the setting of these by the user in the shell
and the iso_connected_benchmark sample
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Since CRC32 hash/checksum support is enabled by default, make it
select the CRC Kconfig symbol
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Only SMP over console transports need CRC support, therefore do
not imply CRC support for MCUmgr entirely because only 2 optional
transports require it
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
SMP over console uses a checksum, therefore it is required in order
to enable these transports
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
According to the UART API documentation, implementation must block when
the transceiver is full. For CDC ACM UART, TX ringbuffer can be
considered as transceiver buffer/FIFO. Blocking when the USB subsystem
is not ready is considered highly undesirable behavior. Blocking may
also be undesirable when CDC ACM UART is used as a logging backend.
Change the behavior of CDC ACM poll out to:
- Block if the TX ring buffer is full, hw_flow_control property is
enabled, and called from a non-ISR context.
- Do not block if the USB subsystem is not ready, poll out
implementation is called from an ISR context, or hw_flow_control
property is disabled.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
When a usb_transfer is cancelled, the callback is finally invoked.
Silly, there is no transfer status passed, and in the callback we can
only check the size and device status.
Reported-by: Alex Kaiser
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The warning which became error looks like this
error: type qualifiers ignored on function return type
[-Werror=ignored-qualifiers]
219 | const char * const wifi_ps_txt(enum wifi_ps ps_name);
It is pointless to add a const qualifier to a return value.
So remove the const pointer to avoid this warning.
Fixes#64197
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Fixes an issue whereby the erase function would return an unknown
error, which would happen when the slot was already erased.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
When EATT is established, the value returned from `bt_att_get_mtu` is
not useful to determine the ATT_MTU that applies to a ATT response. This
is because `bt_att_get_mtu` may return the value for a different bearer
than the request is serviced on.
To fix this, the params struct for the GATT read operation is given a
new field that will record the ATT_MTU that applies to this ATT
operation. This value is then used to determine if the GATT long read
operation is concluded.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/61741
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The interface number is generated automatically if one
presses <tab> when expecting the interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow multiple commands use the same dynamic shell command
completion when expecting network interface index.
For example "net iface" and "net stats" are such commands.
The network interface expansion cannot be used in "net ipv6 add",
"net ipv4 add" and "net route" commands as they require more
data after the network interface index argument.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The "net stacks" has been obsolete for a long time already
so remove it for good. It is replaced by "kernel stacks" cmd.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This is a preparation for the refactoring. The old "net" command
is renamed "net_old" so that the individual commands can be
placed into a separate .c files.
This is done like this because we need to use the
SHELL_SUBCMD_SET_CREATE() to create the sub-command and then
use the SHELL_SUBCMD_ADD() in the .c files to add the command
into the sub-command and not get conflict with the same name
sub-command.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This is preparation commit that moves the net shell code to
subsys/net/lib/shell directory. The following commits will
then refactor the code in net_shell.c to smaller and more
manageable pieces.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
To enable runninng and testing this backend on the POSIX
architecture, we need to allow defining the shared memory
buffer as a compiler provided symbol, instead of a hard
address provided by the DTS.
For this case we refer to a symbol a POSIX arch implementation
(typically the board) needs to provide.
It is the responsability of that implementation to ensure
that symbol exists and points to a memory buffer of the
DT defined size.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Add sleep prevention in crucial USB-C stack functions to make
state transitions faster and to send responses faster.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
Add internal function that prevents one sleep of the USB-C stack.
It can allow to have longer sleep times to conserve more power, while
still having possibility to respond in the required time and
set specific registers.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
HAS_DTS has become a redundant option. All Zephyr architectures now
select this option, meaning devicetree has become a de-facto
requirement. In fact, if any board does not provide a devicetree
source, the build system uses an empty stub, meaning the devicetree
machinery always runs.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
In llext_copy_symbols the check after llext_read
was looking the result of llext_seek operation instead
of the read.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Do not use timeout for UART callback. The UART IRQ bases on the IDLE
line, so waiting for additional bytes is not necessary and it introduce
additional latency.
Another issue with the timeout is that the UART drivers use sysworkq for
implementing timeout. The sysworkq thread may have lower prio than the
host command thread, which may cause a delay in calling the UART
callback, which gives the semaphore to the HC handler.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
The `BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS` is not expected to generate a
response from the controller, but from the spec:
Normally, no event is generated after the
HCI_Host_Number_Of_Completed_Packets command has completed. However, if
the HCI_Host_Number_Of_Completed_Packets command contains one or more
invalid parameters, the Controller shall return an HCI_Command_Complete
event with a failure status indicating the Invalid HCI Command
Parameters error code.
In practice, this can also be generated if flow control is inadvertedly
turned off during operation. Running `hci_cmd_done` is not correct when
the event happens (as there is no corresponding command buffer), and
`ncmd` should not be returned as this command ignores the semaphore when
sending.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Refactors the implementation of the Opcode Aggregator
models to allow them to coexist on the same device.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Instead of strlen() use sizeof() in FL() macro. This way
all the checks are done at compile time instead of runtime.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Adds a goto statement to ensure that model extensions are registered
in Composition Data Page 1 if it is enabled.
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
This fixes an issue where the DFU client could get stuck trying to
transmit a message to servers if the DFU client was misconfigured, for
instance missing application key or network key.
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
If instantiated models don't have any relations at all, then the
extensions list will be empty. We should allow to disable it at all
to not waste RAM.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Add Kconfig option to control TCP RST behavior on connection attempts on
unbound ports. If enabled, TCP stack will reply with RST packet (enabled
by default).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Send RST as a reply for unexpected TCP packets in the following
scenarios:
1) Unexpected ACK value received during handshake (connection still open
on the peer side),
2) Unexpected data packet on a listening port (accepted connection
closed),
3) SYN received on a closed port.
This allows the other end to detect that the connection is no longer
valid (for example due to reboot) and release the resources.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add a helper function which allows to send a RST packet in response to
an unexpected TCP packet, w/o associated connection or net context.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As composite operations don't have path in CoAP packet,
it wrongly triggered a check for security object and got
denied the access.
Fixes#64012
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When objects are initialized, empty strings should be set to length of
zero, instead of length of the full buffer.
So use INIT_OBJ_RES_DATA_LEN() to give both, the buffer size and data
length.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When resource instances are initialized, we must calculate
beginning of the data buffer using the index and maximum
data length. Otherwise buffers would overlap with previous.
Fixes#64011
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
As the lwm2m_registry.c and specificly lwm2m_set()
functions already ensure null-terminator on string and
count that into string lenght, the content type handlers
should do the same.
When string is written, strlen()+1 is the data length.
When string is read, use the data length, so we don't
leak uninitialized strings. If buffer overrun have
removed the null-terminator the strlen() migh be larger
than data_len.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
If a receive state is removed, then the bis_syn_req callback
will be called with 0x00000000, to indicate to the application
that the sink should be desynced.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The flag was not properly set when the broadcast sink
did not add the source (e.g. if a broadcast assistant
added it).
This also downgrades two LOG_WRN to LOG_DBG as they may
happen without indicating an issue.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Resend the request with Echo option and the received Echo
option value when receiving a 4.01 (Unauthorized) response
with the Echo option.
Add missing header file kernel.h to coap_client.h.
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
When the BLOB server is in Pull mode and all chunks were received for
the current block, and the current block is the last block, then
according to section 5.2.4 of MshMBTv1.0 the server should stop sending
BLOB Partial Block Report messages if it determines that the client
knows that the transfer is complete:
```
While the Pull BLOB State Machine is in the All Chunks Received state,
the Pull BLOB State Machine continues to send the BLOB Partial Block
Report messages until one of the following happens:
• The Receive BLOB Timeout timer expires.
• If the current block is not the last block, then the client starts a
new block, in which case a new Pull BLOB State Machine is instantiated.
• If the current block is the last block, then the server determines
that the client knows the transfer is complete. For example, a
higher-layer model may indicate that the client considers the transfer
complete.
```
We currently don't have any OOB mean (for example, API) to determine
whether the client knows that the transfer is complete. We also need to
keep in mind that the Partial Block Report message can get lost so one
transmission may not be enough. The client could immediately send BLOB
Transfer Get message to get the transfer status, but this goes against
its state machine defined in section 6.2.4.2, where a Block transmission
completes when a BLOB Partial Block Report message is received with an
empty list of requested chunks (table 6.4, figure 6.1).
Because of this, we need to keep sending Partial Block Report messages.
We can keep sending them at least until Block Report timer expires.
If the client sends BLOB Transfer Get message, then it finished with
sending the block and we can change the phase and finish the transfer.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
"const k_tid_t" is "struct k_thread * const" and not
"const struct k_thread *" as the code may be assuming. Just
drop it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The stack size was previously hardcoded in the source code, making it
difficult to change when enabling options that require a larger stack.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
According to IEEE Std 802.1AS-2011 11.3.3, gPTP messages are not
VLAN-tagged.
Remove the use of VLAN headers for gPTP messages on the TX path.
The RX path is handled by the drivers. The network drivers in Zephyr
might need to be updated as well in order to accept receiving
non-VLAN-tagged gPTP messages when the CONFIG_NET_VLAN option is
selected.
Continue sending gPTP packets with VLAN tags when CONFIG_NET_GPTP_VLAN
is enabled. Specify that this option is for testing purposes.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
The previous implementation was setting priority 3 (Critical
applications) for Sync, Pdelay and Pdelay_Resp messages; and priority 6
(Internetwork control) for the other PTP messages. This might have been
done under the incorrect understanding that "Critical applications" was
the highest priority.
This resulted in the Pdelay_Resp_Follow_Up getting sent before the
Pdelay_Resp message when enough TC_TX queues were being used
(NET_TC_TX_COUNT >= 2), which is an inversion compared to the intended
order.
Invert the priority of the outgoing PTP packets so that the PTP event
messages are sent with higher priority, as was originally intended.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
The priority 3 (Critical applications) was incorrectly marked as
"highest priority", which might have led to incorrect use of
NET_PRIORITY_CA in some cases.
Note that this is already correctly advertized in other places, as it
was partially fixed in af8a0b1a5d.
NET_TC_SKIP_FOR_HIGH_PRIO was previously only allowing to push priority
3 (Critical applications) packets directly to the driver, but not the
ones with a higher priority. Change it so that it is now in effect for
priority 3 and above.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
Links host to mbedTLS library if Bluetooth Mesh is enabled, and
CONFIG_BT_TESTING=y.
Bluetooth Mesh has test dependencies in the host.
In order to compile Bsim tests with these test features
and PSA enabled, the libraries must be linked.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Since the BIS indexes start at 0x01, then BIT(0) is a
invalid BIS sync value and shall not be sent by the
broadcast assistant.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When the initiator provides CCID in the metadata, we verify
that the CCIDs exist on the device.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix bitfield crossing byte boundary - replaced with macros for
setting/getting the values
Fix missing endianness conversion for evt_cntr
Changed aa from uint32_t to uint8_t[4] to align with the rest of
the code and avoid any potential endianness issues
Signed-off-by: Troels Nilsson <trnn@demant.com>
For the CAP acceptor the size and rank characteristic shall
be set as per the CAP spec. Add checks for 0, as 0 indicates
not initializing the characteristics in the CSIS instance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds parsing of Private Network Identity parsing in the proxy client,
allowing the client to use these messages to establish a GATT
connection.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
BT_CTLR_ISOAL_LOG_DBG_VERBOSE, BT_CTLR_ISO_TX_SEG_PLAYLOAD_MIN, and
BT_CTLR_CONN_ISO_AVOID_SEGMENTATION are very tied to the BT_LL_SW_SPLIT
implementation. It is very unlikely that these will ever be used by
another controller
Therefore move them out to the BT_LL_SW_SPLIT specific configuration
file. This will likely create less confusion when using another
controller.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Update the BSIM test and the shell to use
bt_audio_codec_cfg_set_chan_allocation rather than implementing
their own versions.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add new configuration value CONFIG_LWM2M_UPDATE_PERIOD
that allows calculating update period from last update,
instead of calculating it from the lifetime.
In runtime, server is allowed to change the lifetime of the
registration which causes update perdiod to be effected.
When fixed update period is preferred, UPDATE_PERIOD
config is then used.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This commit adds checks for results and in case of error, handles it.
The failed initialization of the TCPC can postpone initialization in
case the TCPC needs more time after powering up. Otherwise if other
error happened, the Type-C Layer will be disabled.
Errors in other places of the USB-C stack, like communication errors,
moves the state machine to the error recovery, restarting the
communication with parner.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
These two functions are used together so there is no need for
splitting them into two functions. This commit also makes this
function required to be implemented by the TCPC driver.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
This commit adds check in cc_open entry state and logs if setting
either of the values were unsuccessful.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
When the get_cc function returns error, the CC lines should be
considered as open. It may happen either due to some chip malfunction
or chip going into sleep mode and needing time to reinitialize.
TCPC should only go to sleep if there is no partner attaches, so
in case of this error, the lines should be considered as disconnected.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
If TCPC supports checking for pending messages, it should be done
instead of forcefully trying to read the message and getting no-data
result. This helps with powereficiency for chips that go to sleep
when there is no message pending. Trying to read the message can
wake up the chip providing higher power usage.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
The TCPC driver initialization can be unsuccessful and it should be
checked and logged if that's the case.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
TCPC API functions should be able to inform the caller if the function
is supported and successfully executed. Bool values doesn't allow this
so it is needed to change the type to int.
For is_rx_pending_msg function the return code should conform to
existing error codes, so in case of function being not supported,
the -ENOSYS should be returned. In case of successful execution,
if there is no pending message, the -ENODATA should be returned and
in case of message pending, the value of 0.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
The BAP unicast babblesim tests now does RX and TX
and verifies that the data is correctly received on both
the client and server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Refactor the codec_cfg_get_frame_duration function to return the
assigned numbers value, instead of a converted value, but with
support for converting the value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Since the default process dhkey gen in bt rx, will block send
Trans Ack, cause peer device send more package.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Since notice that simultaneous advertising is not only used
by relay message, provision over pb-adv can also be used.
so it was changed to a more general name.
refs:https://github.com/zephyrproject-rtos/zephyr/pull/48903
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This will truncate ATT notifications/indications if exceed ATT MTU size.
It is up to the client to exchange MTU.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes sending proper Preset List notifications after
reconnection. The issue was observed when the last preset
known to the client has been removed.
As we do not hold the information about the deleted presets,
we need to use Generic Update procedure to:
1. Notify the presets that have been removed in range
(PrevIndex = current_preset_last, Index=previous_preset_last)
2. Notify deletion of preset Index=previous_preset_last.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Some of the data shall be persistent across connections to bonded
clients. This includes notidication state flags that are used to
determine whether notify bonded client after reconnection.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This refactors the preset list to use sys_slist API. There have been
various issues seen while iterating presets, thus it's more save to use
well-defined and tested sys_slist API.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Defer sending the features, active index, preset list and preset read
response to sysworkq and retry sending in case failed due to buffers not
available at the moment.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Verify that a HAS Server IUT sends changed characteristic notifications
or indications when the Lower Tester reconnects.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This moves common code to set_preset_availability function to be called
from bt_has_preset_available and bt_has_preset_unavailable.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes missing setting of FLAG_CONTROL_POINT_NOTIFY flag that
indicate whether submit control_point_work. In case the there are more
indications/notifications to sent (is_last flag is unset), the
FLAG_CONTROL_POINT_NOTIFY shall be set to resubmit control_point_work.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This removes revering the features value back to previous state if work
submission failes. Even if it fails it indicates an internal sysworkq
issue, so even retry won't help. The client can read the features value
anyway, thus it's sane to just log an error in such case.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Rename the Kconfig option from BT_ISO_ADVANCED to
BT_ISO_TEST_PARAMS to more explicitly denote that it
enables support for using the ISO test parameters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Many releases ago, specifying to block indefinitely in the log
processing thread would do just that.
However, a subtle bug was introduced such that specifying -1
for `CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS` would have the
exact opposite effect than what was intended.
As per Kconfig, a value of -1 should translate to a timeout of
`K_FOREVER`. However, conversion via `K_MSEC(-1)` results in
a `k_timeout_t` that is equal to `K_NO_WAIT` rather than the
intent which is `K_FOREVER`.
Add a dedicated check to to ensure that a value of -1 is
correctly interpreted as `K_FOREVER` in `log_core.c`.
For reference, the blocking feature was described in #15196,
added in #16194, and it would appear that the regression
happened in c5f2cdef09.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Improve it so that:
- it mentions the important fact that it redirects `printk` messages
to the logging subsystem
- it is consistent with the help messages of the other options in this
file (i.e. it starts with "If enabled")
Signed-off-by: Ladislav Podivin <ladislav.podivin@tietoevry.com>
When relocating section symbol addresses the value where the
relocation is to be written is an offset into the section to load.
Simply rewriting it with the section address is not enough, we need
to write the address of the section with the offset into it.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Added a condition to check if the size of the copied
memory is a positive number.
Fixes#58700Fixes#58703
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
Oneline fix to smp_bt.c smp transport register.
smp_client_transport_register() is a void function and
has no return value, so it should be ignored.
Signed-off-by: Alexander Stark <alexander.t.stark@gmail.com>
Add a build option to allow changing the initial state used
in the timer based random generator and by the kernel in the
early random number generator.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Check whether peer is subscribed for ASE state notification before
calling bt_gatt_notify. This handles an assert thrown when the
notification failed to be sent.
Fixes: #63728
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
If the PA gets terminated, we clear the pa_sync field of the
corresponding broadcast sink object.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
For some reason the state_change variable was static, which
does not make any sense. Changed it to a regular local
bool in bt_bap_scan_delegator_mod_src.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Commit makes workable proxy solicitation functionality
only server part without dependencies on client part.
Only on demand proxy server is required.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The `upload_status_rsp_with_progress` function uses the currently set
slot pointer to set firmware id field in the message. If another
upload starts but the firmware is already received, the slot API won't
let us to set the fwid and will return an error code. In this case, the
slot pointer stays invalid as fwid wasn't set, and
`upload_status_rsp_with_progress` will not add fwid as the lenght is
zero.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Handles return values from settings handlers which were missing
and would return "Unknown error" to clients instead of the read
error
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes the error code being returned when trying to perform a
hash/checksum on an empty file to show it is because the file is
empty, not because a paramter (which was not provided) was too
large.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes an issue which would cause a fault if someone attempted
to write to the (non-writable) blinfo keys
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fix hung Controller when establishing CIS on an encrypted
ACL connection with Controller built with direction finding
support enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When the bt_bap_broadcast_source_reconfig was supplied with a subset
of the streams, it would only update the codec cfg and qos for the
streams provided in the parameters.
This commit changes that, so all streams are properly updated,
as they share some common values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When calling bt_bap_broadcast_sink_delete, the broadcast sink
should not attempt to terminate the PA Sync. The PA sync can live
on without the broadcast sink, just as the broadcast sink can live
on without the PA sync (which is why the PA sync check was completely
removed).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When updating the Scan Delegator receive state, we shall only
set the BIS indexes in bis_sync that we are actually synced to.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit increases the buffer used for commands
in the control channel within an instance of the
modem_cmux module. The buffer was not large enough to
store an MSC command if the optional break signals
where included. This commit fixes the issue and
updates the test suite to use the max size MSC message.
Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
If the previous upload was in-band and it didn't complete, the slot will
stay reserved. By design we release slot not at the end of the upload
phase, but at the start of a new upload phase.
This fixes DFU/SR/FD/BV-13-C.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
If a Fw Distribution Client sends the Upload OOB Start message, but the
application layer didn't call bt_mesh_dfd_srv_oob_check_complete yet,
we have no other option other than ignore the message. The next phase
in this case could be Transfer Active, Transfer Success or Failed and it
will be set only after Check Firmware OOB procedure completes.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This message _at least_ 2 bytes long, but can be longer, thus
BT_MESH_LEN_MIN should be used.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
In OOB upload, when Check Firmware OOB procedure completes successfully
and the firmware is already received, we send Firmware Distribution
Upload Status message with update Phase set to Transfer Success. In this
case, we must set Upload Progress to 100%. This can't be done through
the callback as the application layer doesn't yet know that the firmware
is already received. This will happen by the exist from
bt_mesh_dfd_srv_oob_check_complete function, which will return error
code -EEXIST.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
According to the ASCS_v1.0 the ASE in Streaming state shall transit to
QoS Configured state when link loss happen.
Relates: ES-24215 (errata)
Fixes: BAP/USR/SCC/BV-168-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.
Rename it to random.h and get consistently with other
subsystems.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The list of receives in the Firmware Distribution Server model and
and the Firmware Update Client model are 2 different lists.
In the Firmware Update Client model it is called the Update Receives
state and the Active Update Receivers state which is a subset of
receivers from the Update Receivers State. In the Firmware Distribution
Server model it is called the Distribution Receivers List state.
When Distribute Firmware procedure starts, in the Initiate step, the
Receivers List input (which is the input for the Update Receivers
state), is composed of the Distribution Receives List state. During DFU,
the Update Receivers state becomes the Active Update Receivers state
which keeps only active nodes. Timed out or failed nodes dropped out
from this list. The Distribution Receivers List state stays unchanged
and thus don't need to be populated again after every successfull and
failed DFU.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The task_wdt_add function changes the reload_period of the channel to a
non-null value, which indicates that the channel is used. If the
function is interrupted by a task_wdt_trigger running in ISR context
before adding of the new channel has finished, the next timeout will be
scheduled based on inconsistent channel data.
Using a spinlock avoids such data races.
Fixes#61004
Signed-off-by: Martin Jäger <martin@libre.solar>
Added offset to the model relation register for vendor
models to find correct model index
for Composition Data Page 1. The previous implementation used the
'mod_idx' from the 'bt_mesh_model' struct, which led to issues in the
model relation register due to SIG and vender models having the same
model index.
Modified existing functions related to the model relation
register to take in the offset.
Modified macros for determining if a model is a base- or
extending model.
Added check in 'add_items_to_page' to check whether the model relation
is an extension.
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Changed buffer length check in bt_mesh_comp_p1_elem_pull.
The previous threshold would result in the
method not detecting the final element when it consisted of just one
model.
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Fixing kernel crash caused by memory release
while having a scheduled work item pending.
Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
When compiling conn.c using arm-none-eabi-gcc version 11.3.1 20220712
with the -Wmaybe-uninitialized flag a warning is emitted due to
pending_no_cb not being initialized. I'm not sure if initializing it to
NULL is the "correct" fix, but it's certainly not any worse then it being
uninitialized, and it fixes the warning.
Signed-off-by: Dennis Grijalva <dennisgrijalva@meta.com>
Connection states are non-trivial to understand based on their names
only, so add short descriptions in the header file explaining what they
do.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix errenous return value in pacs_gatt_notify function. The function
would always return zero, and not forward the error correctly.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
Don't reset values set in init callback as it is called only once by
bt_mesh_init call. The reset callback is called on every node reset.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
A few of the length checks that deal with HCI packets coming from the
controller were using assert statements. But the recommended practice is
to drop invalid packets and continue execution whenever a malformed
packet arrives from an external source, so replace those assert
statements with branches that will drop the packet and return.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fixed issue when reprovisioning is done on a device with
both RPR client and server on the same device.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
The existing formula for the amount of data that can be filled
in in the current PDU is correct but confusing. Replace it with
a simpler formula.
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Updates the chaining for advertising.
Instead of unconditionally adding a new PDU when new data
is added we now instead fill the last PDU in the chain with
the incoming data, only adding a new PDU when there is
not enough room.
This reduces the nr. of PDUs used for advertising, and also
fixes some qualification failures
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
The indexes were reset to 0 for each subgroup, which meant
that if we had a broadcast source with 2 subgroups and
1 BIS in each, both of them would use index 0x01.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A race condition between ATT RX and the connection teardown can happen, as
the teardown is executed from a workqueue.
For example:
- connection is established
- `connected` cb is called (in BT RX context)
- user calls `bt_conn_disconnect` in that cb
- connection is marked as disconnecting
- ATT teardown & general conn cleanup is scheduled
- BT RX gets an ATT request, tries to handle it
- ATT bearer is still not GC'd, so it tries and fails to send it
-> results in error message "not connected" on log
- ATT teardown & general conn cleanup runs
To avoid that, we not only check the bearer state, but also its ACL conn
state.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Fix leak in scheduled ticker node when rescheduling ticker
nodes.
Applications having active Extended Advertising or Observer
role with the use of ticker reschedule in window feature
would experience assertion check failure due to delayed
radio event preparation or stalled controller with no active
roles.
Fix updating of the ticker linked list when handling
rescheduled tickers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use UTC time by default, and add the option to use local time.
Also, change the default formats to comply with ISO-8601.
Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
When the legacy LLCP implementation was removed this Kconfig option was
mistakenly left over. Remove it now with all its users.
Fixes#63212.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This module calls `log_output_*` functions so it should enable
the `LOG_OUTPUT` Kconfig option explicitly.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit sets the C/R (command/response) bit when UIH
CMUX frames are sent from the modem_cmux module. This bit
is ignored by some modems like the Quectel BG95, as there
is no defined response to this specific CMUX frame type.
However, other modems, like the TELIT ME910, require the
bit to be set (command). If the bit is not set, the modem
will simply ignore the frame completely.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
Make the aa argument const to solve a Coverity issue
that assumes that any value that is being byteswapped
is tainted. Making the argument const should avoid
this assumption from Coverity.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix the coverity issue CWE570, comparison of unsigned int to 0
in the definition of IS_SYNC_ISO_HANDLE
There is a potentially the same issue for IS_ADV_ISO_HANDLE,
fixed that as well
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
`smp_send_pos` is 16 bits wide but it was being
passed as uint8_t, thus truncating.
This made it impossible to receive packets
larger than 256 bytes.
Signed-off-by: Stasys Aužbikas <stasysau@gmail.com>
If RPR server is used then Mesh settings work queue
requires more size during provisioning procedure.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The check for number of streams in a subgroup was reversed, so
it would never allow for correct values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Currently context->local is not set for offloaded interface.
This change move net_offload_bind call after set of context->local.
Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
Added run-time BT_CENTRAL role check for the path that was
central specific and did not have such check.
When multi-role BT device tried to pair without bonding (peripheral role)
while already previously bonded with the same device on another
Bluetooth identity, pairing failed.
It executed central-specific code, which should not be executed in case
when the device acts as peripheral (as it is even opt-out from code when
CONFIG_BT_CENTRAL is not enabled).
Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
In ll_setup_iso_path cis is only ever set if CONFIG_BT_CTLR_CONN_ISO
is enabled, and similarly adv_stream is only ever set if
CONFIG_BT_CTLR_ADV_ISO is enabled.
The two assignments were reported as dead code by Coverity due
to this, which has been fixed by guarding the code with
the respective Kconfigs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
BT_SECURITY_FORCE_PAIR option gets overridden when CONFIG_BT_SMP_SC_ONLY
or CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY is defined. Cache the bit value
before overrides.
Add explicit forced pair handling to existing security level check.
Functionality did not change as this was done implicitly due to integer
comparison for enums.
Add extra clarification to the method doc.
Signed-off-by: Rait Rääk <raitraak@gmail.com>
Only confirmable messages need pending tracking. Non-confirmable
messages are released after sending.
Match incoming packets with token, not message ID.
Ignore responses with non-matching tokens.
Remove unused function send_reset().
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
In case observation token changes (the LwM2M server re-sends
observation request to the client), the LwM2M engine should cancel any
ongoing notifications based on the old token. Otherwise, it will be
impossible to match the pending notification reply (ACK) with the
observer context anymore, causing new notifications for this
observation to stall.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Remove the terminate_ack from struct ll_conn since it is
not used anywhere, and results in dead code.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The remaining bit should be zero if auth is
shorter than PROV_AUTH_MAX_LEN and it should
be trimmed by removing octets with indexes
higher than PROV_AUTH_MAX_LEN.
Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
Zephyr's code base uses MP_MAX_NUM_CPUS to
know how many cores exists in the target. It is
also expected that both symbols MP_MAX_NUM_CPUS
and MP_NUM_CPUS have the same value, so lets
just use MP_MAX_NUM_CPUS and simplify it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The compiler emits a "null where non-null expected" warning unless the
argument of strlen is non-null at compile time.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The maximum size of an extension accept by the shell
was previously a define and is now made configurable through Kconfig.
Signed-off-by: Kai Meinhard <meinhard@gessler.de>
Always clone net_pkt to pass to promiscuous queue.
Previously, net_pkt was passed to L2 before conditionally cloning.
But L2 would in some cases strip ethernet headers, so cloned
net_pkt received through promiscuous interface would be missing headers.
Signed-off-by: Kieran Tyrrell <kieran@sienda.com>
The mode command operation has to be set to WIFI_MGMT_GET when the
option -g is provided. It was mistakenly set to true. Correcting the
same
This PR fixes#63424 and sets the proper value for the get command
Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
Fix issues when setting new values in cfg that modify
the length of the codec configuration LTV value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added comment to KConfig.iso file to make description
of BT_ISO_TX_MTU and BT_ISO_RX_MTU more clear
Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
iso_has_ts wasn't set correcrly for fragments of HCI ISO Data packets,
now it is set depending on timestamp
provided in the original buffer provided by host user
Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
this commit partially reverts e460847b60
According to Core Spec 5.4, Vol. 4, Part E, 5.4.5, Data_Total_Length field
contains length of the whole packet including optional fields of SDU
(Time_Stamp, Packet_Sequence_Number, ISO_SDU_Length, RFU and
Packet_Status_Flag). In Zephyr Host, Data_Total_Length value
is stored in bt_dev.le.iso_mtu field.
Therefore, there is no need to calculate iso_hdr_len(),
this length is already taken into account in conn_mtu(conn).
This commits removes iso_hdr_len() function and fixes
calculation of HCI ISO Data packet length calculations.
Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
Fix number of completed packets generated when BIS HCI ISO
Data packets sent to Controller are in fragments. Use the
ISOAL stored sdu_fragment count to generate the number of
completed packets count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Kconfig option to turn off ISO Data Packet Sequence Number
use to place the ISO Data in the correct radio event,
instead simply buffer it to next radio event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ISO data timestamp to reflect the SDU reference point
and not the ISO event anchor point when PDUs received after
retransmissions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use of payload_count for supporting flush timeout in
Central and Peripheral ISO Lower Link Layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not explicitly check buf parameter in usbh_req_setup()
but add ASSERT to check unresolved data stage conditions.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add command to get the current device configuration.
Revise the shell part to have a set|get configuration
subcommands.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
With the latest change, there is no need for this structure
to be used as a completion handler.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Use the USB device structure and wrappers introduced earlier.
With this patch, users of ch9 requests do not need to work
directly with the UHC API. The requests are now blocked until
there is a response from the UHC. Callers finally have access
to the data buffer and request status.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add a structure to represent a USB device and wrappers to avoid
glue UHC calls when operating on devices. Although there is a long
road to device configuration and management, we can start with
the tools that can also be used for USB device support testing.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Remove ugly hack to call class driver ops.
This is preparation for later changes where we will change
parts to work on structure that represents USB device and
not on glue UHC functions.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The current approach is a bit impractical in the upper layer.
This patch removes the two fifos that hold the transfer buffers
and replaces them with a byte array for the setup packet and
a pointer to a data buffer. The data buffer is mandatory for
all types of transfers except control without a data stage.
The waste of eight unused bytes for non-control transfers should
be insignificant, since an additional pointer would be at least
half of it, and then there would be the overhead of handling it.
This patch also clean up the transfer flags, rename owner to callback
as it reflects the upper layer use case, and add an additional member
to hold the pointer to the USB device (peripheral on the bus).
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit adds support for finding registered mcumgr command groups.
By default, supported command groups are local to the namespace where
they're registered. This api addition allows applications to get
reference to these supported command groups to deregister & re-register
them.
This adds scope for applications to support multiple implementations
of a command group alongside the default.
Signed-off-by: Chandler Keep <chandlersamkeep@gmail.com>
This PR adds a mechanism to avoid calling open() or close()
on pipes which are already opened or closed respectively.
This optimization can help simplify backends implementing
the modem_pipe API by avoiding duplicated boilerplate code.
The TTY backend test suite has been updated to match the
new behavior.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
This commit adds a check to prevent attempting to reestablish
the PPP session if the carrier is down. Without this check,
the PPP FSM attempts and fails to establish a PPP session
twice before giving up. The behavior is not breaking anything,
but it is not desired.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
Rearranges the k_mem_slab fields so that information that describes
how much of the memory slab is used is co-located. This will allow
easier of its statistics into the object core statistics reporting
framework.
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Adds the linkable loadable extensions (llext) subsystem which provides
functionality for reading, parsing, and linking ELF encoded executable
code into a managed extension to the running elf base image.
A loader interface, and default buffer loader implementation,
make available to the llext subsystem the elf data. A simple management
API provide the ability to load and unload extensions as needed. A shell
interface for extension loading and unloading makes it easy to try.
Adds initial support for armv7 thumb built elfs with very specific
compiler flags.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Co-authored-by: Chen Peng1 <peng1.chen@intel.com>
Co-authored-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
A minor overlook from the recent ICMP rework, the registered handlers
should no longer unref the processed packet as it's now the
responsibility of the ICMP module.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Update the function name from codec_cfg_get_chan_allocation_val
to just codec_cfg_get_chan_allocation, and add
codec_cfg_set_chan_allocation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
As we already log fragmented packets there's no need to log them again
unless they have been fully assembled and the result is to be logged.
We also want to log the final packet in all cases (after mangling LL
address) for the non-fragmented case.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
It is the general rule in Zephyr's network stack that methods that
return NET_OK are expected to have "consumed" the packet, i.e. it should
not be referenced any more.
This change applies this rule to the methods in ieee802154_mgmt.* for
improved consistency with the remainder of the network stack.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The "encryption only" security level was deprecated in IEEE
802.15.4-2015. This deprecation has already been introduced in the code
but was overlooked in net config.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
A little refactoring that simplifies dealing with nanosecond timestamp
values in packets and further decouples calling code from PTP:
Benefits:
- simplifies calling code by removing redundant conversions.
- prepares for removing PTP dependencies from net_pkt.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Fixed bug where changing the syslog network server's address while it's
still running would fail most of the time
Signed-off-by: David Corbeil <david.corbeil@dynon.com>
The current zperf tcp/udp download command doesn't provide the option
to bind the server to a specific host address. If there is more than
one interface, it will not be possible to test each interface with zperf
tcp/udp download command without building the Zpehyr.
This patch will add support for zperf tcp/udp download command to bind
server to host interface address.
Signed-off-by: Rahul Singh <rahul.singh@arm.com>
Add the bt_audio_codec_cfg_set_frame_blocks_per_sdu function
to set or add the frame blocks per SDU field in the
codec configuration.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added a new event for LWM2M_RD_CLIENT_EVENT_DEREGISTER for
indicate LwM2M client dereistartion.
Updated unit test and sample for new event type
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Fix a clang warning
ull.c:1235: warning: use of bitwise '|' with boolean operands
The result of ({1/0} &&(int)) is either true(1) or false(0),
not the int and therefore bm is not a bitmask, but just true(1)
or false(0) all together.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Enables support for custom function codes. Modbus specification allows
vendor specific function codes in the range 65-72 & 100-110 [1] and this
feature allows users to implement custom logic for those codes.
Additionally, since the Zephyr Modbus stack doesn't implement all defined
Modbus fcs this feature allows users to add support for codes outside the
basic register reading / writing functionality offered by Zephyr.
Custom function codes can be added on a per-interface basis and the handler
structures are allocated by the caller.
[1]: https://modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf
Signed-off-by: Henrik Lindblom <henrik.lindblom@vaisala.com>
The experimental status of the PPP L2 is long overdue so
it can be removed as the component is working fine.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Z_LOG_EVAL was used in place where COND_CODE_1 was a much
better fit. Z_LOG_EVAL gave the same result but it was not
intended to be used here.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
log_filter_set() is defined to return the actual level that was set by the
call. In case runtime filtering is disabled, this is always the compiled-in
log level, not the level passed by the user.
Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
Add the bt_audio_codec_cfg_set_octets_per_frame function
to set or add the octets per frame field in the
codec configuration.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Split the bt_audio_codec_meta_get functions to cfg and cap
variants. This provides a more explicit API where users
do not need to dereference their cfg/cap structs in order
to use this functions.
Furthermore this will also make the get functions more
similar to the upcoming set functions, where the set functions
will require the use of the cfg and cap structs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The firmware on these devices seems to have a bug that can cause reordering
of received packets. This can lead to new GATT requests being received
before the acknowledgement of the previous GATT response, accompanied by
log messages like the following:
<wrn> bt_att: bt_att_recv: Ignoring unexpected request
Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
This adds a function k_object_is_valid() to check if a kernel
object exists, of certain type, and has been initialized.
This replaces the same (or very similar) code that has been
copied from kernel into the network subsystem.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Adds command allowing to query information on bootloader.
In this case support is provided to query MCUboot information.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The original idea of z_current_get() was to be the counterpart
of k_current_get() when thread local variable for current has
not been initialized if TLS is enabled, otherwise they are
the same function. Now since z_current_get() is being used
outside of core kernel, rename it under kernel namespace so
other subsystem can conceptually use them too.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Re-add the `WIFI_MGMT_FORCED_PASSIVE_SCAN` option removed in #62751.
Now that `struct wifi_scan_params` is a reasonable size, we can enforce
the passive scan request even when no parameter struct is supplied by
the user.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Instead of providing a comma seperated list of SSIDs, provide the SSIDs
individually. This substantially simplifies the implementation.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Fix bug in timeout_expired() function. Coap client was resending
pending messages after 500 ms (COAP_PERIODIC_TIMEOUT) and didn't
wait for retransmission timeout.
Use 64-bit k_uptime_get()
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
Hides types used in the IEEE 802.15.4 L2 sub-API and L2-internal APIs
that are of no public interest and improves documentation of the
remainder.
The changes are mostly minor as the API documentation had already been
improved and clarified in previous changes. Also includes non-visible
documentation to the subsystem-internal Frame API by adding references
to the specification.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Write documentation for conn_mgr and its subsystems, especially
guidelines for writing connectivity implementations
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Refactor the codec_cfg_get_freq function to return the assigned
numbers value, instead of a converted value, but with
support for converting the value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
For asymetrical features there needs to be a separate mechanism to
unmask features in peer. This must be used in central for unmasking in case
of 'unsupported in peer' condition for CIS Create.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
If a CIS create is requested prior to having a complete feature exchange
the central will initiate a feat exch before enqueing the CIS create.
IF then the feature exchange results in peripheral NOT supporting
CIS create the central needs to allocate an RX node for the NTF
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Binary descriptors are data objects stored at a known location
of a binary image. They can be read by an external tool or image,
and are used mostly for build information: version, build time,
host information, etc.
This commit adds initial support for defining such descriptors.
Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
The purpose of this test is to prove that the zephyr host can handle the
behavior described in the Bluetooth Core Specification Vol.3 Part.F
3.3.2 "Sequential protocol".
The host should be able to handle all of those in parallel: one
indication, one write request, multiple commands and multiple
notifications.
The "tester" part had to be written with a "tiny host" implementation
instead of the Zephyr host, as the ZH conflates GATT client and server
and doesn't allow a device to enqueue an ATT request + an ATT indication
on the same bearer.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
If the peer is a zephyr host, there is no problem, as the Zephyr
host limits sending parallel REQs and INDs.
But the spec allows sending those in parallel, and it may end up that
the re-used REQ buffer hasn't been destroyed when an indication comes.
Only re-use the buffer when enqueuing ATT responses.
This means that we may run out of buffers if the peer sends too many
indications and our application also sends a lot of commands/notifications.
The rationale for this is that having to handle a lot of requests is a
more plausible scenario (e.g. being discovered by multiple peers) than
handling lots of parallel indications.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Fix ULL_HIGH ticker operations count, it is discovered in
new BabbleSim test implementations that mesh tests using
Extended Advertising and Scanning enqueue upto 4 ticker
operations before ULL_LOW ticker_job could process it.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
bt_iso_cig_reconfigure would almost always fail due to invalid
checks that did not take the functioner properly into account.
The CIS provided to bt_iso_cig_reconfigure can now be allocated
beforehand, if the CIG for the CIS is the same as the one being
reconfigured.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The CONFIG_NET_L2_WIFI_SHELL isn't always enabled.
But these functions might still be used, so need to
move functions into mgmt.
Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
If an IPv4 address is requested on an IPv6 interface or vice versa
use a sane default fallback address to send the response.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The zperf shell sends a IPv6 ping at the start when working
with IPv6. Convert the sending of the ping to use the new API.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add suitable functions that offloaded network device driver
can receive ICMP Echo-Request (ping) requests and give
ICMP responses back when it receives them from the network.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add new net_if_is_offloaded(iface) that returns true if
the network interface is offloaded (either IP or socket
offloading is enabled for that interface) and false if
the interface is not offloaded.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow user to send ICMP Echo Request message a.k.a pings.
The same ICMP API and framework is used for network stack
internal needs in later commits. One benefit for this new
API is that it allows sending Echo Requests to offlined
network devices.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add DHCPv6 support to the net config library. In case DHCPv6 is enabled,
net config will attempt to acquire IPv6 address and/or prefix when used.
The user can select with Kconfig whether to request address or prefix
(or both).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add a DHCPv6 client implementation for Zephyr (RFC 8415).
The implementation allows to request IPv6 address and/or prefix from the
DHCPv6 server, and for now supports only the mandatory set of DHCPv6
options needed to achieve this. Currently the implementation supports
the following scenarios:
* Requesting new IPv6 address/prefix with Solicit/Request exchange
* Refreshing existing leases with Confirm, Renew or Rebind (depending
on the context).
For now, no Information Request (the case where neither IPv6 address or
prefix are requested) is supported. No support for Reconfigure was added
either, as this is optional (the client manifests clearly to the server
that it does not support Reconfigure). Support for these can be added
later if needed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Adds a bootloader configuration interface which allows for a
bootloader (e.g. MCUboot) to set configuration in a shared data
area which is then read by the application.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Besides the changed channel reference, the message subscribers receive a
copy of the message during the VDED execution. ZBus guarantees message
delivery for `MSG_SUBSCRIBERS`.
Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
Code using sys_csrand_get should depend on CONFIG_CSPRNG_ENABLED symbol
and not in ENTROPY_HAS_DRIVER since they are not using the entropy
device directly.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
irq_lock() does not make this this csprng api thread safe
in SMP systems. Change it to use a mutex.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Replaces the previous approach to define bands via hardware capabilities
by the standard conforming concept of channel pages.
In the short term this allows us to correctly calculate the PHY specific
symbol rate and several parameters that directly depend from the symbol
rate and were previously not being correctly calculated for some of the
drivers whose channel pages could not be represented previously:
* We now support sub-nanosecond precision symbol rates for UWB. Rounding
errors are being minimized by switching from a divide-then-multiply
approach to a multiply-then-divide approach.
* UWB HRP: symbol rate depends on channel page specific preamble symbol
rate which again requires the pulse repetition value to be known
* Several MAC timings are being corrected based on the now correctly
calculated symbol rates, namely aTurnaroundTime, aUnitBackoffPeriod,
aBaseSuperframeDuration.
In the long term, this change unlocks such highly promising functional
areas as UWB ranging and SUN-PHY channel hopping in the SubG area (plus
of course any other PHY specific feature).
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
In `gatt_write_ccc_rsp`, the third field of
`SYS_SLIST_FOR_EACH_NODE_SAFE` was use as the `prev` sys_node when
calling `gatt_sub_remove`. This was wrong because the third field of
`SYS_SLIST_FOR_EACH_NODE_SAFE` is actually the next node.
Fix the issue by adding a pointer to the previous node and passing it to
`gatt_sub_remove`.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Fix BIS implementation for checking overrun of the BIS PDU
sliding window buffer overrun.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Provisioner should be able to manage received capabilities
unconditionally. Mandatory oob authentication is the node
feature and it is still compile time feature.
Split handling of this feature on provisioner and node part.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
According to specification it is possible to provide
static oob value with any length. Mesh should trim or
append\prepend by zeroes if it is longer\shorter than
required value.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Add BT_CTLR_EVENT_OVERHEAD_RESERVE_MAX Kconfig to allow the
omit of EVENT_OVERHEAD_START_US and EVENT_OVERHEAD_END_US in
the time reservation calculations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This change from using the mechanic of CONFIG_BT_KEYS_OVERWRITE_OLDEST
to instead handle the bonding cache through bond_deleted.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
Added retry mechanic to CSIP notifications by adding them into system
workqueue. Bookkeeping is done for notifications for all clients, and
potentially disconncted clients will also receive notifications on
reconnect. This also adds mechanic to restore the local clients list
upon registration of the service, as well as BSIMs to test notify on
reconnect.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
Reformated csip_set_member to use atomic flags for notifications
instead of a pending notification array. This better conforms the
style of the code to how its done in other LE Audio services.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
Previously each piece of LwM2M SEND was
using token length of zero. I think this was unintentional.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
To protect the integrity of outgoing block-wise transfers, append
Etag option that allows client to see if the received block is
generated from same content as it is expecting.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Allow blockwise-send buffers to be used with GET and FETCH
queries as well.
When outgoing packet is split into multiple blocks, don't free
it when first block is send. Keep it in memory until some other requests
come.
Following queries to next block are matched using CoAP token.
However, this required Leshan to use COAP.BLOCKWISE_REUSE_TOKEN=true
option from Californium.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
lwm2m_udp_receive() is only called with same function
pointer, so there no need to carry that in the parameter.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
In reality, single-write is the only operation that handles
BLOCK1 operations when receiving paylod.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Partial content format support is required to have a proper support
for content format OPAQUE instead of threading it as a part of
plain text format.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Back-to-back Tx Rx implementation was incorrect for nRF53
that uses DPPI. Both current and next DPPI channels where
enabled in the implementation which only worked correctly
to have the right tIFS when current and next PDU length
were same.
Fix ensures that the correct current DPPI is subscribed
to by the radio subscribe.
The implementation has been refactor to be able to use the
current sw_tifs_toggle value in the HAL implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added functionality to change the syslog server's
ip address at runtime as well as sample for
syslog network backend
Signed-off-by: David Corbeil <david.corbeil@dynon.com>
Move commands that require parameters first into the list.
Move syntax line first, command documentation second,
flags last. This is much like Unix commands do
❯ /bin/ls --help
Usage: /bin/ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Compared to:
uart:~$ lwm2m
lwm2m - LwM2M commands
Subcommands:
read :read PATH [OPTIONS]
Read value from LwM2M resource
-x Read value as hex stream (default)
-s Read value as string
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Fix CIS assymmetric PHY usage by adding implementation to
use correct PHY in radio when switching transceiver.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing NRF_CCM subscribe clear which can lead to
spurious trigger of TASK_CRYPT in NRF_CCM. This may
lead to corruption of Rx PDU buffers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We must send the packet without queueing it. The pkt has already
been queued for sending, once by net_if and second time in the ARP
queue. We must not queue it twice in net_if so that the statistics
of the pkt are not counted twice and the packet filter callbacks
are only called once.
Fixes#62483
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The commit adds support for uploading image to board with MCUboot
configured with DirectXIP with revert.
It allows to set uploaded image either for test or as permanent
boot application, until newer image gets confirmed.
Note that in DirectXIP with revert MCUboot will remove image
that has not been set for test nor confirmed and MCUmgr does not
set either mode unless image has the mode set within uploaded
binary.
The commit adds Kconfig option
CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT
that enabled the new mode of operation within MCUmgr.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
hal_radio_tx_chain_delay_ns_get() was incorrectly
returning the microsecond value, resulting in a 1us
error in the timing => Fix it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Align the header a bit with the one for the real radio,
adding missing Tx power levels and removing TODO which did not
need doing.
The old one originated as a copy of the nrf52833 one, and did not
evolve like the real ones.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Remove a few macros which are not used anywhere in the tree.
For the sake of simplifying the header and easing its understanding.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The following changes have been done:
1.
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_REGISTER_TASK(index)
= HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_TASK(channel)
has been convered into
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_REGISTER_TASK(index, channel)
2.
HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_REGISTER_TASK(index)
= HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_TASK
Which was only used in one place, has been replaced with the
equivalent HAL call
3.
HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_REGISTER_TASK(index) = 0
was replaced with the HAL subscribe clear function
nrf_dppi_subscribe_clear(NRF_DPPIC,
HAL_SW_DPPI_TASK_EN_FROM_IDX(SW_SWITCH_TIMER_TASK_GROUP(index)));
4.
NRF_DPPIC->SUBSCRIBE_CHG[group].EN/DIS = 0;
have been replaced with the equivalent HAL clear call
5.
NRF_DPPIC->TASKS_CHG[group].DIS = 1;
have been replaced with the equivalent hal task_trigger() call
6.
Manually setting the CHG registers, has been replaced with a
clear + add (because the hal does not have a set function yet)
So,
NRF_DPPIC->CHG[group] = value
has been replaced with
nrf_dppi_group_clear(NRF_DPPIC, group);
nrf_dppi_channels_include_in_group(NRF_DPPIC, value, group);
(A set function has been requested from the HAL team)
Note: There is other direct registes writes to the dppi subscribe and CHG
registers in the coded phy parts which have not been changed yet.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This requirement was implicit as the only backend the host is currently
tested with behaves this way.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Fix regression in sw switch single timer id use for nRF53x
series SoC.
Regression introduced in commit cfcbe5d68e ("Bluetooth:
Controller: Remove redudant header file includes").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Be explicit about the HCI backend that Bluetooth unit tests require.
Some unit tests depend on `BT_HAS_HCI_VS`, so also enable that.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Rename the bsim header in preparation for having more
simulated targets.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
To avoid a build error when coded phy is not enabled
for a nrf53: These three functions are only used for coded phy,
and depend on macros which are only defined if coded phy
is enabled.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Switch use of kconfig:
* SOC_SERIES_NRF53X -> SOC_COPATIBLE_NRF53X
* SOC_NRF5340_CPUNET -> SOC_COMPATIBLE_NRF5340_CPUNET
to also select those options/code when building for
the nrf53 simulated targets.
Also switch three kconfig range dependencies from
SOC_SERIES_NRF52X to SOC_COPATIBLE_NRF52X
(IRQ priority related) for consistency. These sound
not really have an impact.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Fix assertion due to late Peripheral CIS active flag being
initialized. CIS active flag shall be initialized when it is
acquired.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
It is always possible to bind to same port if the sockets
are in different address family.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Turn the nested arrays of `scan_params->chan` into a single array.
This adds the requirement to specify the band for each channel, but
eliminates the large amount of dead memory for unused bands. Overall,
this saves 50% of the RAM space for this variable.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Make the maximum number of channels that can be manually scanned
configurable by the application. The previous value of 233 was vastly
overallocating memory as the largest band only contains 60 allocated
channels.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
A few attributes isn't cloned togerder with pkt.
This commit add missing part.
Additionally, because the `eof` flag in net_pkt structure is
avilable unconditionally hence `#if defined(CONFIG_NET_SOCKETS)`
guard has been removed form setter and getter functions for
this flag.
Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
In net_pkt structure couple of flags are no longer used.
Flag pkt_queued can be removed permanently togeter with setter
and getter functions.
Second flag sent_or_eof has been renamed because it is still
used partially only for indicating EOF. Additionally unused setter
and getter for 'sent_' part of this flag are removed.
Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
Maximize BIG event length to extend upto ISO interval, and
allow PTO and Control subevents to be pre-emptible.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Calculate Broadcast ISO event overheads due to extended and
periodic advertising events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updates possible return errors for fs mgmt file upload, to clarify
when a provided path is on a read-only filesystem or if the mount
point does not exist.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
In spec:
The LwM2M Client MUST reject any LwM2M Server operation on
the Security Object (ID: 0) with an "4.01 Unauthorized" response
code.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
With bootstrap one function is unused. Fix by changing
ifdef to if (IS_ENABLED()) so linker can drop it.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
If autoinit is not enebled, it is allowed to build a few backends and
initialize a proper one in runtime.
Check number of backends only if autoinit is enabled.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
The header file contains mixture of functions and static arrays.
Replacing static arrays to functions.
Initialize functions in C file.
Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
Fix missing Coded PHY implementation conditional compile
causing compile error when disabling Coded PHY support in
SoCs that have radio that support Coded PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Revert EVENT_OVERHEAD_START_US value for Coded PHY support,
needed to pass LL/DDI/SCN/BV-21-C and LL/DDI/SCN/BV-25-C.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reduce number of successive calls to ticker_job() by
disabling mayflies in the ULL_HIGH priority, enqueue
ticker_yield_abs() and ticker_start() before re-enabling
so that single ticker_job() handles both yield and start.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix short prepare handling when more than one event is
enqueued in the pipeline and the short prepare is placed at
the end of the prepare pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ticks_slot_window use in Observer, do not use for
unreserved continuous scanning, and do not use when scanning
on both 1M and Coded PHY simultaneously.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use ticker_ticks_diff_get consistently when calculating
difference between ticker ticks when determining short
prepare requests.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the state/role context parameter in prepare pipeline
to identify the preempt timeout that was setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
These change are reverted as part of fixing regression
failure in LL/DDI/SCN/BV-21-C and LL/DDI/SCN/BV-25-C.
This reverts commit 0d54ca8761.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for reading and writing long values (> MTU)
when using the CAP API.
This change does make it slightly slower to execute the
CAP procedures as it is now done on a one-by-one basis,
which affect multi-ACL setups, but that also means
that the buffer requirements for CAP will generally be lower.
There is still room for improvement as we can perform the BAP
operations in parallel on each ACl, which should return this to
its former performance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the wifi_mgmt interface overriding default values with values
from kconfig. The defaults were only applied when a `params` struct was
provided by the application.
This is the case when the application is explicitly setting the options
it wants, why is the mgmt API changing these. When `params` is NULL and
thus modem defaults are requested, these defaults aren't applied. This
is the opposite behaviour from what seems reasonable.
In addition, these options are:
* Undocumented
* Using non-trivial string parsing functions (strtok)
* Adding complexity to the API implementation by forcing support for
ROM versions of command line arguments.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add parsers to retrieve metadata values from codec
capabilities and codec configuration structs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the order of operation in
broadcast_sink_iso_disconnected so that when the application
gets the last stopped callback, the BIG has already been cleaned
up, and the broadcast sink is in a reusable state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of calling ase_release for each ASE in the ACL
disconnected callback, we now call the state_transition_work_handler
directly. This is to ensure that when the disconnected callback
returns, the bt_conn object has been properly unref'ed in
a timely manner.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Replace the BT_AUDIO_CODEC_LC3_ID macro with the
BT_HCI_CODING_FORMAT_LC3 as there is no reason to
define and use the LC3 ID different than the other
allowed codec IDs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When using BT_HCI_CODING_FORMAT_TRANSPARENT as the codec_id, the
codec configuration (cc) len sent to the controller shall be 0.
Since this goes for all devices, we ensure that we don't
send invalid codec ID and cc data over air.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the bt_bap_broadcast_source_reconfig to use the same
parameter struct as bt_bap_broadcast_source_create so that
the two are more similar, since they both set the same values.
This allow for full control of which subgroups and stream
are updated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There was a new Kconfig for USB-C init priority that is conflicting
with currently used Kconfig for init of VBUS and TCPC.
This commit changes the names to more specific related to the subsystem
they belong to.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
This commits adds support for the SO_REUSEPORT socket option.
The implementation follows the behavior of BSD and tries to also follow
the specific additional features of linux with the following
limitations:
* SO_REUSEADDR and SO_REUSEPORT are not "the same" for client sockets,
as we do not have a trivial way so identify a socket as "client"
during binding. To get the Linux behavior, one has to use SO_REUSEPORT
with Zephyr
* No prevention of "port hijacking"
* No support for the load balancing stuff for incoming
packets/connections
There is also a new Kconfig option to control this feature, which is
enabled by default if TCP or UDP is enabled.
Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
This commit adds support for the SO_REUSEADDR option to be enabled for
a socket using setsockopt(). With this option, it is possible to bind
multiple sockets to the same local IP address / port combination, when
one of the IP address is unspecified (ANY_ADDR).
The implementation strictly follows the BSD implementation and tries to
follow the Linux implementation as close as possible. However, there is
one limitation: for client sockets, the Linux implementation of
SO_REUSEADDR behaves exactly like the one for SO_REUSEPORT and enables
multiple sockets to have exactly the same specific IP address / port
combination. This behavior is not possible with this implementation, as
there is no trivial way to identify a socket to be a client socket
during the bind() call. For this behavior, one has to use the
SO_REUSEPORT option in Zephyr.
There is also a new Kconfig to control this feature similar to other
socket options: CONFIG_NET_CONTEXT_REUSEADDR. This option is enabled by
default if TCP or UDP are enabled. However, it can still be disabled
explicitly.
Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
Fix the order of setting the flag that indicates that
preempt timeout has been successfully requested versus
the request is waiting to be scheduled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ticker implementation to prefer to keep ticker node
started in case of race condition to start and stop.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
While matching source address for a given Link-Local destination the
functions iterate over interfaces and return a first result with a
valid LL-address. However, they should first try to fetch address of
the default interface as it not always the first one on the list.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
Allow Bootstrap server to close the DTLS connection immediately
after receiving Ack to Bootstrap-Finish command.
This is not an error as either parties are allowed to tear down
the connection.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Allow certain RD-client states to timeout.
As stated in LwM2M specification:
The bootstrap procedure failed when the LwM2M Client did not
receive the "Bootstrap-Finish" operation after the
EXCHANGE_LIFETIME time period expired.
The EXCHANGE_LIFETIME parameter is defined in RFC 7252
We must handle the case where Bootstrap server is not sending
information towards us.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Add state checks for the get_id and get_base functions, as the
ID and base are not valid when the state of the broadcast
source is BT_BAP_EP_STATE_IDLE.
Since the broadcast_source_get_state uses the slist functions,
the broadcast source object for bt_bap_broadcast_source_get_id
can no longer be `const`.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When publish buffer run out, no thread active process work.
Fix this, by reschedule process work.
Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
Current MQTT-SN topic and publish allocators are not thread safe.
Fix this, by using k_mem_slab instead of arrays.
Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
Releasing the lock before notifying condvar led to a race condition
between a thread calling k_condvar_wait to wait for a condition variable
and another thread signalling for this same condition variable. This
resulted in the waiting thread to stay pending and the handle to it
getting removed from the notifyq, meaning it couldn't get woken up
again.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
When a packet can't be cloned we crash as we try to initialize the
cursor on a nullptr. We should check if we have a valid pointer,
and if we don't we drop the packet along with a warning.
Signed-off-by: Andreas Ålgård <aal@ixys.no>
In low memory conditions, its possible for socketpair memory allocation
to fail and then the socketpair is freed but after that the remote
semaphore is released causing a crash.
Fix this by freeing the socketpair after releasing the semaphore. Add a
test case to induce low memory conditions (low HEAP and high socketpair
buffer size), with the fix issue is not seen.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This commit optimizes the performance of the script chats by
storing the size of requests with the chat script chat, negating
the need to use strlen() within the modem_chat module every time
a chat script chat request is sent.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
This commit adds one new feature, modem_chat_run_script(),
which synchronously runs a script.
The existing function modem_chat_script_run() is async,
and doesn't follow the naming convention created for the
other modem modules, specifically, all functions are sync,
unless appended with _async.
To preserve backwards compatibility, the existing function
modem_chat_script_run() will remain until deprecated. It
simply calls modem_chat_run_script_async().
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
Intent is to pass Ellisys ISOAL quality tests for framed TX scenarios
where the TX SDU includes a time stamp that is not based on the
controller's clock.
Changes:
-- Include controller's reception time as a separate field in the TX SDU
information
-- Include decision on whether SDU time stamp is valid and based on the
controller's clock
-- Arbitrate and select / compute time stamp for the SDU
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Changes:
-- Corrected reading and writing time offset in framed segment header to
account for endianness
-- Corrected bit positioning of time offset bit field in the segment
header structure definition
-- Fixed upstream Zephyr BSIM test build failure due to debug logging
39-bit variable
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Changes:
-- Disregards target event after segmenting the first TX SDU and instead
decide event based on the next payload and feasibility to fragment
for that event (time-offset > 0)
-- Corrected error SDU release logic when an error occurs while
expecting the start of a new SDU, to avoid releasing an SDU which
could be received in the next payload or event
-- Included additional debug logging
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Revert back the EVENT_OVERHEAD_END_US value to original
value in initial commit 5c3709c13f ("bluetooth:
controller: Add def's re. update to slot reservation calc").
40 us is a sufficient margin considering ~30 us being the
worst case Rx chain delay for S8 Coded PHY on nRF5x SoCs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rather than yielding to idle thread, keep the part awake.
So debugger can still access it,
since some SOCs cannot be debugged in low power states.
Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
This adds support for the Upload OOB Start message to the DFD server, by
providing callbacks that the application can use to hook any OOB scheme
into the model behavior.
There are also extensive changes to the dfu_slot module, to accomodate
the new needs that appeared with the support for OOB transfer (mainly,
fwid, size and metadata are no longer available when the slot is
allocated, they appear later in the handling).
Signed-off-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
All WiFi channel numbers fit within a 8 bit number, as the maximum
allocated channel is 233. This halves the memory requirement.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The errors are printed in hex, but no prefix was used. This could be
confused with usual errno return values. The 0x prefix makes clear
that it's a hex value.
Also a missing minus sign is added to one log message.
Signed-off-by: Martin Jäger <martin@libre.solar>
NET_STATISTICS_PPP are dependend on NET_L2_PPP, not on NET_PPP.
This allows to use statistics also in modem subsys.
Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
Add check for device busy when CONFIG_PM_NEED_ALL_DEVICES_IDLE is
set to y because one or more devices may still in busy and causes
problem when system go into low power in Intel ISH platform.
Signed-off-by: Leifu Zhao <leifu.zhao@intel.com>
Usage of application level for device drivers needs to be avoided. Also
introduced a new init level, with default to 90 as other dependencies of
USB-C run at priority 80.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Convert the driver to a dt-based device. Also update Kconfig so that it
depends on the right compatible being enabled, initialize in POST_KERNEL
(APPLICATION should not be used for devices) and remove one redundant
include.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
The device model was not used for anything useful, only to call some
init code. Change to SYS_INIT instead.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This is the final step in making the `zephyr,memory-attr` property
actually useful.
The problem with the current implementation is that `zephyr,memory-attr`
is an enum type, this is making very difficult to use that to actually
describe the memory capabilities. The solution proposed in this PR is to
use the `zephyr,memory-attr` property as an OR-ed bitmask of memory
attributes.
With the change proposed in this PR it is possible in the DeviceTree to
mark the memory regions with a bitmask of attributes by using the
`zephyr,memory-attr` property. This property and the related memory
region can then be retrieved at run-time by leveraging a provided helper
library or the usual DT helpers.
The set of general attributes that can be specified in the property are
defined and explained in
`include/zephyr/dt-bindings/memory-attr/memory-attr.h` (the list can be
extended when needed).
For example, to mark a memory region in the DeviceTree as volatile,
non-cacheable, out-of-order:
mem: memory@10000000 {
compatible = "mmio-sram";
reg = <0x10000000 0x1000>;
zephyr,memory-attr = <( DT_MEM_VOLATILE |
DT_MEM_NON_CACHEABLE |
DT_MEM_OOO )>;
};
The `zephyr,memory-attr` property can also be used to set
architecture-specific custom attributes that can be interpreted at run
time. This is leveraged, among other things, to create MPU regions out
of DeviceTree defined memory regions on ARM, for example:
mem: memory@10000000 {
compatible = "mmio-sram";
reg = <0x10000000 0x1000>;
zephyr,memory-region = "NOCACHE_REGION";
zephyr,memory-attr = <( DT_ARM_MPU(ATTR_MPU_RAM_NOCACHE) )>;
};
See `include/zephyr/dt-bindings/memory-attr/memory-attr-mpu.h` to see
how an architecture can define its own special memory attributes (in
this case ARM MPU).
The property can also be used to set custom software-specific
attributes. For example we can think of marking a memory region as
available to be used for memory allocation (not yet implemented):
mem: memory@10000000 {
compatible = "mmio-sram";
reg = <0x10000000 0x1000>;
zephyr,memory-attr = <( DT_MEM_NON_CACHEABLE |
DT_MEM_SW_ALLOCATABLE )>;
};
Or maybe we can leverage the property to specify some alignment
requirements for the region:
mem: memory@10000000 {
compatible = "mmio-sram";
reg = <0x10000000 0x1000>;
zephyr,memory-attr = <( DT_MEM_CACHEABLE |
DT_MEM_SW_ALIGN(32) )>;
};
The conventional and recommended way to deal and manage with memory
regions marked with attributes is by using the provided `mem-attr`
helper library by enabling `CONFIG_MEM_ATTR` (or by using the usual DT
helpers).
When this option is enabled the list of memory regions and their
attributes are compiled in a user-accessible array and a set of
functions is made available that can be used to query, probe and act on
regions and attributes, see `include/zephyr/mem_mgmt/mem_attr.h`
Note that the `zephyr,memory-attr` property is only a descriptive
property of the capabilities of the associated memory region, but it
does not result in any actual setting for the memory to be set. The
user, code or subsystem willing to use this information to do some work
(for example creating an MPU region out of the property) must use either
the provided `mem-attr` library or the usual DeviceTree helpers to
perform the required work / setting.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Fix missing lazy calculation when using ticker interface
required for Central CIS create.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix initialization of CIS lazy_active event count used when
first CIS event is active. Now initialization for first and
any subsequent CISes made active.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reduce the max timeout for shell to 1 second.
Change the sip_svc open shell function to take millisecond as timeout
argument.
Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
This PR makes the modem_pipe instances track if they have
data ready to receive, and invoke the RECEIVE_READY event
every time they are attached if the backend implementing
the pipe has notified that receive is ready.
This mechanism ensures that modules attaching to a pipe
get the async RECEIVE_READY event immediately after
attaching to a pipe if there is data ready, instead of
having to poll the pipe, or worse, wait until newer data
becomes available.
The addition revealed a timing issue in the cmux test
suite. Specifically the CMUX instance now immediately
receives the response to a command which the CMUX
instance has not sent yet, causing it to drop the
response.
The CMUX test suite now uses the transaction
mechanism of the mock_pipe to wait for the command
before sending the response.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
This patch amends the existing L2CAP accept callbacks to use the new
accept signature that includes a pointer to the L2CAP server structure.
Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
Add a pointer to the associated server structure in the L2CAP accept()
callback. This allows the callee to know which server an incoming L2CAP
connection is associated with.
Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
The bt_conn_exists_le is commonly hit by users attempting
to connect (either as central or peripheral) to a device
they are already connected to in some way. The current log statement
does not provide particularly much information, so added more.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix some compiler instruction re-ordering. Mayfly code with
cpu_dmb() help avoid stalled memq_ull_rx processing when
rx_demux is to be executed using mayfly.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
ISO-TP CAN-FD support can be enabled at runtime.
Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
Signed-off-by: Martin Jäger <martin@libre.solar>
SWO reference frequency was set based on `swo-ref-frequency` under `itm`
nodelabel or `/cpus/cpu@0/clock-frequency` property. Not all platforms
configure those.
All ST devices configure CPU frequency in `clock-frequency` under `rcc`
nodelabel. Configuring the same value for each board in
`/cpus/cpu@0/clock-frequency` would be one way to make SWO work out of the
box. There is lots of copy-pasting involved in this, which makes this very
error-prone.
Introduce Kconfig option, which will default to values configured in `itm`
or `/cpus/cpu@0`. The main advantage will be for platforms like ST, where
CPU clock frequency is already configured in another place. Thsoe could
override default value in SoC, board or any other platform specific layer.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
The current implementation uses both, host and card capabilites to derive
the maximum bus width to be used. However, in cases where a MMC device is
not connected to the host via shdc using the full bus width of 8 lines,
device initialization fails. Introducing the `bus-width` property
circumvents this by reducing the host bus capabilites and forcing
communication with the MMC device using 1, 4 or 8 lines.
Signed-off-by: Mourad Kharrazi <mourad.kharrazi@ithinx.io>
This change brings in support for setting various Wi-Fi modes and
enables a specific Wi-Fi interface to be also placed into a sniffer
operation via monitor mode and promiscuous mode. A raw TX- packet
Injection mode is also introduced
Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
Even though the OOB information is optional we can add it
to extended scan reports in cases there is detected unprovisoned
devices.
Referring to MshPRT section 4.4.5.3:
When the Remote Provisioning Extended Scan procedure completes without
receiving an advertisement from the unprovisioned device, the
OOBInformation and AdvStructures fields shall be skipped. When the
obtained data is empty, the AdvStructures field shall be skipped. The
Status field shall be set to Success.
and referring to MshPRT section 4.3.4.9:
The OOBInformation field contains the OOB Information of either the
unprovisioned device or the Remote Provisioning Server.
Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
This adds support to allow any priority from the user instead of
limiting to the protocol values (0-7). This is useful in conveying
custom priorities from application to the driver/chipset.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This is handy in testing of setting priority directly rather than
deriving from DSCP. Please note ICMP doesn't use net context.
This is applicable for both shell and API.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This is a private kernel header with private kernel APIs, it should not
be exposed in the public zephyr include directory.
Once sample remains to be fixed (metairq_dispatch), which currently uses
private APIs from that header, it should not be the case.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit adds the DFM (DevAlert target side code) module and
moves the TraceRecorder module into the percepio module, which
results in the TraceRecorder module definition being removed
from the west manufest and module definition within zephyr.
Signed-off-by: Aron Lander <aron.lander@percepio.com>
This commit adds support for partial matches for the modem_chat
module. A match is a combination of an expected response to a
request along with delimiters to use and a handler for the
parsed response.
The usual behavior of the modem_chat script is to continue to
the next step when any expected response is received. The partial
flag indicates that the script should not proceed to the next
step if the response matches the match. This is useful for
commands which respond with an unspecified number of lines,
followed by an "OK". This flag allows the script to essentially
run in a "while" loop until OK is received.
Along with this addition, a more scalable macro for initializing
the modem_chat match struct, MODEM_CHAT_MATCH_INITIALIZER().
Without this macro, we will need 4 different macros to initialize
the 4 variants of a chat_match, and 8 when the next feature is
added...
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
The ICMSG backend now has a dedicated workqueue to process incoming IPC
messages. The system workqueue is no longer utilized for that purpose.
Testing shows that in certain scenarios substituting a RPMsg backend
with ICMsg results in deadlocks.
The deadlocks were a symptom of running a synchronous RPC protocol from
the context of the system workqueue and transpired as follows:
1. The RPC protocol sends a request over the ICMsg backend on the system
workqueue thread.
2. The RPC protocol puts the thread to sleep until response is received.
This puts the system workqueue thread to sleep.
3. The response to the request arrives over ICMsg backend.
4. The backend signals a work item to the system workqueue.
5. The system workqueue is unable to process the response due to being
previously pended on the RPC request.
The deadlock was initially observed with the nrf-802154 driver in
conjuntion with the IPv6 stack.
To prevent this condition from occurring, the approach was selected to
give ICMsg a dedicated workqueue thread.
Added a Kconfig option that enables the dedicated workqueue by default.
The config can be disabled, if the user wants to preserve RAM capacity
and is certain that the deadlock condition is not encountered.
Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
wifi_utils_parse_scan_ssids could cause a crash if a constant string is
passed to it. Fix this by duplicating the input string parameter before
parsing it with strtok_r.
Also limit the range of the CONFIG_WIFI_SCAN_SSID_FILT_MAX parameter
from 1 to 4 to avoid stack overflow due to users specifying a large
value for this parameter.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
wifi_utils_parse_scan_bands could cause a crash if a constant string is
passed to it. Fix this by duplicating the input string parameter before
parsing it with strtok_r.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Stores persistent on-demand private GATT proxy state in separate
settings entry. This is implemented to avoid issues related to
backwards compatibility between device firmware updates.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Stores persistent private beacon state in separate settings entry.
This is implemented to avoid issues related to backwards compatibility
between device firmware updates.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Makes the long workqueue init priority configurable and sets
the default to 50, this is to allow for relocating bluetooth
libraries to other parts of memory e.g. external flash, and
allows for those flash drivers to be initialised prior to
calling functions residing in them.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit delegates the modem_pipe_notify_closed() call
resulting from the UART async API UART_RX_DISABLED event
to the workqueue. This is neccesary as the async UART
callback may be called from ISR context.
modem_pipe_notify_closed() must be called from outside of
the ISR context as it takes a mutex.
The commit also adds a missing break to the async UART
callback, and adds a missing dependency to the Kconfig
for the UART backends, RING_BUFFER=y
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
The variables are usually placed into an output region located in FLASH
memory when linking, but the variables are not marked `const`, so the
section ends up with `W` writeable section flag:
```bash
❯ arm-zephyr-eabi-readelf --section-headers build/zephyr/zephyr.elf | \
grep -E '(Section Headers:)|( \[Nr\])|(zephyr_dbg_info)'
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[10] zephyr_dbg_info PROGBITS 60012298 01238c 000040 00 WA 0 0 4
```
Set them as const to set the output section to read-only:
```bash
❯ arm-zephyr-eabi-readelf --section-headers build/zephyr/zephyr.elf | \
grep -E '(Section Headers:)|( \[Nr\])|(zephyr_dbg_info)'
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[10] zephyr_dbg_info PROGBITS 60012298 01238c 000040 00 A 0 0 4
```
Signed-off-by: Noah Pendleton <noah.pendleton@gmail.com>
cur_inst is the copy of ots_client instance to prevent duplicate
API call while client is in middle of read/write procedure.
But cur_inst can only be cleared while write_obj_tx_done or read rx_done.
If ACL is disconnected while read/write is on-going, there is no chance
for cur_inst being cleared.
This causes ots client will no longer perform select/read/write
procedure anymore. API will always return -EBUSY.
Let l2cap_disconnect check if cur_inst is NULL and NULL it
unconditionally as what it is designed.
Make bt_ots_client_unregister public API.
Signed-off-by: Pirun Lee <pirun.lee@nordicsemi.no>
This adds endpoint by stream lookup function used to find the active
endpoints that use the stream object provided. The function is used
instead of dereferencing stream->ep that may be not valid if application
did not memset the stream object.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Once the application bt_bap_stream_ops.released callback is called make
sure the stream->ep pointer is valid so that application can still access
the endpoint details like e.g. endpoint direction.
Fixes: ASCS/SR/ACP/BV-{24,25,26,27,28,29,30,31}-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When using the LC3 codec, the cid and vid fields of the
codec shall both be 0x00, as per the BAP and ASCS specs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a network configuration option to configure whether IEEE 802.15.4
packets are expected to be ACKed or not.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
In the IEEE 802.15.4 area certain settings must be set before
net_if_up() may be called (e.g. the channel).
Also net_if_up() may not be called if
CONFIG_IEEE802154_NET_IF_NO_AUTO_START=y.
This fixes the set-up order and handling of
CONFIG_IEEE802154_NET_IF_NO_AUTO_START.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Use the HAL event clear functions to clear EVENTS
instead of accessing the registers directly.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Use the HAL event clear function to clear the RTC EVENT
instead of accessing the register directly.
This allows using an updated version of the RTC HW models
which generate level interrupts (as the real HW) and in
which if the EVEN register is not properly cleared,
the interrupts are kept high, resulting in the interrupt
handler reentering immediately after exiting.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The command was missing a metalen check, and attempted
to access array of size 0, which could give a build
warning.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds support for composition data page 2 & 130.
In this implementation the responsibillity for filling the page 2
buffer is left to the application through the new comp page 2 cb API.
Only the application can know/decide if the device is NLC compliant,
and must thus be given the responsibillity for cheking the NLC profile
requirements, defined in the NLC specs, and filling the response buffer
for comp data page 2.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
If the central disconnects a CIS while it is being
established, then we receive both a CIS established event
with BT_HCI_ERR_OP_CANCELLED_BY_HOST and a disconnect complete
event.
In this case we should not call bt_iso_disconnected in the
CIS established event handler, as that will also be
called from the disconnect complete event handler.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
As per the core spec, the CIS is not allowed to disconnect
a CIS if it is pending (i.e. in the connecting state).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
So far only object tracing/tracking could be individually disabled (e.g.
CONFIG_TRACING_SEMAPHORE=n). Now tracing of any API may be disabled
(e.g. CONFIG_TRACING_PM=n).
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The CIS Central uses the algorithm described in BT Core 5.4 Vol 6,
Part G, Section 2.2 to calculate the Max_PDU value for framed mode.
However, HAP needs the Max_PDU to be calculated according to "Core
enhancement for ISOAL CR" coming with the "Atlanta" update. With this
update, the fragmentation is controlled via a parameter at CIG creation.
Enabling CONFIG_BT_CTLR_CONN_ISO_AVOID_SEGMENTATION will set the
ISO_Interval to 7.5 ms for a 10 ms framed CIG, and calculate Max_PDU to
45/65 for 16/24 kHz.
Signed-off-by: Morten Priess <mtpr@oticon.com>
In case RST packet is received or malformed packet is received, the TCP
should not proceed with the state machine execution (which may process
the invalid packet) but rather jump directly to exit, where the
connection will be closed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The net_mgmt subsystem offers a function which waits (blocks)
until a specified net event occurs. An event callback is
pushed to the stack, then added to the net_mgmt_event_callback
list. If the event occurs, the net_mgmt thread calls the
callback and deletes the callback from the list. However, if
the event does not occur within the timeout specified when
invoking mgmt_event_wait_call() the function will return,
corrupting the callback structure the stack is reused.
This PR fixes the issue by deleting the callback before exiting
in case the event does not occur.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
The previous design with dedicated bits in the structure required a
user to explicitly set each bit.
Using one flags variable allows to extend the features more easily
in the future and avoids breaking existing code.
This change is particularly useful for the FDF and BRS flags required
for CAN-FD support.
See also previous similar change for the CAN driver in
f8a88cdb27
Signed-off-by: Martin Jäger <martin@libre.solar>
CAP requires setting the streaming context in the metadata,
which requires 4 octets of metadata, so the metadata for
CAP must be greater than or equal to 4.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In default_get_timestamp(), sys_clock_tick_get() is returned when
CONFIG_LOG_TIMESTAMP_64BIT=y. The timestamp frequency should reflect this.
Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
According to the mesh 1.1 spec, section 4.4.14.1: “. The access layer
security on the On-Demand Private Proxy Client model shall use the
device key of the node supporting the On-Demand Private Proxy
Server model.“
This commit alters the API and implementation to reflect this.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
The backend currently returns the pipe closed event immediately
after calling uart_rx_disable() which is not the correct behavior.
the pipe closed event should be called when the UART_RX_DISABLED
event is raised by the UART driver.
With this fix, back-to-back open/close/open... will work as
expected, where before the second open would often fail since
the UART was not actually disabled yet.
Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
Remove ifdef around `srcs` and let linker exclude it when Opcode
Aggregator Client model is not enabled.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
If the bonding information has been cleared before pairing had a chance
to complete (probably by the application), indicate this by setting an
appropriate log message.
Also check that keys exist before calling `bt_keys_store`.
Fixes#59788 and #61465
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
This fixes bt_audio_codec_cfg_get_chan_allocation_val return value that
shall be 0 in case of success.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes data pointer that was never set because wrong pointer
assignment.
It's regression introduced in:
b4af917ad0
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Use NRF_CCM HEADERMASK register to use correct Additional
Authentication Data (AAD) from ISO PDU header.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix an issue in the CCC configuration when the Peripheral device
maintains two or more distinct connections on different identities
with the same peer. The issue occurs when the local device performs
the pairing and the bonding procedure on a connection associated
with one of the Bluetooth identities. During the identity resolution,
the peer address field in the CCC descriptor is converted from the
RPA-type address to the Identity Address. However, the destination
address on the remaining connection objects associated with other
Bluetooth identities is not converted. Due to this, their CCC
configuration is reset and GATT indications and notification fail
to be sent even if the Central device subscribed to them.
Added necessary code to iterate over all connection objects during
the identity resolution phase and aligned their destination address
from the RPA-type to the Identity Address.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Fix timestamp calculation to use CIS reference anchor point
instead of incorrectly used CIG reference anchor point.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
NVS lookup cache currently uses CRC8/16 as a hash function
to determine the cache position, which is not ideal choice.
For example, when NVS lookup cache size is 512 and 256
subsequent NVS IDs are written (that is, 0, 1.., 255), this
results in 128 cache collisions.
It is better to use a dedicated integer hash function. This
PR uses one of the 16-bit integer hash functions discovered
with https://github.com/skeeto/hash-prospector project. The
hash function was additionally tested in the context of NVS
lookup cache using simple NVS ID allocation patterns as well
as using real device NVS dump.
Also, add a test case to verify that the hash function is
not extremely bad.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Add TI VIM (Vectored Interrupt Manager) interrupt controller support.
VIM is a TI specific custom interrupt controller for ARM cores.
In J721E soc, VIM aggregates interrupts to Cortex R5 cores.
TRM for J721e https://www.ti.com/lit/zip/spruil1
File: spruil1c.pdf
VIM: section 6.3.3.6
Signed-off-by: Prashanth S <slpp95prashanth@yahoo.com>
Modify the signature of the k_mem_slab_free() function with a new one,
replacing the old void **mem with void *mem as a parameter.
The following function:
void k_mem_slab_free(struct k_mem_slab *slab, void **mem);
has the wrong signature. mem is only used as a regular pointer, so there
is no need to use a double-pointer. The correct signature should be:
void k_mem_slab_free(struct k_mem_slab *slab, void *mem);
The issue with the current signature, although functional, is that it is
extremely confusing. I myself, a veteran Zephyr developer, was confused
by this parameter when looking at it recently.
All in-tree uses of the function have been adapted.
Fixes#61888.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Modify when the BT_BAP_EP_STATE_ENABLING state is set during
bt_bap_broadcast_source_start.
The reason why the state is now set before the call to
bt_iso_big_create, is to handle the case where the BIG
created event actually happens and is handled (by another
thread) faster than the state change is done, which could
cause an invalid state check if the streaming state is
attempted to be set before the enabling state.
Since the events from the controller may be handled by a
different thread, we should not assume that this function returns
before the event is handled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The application gets notified about both valid and invalid data.
As data arrives every SDU interval, we would like to only print the
valid data to avoid the shell being flooded with logs.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
For flash device, littlefs should be located at the partition.
Current implementation of the fs shell is hardcoded for the flash device
and the compilation fails if STORAGE_PARTITION isn't defined in the
device tree.
Add options for block dev support. This allows to mount littlefs on the
block device from the shell, and also removes the compile time
dependency on STORAGE_PARTITION, if CONFIG_FS_LITTLEFS_BLK_DEV is set.
Fix mounting of littlefs blk device. lfs_mount stucks in case when the
read/prog buffer less than SDMMC block size, because it can cause memory
corrupt, for example, look into function 'card_read_blocks' how it writes
data to read buffer in case when buffer isn't aligned. With default
config we have 32 bytes in the read buffer but trying to write
'block_size' to it and get memory corrupt, the same issue will be in
case when the read buffer is aligned.
This is an incremental improvement, ideally, someone should implement
selection of the storage dev from the shell args.
Co-authored-by: Mykola Kvach <mykola_kvach@epam.com>
Signed-off-by: Dmytro Semenets <dmytro_semenets@epam.com>
This utility header was accessing directly the interrupt
controller HW models, but those are not an interface one
can expect to not change, or to be avaliable in different
targets.
Instead we change it to use the APIs we have a contract
about, that is, the ones all POSIX arch boards are
expected to provide.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Rename BT_AUDIO_CODEC_QOS_[UN]FRAMED to
BT_AUDIO_CODEC_QOS_FRAMING_[UN]FRAMED and give a name
to the enum, which is then used by the
struct bt_audio_codec_qos.
The rename was needed as we had a codec_qos initializer of the
same name, so the values were renamed to avoid duplicated
macro names.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If network interface name support is enabled, print the name
when showing network interface data.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Make sure we use the network interface name (if configured)
instead of device name when binding to certain network
interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If CONFIG_NET_INTERFACE_NAME is enabled (default is y), then
system will automatically set a user friendly name to the network
interface like eth0, wlan0 etc.
Application can change the interface name if needed.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Fix few mismatched CONTAINER_OF, few missing pointers to the first
element, one explicit casting.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add option to prefix log message with thread ID or thread name.
Align tests and add test case to the log_output test.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Add Kconfig LOG_THREAD_ID_PREFIX option which allows storing
thread id in the log message and process it as message prefix
(as id or thread name).
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Fix incorrect use of Max_SDU_Size and SDU_Interval parameters in
ISO Transmit Test Mode code.
Fixes EBQ test LL/CIS/PER/BV-08-C.
Signed-off-by: Morten Priess <mtpr@oticon.com>
This changes bt_audio_codec_cfg_get_val function to return the data
length found. Otherwise, this function gives no information about the
returned data length.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fix few mismatched CONTAINER_OF, one missing k_work_delayable_from_work
and few that should be pointing at the first elemnet.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The twt and ps helper functions were not namespaced (were missing
wifi_ prefix).
Also change wifi_get_twt_... to more logical wifi_twt_get...
like the other twt prefixed functions and wifi_get_ps... to
wifi_ps_get... like the other ps prefixed functions.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Clean up sizes of some SD data fields, as the max value of these fields
is limited by the SD specification
Specifically, the limits are as follows:
num_io: 0-7, 3 bits (SDIO only)
relative_addr: 16 bits (SDMMC/MMC)
block_size: 12 bits (Max of 2KB, uint16_t used)
sd_version: 8 bits (currently at version 3)
card_speed: 8 bits (could potentially be reduced in size)
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Makes img_mgmt_slot_to_image image number independent and moves
it to header file as static inline.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The erase logic has been switched to using img_mgmt_get_opposite_slot
and the img_mgmt_get_other_slot has been removed.
The commit adds CONFIG_MCUMGR_GRP_IMG_ALLOW_ERASE_PENDING Kconfig
options, default set to n, that allows to make pending slot
erasable. The option only allows erase on pending slot that
is not revert slot.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Make img_mgmt_active_slot independent from
CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER for MCUboot swap type
algorithms.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit modifies image list command operations to use
img_mgmt_get_next_boot_slot instead of directly relying of
MCUboot flags.
The function is now used, also, by img_mgmt_slot_in_use to
figure out whether queried slot is in use.
The commit introduces two new Kconfig options
MCUMGR_GRP_IMG_ALLOW_CONFIRM_NON_ACTIVE_IMAGE_SECONDARY
MCUMGR_GRP_IMG_ALLOW_CONFIRM_NON_ACTIVE_IMAGE_ANY
that allow users to enable confirming non-active images slots.
The MCUMGR_GRP_IMG_ALLOW_CONFIRM_NON_ACTIVE_IMAGE_SECONDARY is y
by default to keep original behavior of logic that accidentally
allowed confirming secondary slot.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds functions:
img_mgmt_get_next_boot_slot
img_mgmt_get_opposite_slot
to simplify obtaining information on next boot slot.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Added optional support for read ISO link quality command.
Added link quality member in struct ll_iso_stream_hdr.
Signed-off-by: Mads Winther-Jensen <mdwt@demant.com>
If there are duplicate handles the Controller shall return the
error code Invalid HCI Command Parameters (0x12)
Fixes a failure in the EBQ test LE/AdvExt/Req-01 (part of the Ellisys
quality test suite)
Signed-off-by: Troels Nilsson <trnn@demant.com>
currently when no enough memory is found a (1 << (-1)) value is returned
instead of 0.
Fix this by returning 0 and simplify log2 computation
Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
Fixes some incorrect assertions in ull_adv.c on connection establishment
Note that the usual checks using adv->lll.conn doesn't work here,
since ull_periph_setup() NULLs the lll's conn structure pointer
before stopping the ticker
Signed-off-by: Troels Nilsson <trnn@demant.com>
This PR adds the following modem modules to the subsys/modem
folder:
- chat: Light implementation of the Linux chat program, used to
send and receive text based commands statically created
scripts.
- cmux: Implementation of the CMUX protocol
- pipe: Thread-safe async data-in/data-out binding layer between
modem modules.
- ppp: Implementation of the PPP protocol, binding the Zephyr PPP
L2 stack with the data-in/data-out pipe.
These modules use the abstract pipes to communicate between each
other. To bind them with the hardware, the following backends
are provided:
- TTY: modem pipe <-> POSIX TTY file
- UART: modem pipe <-> UART, async and ISR APIs supported
The backends are used to abstract away the physical layer, UART,
TTY, IPC, I2C, SPI etc, to a modem modules friendly pipe.
Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
Ensure card CSD and CID variables are initialized in sd_ops functions
for reading card CSD and CID data.
Fixes#59562
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Add TLS_DTLS_CID socket option, which enables to use the Connection ID
extension for the DTLS session.
The option provides control of the use of CID with the `setsockopt()`
function. The value provided can disable, enable, and control whether to
provide a CID to the peer. It uses a random self CID (if told to provide
one to the peer) unless TLS_DTLS_CID_VALUE set previously.
Add TLS_DTLS_CID_VALUE to get or set the CID sent to the peer, if any.
Add TLS_DTLS_PEER_CID_VALUE to get the CID value provided by the peer,
if any.
Add TLS_DTLS_CID_STATUS to determine if CID used, and whether
bidirectional or one way.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
bt_l2cap_chan_send_sdu previously returned the number of bytes sent
in the last sent sdu buf fragment or 0 if the buf has only
one fragment. bt_l2cap_chan_send_sdu now returns the total data
bytes sent from the buf.
Signed-off-by: Tom Finet <tom.codeninja@gmail.com>
Fix a bunch of mismatched CONTAINER_OF, few missing
k_work_delayable_from_work conversions but also many
bt_l2cap_le_chan/bt_l2cap_chan and few others.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
rp_enc_state_wait_ltk_reply() is executed in thread context, so
it is not allowed to move the encryption state machine forward.
Defer LTK reply handling to next prepare event by introducing a continue
state.
Update the unit test to reflect this, and remove the TODO that actually
said there was an issue in the first place.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Fix few mismatched CONTAINER_OF, few missing k_work_delayable_from_work
and a missing reference to the array first element.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Prevent compiler optimizations from changing the order of assignments in
the ticker API transactions. This could cause lost operation requests
and unexpected behavior under certain race conditions.
Signed-off-by: Morten Priess <mtpr@oticon.com>
There were a few issues in the way that PACS handled notifying:
1) A couple of dangling pointers (fixed by declaring some
`static const struct bt_uuid`
2) Some wrong Kconfig guards were used
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The use of private APIs z_add_timeout() and friends is not recommended.
With this commit, usual kernel timer APIs are used.
Fixes#61738
Signed-off-by: Martin Jäger <martin@libre.solar>
The connectivity monitoring subfeature of conn_mgr is currently also
named conn_mgr, which is confusing.
This commit renames it to conn_mgr_monitor, or conn_mgr_mon for short,
for clarity.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Add a helper allowing connectivity implementations to more easily access
connectivity flags on connectivity bindings.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Adds conn_mgr_binding_lock/conn_mgr_binding_unlock, which connectivity
implementations can call to lock or unlock the passed in connectivity
binding.
This allows connectivity implementations to safely make direct accesses
to binding data from outside conn_mgr_conn_api callbacks, and should
allow cleaner, more robust connectivity implementations to be written.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Splits many definitions from conn_mgr_connectivity.h off into their own
header, conn_mgr_connectivity_impl.h
conn_mgr_connectivity.h now focuses solely on user/application-facing
APIs, and conn_mgr_connectivity_impl now contains all functions, utils,
definitions intended for use by connectivity implementations, including
conn_mgr_if_get_binding, which is now available for use by connectivity
implementations.
This lays the foundation for allowing connectivity implementations
easier and safer access to their internal state through internal APIs.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Adds a target RPA known unknown cache; it fulfills a similar function
to the existing peer RPA cache, used for scanning of directed
advertisements
Signed-off-by: Troels Nilsson <trnn@demant.com>
According to mesh 1.1 spec (4.4.1.2.2 Composition Data state):
“If the complete list of models does not fit in the Data field, the
element shall not be reported.“
The implementation of bt_mesh_comp_data_get_page_1 does
not consider this, and further it will assert the device if the passed
buffer is to small.
This commit adds a check that prevents populating passed buffer
if the full element entry wont fit in the buffer.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Remove the qos field from
bt_cap_unicast_audio_start_stream_param as it was not used.
The QOS values are set when creating the unicast group,
and not when starting the streams.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
ZBus stores observers in two ways: statically using a list and dynamically
using a memory slab. Both present limitations. Static observers work only
for channel definition. The dynamic observers rely on a memory slab that
forces the user to manage its size to avoid issues with adding
observers. This commit fixes the static allocation problem by using the
iterable sections for allocating observation data and replacing the VDED
execution sequence since now it is possible to prioritize static observer
execution. All the runtime observers are dynamically allocated on the heap
instead of a specific memory pool.
BREAK changes (only internal, not APIs):
* ZBus channel metadata changed. Remove the observers' static array
pointer. Rename the `runtime_observers` pointer to `observers`. Add
`observer_start_idx` and `observer_end_idx`;
* Change the VDED execution sequence. The position (on definition time),
the priority in conjunction with the lexical order, is considered for
static post-definition time observers. At last, the runtime observer
follows the adding sequence;
* Replace the `CONFIG_ZBUS_RUNTIME_OBSERVERS_POOL_SIZE` with
`CONFIG_ZBUS_RUNTIME_OBSERVERS`.
New APIs:
* New iterable section iterators (for channels and observers) can now
receive a user_data pointer to keep context between the function calls;
* New `ZBUS_LISTENER_DEFINE_WITH_ENABLE(_name, _cb, _enable)` and
`ZBUS_SUBSCRIBER_DEFINE_WITH_ENABLE(_name, _queue_size, enable)` that
enable developers define disabled observers. They need to be enabled
during runtime to receive notifications from the bus;
* `ZBUS_CHAN_ADD_OBS` macro for adding post-definition static observers of
a channel.
Important changes:
* Move the ZBus LD file content to the `common-ram.ld` LD file. That was
necessary to make ZBus compatible with some Xtensa and RISCV boards.
Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
Drop few redeclared variables, fixes some:
settings_mgmt.c:454:30: error: declaration of ok shadows a previous
local [-Werror=shadow]
454 | bool ok;
| ^~
settings_mgmt.c:436:14: note: shadowed declaration is here
436 | bool ok = true;
| ^~
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Refactor the bt_audio_codec_cfg to use flat arrays to store
metadata and codec specific configurations.
The purpose of this is to make it easier to copy the data
between layers, but also to support non-LTV data for non-LC3
codec configurations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added a BSIM tests for PACS notification functionality. This test
tests that all optional notifies are working, as well as verifying
that a disconnected subscribed client will be notified on reconnect.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
This fix allows PACS to notify bonded clients, that were disconnected
when a characteristic with notify property was changed, are being
reconnected.
This fix also implements a defer work so to not block the bt rx
thread during auth callbacks. All other notify calls are for
consistency and style also moved to use the defer work.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
Added Kconfig options to make the various PACS characteristics that are
optionally notifiable selectable as notifiable. Selecting a
characteristic as notifiable will make it so for all pacs instance on
the device.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
Add a a new source coverage for native builds
and new kconfig choice of COVERAGE mode to select which:
* COVERAGE_NATIVE_GCOV: what we had until now with native builds
* COVERAGE_NATIVE_SOURCE: a new LLVM source coverage mode
* COVERAGE_GCOV: the old COVERAGE_GCOV (embedded gcov data generation).
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Fix few instances of delayable work handlers using the k_work pointer
directly in a CONTAINER_OF pointing to a k_work_delayable.
This is harmless since the k_work is the first element in
k_work_delayable, but using k_work_delayable_from_work is the right way
of handling it.
Change a couple of explicit CONTAINER_OF doing the same work as the
macro in the process.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This change allows to register additional handlers for ICMPv6 so the
user can handle some of the messages between they are handled by the
ICMPv6 module in Zephyr by returning NET_CONTINUE.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
There was a corner case which was not handled well in a scenario, when
listening socket was closed during an active handshake with a new
client.
When a listening socket is closed, the accept callback is cleared on the
TCP context. If this happened during a handshake with a new client, i.
e. before final ACK from the client was processed, this lead to a
context leak, as application did not take ownership of the connection
(i. e. had no means to close it).
Fix this, by proactively closing the connection at the TCP level when no
accept_cb is available. Instead of ignoring the fact that no accept_cb
is available, the TCP stack will now enter TCP_FIN_WAIT_1 state and
proceed with a graceful teardown of the connection.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
getsockname() did not work properly on bound sockets, as it verified
whether the socket has an active connection before retuning result. This
is not correct, as socket after bound may not have a connection yet.
Fix this, by verifying that local_addr on an underlying net_context is
set, to determine whether socket has a local address assigned, before
returning result.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This adds SoC and board configs to support the dc233c core
that is available on QEMU. This core has more features than
sample_controller, such as MMU support.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
* Renamed 'coap_client_init_path_options' to
'coap_packet_set_path'
* Moved into 'coap.c'
* The function is public now
Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
Fix options initialization for path and query
when a final segment is one character long.
For example, "a/b" inits path as ["a"] instead
of expected ["a", "b"]. The same applies to
query option. The "a/abc?a&b" options won't
contain "b".
Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
Adds a settings management group to MCUmgr which allows for
manipulation of the zephyr settings from a remote device.
Includes callback hooks to secure access from an application.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
net_iface_status is larger than scan_result, causing
net_iface events to be dropped due to info exceeding
NET_EVENT_INFO_MAX_SIZE.
Signed-off-by: Noah Luskey <LuskeyNoah@gmail.com>
The previous patch to address race condition on STREAM sockets had a
side effect on DGRAM socket, where net_context_recv() is not only
installing recv callback, but also registering a connection at net_conn
level. Doing so before setting remote address first (which is done in
net_context_connect()) had an impact on the connected DGRAM socket
operation, which now accepted packets from any remote peer, and not only
the one socket was connected to.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
ICMPv6 messages with type < 128 are error messages, where we should not
send back another error. The meaning of the code depends on the type.
Signed-off-by: Andreas Müller <andreas.mueller@husqvarnagroup.com>
When resource data length is set to zero, we still need to
ensure that string reading will return an empty string.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Will exclude the code for prefix and checksum functionality if none
of the entries on a device make use of these features, saves ~816
bytes when both features are excluded.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
CONFIG_COVERAGE has been incorrectly used to
change other kconfig options (stack sizes, etc)
code defaults, as well as some samples behaviour,
which should not have dependend on it.
Instead those should have depended on COVERAGE_GCOV,
which, being the one which adds special code and
temporary RAM storage for embedded targets,
require changes to many features.
When building for the native targets, all this was
unnecessary.
=> Fix the dependency.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The CMSIS module glue code was part of arch/ directory. Move it to
modules/cmsis, and provide a single entry point for it: cmsis_core.h.
This entry header will include the right CMSIS header (M or A/R).
To make this change possible, CMSIS module Kconfig/CMake are declared as
external, allowing us to add a new Zephyr include directory.
All files including CMSIS have been updated.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
MCUmgr client upload max data payload length was missing
Transport layer CRC + 16bit lenght. Full net buf packet was
possible to send but receiver side it was blocked because there
was not space for calculate CRC and length.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Retry sending notification was not sent due to e.g. lack of
buffers currently available.
Fixes: #57456
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Retry sending notification was not sent due to e.g.
lack of buffers currently available.
Fixes: #57452
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Changed Add to Enable in help text to convey the intended use of the
Kconfig NET_L2_WIFI_MGMT.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Add a scan command option to print the help text for the scan command.
This is to facilitate ease of using the command (since now there are
many different options added to the scan command).
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Add scan extension to allow limiting the scanning to specific channels.
Only 20 MHz channel specifications are allowed presently.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Add scan extension to allow limiting the scan results to a user defined
maximum number. This parameter is intended to return results with the
best RSSI. It cannot be counted upon to limit the scan times since the
Wi-Fi chips might have to scan all the channels to find APs with the
best RSSI values across all channels.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Add scan extension to control scanning time spent on channels where
passive scanning is used.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Added scan extension to support scanning individual Wi-Fi bands or
combinations thereof.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
Modify the way the scan type option is passed to the wifi scan command.
This makes it flexible to add more scan options.
Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
This fixes missing Fix bt_tbs_client_cb.discover call that has been
observed when CONFIG_BT_TBS_CLIENT_CCID was disabled. In such case the
discovery proces was not finished from application point of view,
as the callback was not called.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This removes odd `subscribe` parameter from bt_tbs_client_discover
function parameters list. As the API user enables specific
CONFIG_BT_TBS_CLIENT_* option, the client implementation should
subscribe to the characteristic notifications so that the user receives
the value updates.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
- Fix masking for no coded phy
- Allow ISO_Interval < SDU_Interval for framed mode
- Change BT_HCI_ERR_INSUFFICIENT_RESOURCES to
BT_HCI_ERR_CONN_LIMIT_EXCEEDED.
- Prevent starting same CIS twice
- Cancel an initiated CIS creation procedure if terminated before
sending CIS_IND.
- Implement canceling of local CC procedure. Respond to CIS_RSP with
REJECT, if canceled after CIS_REQ was sent.
- Introduce state CIG_STATE_INITIATING for central, to keep track of
initiating CIS connection, in transition between CONFIGURABLE and
ACTIVE.
Fixes EBQ test /HCI/CIS/BC-03-C.
Signed-off-by: Morten Priess <mtpr@oticon.com>
This fixes the error below:
main.c: In function ‘bt_mesh_provision’:
main.c:173:17: error: ‘node’ may be used uninitialized in
this function [-Werror=maybe-uninitialized]
173 | bt_mesh_cdb_node_del(node, true);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
With gcc from the zephyr sdk and -Wold-style-declaration is giving this
output:
zephyr/arch/arm/core/aarch32/cortex_a_r/fault.c:101:1: warning:
'inline' is not at beginning of declaration [-Wold-style-declaration]
101 | static void ALWAYS_INLINE
z_arm_fpu_caller_save(struct __fpu_sf *fpu)
| ^~~~~~
I searched to all of the source code to find these further occurances
where inline is not at the beginning of a function declaration.
Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
The bt_cap_initiator_started may be called in cap_stream_started_cb,
even if there is no unicast support. Added a guard for
CONFIG_BT_BAP_UNICAST to avoid calling an unlinked function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename shadow variables found by -Wshadow
After e38fc6de8a
was merged, this cause CI failures.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This enables -Wshadow to warn about shadow variables on
in tree code under arch/, boards/, drivers/, kernel/,
lib/, soc/, and subsys/.
Note that this does not enable it globally because
out-of-tree modules will probably take some time to fix
(or not at all depending on the project), and it would be
great to avoid introduction of any new shadow variables
in the meantime.
Also note that this tries to be done in a minimally
invasive way so it is easy to revert when we enable
-Wshadow globally. Source files under modules/, samples/
and tests/ are currently excluded because there does not
seem to be a trivial way to add -Wshadow there without
going through all CMakeLists.txt to add the option
(as there are 1000+ files to change).
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
There are a few structs, unions, and enums where -Wshadow would
complain. Since names being the same are intentional, we need
to tell compiler to ignore -Wshadow for those names.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
When the application closes the connection, it enters the FIN1 state.
Restructure this sequence to RST on data received after the application
has closed the socket.
Next to that deal with packets that contain both data and a FIN flag.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
As the metadata has to be validated anyway, let the initial vaidation of
metadata to be done in ASCS. The application can still reject the
metadata, but the length validation and supported type validation can be
performed by the stack.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The `ioctl()` interface is already supported by the network
subsystem but there was no `zsock_` interface available for it.
Add the `zsock_ioctl()` syscall.
Implement two somewhat commont ioctl requests for socket
file descriptors; namely
- `FIONBIO` set non-blocking I/O mode
- `FIONREAD` get the number of available bytes
In the process, added `net_pkt_ip_proto_hdr_len()`
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
In order to get a semi-accurate assessment of how many
bytes are available on a socket prior to performing a read,
BSD and POSIX systems have typically used
`ioctl(fd, FIONREAD, &avail)`
We can support this in Zephyr as well with little effort, so
add support for `socketpair()` sockets as an example.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Previously, if a net_context had multiple packets already in
the receive queue, and a call to zsock_recvfrom() was made with
a buffer large enough to receive content from multiple packets,
only the content from a single receive buffer would be received.
Since zsock_recvfrom() is a system call, which has a
non-negligible overhead, it makes sense to receive as many bytes
as possible per system call.
Add zsock_recv_stream_immediate() as a shorthand for
"fill this receive buffer with as many bytes as possible without
blocking". Allow nullable buffer parameters so that we can also
have a shorthand for "count how many bytes are immediately
available".
With minor refactoring, zsock_recv_stream_timed() is a simple
wrapper around zsock_recv_stream_immediate() that handles timing
and error conditions.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
When using the JIT scheduler (CONFIG_BT_CTLR_JIT_SCHEDULING), doing
ticker updates which only change the slot reservation, will fail.
For compatibility, the updates to ull.ticks_slot are preserved, as some
link layer implementations use this to predict collisions.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When executing a local CIS_TERMINATE procedure, the reason sent to the
host must be changed to match the perspective of the initiator.
According to BT Core 5.4 Vol 4, Part E, section 7.1.6, the disconnect
reason must be BT_HCI_ERR_LOCALHOST_TERM_CONN for a local disconnect.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Do not assert in case of race conditions or asymmetric CIS
create/release. There are cases where ll_conn_iso_stream_get_by_group
legally returns NULL, and this should just cause for-loop continuing to
next iteration.
Signed-off-by: Morten Priess <mtpr@oticon.com>
To keep track of requested/pending CIS LLL flushing, change 'flushed'
binary state to 'flush' with states NONE, PENDING and COMPLETE.
This enables CIS teardown to know that a CIS already has a pending LLL
flush, and ULL does not need to initiate it.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Add support for SPI host command backend for STM32 chips family.
Unfortunately, the current SPI API can't be used to handle the host
commands communication. The main issues are unknown command size sent
by the host(the SPI transaction sends/receives specific number of bytes)
and need to constant sending status byte(the SPI module is enabled and
disabled per transaction). Thus the SPI backend includes basic SPI STM32
driver adjusted to host command specification.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
While the maximum sizes were already correctly checked by the code, the
minimum sizes of the PDUs were not. This meant that PDUs smaller than
the minimum required length (typically 6 bytes for AdvA) were
incorrectly forwarded up to the Host.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Set correct SHELL_BACKEND_SERIAL_INIT_PRIORITY if ACPI is enabled.
Otherwise when enabling SHELL using menuconfig, etc serial backend is
not working.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Adds separate extended protocol timeout of 120 sec in provisioning
implementation when OOB method Input or Output is used. This
complies with recommendation in the mesh 1.1 protocol spec (5.4.4).
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
This is a stable API treewide change changing the newly introduced
"ret" response to "err" as it was overlooked that the shell_mgmt
group already used "ret" to return the exit code of the command
and this created a collision. Since SMP version 2 was only recently
introduced, there should not be any public implementations of it
as of yet, but the original function has been kept and marked as
deprecated.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes a stray ifdef which causes a build failure if the automatic
UDP start Kconfig is not enabled.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
When calling `bt_iso_chan_disconnect()` while the channel is
connecting, the host should simply use HCI Disconnect.
Note: For the peripheral it is not allowed to call HCI Disconnect
on a CIS after it has accepted the CIS request, but before it has
received the CIS established event. The implementation in this
commit does not fix this case. In that case the controller will
return an error code.
Also, this commit does not handle the events following the
HCI Disconnect correctly.
In this particular case, two events are raised by the controller.
See Core_v5.4, Vol 6, Part D, Figure 6.51.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
The default stack size is too small on 64bit.
Some standard shell commands cause stack overflow
Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
Both options are kind of mutually exclusive and can't be used together.
Also, USE_IDENTITY is used for debug purpose and could be useful when
debugging Private Proxy as well. Since CONFIG_BT_MESH_DEBUG_USE_ID_ADDR
is not allowed to be used in production, it is fine to use it for
Private Proxy advertisements as well.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Commit adds configuration for mesh with mbedtls PSA
to CI BabbleSim tests as well as emulation of
the Internal Trustable Storage(ITS) based on Zephyr's
settings to run in parallel environment.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Let's just let the user implementation to its things, like
checking, locking and stuff.
The tracing_user.c now just acts as a glue.
Moved previous implementation to its sample, and cleaned up
headers.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
When dealing with multiple connections in the shell as the central,
it is more often than not the newest connection you want
to interact with.
The behavior for the peripheral remains unchanged.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This fixes ASE state transition to QoS Configured state that shall be
done autononously when CIS has been terminated due to link loss.
As per ASCS v1.0:
"If the server detects link loss of a CIS for an ASE in the Streaming
state or the Disabling state, the server shall immediately transition
that ASE to the QoS Configured state. Link loss of a CIS for an ASE in
any state other than Streaming or Disabling shall not cause a
transition of the ASE state machine."
Fixes: #60669
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The added function allows to check if a descriptive block
option was already added to a message.
Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
In some cases the options of a CoAP message are reused for
block transfer. Then the block header needs to be updated.
The current approach is to remove the old block option and
add an updated one.
Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
The provided function allows to remove a CoAP option in a
message. This is useful for reusing parts of a message.
Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
A recent refactor of bt_audio_codec_cap to flat arrays missed setting
data_len and meta_len fields.
Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
The reply callback doesn't need to handle the case when the
code of the reply is 'continue' (2.31). In that case the callback
is not executed until the last block is transmitted.
Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
When using block-wise transfer, call the reply callback only when
the last block arrived.
Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
Fix possible race conditions when state and results are written
by locking the registry, so a first write does not cause Notify
message to be send too early.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
When the protocol layer like TCP is blocking transmission, the socket
layer will attempt and wait for a maximum amount of time before returning
with an ENOBUFS error.
This change allows to set the maximum waiting time from the configuration
file instead of using a fixed 10 second value.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Qualification test CSIS/SR/SP/BV-03-C [Lock Timeout]
Specification: Coordinated Set Identification Service Revision v1.0.1
Section 5.3.1.1.
When the server and the client are not bonded and they disconnect when
the value of the Set Member Lock characteristic is set to Locked, the
server shall set the value of the Set Member Lock characteristic to
Unlocked immediately after the disconnection.
Signed-off-by: Henrik Eriksen <heri@demant.com>
Qualification test MICS/SR/SPE/BI-01-C [Invalid Mute Value]
Specification: Microphone Control Service Revision v1.0 Section 3.1.1
If the client writes a value of Disabled or RFU to the Mute
characteristic, the server shall return an ATT Error Response with the
ATT error code Value Not Allowed (0x13) as defined in Assigned Numbers.
Signed-off-by: Henrik Eriksen <heri@demant.com>
Bootstrap executable cause socket to be closed, so
it requires some delay for Ack to be send out as well.
Similarly, add small delay for Update trigger, so the
possible Ack goes out before the actual update message.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When BOOTSTRAP FINNISH message was received, it caused
engine to immediately switch to BOOTSTRAP_TRANS_DONE state
which then closed the connection.
Ack packet was still on the send-queue so it never got send before close().
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Some state changes were do by directly writing into
client.engine_state variable, followed by call next_event_at(0);
This causes hard-to-find side effects.
Refactor all state transitions to use set_sm_state() to have better
control for it.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
The command did no longer set the user specified data if the user
specified more than 1 AD field.
We were using the return value of ad_init() to set the number
of AD fields. This did not take into account the number of
existing data fields. By chance this usually returned 1.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
In case a TCP connection should be established with a specific source
IP address (e.g., by calling bind() prior to connect() on the socket),
we have to actually place the address in the outgoing packet.
Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
To prevent failure stopping a ticker node after starting it within the
same ticker_job execution (queued operations), defer the stopping until
after start. This will sequence the operations correctly and prevent
failures.
Signed-off-by: Morten Priess <mtpr@oticon.com>
For config CONFIG_BT_CTLR_CONN_ISO_RELIABILITY_POLICY, set
CIG_Sync_Delay fixed as high as possible, and calculate FT by iteration.
This favors utilizing as much as possible of the Max_Transport_latency,
and spreads out payloads over multiple CIS events (if necessary).
Add exit with cleanup as ll_cig_parameters_commit may fail after
creating new CIG/CIS instances.
Fixes issue #59605.
Fixes EBQ test HCI/CIS/BI-12-C.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Convert the ISO-TP SF length check in send_sf() from __ASSERT() to a
runtime check.
Fixes: #61501
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
There is no reason why the capabilities
should be modified by the stack after registration,
nor any reason why a the unicast client application
needs to modify the reported remote capabilities, so
all have been marked as const.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Refactor the bt_audio_codec_cap to use flat arrays to store
metadata and codec specific capabilities.
The purpose of this is to make it easier to copy the data
between layers, but also to support non-LTV data for non-LC3
codec capabilities.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds refactor of bt_vocs object that is common interface for client
and server commands. As the bt_vocs_client is significantly larger than
bt_vocs_server the memory usage is not optimized when bt_vocs has an
union of those. Thus RAM consumption has been minimized by using
CONTAINER_OF macro to reference either to bt_vocs_client or
bt_vocs_server instance that bt_vocs is a member of.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The VOCS API uses `bt_vocs` object to reference both client and server
instance. This adds missing instance type checks to avoid invalid API
usage.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When settings_load() is not called from system workqueue, but still
called from a cooperative thread, rescheduling during the settings
loading can wake up system workqueue and try to register the Mesh
Proxy Service, which can not be allowed yet. This is the case for bsim
tests.
Postpone registering the service with some small timeout.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This fixes possible buffer overflow that may happen when `buf->len`
equals `buf->size` while adding null terminator.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The font existence is checked at the time of linking,
The check at initialization is no longer necessary.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
According to section 4.2.2.4, Compositiion Data page 128 shall be
present if the node supports Remote Provisioning Server (section
4.2.2.4).
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
According to sections 7.2.2.2.4 and 7.2.2.2.5 of MshPRTd1.1v20,
when starting Private Node Identity or Private Network Identity, the
node shall use either RPA or NRPA and the advertising address. The
address shall be regenerated when Random field is regenerated.
Use BT_LE_ADV_OPT_USE_NRPA options to make advertiser generate and use
NRPA on every start of advertising Private Node Identity or Private
Network Identity.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This removes the scanning and PA sync capabilities from the
broadcast sink implementation, moving the responsibility of this
to the application layer.
The reason for this is to add more flexibility and choice to the
upper layers, while simplifying the Broadcast Sink implementation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The broadcast sink scan API is no longer used by the BAP
shell, which handles everything related to PA sync and scan
itself now.
It has also been made easier to sync to a broadcast
source by simply using create_broadcast_sink.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for selecting a periodic advertising
sync object for use. This will also be available outside
the scope of bt.c via the extern declaration.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixes a race condition that could occur if the TX queue was read out
before iso_has_ts was set. In that case, the provided buffer is of
wrong length.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This fixes return error from notify_cb function that was never set up.
As the result, the functions like bt_gatt_notify_cb and bt_gatt_indicate
returned invalid error when failed to send notification.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Looking back at the current INPUT_LISTENER_CB_DEFINE api naming, it
feels like it's a bit overloaded. Rename it to a simpler
INPUT_CALLBACK_DEFINE.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
There are some calls to ull_adv_aux_pdu_set_clear that are set to 0
but the argument is actually unsigned. This PR replaces the '0'
with '0U'
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Remove the shadowing ret variable and fix a bug that was related to
its existence - the shadowing ret variable was assigned with -ETIMEDOUT
which was supposed to be retuned by the function, but was not because
the ret variable at the function scope was left intact.
Also remove the unneded goto unlock; jump (assigning the error code is
the last operation before unlocking the mutex anyway).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This fixes 3 issues that came within PR #59124 for ppp uart usage.
Earlier start/stop of ppp was done at enable() but that
was removed in PR #59124. Now putting enable/disable() back and
putting start/stop there.
Additionally, there was a double ppp carrier ON when NET_EVENT_IF_DOWN.
For that net_if_carrier_on/off is set in uart ppp.c driver.
Also, maybe worth to be mentioned that after PR #59124 there is no
ppp carrier off when lcp is disconnected, for workaround that change,
application should use ppp dead/running events.
Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
When a thread is preempted on ARC, caller-saved registers
are saved on the stack automatically (RIRQ) or manually
by the kernel ISR (FIRQ).
Exposing the thread's relinquish cause hints the debugger
that it can read more or less register values.
Signed-off-by: Bruno Mendes <bd_mendes@outlook.com>
The OP_AGG_SRV is dependent that the OP_AGG_CLI is add
for the OP_AGG_SRV to work. Moved the define of OP_AGG_CLI
so it will call op_agg_send without the OP_AGG_CLI.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
The call to metadata-encode call in code and documentation
does does not match. Because the shell call in the documentation
looks correct the shell call in the code has been changed by
removeing the double metadata request.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Flaky tests give innacurate test summary indicating a misleading
passing test suite. Add new status for flaky tests.
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
First implementation had a math error where the offset would be the
remainder from division (modulo). It should have been an ISO interval
minus the remainder. Refactored to not use modulo.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fixes a coverity-reported issue by explicitly ignoring the return value
of the cas-operation. The return value is the old value, but we are not
interested in it in the situation when we just want to initialize a
value if it is in the uninitialized state.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/60474
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
In certain scenarios, the semaphore sem_ticker_api_cb may be taken
during attempt to complete a synchronous ticker operation such as start
or stop, but is never released via ull_ticker_status_give. This could
happen if ticker temporarily runs out of ticker operation slots for any
ticker client.
The consequence of ULL stuck waiting in semaphore is anything from
allocation assertions to watchdog timeouts.
This commit also sets a timeout on ull_disable calls, which relies on
the disable callback being invoked from 'done'. Invocation of 'done' is
mandatory, and code shall not allow that not to happen, but to avoid
hiding the real cause, the semaphore now has a timeout which causes
assertion in the location the issue occurred.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Check mayfly_is_running() to determine use of blocking- or non-blocking
version of lll_csrand, instead of k_is_in_isr().
As mayflies run in ISR context for Nordic platform, change will have no
impact on Nordic configuration.
For vendors using META_IRQ mayflies, implementation will now prevent
blocking and reduce latencies and jitter in soft-realtime code.
Signed-off-by: Morten Priess <mtpr@oticon.com>
dev_id is used as a pointer at the end of the call chain, so passing it
as an int makes no sense and can cause crashes if the pointer and int
types have different sizes. For example, if we have 64-bit pointers on
a board, the higher part of dev_id will be removed due to an type cast.
Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
Updates NET_SOCKETS_TLS_MAX_APP_PROTOCOLS Kconfig option description to use
DTLS instead of DTL.
Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
* 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>
At the moment, NET_EVENT_IPV6_PREFIX_ADD and NET_EVENT_IPV6_PREFIX_DEL
events provide provide information about an address without its length
and lifetime.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
Fixes several minor display errors in the Segger SystemView output:
* Off-by-one error in some trace ids.
* Add missing syscall trace id.
* Displays easier to read syscall function names.
* Fixes syntax error in k_timer_start output.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Log transfer status and release transfer semaphore regardless if user
provided transfer completion callback or not. This fixes transfer slot
leak when transfer without callback completes.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Using a different channel for responding to a request is forbidden by spec.
The allocator was especially flawed as it iterated over all the EATT
channels to find one w/ a big enough MTU, but the sending was still done
over the same channel as the REQ.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This to ensure we don't fail to send a response and never get an ATT
TIMEOUT due to ACL TX buffer starvation caused by other users of the stack.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The ATT module has provisions to queue a packet/buffer for sending later if
it can't send it right away. For example if the conn.c tx context
allocation fails.
This unfortunately doesn't work if the buffer can't get allocated in the
first place, or if the ATT metadata can't also be allocated.
The metadata is allocated from a global pool set to the same number as
conn.c TX contexts. That can lead to a situation where other users of ATT
manage to queue a bunch of buffers (e.g. the app spamming GATT
notifications), depleting the number of ATT metadata slots so that none are
available.
When none are available, and we receive an ATT REQ, we try to allocate one,
fail, and drop the buffer (!). That pretty much guarantees an ATT timeout.
As a workaround for this, use a per-channel metadata slot, that is only
used for completing transactions.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This is useful in multilink scenarios, especially since there is not user
callback when the ATT channel times out.
Adding a user-facing callback should ideally also be done, but just logging
the address already provides useful insight.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Easier to debug that way.
Ideally we'd have more error codes/logging instead of just returning
UNLIKELY for most errors.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
To allow insighed into the correct functioning of the collision avoidance,
log the internal values and function calls.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
To avoid a TCP connection from collapsing a link, implement a collision
avoidance algorithm. Initially TCP new Reno is implemented for its
simplicity.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Adds the force parameter to the reset command which is now
provided to the callback hook (if enabled).
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Uses the zcbor decode bulk function instead of manually parsing the
array in the function to reduce duplicated code.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Uses the zcbor decode bulk function instead of manually parsing the
array in the function to reduce duplicated code.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commits changes how data on the disk is accessed. There are disk
structures which are packed and their fields are stored in little endian
byte order. To use data in the program structures it has to be translated
from little endian to cpu endianness.
Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
- `ext2_file` and `ext2_dir` merged into one struct and allocated from
dedicated slab
- `ext2_inode` allocated from dedicated slab
- `ext2_disk_dentry` allocated from heap (because their size is not
constant)
- `ext2_bgroup` and `ext2_disk_superblock` statically allocated
Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
Fix the behavior when data should be written to storage device. Now all
writes are done directly to disk_access layer (where it might possibly
be cached).
Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
Added funtion that takes specified action when file system corruption is
detected. Possible actions are: do nothing, make mount point read-only,
panic.
Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
Changes:
- Added few assertions to check if some assumptions are correct
- Fix removing blocks during trucate and inode removal
- Clear entry in inode table after inode has been removed
Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
Changes:
- Add fs::sync function
- Make correct file system in mkfs
- Add few assertions to ensure that all assumptions are correct
Signed-off-by: Franciszek Zdobylak <fzdobylak@antmicro.com>
Flaky tests give innacurate test summary indicating a misleading
passing test suite. Add new status for flaky tests.
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
When a PAwR sync connects to a PAwR advertiser and CONFIG_BT_PRIVACY
is enabled a Resolvable Private Address will be used. Use that
as responder address instead of the identity address to match what
the central sees.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The separate done memq was introduced to handle the old LLCP
stalling processing of the rx queue; This is no longer an issue with
the new LLCP, so we can remove it
Signed-off-by: Troels Nilsson <trnn@demant.com>
Upon receiving a L2CAP PDU, only send credits back if the L2CAP channel
hasn't been disconnected. The recv() callback called from
l2cap_chan_le_recv() can trigger a disconnect, which would cause an
assert failure when attempting to send credits back.
Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
The PPP TX thread handles the transmission of packets at PPP layer.
Make it's priority configurable, so it's priority can be configured higher
then higher protocol layers.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
The TCP work queue is handles all TCP transmission and maintenance tasks.
Make it's priority configurable, so it can be configured to a lower
priority than the lower level network layers to avoid it consuming all
net_bufs before handing over execution to the lower layer network layers.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
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>
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>
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>
This fixes setting invalid List_Item_Length in Current Calls List.
The fix complements 9c7ef8e.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This was recently refactored (in #58440). But it introduced a bug in which
some channels were connected but not the whole list asked for by the peer.
In that case, `result` will not be `SUCCESS` but we still want to call the
`connected` callback as the peer will consider those channels to be
connected when we send the response.
The symptom is that EATT channels are being instantiated, but not
considered connected (ie. usable by the stack).
Also introduce a test that has asymmetric channel resources (5 on central
vs 2 on peripheral) to reproduce the bug.
Fixes#60212
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Make `bt_eatt_count()` return what it says on the tin, ie. the number of
channels that are actually connected.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
When the target board does not have heap by default, allows
statically reserving the space for required socketpairs.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Likely this trigger of the send_data_timer was an alternative for the
function that has been filled in by the ZWP transmission.
At the moment this timer has the potential to cause spurious
retransmissions that can degrade the throughput of the network stack.
Second to that it can accelerate the retransmission process, quickly
running to the number of retransmissions, causing a connection failure.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Add support for setting advanced broadcast ISO parameters
using the ISO test commands. This allows the host to set
ISO parameters that the controller normally would handle.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for setting advanced unicast ISO parameters
using the ISO test commands. This allows the host to
set ISO parameters that the controller normally would
handle.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixes an issue whereby the data packets were not checked to ensure
that the client has not attempted to write more data than the size
that was provided in the original upload packet.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes an issue whereby upload image size would not be checked in
the first packet of an upload, which would allow an image to be
uploaded until it reached the point of it being too large to
fit anymore.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
At any ack, the retransmission timer was cancelled. This means when an ACK
is only partially acknowledging pending data, followed by a packet loss,
the connection ended in a deadlock eventually timing out.
By checking if there is any pending data for transmission before canceling
the retransmission timer, there is no risk of this lock-up any more.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Nordic Semiconductor has been testing the feature extensively on its CI.
The tests includes the sample data and the PTS tests.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
It would be strange to enforce padding for other bus participants but not
use it yourself. This default suggests the likely proper usage, although
it is not a hard dependency
Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
ISOTP_ENABLE_TX_PADDING makes the device transmit frames with TX padding.
ISOTP_REQUIRE_RX_PADDING ensures other devices on the bus use TX padding,
by rejecting non-padded RX frames
Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
The IEEE 802.15.4 API and networking subsystem were using several
inconsistent timestamp resolutions and types. This change defines all
timestamps with nanosecond resolution and reduces the number of
available types to represent timestamps to two:
* `struct net_ptp_time` for PTP timestamps
* `net_time_t` for all other high resolution timestamps
All timestamps (including PTP timestamps) are now referred to a
"virtual" local network subsystem clock source based on the well-defined
types above. It is the responsibility of network subsystem L2/driver
implementations (notably Ethernet and IEEE 802.15.4 L2 stacks) to ensure
consistency of all timestamps and radio timer values exposed by the
driver API to such a network subsystem uptime reference clock
independent of internal implementation details.
The "virtual" network clock source may be implemented based on arbitrary
hardware peripherals (e.g. a coarse low power RTC counter during sleep
time plus a high resolution/high precision radio timer while receiving
or sending). Such implementation details must be hidden from API
clients, as if the driver used a single high resolution clock source
instead.
For IEEE 802.15.4, whenever timestamps refer to packet send or receive
times, they are measured when the end of the IEEE 802.15.4 SFD (message
timestamp point) is present at the local antenna (reference plane).
Due to its limited range of ~290 years, net_time_t timestamps (and
therefore net_pkt timestamps and times) must not be used to represent
absolute points in time referred to an external epoch independent of
system uptime (e.g. UTC, TAI, PTP, NTP, ...).
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The usb_msc.h header does not provide any API. The content is only
used by the MSC implementation for the current USB device stack and
is not required for any use of MSC by the application.
The content has no proper namespace and must not be reused for
anything else in (new) USB support.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
MCUmgr client basic implementation for support Image and OS grpup
commands.
Image Group:
* Image state read/write
* Image Upload secondary slot
* Image Erase secondary slot
OS group:
* Reset
* Echo service, disabled by default
Opeartion's are blocked call and cant't call inside worker queue.
IMG and OS need to be SMP client object for transport.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
SMP client support for generate request and handling
response message.
Updated SMP transport for send request.
Added API for register SMP transport.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
These configs are very tied to the BT_LL_SW_SPLIT implementation,
so it makes sense that these are only visible when that link layer is
used.
For the ones that may be used by other controllers in the future,
a dependency has been added.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Truncation of advertising data has to be done at a PDU
boundary; Including only part of a PDUs advertising data is
not allowed
Signed-off-by: Troels Nilsson <trnn@demant.com>
If the aux scanner already has CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX
advertising data, there is no point in following an aux ptr -
instead flush the data and produce an incomplete report
Signed-off-by: Troels Nilsson <trnn@demant.com>
In some platforms it may be desirable to disable certain CPU power
states, for example, because they have extra requirements not available
on all boards/applications. Because `cpu-power-states` are defined at
SoC dts file levels, the only way to achieve that now was by re-defining
`cpu-power-states` property in e.g. a board file. With this patch, one
can now selectively set `status = "disabled";` to any power state and it
will be skipped by the PM subsystem.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
pm_device_runtime_get() uses a semaphore to protect resources.
pm_device_runtime_get() blocked forever until obtaining the lock, making
it unusable from contexts where blocking is not allowed, e.g. ISRs. With
this patch, we give the chance to use the function from an ISR by not
waiting on the lock and returning -EWOULDBLOCK instead. If device is
suspending (from a previous put_async() operation) the same value is
returned as we can't wait either.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Effectively, this option changes code triple in device descriptor.
Although the name is misleading, renaming it would again lead
to negative user experiences. Instead, clarify what the option does
and always select it where it is required.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Uses the MCUboot bootutil image.h file directly instead of an
outdated copy which resides in the zephyr tree.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds a helper function for initializing devices into the expected power
state, through the devices `pm_device_action_cb_t`. This eliminates code
duplication between the init functions and the PM callback.
The expected device states in order of priority are:
* No power applied to device, `OFF`
* `zephyr,pm-device-runtime-auto` enabled, `SUSPEND`
* Otherwise, `ACTIVE`
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add new net_if API functions which allow to loop over all valid
IPv4/IPv6 addresses assigned to the interface and execute a callback
function on them.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When parsing user input for "wifi connect" and "wifi ap enable"
commands, the SSID and PSK lengths were not verified. It's better to
detect invalid connect/AP enable parameters early, so that help text can
be printed, instead of letting wifi_mgmt command to fail.
For WIFI_SECURITY_TYPE_SAE, follow the Linux convention of limiting the
size to 128 bytes.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Some DHCPv4 servers do not respect BROADCAST flag set on DHCP Discover,
replying with unicast packet, making it impossible to obtain DHCP
address by Zephyr in such cases.
RFC1542 chapter 3.1.1 makes the following statement about the BROADCAST
flag:
This addition to the protocol is a workaround for old host
implementations. Such implementations SHOULD be modified so
that they may receive unicast BOOTREPLY messages, thus making
use of this workaround unnecessary. In general, the use of
this mechanism is discouraged.
Making it clear that being able to process unicast replies from the DHCP
server is not only an optional behavior, but a recommended solution.
Therefore, introduce a support for unicast DHCPv4 in Zephyr. To achieve
this, add additional filtering rule at the IPv4 level - in case DHCPv4
is enabled, there is an active query and the packet is destined for the
DHCPv4 module, let it through for the DHCPv4 module to process,
regardless of the destination IP address.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Allows the application to force the use of an NRPA.
This is applied regardless of any other roles running (ie scanner) or
advertising type.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Increaing mesh scan window in order to reduce the number
of messages colliding into scan window end which happens
every 30ms currently. Increasing the window to 3000ms in
order to improve performance.
Keeping 30ms window only for legacy advertiser support.
Signed-off-by: Alperen Sener <alperen.sener@nordicsemi.no>
When copying parameters into payload buffer, it is possible
that after copying a string over, the pointer to buffer is
no longer aligned on 4 or 8 bytes. And some toolchains may
decide to treat the copy as aligned since the values being
copied are 4 or 8 bytes. This results in unaligned memory
access and hardware exception. So change the copy to memcpy
to avoid potential unaligned access.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The `attr_get` method is added to the ieee802154_radio to allow
reading of driver specific attributes of given device.
The enum `ieee802154_attr` provides common extension pattern
allowing to extend the attribute set.
Accessor function `ieee802154_radio_attr_get` is provided.
Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
Adds a helper function for initializing devices into the expected power
state, through the devices `pm_device_action_cb_t`. This eliminates code
duplication between the init functions and the PM callback.
The expected device states in order of priority are:
* No power applied to device, `OFF`
* `zephyr,pm-device-runtime-auto` enabled, `SUSPEND`
* Otherwise, `ACTIVE`
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The initial goal was to remove sys_clock_timeout_end_calc(). However,
several related issues have been fixed as well.
First this:
int64_t print_interval = sys_clock_timeout_end_calc(K_SECONDS(1));
/* Print log every seconds */
int64_t print_info = print_interval - k_uptime_ticks();
if (print_info <= 0) {
[...]
}
The above condition will simply never be true.
Then there is lots of back-and-forth time conversions using expensive
base-10 divisions for each loop iterations which is likely to impact
performance.
Let's do the time conversion only once outside the loop and track
everything in terms of ticks within the loop. Also the various timeouts
are open-coded based on the absolute uptime tick so to sample it only
once per round. Using sys_timepoint_calc() and sys_timepoint_timeout()
would have introduced additional uptime tick sampling which implies the
overhead of a downstream lock each time for no gain. For those reasons,
open coding those timeouts bears more benefits in this particular case
compared to using the timepoint API.
Then this:
secs = k_ticks_to_ms_ceil32(loop_time) / 1000U;
usecs = k_ticks_to_us_ceil32(loop_time) - secs * USEC_PER_SEC;
The above should round down not up to work accurately. And the usecs
value will become garbage past 1.2 hour of runtime due to overflows.
And no need to clamp the wait period which is on the microsec scale
using the total duration argument being on the millisec scale. That's
yet more loop overhead that can be omitted. The actual duration is
recorded at the end anyway.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This is meant as a substitute for sys_clock_timeout_end_calc()
Current sys_clock_timeout_end_calc() usage opens up many bug
possibilities due to the actual timeout evaluation's open-coded nature.
Issue ##50611 is one example.
- Some users store the returned value in a signed variable, others in
an unsigned one, making the comparison with UINT64_MAX (corresponding
to K_FOREVER) wrong in the signed case.
- Some users compute the difference and store that in a signed variable
to compare against 0 which still doesn't work with K_FOREVER. And when
this difference is used as a timeout argument then the K_FOREVER
nature of the timeout is lost.
- Some users complexify their code by special-casing K_NO_WAIT and
K_FOREVER inline which is bad for both code readability and binary
size.
Let's introduce a better abstraction to deal with absolute timepoints
with an opaque type to be used with a well-defined API.
The word "timeout" was avoided in the naming on purpose as the timeout
namespace is quite crowded already and it is preferable to make a
distinction between relative time periods (timeouts) and absolute time
values (timepoints).
A few stacks are also adjusted as they were too tight on X86.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This fixes missing `static` function specifier.
The bt_att_chan_create_pdu is not called outside of att.c.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Updates the handling of incoming seg ack messages to comply with
the mesh protocol specification, section 3.5.3.3.2 and section
3.5.3.3.3.
Previous implementation did not restart the retransmission timer unless
the incoming ack contained at least one segment newly marked as
acknowledged. According to the spec, the timer should be restated
regardless. The implementation depends on the retransmission
timer to end the transmission early if there was no more retransmission
attempts. Checks have been added to ensure that this now happens
immediately.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
In discover_next_instance coverity did not consider the
ASSERT and warns about possibly dereferecing current_inst
which could be NULL. Modifed the code slightly to make
Coverity happy.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds an optional callback upon image data being written, can be
used for syncing or timeout purposes.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Associate command handler did not validate the provided address length.
In result, if provided address string was longer than the expected
extended address size, strncpy() would not NULL terminate the buffer,
which could lead to unexpected behavior in parse_extended_address(), as
it expects NULL terminated string.
Fix this by validating the length of the provided address string before
parsing.
Additionally, make parse_extended_address() return the parsing result,
so that it can be detected when provided extended address has incorrect
format.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The Codec Specific Configuration Parameters provided by server was
not copied at bt_ascs_config_ase. Detected by PTS in BAP/USR/SCC PTS
test cases, because no LTV values appeared in ASE Codec Configured
notification.
Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
Replaces the manual lookup function with a lookup function which
is provided when registering MCUmgr handlers which can be used to
find the function to translate error codes, allowing out of tree
MCUmgr handlers to provide error translation handlers.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Any system supporting PM must now implement
pm_state_set/pm_exit_post_ops. Before this change any platform could
enable CONFIG_PM=y, even though it did nothing, ie, no power savings at
all.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Add a new Kconfig option that has to be selected by SoCs providing PM
hooks. This option will be now required to enable CONFIG_PM. Before this
change, CONFIG_PM could always be enabled, regardless of SoC providing
any kind of low-power support.
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Linuxptp report UTC offset is 9472 seconds, is a byte order issue,
The right value is 37. Also fixed offset_scaled_log_var byte order.
Signed-off-by: Chen Caidy <chen@caidy.cc>
According to IEEE802.1AS Table 11-6 and 10.6.2.2.9,
802.1AS using peer-to-peer delay mechanism, two-step clock,
Grand master clock should keep this correction_field as zero.
Signed-off-by: Chen Caidy <chen@caidy.cc>
According to IEEE802.1AS 11.4.4.2.1, we need fill
preciseOriginTimestamp as syncEventEgressTimestamp.
In this follow_up message, prec_orig_ts need to filled
from net_pkt_timestamp(sync) for best accuracy. state machine
is software trigger with insufficient precision.
After this change, a grand master endpoint sync accuracy
increase from 3.5ms to 580ns with mimxrt1050_evk board.
Signed-off-by: Chen Caidy <chen@caidy.cc>
Updated SAR default values to align with the latest mesh 1.1 drafts,
and relevant Bsim tests.
Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
When enabling thread analyzer, use printk by default. Otherwise logging
subsystem is enabled which might not be desired.
Fixes#59919
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Every USB device must buffer isochronous data for at least 1 frame in
order to remove packet jitter within a frame. USB Specification Revision
2.0 describes necessary buffering in 5.12.5 Data Prebuffering. USB Audio
1.0 specification mentions buffering in 3.4 Inter Channel Synchronization.
Set bDelay to 1 instead of 0, because bDelay 1 is both the minimum
allowed value and matches the actual device behavior.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Modified bt_cap_stream_ops_register to always register BAP callbacks
to ensure that the callbacks are always forwarded (unless later
overwritten by the application...)
The CAP Initiator Unicast will still register the callbacks itself,
to ensure that the unicast procedures still work even if
bt_cap_stream_ops_register was never called.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When a CIS is established for the peripheral, then not all
QOS values are completely valid as they are simply missing
from the CIS established event. This commit updates the
missing fields based on the QOS settings provided by the
BAP Unicast Client during QoS Configuration of the endpoint.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When initializing emulators for devices registered on an emulated bus,
Zephyr will assert if a matching emulator for the device cannot be
found. This feels overly restrictive --there may be cases where we still
want to build a driver for testing even without an emulator and drivers
should be able to handle situations where there is no device emulator
present (the I2C/SPI transactions will simply fail and the driver never
becomes ready).
This commit removes the assert and replaces it with an warning message if
no matching emulator is found.
Signed-off-by: Tristan Honscheid <honscheid@google.com>
This intoduces dedicated Kconfig option to enable TBS client,
that makes the configuration more intuitive.
While configuring GTBS only, the user does not have to explicitly set
the BT_TBS_CLIENT_MAX_TBS_INSTANCES to 0 to disable the TBS client
functionality.
This adds also `tbs_only_client` test case to test the TBS only build
option.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This improves the code readability and reduces flash usage a bit by
spliting up GTBS from other TBS instances in bt_tbs_server_inst
structure, so that some of the code could be conditionally compiled
out.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds handling of ASE control point operations in separate thread
so that the notifications of ASE state changes are sent from non-BT
thread. This ensures bt_gatt_notify_cb to be blocking waiting for
available buffers to send the notifications.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This patchset is doing three things:
1. It is fixing the bogus algorithm to find the optimal number of
descriptors for a given memory size.
2. It is changing values for VDEV_STATUS_SIZE and
IPC_SERVICE_STATIC_VRINGS_ALIGNMENT to better align to a usual cache
line size.
3. RX/TX VRINGs are now correctly aligned to MEM_ALIGNMENT (and cache
line alignment).
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Add CAP shell commands for starting specific audio configurations
based on the BAP specification.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit adds missing tx power config options for nRF53x SoCs, as
well as the missing Radio defines for nRF53x SoCs.
Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
Use the macro to print to handle for cases where shell context is NULL,
this is possible because in this net management event handler shell
context is not passed.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Adds callback API for the following config client status messages:
- Composition data status
- Model publication status
- SIG model subscription list
- Vendor model subscription list
- Netkey list
- Appkey list
- SIG model app list
- Vendor model app list
- Key refresh status
- Heartbeat publication status
- Heartbeat subscription status
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
The BAP stream object should not have a dir field. The
dir field should be stored in the EP only (to avoid having two
fields storing the same value, causing possible issues).
The field was removed, and the places that use it has been updated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for transmitting on multiple streams, e.g.
with the simple `send` command or with the sine generator.
This extends the start and stop sine to take a "all"
paramter to start sending on all streams.
This also fixes an issue with the seq_num when multiple
streams are transmitting, since the timing may get delayed
which then delays the seq_num which are then scheduled too late.
The fix here is to only use the timer for the inital sequence
number when starting to send the sine way, and then increment it
per TX.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The commit fixes build issue when building for two application
images in board that does not have slot0_ns_partition.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fix conditional compilation within img_mgmt_get_other_slot,
where CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER has been
incorrectly checked and #endif incorrectly placed.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Some controllers support additional connection parameter ranges
beyond what is described in the specification. Enabling this new option
allows the application to set any value to all connection parameters.
Tbe Host will perform no limits nor consistency checks on any of the
connection parameters (conn interval min and max, latency and timeou).
However, the Host will still use numerical comparisons between the
min and max connection intervals in order to verify whether the
desired parameters have been established in the connection.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add a feature to suppress commands. The suppressed commands are not
logged on the command reception.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Statically created threads with K_THREAD_DEFINE() are launched only
after the SYS_INIT phase. This does not play well with NET_CONFIG
library, which may block during SYS_INIT until network interface
is UP and RUNNING.
In order to be able to connect to L2 network and thus mark the
network interface as running and unblock NET_CONFIG, we need to be
able to run conn_mgr thread during SYS_INIT. This can be achieved,
by starting the thread dynamically during SYS_INIT phase, instead
of relying on static thread creation.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
net_if_lock() should be called only after iface pointer is verified not
to be NULL, otherwise we can end up dereferencing NULL pointer in
certain corner cases.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When building with the native simulator instead of attempting to
call directly to the host libC, use the trampolines provided
by the runner.
In this way we can build this code even if we are building
Zephyr with an embedded C library.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Split this tracing backend in a top and bottom to enable
building it with embedded libCs with the native simulator.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This fixes invalid memset of QoS parameters that may happen if Config
Qos operation is requested on ASE in QoS Configured state. In such case
if the requested parameters have been rejected, the ASE QoS parameters
shall remain unchanged (were memset instead). Otherwise, the stack shall
send QoS Configured state notification with cleaned up parameters (all
zero's) which was not done.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The TLS credentials libraries are purely software constructs with no
external dependencies, run them immediately after the kernel setup to
allow other initialisation functions to add credentials without the
requirement to run in the back half of the `APPLICATION` priority.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Fixes erroneous packing/unpacking of model app list messages
in the configuration client and server. According to the mesh 1.1
protcol spec (4.3.1.1) two app indexes shall be packed in a 3 octet
interleaved format. The current implementation packs them in 4 octets.
This commit also provide a helper function for unpacking key indexes
as public API to facilitate future config model callback API.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Adds a comment stating the state of the peripheral SDU size
and why it is being assigned the PDU size on CIS established.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add two input subsystem options: one for dumping input events, one for
triggering input reports from the shell.
The two are independent from each other, so dumping can be enabled on
any application that has no shell, but if the shell command is present
logging can be toggled on and off with a shell command.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Changes the Kconfig option to allow disabling mutex support, this
is to allow other Kconfig options to disable the feature.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add a user possibility to set a callback for receiving a new function.
It allows instant performing some actions, that need to be done before
context switch.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Verify validity of a received command before passing it to the general
handler.
It allows performing some actions, right after receiving the command.
The context switch is not needed. Such feature may be needed for
overloaded system, where instant reboot is required.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Add a function to signal a new host command by a backend.
Use a function instead of giving semaphore, because it allows more
actions on rx event, common for all backends.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Add a config to save the final result of a last host command that has
sent EC_HOST_CMD_IN_PROGRESS response. To get the final result use the
ec_host_cmd_send_in_progress_status function.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
According spec, for the same iv index, iv update flag
should trans to false, when iv update procedure complete.
When local environment has attack-node
to store old network beacon(1,1), and re-send same
network beacon(1,1) after 192hours, will cause whole
bluetooth mesh network broke.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
OOB information should be in little endian in scan report messages.
URI hash should be retrieved as it is from unprovisioned device beacon
and encoded likewise into scan report messages like we do for UUID.
Signed-off-by: Alperen Sener <alperen.sener@nordicsemi.no>
This fixes possible ASE leak in bt_ascs_config_ase in case
ascs_ep_set_codec function returns an error.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This removes code duplicates.
ASE Disable operation handler has been refactored by providing the
`rsp` pointer as one of the function parameters. ascs_cp_rsp_add is
not called from ase_disable explicitly, so the contents of the
response buffer are not changed in case the ase_disable is called
from non control point context.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This removes code duplicates.
The ASE Release operation handler has been refactored by moving the state
validation check to the ase_release function body and providing the
`rsp` pointer that is later filled. ascs_cp_rsp_add is not called from
ase_release explicitly, so the contents of the respons buffer are not
changed in case the ase_release is called from non control point context
e.g. `disconnected` callback.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Check if a network interface is managed by a network manager before
falling back to offload API.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This introduces support for Wi-Fi network managers in Zephyr. The
motivation is for the Wi-Fi management layer to work with both
Network managers and offloaded Wi-Fi drivers. The device driver
decides which one to use.
network manager : Apps -> Wi-Fi Mgmt -> Network Manager -> Wi-Fi
interface
offloaded : Apps -> Wi-Fi Mgmt -> Wi-Fi offloaded interface
Support for multiple network managers has been added, each device can
choose its own network manager and there can be mix and match:
wlan0 - Offloaded
wlan1 - Network manager 1
wlan2 - Network manager 2
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Decouple interface and Wi-Fi APIs, Wi-Fi APIs are common independent of
Wi-Fi offload or implemented natively (This is preparation for
introducing Native Wi-Fi).
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
The management thread *barely* fits in 768 bytes of stack; when thread
local storage is in use and TLS variables are also allocated from the same
region, this stack can overflow.
Increase to 800 bytes to leave plenty of room for TLS variables.
Signed-off-by: Keith Packard <keithp@keithp.com>
Removes redundant ACK state from `struct ieee802154_context` and
simplifies the ACK procedure.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This change introduces test coverage for association request and
response. Based on this coverage, several closely related issues were
found in the association process which cannot be split into separate
changes without breaking the build.
Most notably did the associate and disassociate net_mgmt commands send
already encoded IEEE 802.15.4 MPDUs to L3 rather than L2. L3 treated
them as payload and made L2 wrap them with another LL header/footer
which produced invalid packets.
The tests also enforce better aligment of the association process with
the IEEE 802.15.4-2020 standard:
* Association requests now ask for ACK as required by the standard. The
fake driver was enhanced to produce ACK packages when requested.
* macPanId and macCoordinator* MAC PIB attributes are set in the right
order for improved filtering of association responses.
* The coordinator may decide not to assign a short address to the end
device even when associated. This is now supported.
* The coordinator may or may not use a short address. Coordinators
choosing not to support short addresses are now supported.
* Updating the association will now remove any previously added short
address from the hardware filter.
* The short address may no longer be changed by the user while
associated to a PAN. Only the coordinator is allowed to allocate short
addresses.
* Validation of outgoing and incoming association request/response
packets is improved.
All changes are documented by pointers into the spec.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Fixes an off-by-one bug in the parsing routine of the coordinator
address when associating via shell command.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Input validation of some of the IEEE 802.15.4 net_mgmt commands was
incomplete and/or inconsistent. This change introduces a consistent
approach to input validation that is easier to follow.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Calculates macResponseWaitTime and applies it to the association
process.
As the timing calculation re-uses symbol period calculations and other
PHY timing constants previously introduced, these are now shared as
utility functions.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The IEEE 802.15.4 stack defines radio API helpers that provide
simplified and encapsulated access to radio API features.
These helpers were missing the `_radio_` infix. This infix is introduced
to clearly distinguish between MAC and PHY concerns. While PHY features
may be shared between L2 implementations (including the functions
concerned here), this is not true for MAC features.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The IEEE 802.15.4-2020 standard introduces an association type field to
support fast association, see sections 6.4.3 and 7.5.2. We do not yet
implement fast association but we introduce the flag to make this
obvious.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Minor simplification in the definition of IEEE 802.15.4 Kconfig packet
fragmentation configuration.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The additional hooks provide infrastructure to construct
rules on another network stack levels. Main benefit of this
approach is packets are pre-parsed and e.g. IP filter is
easier to implement. These hooks are equivalent of prerouting
and local_in in linux's netfilter.
Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
Fixes an issue where a variable was used without being correctly
set by other parts of the code.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This moves copying of parameters after application return value
validation so that the metadata is not stored if rejected.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Merging the two structs cleans up significant amount of code
and makes it easier to expand later.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Previously the calculation of the PSN was done using
just a timer. This would not work correctly when
attempting to send multiple packets in a single SDU
interval (e.g. to enqueue 2 or more).
Previously we only ever attempted to send 1 packet in
the `sent` callback but scheduling the work item. However
in the case that the `sent` callback was called twice
before the work item had been triggered (possible due
to the priority of the RX thread being higher than the
system workqueue thread). This has been modified so that
if we can enqueue more packets in the lc3_audio_send_data
function, we re-enqueue the work item. We re-enqueue rather
than sending multiple in a single call to avoid blocking
other items on the system workqueue from being scheduled.
This could cause possible missed intervals (if other workqueue
items are processed), but it should be OK from a ISO perspective,
and the new PSN calculator handles this much better.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify lc3_audio_send_data to be triggered on a delayable
k_work so that we can retry it with a delay if it fails for whatever
reason.
This also moves the calculation of the seq_num closer
to when it is used, which makes sense as it is based on
a timed calculation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The current API for changing the bondable mode uses the global flag.
With Zephyr support for multiple Bluetooth identities, the API for
changing the bondable mode should be more fine-grained.
The bondable requirements of one identity should not have an impact on
another identity which can have a different set of requirements.
This change introduces function to overlay bondable flag per
connection.
Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
Current structure of Bluetooth Mesh Kconfig options is quite messy.
This makes impossible to understand which configuration belongs to
which feature. Especially when using interactive Kconfig interface, like
menuconfig or guiconfig.
This commit restructures the options grouping them by protocol layer
they belong to (Network, Transport, Access, etc.), or specific feature
(LPN, Friend, Proxy, Relay, etc.), or implementation (Advertiser, Shell,
Persistent storage). Amount of supported keys, subnets, group addresses
and labels are grouped under Capabilities menu. Generic options that
don't fall to any category are kept at the root menu. For better
visibility, if a specific feature or layer has more than 1 option, they
are hidden under menu.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The sizeof is used in a wrong way which causes incorrect checking a
version of a command. Use NUM_BITS instead.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
The response buffer has to be cleared every command not to pass
unintended content e.g. response from a previous command, or stack
content.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Update the response buffer size, passed to a command handler, every
command, since a backend could change it in runtime.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
PR adds the statistic module to estimate frame handling.
The module helps to understand the ratio of
the received\relayed\dropped\transmited frames.
That shows the efficiency of the current configuration\implementation.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The broadcast_id and the pa_sync fields should be set before calling
broadcast_sink_add_src as broadcast_sink_add_src will those values to
compare against other receive states.
The function was also missing a call to broadcast_sink_cleanup
for the newly allocated sink in case there was an error.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The CIG state variable is set to CIG_STATE_CONFIGURABLE, but then
cleared by memcpy from configuration cache. Set state after memcpy.
Fixes EBQ test /HCI/CIS/BI-10-C.
Signed-off-by: Morten Priess <mtpr@oticon.com>
In the case where memq_deinit in LLL flushing ends up with the free
link being the link provided by the CIS instance, and pointed to by
lll.link_tx_free, the free counter data in the link element is
overwritten during central CIS creation.
This has the effect that when starting the next CIG, there will suddenly
be 0 links available, and controller fails assertion.
By saving- and restoring the lll.link_tx before and after CIS
configuration cache copying, the free counter is intact.
Signed-off-by: Morten Priess <mtpr@oticon.com>
An advertising report must not be generated unless the AUX_ADV_IND
has been received (for ADV_EXT_IND with an auxptr)
Signed-off-by: Troels Nilsson <trnn@demant.com>
Use CONFIG_BT_CTLR_PHY_CODED to flag out coded phy code
Don't schedule a scan for coded phy when it is not supported
Signed-off-by: Troels Nilsson <trnn@demant.com>
When a stream leaves the streaming state the `stopped` callback
will now be called, similar to how the `started` callback works.
This ensures that `stopped` is always called and not just when
the CIS disconnects.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
So they depend or select on the right NATIVE_BUILD
instead of NATIVE_APPLICATION.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
parse_number() helper function accepts long * pointer or the output,
however in several places, an address of a variable of incompatible
type was passed to the function (for example an address of a bool
variable was cast to (long *) and provided to the function). This
could cause memory overwrites or other unexpected behaviour.
Fix this, by defining a helper variable of type long, and use it with
the parse_number() function. Only after successful parsing, the value is
then assigned to the proper destination.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
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>
The enum used for connection types gets named bt_conn_type to guard
against accidental usage of generic integers with relation to it.
The added default case in several switch statements avoids warnings
against unhandled enum values.
Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
Fail gracefully if an HCI event of one type arrives for a handle of a
different connection type. The requested types are currently based on
what fields are used, not on the usage context, in order to keep every
correct use so far still working.
A warning is logged if the connection identified by the handle does not
match the requested connection type.
Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
The "virtio_" prefix is used by the open-amp library API.
Rename local functions using "ipc_virtio_" prefix to avoid
function redefinition.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Instead of waiting for ase_buf to be available, the read of an
ASE in IDLE state can be handled without using ase_buf.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes missing control point status and ASE status change, when
failed to disconnect the CIS. As the server may, but does not have to
disconnect the CIS, the operation should not be considered as failed
when it happens.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
PR instantiates cdb and core keys to prevent scenario
when key is changed over cdb API and gets new ID but
core still operates with old ID(potentially invalid).
Known issue the keys will be desynchronized
during\after key refresh procedure.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
This commits eliminates the old way of
pacs notifications, replacing k_work with
simple bt_gatt_notify.
Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
When doing the bt_ots_dir_list_reset_anchor we now explicitly ignore
the return value of bt_gatt_ots_obj_manager_first_obj_get
to fix a coverity issue.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Cast ticker_stop() calls to void where return value is not checked.
This is to satisfy coverity and indicate that return value is not
important.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
This change replaces one letter variable names with considerable
variable spans by much more readable alternatives that ease code
maintenance and help human reviewers to catch semantic errors.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The f_ctx variable renamed in this change has a considerable variable
span. This makes the code hard to read as the variable name is neither
defined in the IEEE 802.15.4 standard nor can it be deduced from the
variable name.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The 'ar' abbreviation has a well defined meaning in IEEE 802.15.4 which
is NOT the meaning of the local "ar" variable being renamed in this
change (see the comparison to the actual MHR ar field in this change
set).
To avoid confusion, a non-abbreviated variable name is introduced
instead.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The 'af' abbreviation is nowhere standardized in IEEE 802.15.4 and makes
the source code unnecessarily hard to read. It is replaced by a readable
long name.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Several distinct naming conventions existed within the IEEE 802.15.4
stack wrt header length. This change converges to a single naming
convention, the one that is less ambiguous and already most used.
The change also makes the distinction between L2 (link layer/LL) header
length and 6LoWPAN fragmentation header length to avoid confusion.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This change is in preparation for the newer frame version's more
complex compression algorithm that may compress both, the source
and the destination PAN independently.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This change renames buf to pkt_buf in one very specific instance to
distinguish the packet buffer from the frame buffer which is kept in the
same local scope. In all other instances the meaning of "buf" should be
obvious from context, not so here, though
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The bt_csip_set_coordinator_csis_inst_by_handle did not check the input
parameters and could call lookup_instance_by_handle with handle == 0
which triggers an ASSERT.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If we are use the shell as a CAP initiator, then we need to
register the stream callbacks for the CAP streams as well, as
CAP will use the BAP callbacks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When populating the conns array in
bt_cap_initiator_codec_configured, coverity did not like just
having the __ASSERT, so modified the checks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When syncing via the broadcast sink or the scan delegator
it makes more sense to filter on duplicates, as the expected
data rarely changes.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The internval of how often we report
receive stats can now be configured via the cmd_recv_stats
command.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add more information when we print the recv every 100th
packet, and remove all per-recv printing.
This also resets all information on stream start. This does,
however, no properly support multiple streams.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The callback should not be modified by the stack,
and should thus be const.
Also fixes a missing include of conn.h.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
To further reduce the need for networking boilerplate in applications,
provide bulk versions of net_if_up, net_if_down, conn_mgr_if_connect,
and conn_mgr_if_disconnect that affect all available / eligible ifaces
at once.
Since it is not intuitive whether these functions should affect ifaces
which conn_mgr is ignoring, these functions take an argument that allows
this to be specified by the application.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
To reduce the amount of boiler-plate needed in applications, this commit
grants conn_mgr the ability to automatically take ifaces that have given
up on connecting into the admin-down state.
Tests adjusted as appropriate.
This behavior can be disabled globally by disabling
NET_CONNECTION_MANAGER_AUTO_IF_DOWN, or disabled per-iface using the
CONN_MGR_IF_NO_AUTO_DOWN flag.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
To reduce the need for boilerplate in application code, conn_mgr now
supports an auto-connect feature on all ifaces with connectivity
bindings.
conn_mgr will automatically call conn_mgr_if_connect on any iface with a
connectivity binding that enters the admin-up state, unless the newly
added CONN_MGR_IF_NO_AUTO_CONNECT flag has been set for that iface.
Also adjust automated tests to account for and take advantage of this
behavior.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
- Add missing event sleep after taking all ifaces up in
test_connect_disconnect.
- Add missing event sleep after resetting ifaces in conn_mgr_conn_before
- Fix typo in comment for internal state flags.
- Add missing NET_MGMT_EVENT_BIT to conn_mgr_connectivity event
definitions.
- Missing net_mgmt.h include in conn_mgr_connectivity.h
- Split conn_mgr_conn iface reset into network and state resets, before
and after event sleep, so that triggered events do not corrupt the
state reset.
- Reduce SIMULATED_EVENT_DELAY to 100ms to avoid timeouts on real-time
targets.
- Use macro for simulated event wait times.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
This restores a line of code that was accidentally deleted in
5580cb4391. This fixes an uninitialized
`le_addr` getting printed and producing garbage output in the scan
results.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Patch to rename struct bt_ots_init to struct bt_ots_init_param
to avoid duplicating the name bt_ots_init.
Fix for issue#45968
Signed-off-by: Jai Arora <infolinesoni@gmail.com>
Rename the bt_codec struct to bt_audio_codec_conf or
to the new struct bt_audio_codec_cap.
Rename the bt_codec_data to bt_audio_codec_data.
The purpose of this is to split the codec specific configuration
and codec capabilities into seperate structs, as they do not
reflect the same values, or used for the same purpose.
This commit depends on the preset macros workings on either
type of struct (for now), but will be modified in future updates.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Set default offloaded interface during net_context_get() call, so that
net_context_recv() can be called before net_context_connect(). There is
already an assumption about using default network interface, so this should
not be harmful.
Fixes: 2c75070360 ("net: sockets: tcp: Fix possible race between
connect/recv")
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
This fixes metadata length checks for BT_AUDIO_METADATA_TYPE_EXTENDED
and BT_AUDIO_METADATA_TYPE_VENDOR that should be at least 2 bytes long.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The CCID list can be empty, as the Assigned Numbers is not strict
regarding it's minimum length.
Fixes: #59666
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes missing drop of ISO Data PDUs received in non-streaming state.
The client shall indicate first it's readiness to receive the ISO Data.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes missing drop of ISO Data PDUs received in non-streaming state.
The server shall indicate first it's readiness to receive the ISO Data
by calling bt_bap_stream_start that triggers state transition from
Enabling to Streaming state.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add check for CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 1 before
comparing inst_cnt, as otherwise it was always false which
caused a coverity issue.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Default scan mode is Active. User can force the scan mode to passive
through Kconfig option or using 'passive' option from shell.
Using either of this option will override regulatory settings and
forces all scan channels to be passive only.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
The cmd_csip_set_coordinator_discover_members did not properly
handle the members_found and addr_found values.
It has been modified to run through all known values
before scanning, and set the value appropriately.
This also fixes a minor bug where err = 0 was missing.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add LL_ASSERT_OVERHEAD define to reuse the assertion check
related to increase in actual EVENT_OVERHEAD_START_US value.
Introduce Kconfig option to permit radio event be skipped
when increased prepare callback latencies are measured,
instead of assertion.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Connected ISO implementation to correctly handle SN,
NESN and payload_count when prepare callback is aborted due
to CPU overhead related latencies.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the EVENT_OVERHEAD_START_US verbose assertion to each
state/role LLL implementation so that correct state/role
that is delayed is conveyed in the assertion message.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add -ECANCELED on return from lll_preempt_calc so that
assert check can be placed in the prepare callbacks of the
state/role implementations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix to not use pre-programmed PPI when NRF_TIMER0 is not
used as the radio event timer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix CIS create implementation to consider CIG events with
laziness before the new CIS in an already active CIG is
made active.
Previous laziness value of the CIG events is determined and
at the CIG event where the new CIS event_count is calculated
the lazy_active value determined is decremented from the
total lazy value.
Without this fix, event_count of the new active CIS events
where incorrect, causing CIS create resulting in fail to be
established.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Since the acl mtu for mesh is reduced to 37 in PR #59004, there is no
need in BT_L2CAP_TX_MTU to be longer than 33 bytes for mesh.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
If disconnection has been triggered in between the security update and
the call to `smp_pairing_complete` we need to abort the pairing.
The disconnection may have been triggered by `bt_unpair`, in that case
the keys will have been erased and it will lead to an assertion to
continue as if nothing happened.
To resolve this issue, at the beginning of `smp_pairing_complete` the
`status` is set to `BT_SMP_ERR_UNSPECIFIED` if there is no connection.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
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>
Use only single thread for handling polling of the sockets.
Each client will have only 1 active socket which to poll.
Each client can have multiple simultaneous requests ongoing.
The client only has one buffer for receiving and one buffer for sending.
Therefore the messages are reformed when resending.
Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
Two different IPv6 addresses can have the same solicited node multicast
address, for example when they are derived from the same EUI-64
interface identifier during the auto-configuration process. For example,
an interface with a physical address 70:07:12:34:56:78 can have the
following:
- link-local address FE80::7207:12FF:FE34:5678
- global unicast address 2001🔢::7207:12FF:FE34:5678
Both addresses will have the same solicited-node multicast address
FF02::1:FF34:5678. Currently, if one removes the global unicast address,
the solicited-node multicast address is also removed, leaving the
link-local address out of the solicited-node multicast group. This
breaks some protocols like Neighbour Discovery.
Count how many times the solicited-node multicast address is used and
remove it only if it is not shared by any other unicast address.
Fixes#59683
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
First search for a match, then perform the removal outside the loop.
There is no functional change but this prepares for some future changes.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Move the creation of the multicast solicited node address outside the
loop. There is no functional change but it prepares for some future
changes.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Instead of setting the default_stream when we initiate
the configure operatio, we set it when it has succeded.
In case that the codec configure fails, the stream should
not really be considered configured as the default.
This also ensures that the default_stream is set when
using the CAP shell commands.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Currently, it is not possible to use hawkbit with code that requires
POSIX_API to be set due to the dependency on NET_SOCKETS_POSIX_NAMES.
Since a lot of other code has already been moved to `zsock_`, this
commit does the same for hawkbit.
Co-authored-by: rojedag <r.ojeda@vogl-electronic.com>
Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
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>
It may happen that CIS is scheduled in the future and did not started
yet once accepted. When ASE goes to Releasing state in such case
the ISO has to be disconnected, because otherwise ASE will stuck in
releasing state.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Since clear_lc3_sine_data references audio_send_work, it must
be declared before the clear_lc3_sine_data function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_bap_scan_delegator_find_state did not properly return the
correct receive state due to confusing return value of the
iterator function.
Modify it to use a simple bool.
This fixes all issues with "Failed to find receive state for sink"
when using the Broadcast Sink.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In the CSIP Set Coordinator verify_members we verify that
all members have unique ranks.
This was done as part of the initial loop, but it is
more efficient to do this as a separate loop as we can reduce
the number of items to compare, as well as guarding this properly
by !zero_rank.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixes 2 issues:
1) The broadcast code would only ever get the first value, even if
the command specified up to 16 values.
2) The broadcast code is not just hex values, so hex2bin does not make
sense, and strlen + memcpy is much simpler.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When the broadcast assistant have found the expected broadcast
source it should stop scanning.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The shell_print was meant to print the address of the broadcast
source along with the broadcast_id.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bad code field should only be printed when there is an actual
bad code, otherwise it just prints all-0s.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move BT_CTLR_SCAN_SYNC_ISO_SET to Kconfig from Kconfig.ll_sw_split
This means it can be used by other controllers and alligns with location
of other iso configs - e.g. BT_CTLR_SYNC_ISO_STREAM_COUNT
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
Add a native way to log Host Command communication.
Use Zephyr logging system to do it. Use debug and normal levels.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Use one common function to send Host Command response. It allows
handling all response types within one function.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Add a configuration option to set Wi-Fi as default interface and also
add an API to get first available Wi-Fi interface.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Identify the Wi-Fi capability to the networking stack and also the type
of Wi-Fi (Native vs Offloaded), this helps identifying Wi-Fi interfaces
that can be used by applications.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Wi-Fi is based on L2 Ethernet, so, all drivers are registered as
Ethernet L2, but in order to distinguish true Ethernet and Wi-Fi
devices, add a L2 type within Ethernet.
Also, handle offloaded net devices that also offload Wi-Fi.
This approach is better than adding a new Wi-Fi L2 as that would mean
invasive changes which are unnecessary.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
As per table 4.2 in BAP v1.0.1, the BAP unicast client shall
support at least 2 (> 1) endpoints in either direction if it
supports that direction.
Since Kconfig does not support such requirements (0 || > 1),
this is done using a BUILD_ASSERT.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
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>
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>
Most AP's are not sending proper HE triggers or stopping triggers after
sometime, so, change the default to non-triggered based TWT.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
If the remote responds with and security related error the stack tries
to increase the security level to satisfy the remote permissions.
This fixes missing ATT timer reset on security related ATT Error
Response as the ATT operation is considered as complete.
< ACL Data TX: Handle 0 flags 0x00 dlen 7
ATT: Read Request (0x0a) len 2
Handle: 0x0084
TMAS: Role
> ACL Data RX: Handle 0 flags 0x02 dlen 9
ATT: Error Response (0x01) len 4
Read Request (0x0a)
Handle: 0x0084
Error: Insufficient Authentication (0x05)
TMAS: Role
Error code: 0x05
< ACL Data TX: Handle 0 flags 0x00 dlen 6
SMP: Security Request (0x0b) len 1
Authentication requirement: Bonding, No MITM, SC, No Keypresses
= bt: bt_att: ATT Timeout
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
If connection reference is acquired from `bt_conn_lookup_addr_le` but
`bt_gatt_ccc_cfg_is_matching_conn` return false the connection was not
unreferenced properly. This commit fix the issue by unreferencing the
connection if the condition is false.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
This fixes notification callback that can be called with NULL conn
parameter when peer is being unpaired.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When writing a test suite, it's more common to want the 'before'
hook to run in privilaged mode, even when the test is run in userspace.
Reconfigure ztest to first run the test thread callback in privilaged
mode and only enter userspace after the test rule and suite's 'before'
functions ran.
Signed-off-by: Yuval Peress <peress@google.com>
The RTT backend of the shell does not support several of the more
advanced terminal features. This commit proposes to inactivate these
features by default when RTT is selected as shell backend.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
unpair may be called from bt_unpair where addr is NULL.
One such case is the `bt clear all` shell command which
calls bt_unpair with addr = NULL, and the addr is just forwarded
to unpair which does not check for NULL.
bt_unpair allows for the addr to be NULL to clear all, but only
if SMP is enabled.
Modified the checks in bt_unpair to increase readability
and ensure that unpair is not called with NULL.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Switch the driver to the soft CSMA/CA algorithm as an intermediate
compromise for improved standard compliance (namely expontential
backoff) until true hardware support can be implemented by chaining
radio commands.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The extra ztest functionality for the posix arch
requires the host libC. Disable it if we are
building with an embedded libC.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This fixes TMAS characteristic permissions.
The characteristic shall have no security related
permissions as per TMAP_v1.0.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
bt_mesh_elem_find can return NULL.
This also gets rid of VLA in bt_mesh_shell_mdl_print_all.
Coverity-CID: 321075
Fixes#59522
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
If the stream is stopped or released, we did not clear the
txing_stream which is what would stop the sine from being
attempted to being sent.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The seq_num in lc3_audio_send_data was updated twice:
Once when calling get_next_seq_num and once at the end
of the function.
This increased the sequence numbers too fast, and made
TX not worker properly.
Modified to only use get_next_seq_num.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In `gatt.c`, the function `bt_gatt_ccc_cfg_conn_lookup()` was not
checking that `conn` was not NULL. That leaded to a NULL pointer
dereferences later in `bt_conn_is_peer_addr_le`.
Fix by checking that `conn` is not NULL.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
When CONFIG_PM_DEVICE is enabled IPC Device may be during power transition
during a call to intel_adsp_ipc_send_message function.
Changed signatures of intel_adsp_ipc_send_message and its sync version
to return int and negative error codes on error.
On attempt to send IPC message during Device power transition
-ESHUTDOWN error code is returned, on busy state -EBUSY.
Updated all function references.
Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
If the procedure was called, we print a more specific string
to let the user know that there was not an actual issue.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In the case that the advertising data has both a device name
and a broadcast name, whichever one comes first will be used.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This code is meant to run in the context of a exception.
Most architectures will fail the asertion made in z_impl_k_sem_take()
when timeout is not K_NO_WAIT.
This commit ensures K_NO_WAIT is used when arch_is_in_isr() is true.
Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
Provisionee shall fail if provisioner sent public key
identicall to OOB public key back.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
If the address was removed immediately after being added (e.g. because the
interface MAC address is changed on boot), it would remain in the DAD timer
list.
In one scenario, the DAD timeout would eventually fire, causing the
now-removed address to be modified, potentially causing issues that way.
In another scenario, if the interface was immediately brought back up
again with a different link-local address, this new address would reuse the
first address slot on the interface. Starting the DAD process for this new
address would lead to the same address slot being added to the DAD timer
list a second time, causing an infinite list and associated lockup during
iteration.
Always remove the address from the DAD timer list when it is removed from
the interface, not just when DAD fails.
Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
This remanes send_buffer to tx_buffer to be
consistent with Rx buffer naming and with
mbox naming.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
This improves packet reception and fix an issue
where packets bigger than internal Rx buffer
were silently dropped. In current solution
local data coping for reception is not needed.
User gets direct pointer to shared memory which
allow to efficient receive as much data as was sent.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
Adds status checking to the command status hook which allows an
application to inspect a request and, optionally, reject it.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds an optional Kconfig that adds mutex locks to image management
group functions, this prevents collision between multiple threads
and/or transports.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
The `net_if` layer should not be forcing `NET_IF_LOWER_UP` to be set on
all interfaces at runtime. Because `net_init` runs relatively late by
default, this is overriding any control the driver itself may have
performed using `net_if_carrier_on/off`.
Initialise this bit at compile-time instead. As the structure is already
being initialised, this doesn't increase any footprints.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
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>
The loop was supposed to set the alert level to the highest
value by any device. The loop, however, only made sense if
CONFIG_BT_MAX_CONN > 1.
It has been modified to start from [0] instead of [1] and
the initial condition was modified.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new Kconfig parameter NET_CONFIG_MY_VLAN_ID as initial network
configuration to enable users to set VLAN identifier at startup.
Add a new setup_vlan(...) function to setup the VLAN identifier in
the device, the call have an effect only when NET_CONFIG_MY_VLAN_ID
is above zero.
Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Device dependencies are not always required, so make them optional via
CONFIG_DEVICE_DEPS. When enabled, the gen_device_deps script will run so
that dependencies are collected and part of the final image. Related
APIs will be also made available. Since device dependencies are used in
just a few places (power domains), disable the feature by default. When
not enabled, a second linking pass will not be required.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The option can now be set by projects. This change will also allow to
make it dependent on a future CONFIG_DEVICE_DEPS option.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Rename the Kconfig option to be in line with recent renamings in device
handles/dependencies.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Rename struct device `handles` member to `deps`, in line with previous
renamings in the device API.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Rename multiple internal device macros to use the DEVICE_DEPS naming, so
that it is clear they belong to the device dependencies APIs.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
These macros are used internally by the device dependencies functions.
There's no need to expose them publicly, so prefix them with Z_ and add
them under INTERNAL_HIDDEN docs section.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Instead of trusting blindly that k_mem_slab_init()
will succeed, let's check it, and handle failures
appropriately.
Otherwise, a buffer of garbage will be passed
around, leading to misterious failures later on.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This PR adds ability to build mesh with tf-m psa
for platforms those support tf-m.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Fixing error: undefined reference to 'vs_set_min_used_chans'
when building with 'BT_HCI_VS_EXT' option disabled.
Signed-off-by: Michał Grochala <michal.grochala@nordicsemi.no>
BT_ID_DEFAULT is hardcoded in mesh. Added clarification about
the necessity of another local identity allocation for BLE
if it coexists with mesh.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
websocket_disconnect api does not closes mqtt's tcp socket, so
tcp socket must be closed after done.
Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
The websocket_connect api expects connected tcp socket, do not close
the user supplied socket so that the caller can re-use it if needed.
Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
The BLE backend has a bug that when the MTU size is less than
the buffer the notification always fails and does not allow
to flush the buffer.
This fix checks for the MTU size of the current connection
and adjusts it. In addition, the buffer size is no longer
settable by the user and depends on the transmission size
of MTU set with CONFIG_BT_L2CAP_TX_MTU.
Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
The PAN ID in IEEE 802.15.4 frames is little endian while in the
IEEE 802.15.4 context it is kept in CPU byte order.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The ACK procedure had the following issues:
- MAC commands were not acknowledged.
- When the package is a broadcast package the package must not be
acknowledged.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Acknowledgment is mandatory if legitimately requested by the package's
"ACK requested" flag. The L2 layer will have to ensure that compliant
ACK packages will always be sent out automatically as required by the
standard.
For IEEE 802.15.4 compliance, the NET_L2_IEEE802154_ACK_REPLY option is
therefore being deprecated.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The existing calls to ieee802154_radio_send() and soft MAC ACK handling
were inconsistent and/or not properly integrated with more recent
radio driver capabilities as CSMA/CA and ACK in hardware.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The method ieee802154_radio_handle_ack() does not belong to the
PHY/radio layer but to the L2 layer. It is a callback called from the
radio layer into the L2 layer and to be implemented by all L2 stacks.
This is the same pattern as is used for ieee802154_init(). The
'_radio_' infix in this function is therefore confusing and
conceptually wrong.
This change fixes the naming inconsistency and extensively documents
its rationale.
It is assumed that the change can be made without prior deprecation of the
existing method as in the rare cases where users have implemented custom
radio drivers these will break in obvious ways and can easily be fixed.
Nevertheless such a rename would not be justified on its own if it were
not for an important conceptual reason:
The renamed function represents a generic "inversion-of-control" pattern
which will become important in the TSCH context: It allows for clean
separation of concerns between the PHY/radio driver layer and the
MAC/L2 layer even in situations where the radio driver needs to be
involved for performance or deterministic timing reasons. This
"inversion-of-control" pattern can be applied to negotiate timing
sensitive reception and transmission windows, it let's the L2 layer
deterministically timestamp information elements just-in-time with
internal radio timer counter values, etc.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The IEEE 802.15.4 standard clearly separates clear channel assessment
from retransmission. This separation of concern was not represented in
the current channel access vs. retransmission implementation which
resulted in considerable duplication of code and logic.
This change removes the duplication of logic and encapsulates the
resulting functions in a private API that may only be used from within
Zephyr's native L2 layer.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The CSMA/CA algorithm had multiple issues:
- Timing of backoff periods depends on the PHY's symbol rate and other
PHY-specific settings. We introduce a preliminary solution that works
with current drivers. A fully standard-compliant long-term solution
has already been conceptualized but requires further pre-conditions,
see #50336 (issuecomment-1251122582).
- We enforce the condition defined in the standard that macMinBe must be
less than or equal macMaxBe.
- According to the standard a CSMA/CA failure should lead to immediate
abortion of the transmission attempt, no matter how many
retransmissions have been configured.
- The number of retransmissions was off by one. It is now used as
defined in the standard algorithm.
- Retransmissions are only allowed when acknowledgement is requested in
the packet.
- prepare_for_ack() has side effects and must be called before each
retransmission.
We also replace variables by constants where possible.
The function was renamed as it represents unslotted CSMA/CA and does not
support other CSMA/CA modes. These may be introduced in the future.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The ALOHA algorithm had two minor implementation errors:
- The number of retransmissions was off by one.
- Retransmissions are only allowed when acknowledgement is requested
otherwise it is to be assumed that the transmission was successful.
- prepare_for_ack() has side effects and must be called before each
retransmission.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The allowable ranges of several CSMA/CA-related settings were not
conforming to the standard, see IEEE 802.15.4-2020, section
8.4.3.1, table 8-94 (MAC PIB attributes). This change fixes the ranges.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Setting default value for BT_BUF_ACL_TX/RX_SIZE and
BT_CTLR_DATA_LENGTH_MAX to 37, as this will process the
incoming data the most efficient way.
When GATT is enable BT_BUF_ACL_RX_SIZE does not have to be 73,
as this will just give segmented messages for the public keys
exchange during provisioning.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
After adding support for virtual addresses with collision (where two
Label UUIDs have the same virtual address), the format of the data in
the persistent storage with the Label UUIDs which a model is subscribed
to or publishes to has been changed. The recovery code is added and the
Label UUIDs will be recovered by picking first Label UUID matching to
the virtual address in the subscription list or model publication. This
options can disable the recovery code and save some flash if the
recovery is not required (e.g. virtual address support wasn't enabled
before this option was added, or the devices were unprovisioned before
upgrading to the version with this option).
Making this option as deprecated to be able to drop support of this
option and remove the recovery code eventually.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit adds the following features related to virtual addresses
support:
- Allows to store Label UUIDs which virtual addresses collide;
- Allows to decrypt messages encrypted with a virtual address with
collision;
- Allows to publish a message to a specific Label UUID to avoid virtual
addresses collision by adding a pointer to Label UUID to
struct bt_mesh_msg_ctx and struct bt_mesh_model_pub;
- Allows to differentiate Label UUIDs in the model's Subscription List
by storing all subscribed UUIDs in struct bt_mesh_model.uuids field.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
When LPN sends a segmented message to itself, it unnecesseraly polls
Friend. Since Friend doesn't receive this message, the segmented message
transmission will eventually fail (send end callback will return error),
while the message will actually be passed to the access layer.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit wrap the `settings_set_one` and `settings_delete` functions
in `bt_settings_store_one` and `bt_settings_delete`. By doing that the
Bluetooth settings can be managed in a single place.
This commit also introduce a new API to manage Bluetooth storage with
`bt_settings_store_*` and `bt_settings_delete_*` functions. Each
Bluetooth settings key have their own store and delete functions. Doing
that so custom behavior for key can be done if necessary.
This change is motivated by a need of keeping track of different
persistently stored settings inside the Bluetooth subsystem. This will
allow a better management of the settings that the Bluetooth subsystem
is responsible of.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If a user tries to enable TWT too early in the connection, then we might
enter TWT sleep even before DHCP is completed, this can result in packet
loss as when we wakeup we cannot receive traffic and completing DHCP
itself can take multiple intervals. Though static ip address can be
assigned too. Reject TWT till Wi-Fi interface has
a valid IP address.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
The debug pins were configured in a board specific file, however, the
subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/debug.h file
already contains board-specific pins, meaning there's no need to split
the information in 2 places. Move the GPIO configuration calls to the
DEBUG_INIT() macro in the controller debug header.
Note that in the future, Devicetree should be used to provide a
hardware-agnostic debug module.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
When config BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START is enabled, the
minimum accepted offset value in the CIS_REQ is the minimum defined by
the spec.
Add define CIS_MIN_OFFSET_MIN with value 500 us, as defined in the Core
spec. The previously used value of 400 us was incorrect.
Signed-off-by: Morten Priess <mtpr@oticon.com>
This commit replaces the workarounds spread around the
drivers and subsystems with the updated PPP L2
interface.
Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
Currently, the L2 PPP subsystem is not using the network
interface subsystem appropriately. Here are the issues:
1. net_if_up hidden away internally in net L2 PPP
2. net_if_down not used at all...
3. net_if_carrier_on / off is not used, a workaround is
used instead, which results in duplicated code
4. L2 PPP does not listen for network events, instead
it needs the workaround callbacks from drivers.
5. The carrier_on workaround is delegated to a complex
and broken sys work queue item.
This commit fixes all above issues. net_if_up/down and
net_if_carrier_on/off now work as expected. workaround
for carrier_on/off has been removed.
Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
A mesh key type has been added to be able to choose the different
key representation for different security libraries.
The type as well as some functionality related to Mesh key
management has been added as a public API.
If tynicrypt is chosen then keys have representation
as 16 bytes array. If mbedTLS with PSA is used then keys are
the PSA key id. Raw value is not kept within BLE Mesh stack
for mbedTLS. Keys are imported into the security library
and key ids are gotten back. This refactoring has been done
for the network(including all derivated keys), application,
device, and session keys.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The auto-connect by name did not verify that the found device
was connectable before attempting to connect.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Even if PRB state is disabled, PRB can still be sent over GATT if Proxy
Privacy parameter is enabled. In such case PRB won't be regenerated.
To keep the privacy of the network, PRB should be regenerated when sent
over GATT regardless of PRB state.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
According to section 6.7, upon connection Proxy Server shall determine
value of Proxy Privacy parameter (sections 6.5 and 7.2.2.2.6). Depending
on that, it will either send Secure Network Beacon or Private Beacon to
Proxy Client, but never both.
Proxy Privacy parameter is determined by GATT Proxy, Node Identity
states and their private counterparts (section 7.2.2.2.6). Since
non-private and private states are mutually exclusive, it is enough to
only check either Private GATT Proxy state or Private Node Identity
state of any known subnet for which the state is currenty enabled.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Fix binding between GATT Proxy, Node Identity and their private
counterpart states according to sections 4.2.45.1 and 4.2.46.1
accordingly. When non-private state is enabled, the private counterpart
is disabled. The reverse binding prohibits change of non-private state.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This fixes the failure to use a resolvable private address in this
scenario.
1. call `bt_le_oob_get_local`, will generate and mark RPA as valid
2. start connectable adv w/ IDENTITY bit
3. start connectable adv w/o IDENTITY
4. RPA is not set (in `bt_id_set_private_addr`) because RPA
is still marked as valid
When EXT_ADV is enabled and the controller supports it, a different code
path is taken that doesn't have this issue.
Unconditionally invalidating the RPA when starting advertising works around
this issue.
Fixes#56326
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Instead of assuming pointers are 32bits wide,
cast them to the appropriate pointer arithmetic type.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Currently, when an incoming dynamic LE L2CAP connection is requested by
a peer, the connected() callback provided by the user is raised
*before* a L2CAP_LE_CREDIT_BASED_CONNECTION_RSP is sent back to the
peer.
In some cases the user will start sending data in the connected()
callback which would be received too early by the peer.
This commit fixes this behavior by making sure the connected() callback
is raised only after the connection response has been sent to the peer.
Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
The RSSI value in net_pkt (net_pkt_cb_ieee802154.rssi) was used
inconsistently across drivers. Some drivers did cast a signed dBm value
directly to net_pkt's unsigned byte value. Others were assigning the
negative value of the signed dBm value and again others were offsetting
and stretching the signed dBm value linearly onto the full unsigned byte
range.
This change standardizes net_pkt's rssi attribute to represent RSSI on
the RX path as an unsigned integer ranging from 0 (–174 dBm) to 254 (80
dBm) and lets 255 represent an "unknown RSSI" (IEEE 802.15.4-2020,
section 6.16.2.8). On the TX path the rssi attribute will always be
zero. Out-of-range values will be truncated to max/min values.
The change also introduces conversion functions to and from signed dBm
values and introduces these consistently to all existing call sites. The
"unknown RSSI" value is represented as INT16_MIN in this case.
In some cases drivers had to be changed to calculate dBm values from
internal hardware specific representations.
The conversion functions are fully covered by unit tests.
Fixes: #58494
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Fix an issue causing a wrong Bluetooth identity value to be stored. It
was happening because the `bt_dev.id_count` was incremented after the
settings being stored.
To fix this, `bt_dev.id_count` is now incremented right before the ID
creation and is decremented if the ID creation failed.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
call k_thread_foreach_unlocked to avoid assertions caused
by calling shell_print while holding a global lock
Signed-off-by: Maxim Adelman <imax@meta.com>
Fix for not getting expected event information at application.
net_mgmt_event_notify_with_info() expects the address
not the value as pointer.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
Fixes wrongly declaring duplicate local variables that already
exist and hiding the previous variables definitions.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
shell_strtoull used a unsigned long instead of a unsigned
long long to store the result in stroull, so the return
value may have been truncated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix corner case when client RX request with same token than
own request where it wait responses.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
bt_uuid_str expects UUID in little endian while UUID encoded into
unprovisioned mesh beacon is encoded in big endian. sys_memcpy_swap will
change endianess of uuid so that bt_uuid_str can be used.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
CONFIG_BT_MESH_PROV_DEVICE_LOG_LEVEL_INF may not be present while
CONFIG_BT_MESH_PROV_DEVICE_LOG_LEVEL is always present.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Prevent potential buffer overflow when encapsulated response is more
than CONFIG_USB_REQUEST_BUFFER_SIZE. Log error and truncate response if
USB control transfer request buffer is not large enough.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
When calling the `terminate_call` the `inst` would always be NULL
as we had just terminated the call that we attempted to look up.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A bug was introduced in one of my earlier commits: The shell does no
longer print the full extended address. Fixes the issue.
Fixes: #59125
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Compiling an application with CONFIG_NET_ZPERF=y leaving
CONFIG_ZPERF_WORK_Q_THREAD_PRIORITY at its default value would
systematically cause a kernel panic during thread initialization.
The Kconfig variable is NUM_PREEMPT_PRIORITIES by default. Application
threads may not define a priority lower than NUM_PREEMPT_PRIORITIES - 1,
though.
This change limits zperf's thread priority to a valid range. It does not
change the default value as it makes sense to default the thread
priority to the lowest possible value (which is NUM_PREEMPT_PRIORITIES)
but Kconfig does not allow for arithmentic. So the combination of
CLAMP() plus the Kconfig default will ensure min priority plus limit the
range to valid values no matter what has been defined as priority in
Kconfig.
Fixes: #59141
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
In previous patch fixing this issue, I've missed the fact that offloaded
drivers would not set the context->local address, which resulted in a
regression, where the previously introduced assert would hit in
offloaded cases. Not setting laddr is not a problem in case of
offloading, as it's only used in net_tcp_connect() which would not be
reached in this case.
Therefore I propose to remove previous patch to get rid of regression.
As an alternative fix, verify the laddr just before use, so that it is
only checked when native net stack is in use.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
BlueZ stack in Linux distributions use disable all
advertising sets when advertising is turned off.
Add missing implementation to support disabling all
active advertising sets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rework internal header files to not have includes, rather
have the required includes in the c source files.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In order to have clean, self-contained HCI headers that do not have any
dependencies towards the Host or any other part of the system (except
types), reorganize the headers in the following way:
- Split out the macros and structs from hci.h to a new hci_types.h
- Merge the existing hci_err.h into the new hci_types.h
Fixes#58214.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add function to cancel any current proecedure. This is useful
in cases where the connection to one or more acceptors is lost
or if some acceptor does not respond to our requests for whatever
reason.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
An ASCS endpoint may go into either the idle or codec configured
state when a stream is released. However since we have such a high
coupling between audio streams and endpoints, we need to consider
the endpoint as having been released (i.e. gone to the IDLE state).
This is handled by a boolean state variable for now, but we may
want to consider a more generic approach where streams and
endpoints may be less coupled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When an audio stream in a bidirectional CIS is released,
it should not disconnect the CIS if there is still a stream
for the opposite direction streaming. Only if both streams
are not in a streaming state, should ASCS attempt to disconnect
the CIS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Log status values in events as hex instead of decimal
to make it easier to compare to the spec and hci_err.h
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Without this fix, for every call to shell_vfprintf,
a prompt string and vt100 codes are printed too,
resulting in mangled log output.
Signed-off-by: Lars Knudsen <lakd@demant.com>
When a device disconnects we previously just unref'ed it and
set default_conn = NULL. However, if we are connected to mulitple
devices, it makes sense to set the default_conn to one of the
other connections.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the implementation of parse_search to use a
net_buf_simple and bt_data_parse to parse the LTV
search structure.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Set the secondary advertising PHY to a valid value when using
legacy advertising through the LE Set Extended Advertising Parameters
command.
Fixes#57885.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Implement APP_NAME define in Kconfig for Segger SystemView module.
Use APP_NAME in Systemview initialization function
Signed-off-by: Nathan Olff <nathan@kickmaker.net>
As the coarse tick of ACL prepare and CIG prepare jitter by
+/- 1 tick, hence when initially scheduling the CIG place it
with enough margin so that cis_offset_min calculated when
there already exists a CIG can be larger than peer's
cis_offset_min being negotiated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrectly stored Broadcast ISO interval in
microseconds instead of storing in 1.25 ms units.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Introduce a Kconfig BT_CTLR_ISOAL_SN_STRICT to relax the Tx
ISO Data SDUs being dropped due to strict check of sequence
numbers in ISOAL, i.e. dropped when ISO Data SDUs are
delayed from upper layer with respect to the current
payload number in the ISO radio events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
block_size_log can be 0x20 which will shift 1 by 32 bits which will
cause undefined behavior. Adding ULL to 1 is an option but this will add
little bit more code when debug option is enabled. So simply print the
logarithmic value.
Coverity-ID: 316387
Fixes#58951
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
GATT server was not doing enough check before udpating the CCC.
For example, a non-bonded client could update the CCC of a bonded client
by spoofing his address.
This fix the issue by dissociating the CCC configuration of a bonded and
a non-bonded peer. To do that, a new field is added to the CCC config:
`link_encrypted`.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
In PR (#58723) has introduce another bug, that,
the flag ADV_FLAG_PROXY set before actually enabled.
When ctx:: BT RX call schedule_send will atomic_test_and_clear
ADV_FLAG_PROXY, but at this time, the proxy advertising will
not at advertising state, maybe in update params or set adverting
data phase,
so that, call bt_le_ext_adv_stop will nothing, and then call
k_work_reschedule --> send_pending_adv(at this time, the proxy
advertising actually enabled, but the upper layer clear proxy flags),
cause latest advertising unable start, because unable in advertising
state to update params(-EINVAL).
Fixes: #58721
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Coverity reported, that laddr pointer used in net_context_connect()
could be passed as NULL to net_tcp_connect() where it could be
dereferenced. This is because the actual setting of laddr to a valid
address structure was only done after
net_sin/sin6_ptr(&context->local)->sin/sin6_addr verification.
In practice though, the aforementioned pointer verification would always
pass, as the bind_default() guarantee that the context->local address is
set to an unspecified address (if it hasn't been set earlier).
Therefore refactor the code a bit: replace the pointer verification
with NET_ASSERT - only to assure that we can catch regression in case
for any reason the behavior of bind_default() changes. This should also
ensure that Coverity no longer reports that laddr is NULL when reaching
net_tcp_connect().
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As since commit bff6a5c, params.dst.ext_addr is no longer assigned with
the ctx->coord_ext_addr pointer, but a endianness swap is included, it
should be assigned with a proper buffer before the memcpy.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Coverity reported potential issues with implicit signed/unsigned type
conversions and potential problems with this. Fix this, by casing the
byte-shifted data variable to uint64_t type explicitly.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
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>
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>
In case TCP connection is being closed from the TCP stack, due to for
instance retransmission timeout, the stack should also switch the TCP
state to CLOSED. Otherwise, there was a risk of dereferencing the TCP
context twice, for example if the application was in active socket
send(), and tried to reschedule data transmission.
Additionally, make sure that the TCP_CLOSED state handling is a no-op
state - otherwise, there is a risk that if packets keep incoming before
the application dereferences the TCP context on its side, TCP stack
will incorrectly dereference the context for the second time from
within due to current TCP_CLOSED state logic.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As long as we do not have NVS support in TBS, the subscriptions shall be
removed once ACL is disconnected to avoid potential crash on
reconnection, as the subscription parameters might be not valid anymore.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes repeated attempt to bt_tbs_client_discover that failed
because srv_inst->current_inst was not cleared during previous discovery
process. The issue seen in case the GATT Read CCID returned an error.
The code has been factored out to separate helper function.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes missing guard access to GATT read parameters.
The code checks `busy` flag and returns an error in case there's ongoing
GATT Read operation already.
Fixes: #58425
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The port we are connecting to is stored in network byte order,
thus, we need to convert it to the CPU's byte order before logging
Signed-off-by: Mark Oude Elberink <mark@oude-elberink.de>
`local_addr` would only be initialized if `context->local->sin*_addr` was
non-null. However, since `context` is a fresh context object, `local_addr`
always remains at its initial value of `INADDR_ANY`, which is propagated to
the context by `net_context_bind()`.
By populating `local_addr` using the TCP endpoint, `getsockname()` now
returns the correct local address.
Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
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>
-- Implemented reporting of lost / missing SDUs for framed PDUs. This
should result in SDUs being released when only framed padding PDUs or
error PDUs are received.
-- Removed unused configuration params structure, storage and linked
APIs.
-- Reduced default logging level to INF instead of DBG.
-- Included debug logging messaged for framed consumption.
-- Removed separate latency_unframed and latency_framed and replaced
with a common sdu_sync_const as they are mutually exclusive for each
sink.
-- Restricted framed time stamp calculation only to situations where all
dependent information is available.
-- Corrected SDU sequence numbering to release starting at zero.
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Based on interpretation of Clarification Errata ES-22876 Request for
Clarification - Recombination actions when only padding unframed PDUs
are received, it was decided that an SDU should be released as "Missing"
when only padding PDUs are received for any SDU.
- https://bluetooth.atlassian.net/browse/ES-22876
This change will also assist streaming in the Common Central design
where the central was found to send only padding PDUs before streaming
starts.
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
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>
If the num_ase == 0xff then it is a special case that needs to be
handled like if num_ase == 0x01.
If there is an error with ase_id = 0x00 then the error cannot
be translated to a specific stream, so the callbacks may now get
NULL for the stream object.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When CCC or CF store on write is disabled and the other one is enabled,
leading to the delayed store being enabled. This cause the value of the
corresponding `n` selected option to not be stored at all.
To fix this, the checks to know if we need to store the CCC or the CF,
happening at the disconnection, are now ensuring that the CCC or the CF
are stored even if the one of them does not enable store on write.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Remove the lower check (BT_BAP_BASS_OP_SCAN_STOP) in
BT_BAP_BASS_VALID_OPCODE as it is always used on unsigned
variables, so no point in check if it is lower than 0.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add check for the index in the function itself, as well as where
we call it internally, to ensure that we do not attempt to access
invalid indexes of broadcast_assistant.recv_state_handles.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This fixes missing `CONFIG_*` prefix.
The `BT_HAS_PRESET_CONTROL_POINT_NOTIFIABLE` option is already guarded
with `BT_HAS_PRESET_SUPPORT`, so it has been removed from `depends on`
condition.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes regression causing compilation errors seen when the
code is built without preset support (BT_HAS_PRESET_COUNT = 0).
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
nvs_sector_close has not been initializing nvs_ate.part, before
writing it to flash.
Fixes#58699
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Added assert when looking up the next instance, as the caller of this
function should ensure that the index is correct before calling
discover_next_instance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If the minimal value of an IN_RANGE is 0, then it is
a useless check, and the cases have been modified to
not use IN_RANGE. This also fixes some coverity issues.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The check was a && but should have been an ||. Fixed by moving
the check to a new if statement.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When notify_app is called for BT_TBS_CALL_OPCODE_TERMINATE
we did a lookup on the call index, but never did a NULL check
before dereferecing it.
This does not fix the issue that the instance will always
be NULL in this case, as we have terminated the call so
we cannot possibly look up the call afterwards.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The friendly copy always assumed that the friendly name could
fit in memory, which could cause overflows. Fixed by using
utf8_lcpy as that not only ensures that the copy is truncated
to fit in memory, but also ensures that it is null terminated
and truncated in a way that supports multi-byte UTF8 characters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The previous implementation would read from `addr->val[0]` before it was
initialized if the input string started with a colon ':'.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
If offset is only 32-bit, then it can never be > UINT32_MAX,
so added another conditional that only if the type (off_t) is
larger than 32-bit, we perform the maximum value check.
off_t is not a standard type and thus the size of it is poorly
defined, and are just defined as a signed integer type.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The check compared the levels against < BT_IAS_ALERT_LVL_NO_ALERT
which of course does not make sense given than the lvl_u8 is an
unsigned value that can never be < BT_IAS_ALERT_LVL_NO_ALERT.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use unsigned long long and shell_strtoull to get the ID of
OTS objects, as unsigned long may not be able to store all 48
bits.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a shell_strtoull function that works similar to
shell_strtoul except that it calls strtoull instead
of strtoul.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Ensure that scan_filter.addr is NULL terminated by only copying
the sizeof the buffer -1 and then always setting the last byte to
\0.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The number of buffer provided was verified in the final else block of a
long validation sequence. It would never be executed though, as one of
the conditions before would always evaluate to true.
As the number of buffers provided verification appears to be significant
in this case, as the buffers are referenced during other validations,
move this check at the beginning of the sequence instead. This also
eliminates the dead-code problem.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Use if-else-endif construction to avoid dead code.
Coverity-CID: 316484, GitHub issue #58539
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Just drop PENDING_RESET flag without checking it.
Coverity-CID: 316394, GitHub issue #58530
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Use ULL suffix to promote the type of the shift operand to uint64_t to
avoid undefined behavior when block_size_log is 32.
Coverity-CID: 316387, GitHub issue #58528
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Coverity is complaining:
CID 316017: Control flow issues (NO_EFFECT)
>>> This less-than-zero comparison of an unsigned value is never true.
148 for (size_t i = 0; i < ARRAY_SIZE(substate_lock_t); i++) {
This is a false positive but we can still optimize the code and making
coverity happy by simply avoiding compiling the offending code when no
power states are defined into the DT.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
In places where we verify that the value of the long
variable does not exceed the limits of int32_t, we do
actually not need to compare the values if the two
types are the same size, which is often the case for
32-bit systems.
This fixes a variety of coverity reported issues.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When copying the address in cmd_scan_filter_set_addr we now
use strncpy to not copy more bytes than what fits. This
should already have been fixed with a check earlier in the
function, but coverity still complains.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
For IEEE 802.15.4 compliance, the NET_L2_IEEE802154_ACK_REPLY option must
automatically be active if the radio driver does not AUTOACK and inactive
otherwise. No user interaction is required.
Future changes will deprecate this option and replace it by a standard
compliant automatic mechanism.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The IEEE 802.15.4 standard does not specify a "Sub-GHz" option.
Therefore this option will be deprecated in the foreseeable future.
Rationale: Selecting PHYs and frequency bands is abstracted by the
concept of channel pages (see IEEE 802.15.4-2020, 10.1.3).
Radio drivers may expose additional configuration options that
specify the low level frequency band, operating mode and other
PHY-specific parameters. Such parameters should be exposed on a driver
instance level, e.g. via devicetree or as runtime options of the driver.
PHY-specific attributes derived from driver settings (e.g. available
channels) can then be announced to L2 w/o the user having to be aware of
any implementation details of the specific PHY.
Future changes will introduce the necessary infrastructure to define
channel pages and other PHY-specific configuration options to
replace this option. New drivers should therefore not rely on this
option.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
In theory, coap_header_get_token() should only be used on already parsed
packets, and coap_packet_parse() would detect an invalid token length in
a packet. Coverity however complains about possible out-of-bound access,
as in theory the function can return token length up to 15. Therefore
add an extra validation of the token length within the function, to
avoid out-of-bound access due to programming errors and to make Coverity
happy.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Log level is stored on 3 bits thus in theory it can be set to 7
and yet accepted levels are up to 4 thus Coverity complains.
Adding assert that prevents use of levels above 4.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Now that `lorawan_init` only initialises data structures and does not
start the stack or communicate with a physical device, run the init as
soon as possible. This allows `lorawan_register_downlink_callback` to
be called much earlier by other init functions.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
When `CONFIG_BT_SETTINGS_DELAYED_STORE` is enabled (by default it is),
the local GATT server will delay the write to flash of the CCC and CF
values. The delay is defined by `CONFIG_BT_SETTINGS_DELAYED_STORE_MS`.
If a disconnection happen before that delay, the `bt_gatt_disconnected`
will reschedule the delayed store operation. But that operation will not
happen before `bt_gatt_disconnected` is complete, at this moment, the
CCC and CF values will have already been cleared.
To fix this issue, the delayed store operation is now done during the
`bt_gatt_disconnected` function.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
When proxy advertising enabled, but at same time, the
connection event report, will cause `ADV_FLAG_PROXY` not
set, so cb `connected` will not be process, cause mesh message
unable to sent.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/58721
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Only set a cpu as active (on pm subsystem) when the cpu is effectively
initialized. We cannot assume on pm subsystem that all cpus were
initialized since when the option CONFIG_SMP_BOOT_DELAY is used cpus are
initialized on demand by the application.
Note that once cpus are properly initialized the subystem is able to track
their status.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Some Bluetooth controllers (Nordic Softdevice) now use
`BT_HCI_ERR_INSUFFICIENT_RESOURCES` to signify when advertising sets
cannot be created, instead of the old `BT_HCI_ERR_CONN_LIMIT_EXCEEDED`.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
On CIS disconnect, the central will clear all data paths.
However hci_le_remove_iso_data_path will fail if attempting to remove a
data path that has not been setup, so if only the CTLR_TO_HOST
direction was set, and the HOST_TO_CTLR bit was set, the
function returned an error and never attempted to clear the other
direction.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
On CIS disconnect, the peripheral will clear all data paths.
However ll_remove_iso_path will fail if attempting to remove a
data path that has not been setup, so if only the CTLR_TO_HOST
direction was set, and the HOST_TO_CTLR bit was set, the
function returned an error and never attempted to clear the other
direction.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Before this change we had 2 top-level Doxygen entries for Testing APIs:
- Zephyr tests
- Zephyr testing suite
This patch creates a single top-level group to contain ZTest and FFF
extensions.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The buffer_output interface is called a few times during one core dump,
so we need to maintain a memory write pointer to prevent data overwriting.
Signed-off-by: Rander Wang <rander.wang@intel.com>
This patch fixes commit b70f92e570
("net: buf: keep memory alignment provided by k_heap_alloc and k_malloc").
One-line was overlooked in the above patch and may result in a
cloned net_buf using a data block that has already been freed.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Although websocket_recv_msg function accepts timeout parameter, the
functionality was rather limited, allowing only to either work in
non-blocking manner, or to block indefinitely. Any timeout value
other than -1 (forever) ended up in non-blocking operation.
This PR fixes this by implementing a basic timeout mechanism, built on
top of poll(). For now on, only timeout of 0 will result in non-blocking
operation, any other timeout will make the function block for the
specified amount of time.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Up until now, it has not been possible to reconfigure a CIG and its
CISes after initial configuration, without first removing the CIG.
With this commit, le_set_cig_parameters allows the following
reconfiguration operations in configuration state:
- Set new CIG configuration parameters on existing CIG
- Iteratively configure single CIS (of more CISes)
- Increment number of CISes via multiple configuration calls
- Keep handle- and CIS_ID relation
Changes:
- Pass handles in le_set_cig_parameters from ll_cig_parameters_commit
via output variable.
- Implement CIG state variable instead of 'started', with states
IDLE/CONFIGURABLE, ACTIVE and INACTIVE.
- Implement ll_conn_iso_stream_get_by_id for easier access to specific
CIS.
This fixes the following CIS Central EBQ tests:
- HCI/CIS/BI-10-C
- HCI/CIS/BI-11-C
- HCI/CIS/BI-13-C
- HCI/CIS/BV-05-C
Signed-off-by: Morten Priess <mtpr@oticon.com>
The path_dir variable of BT_HCI_OP_LE_REMOVE_ISO_PATH must be bitflags,
with the following meaning:
- BIT(0) : DIR_HOST_TO_CTLR
- BIT(1) : DIR_CTLR_TO_HOST
Signed-off-by: Morten Priess <mtpr@oticon.com>
According to the Core spec, the direction parameter passed to this function
should be bitfields, i.e.:
- BIT(0) : DIR_HOST_TO_CTLR
- BIT(1) : DIR_CTLR_TO_HOST
Signed-off-by: Morten Priess <mtpr@oticon.com>
In `private_random_update`, when first beacon is advertised, there could
be a case when uptime is less then interval * 10s
(`priv_random.timestamp` is equal to 0 for first beacon). Then, Private
Random value will not be generated and will be set to all zeros.
New Private Random must also be generated before Random Interval
expires, when KR or IVU flags are changed. Reset timestamp to 0 on
`bt_mesh_beacon_update` to generate new Random value.
Do not generate new private random if it won't be used (Private Beacon
state is not enabled).
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
In order to allow the TLS accept() call to be interrupted, it should
release the top-level TLS socket mutex before blocking. As the
underlying TCP accept() makes no use of TLS resources, and has its own
mutex protection, it should be safe to do so.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The accept() so far would block with mutex held, making it impossible to
interrupt it from another thread when the socket was closed.
Fix this, by reusing the condvar mechanism used for receiving. It's OK
to use the same routine, as underneath accept() is monitoring the same
FIFO as recv().
Additionally, simplify k_fifo_get() handling in accept() - as the
waiting now takes place on condvar, it can be used in a non-blocking
manner. Blocking accept() call should not reach this place if there's no
new incoming connection waiting on the FIFO.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The MPU stack guard can move the start address of a thread stack.
Don't allow both options to be enabled at the same time.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Removed few VIF properties which are being hardcoded
Updated the script to parse source VIF XML and add information to
the output
Added optional Kconfig option to configure custom source VIF XML path
Cleaned up the code
Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
The IN_PROGRESS status is a specital status that can be sent during
handling a host command. Synchronous backends don't support it, so
an additional check is required.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
A function to send Host Command response is needed for commands that
that sends IN_PROGRESS status or doesn't return e.g. perform reboot.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Installing recv callback with net_context_recv() after
net_context_connect() left an opening for a possible race - in case the
server send some data immediately after establishing TCP connection, and
Zephyr did not manage to install the callback on time, the data would be
lost, corrupting the stream.
This can be avoided, by installing the recv callback before the
connection is triggered. As net_context_recv() called w/o timeout only
registers the callback function, it should have no negative impact. The
only change on the TCP side is when the connection is closed - in case
TCP is in connect stage, do not call the recv callback (before this
change it'd be NULL at that point).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This ensures that when running a combined host + controller build, the
ISO features in the controller are enabled automatically.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Fix the wrong calculation for inverting implemented by
commit 7068587505
("fb: cfb: support inverting with coordinates that do not align
with the tile")
Remove the cfb_invert_area() calling.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Fix the wrong calculation for inverting implemented by
commit 7068587505
("fb: cfb: support inverting with coordinates that do not align
with the tile")
Fixed not enough consideration when the drawing area height
is eight lines or less.
Simplify to XOR calculation.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add the `draw rect` command to execute the `cfb_draw_rect()` API.
This command render rectangle.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
Add the `draw point` command to execute the `cfb_draw_point()` API.
This command render single dot.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
Support for multiple instances of a class implementation,
and the ability to register an instance to a configuration
at runtime, requires a mechanism to add a string descriptor
and update its index based on the total number of descriptors.
We also need to handle some special string descriptors like
Product or Serial Number provided by the application.
Marked as such by using specific macros, these descriptors
can be sorted out by the stack and the device descriptor
indexes are updated automatically.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add and use specific macros for manufacturer, product, and
serial number string descriptors.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
While this does not provide much of an advantage yet,
it will allow us to add descriptors and assign an index
more easily in the next commit.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
When we enable USBD shell support with samples like cdc_acm or mass,
there would be another USB device context besides the one provided
by the shell. This patch introduces a new command to select an
alternate context to be used by USBD shell commands.
Also fix the type where "add" command should be "remove".
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
If we try to reuse a string descriptor node, the content will
be corrupted because the device stack assumes it is still ASCII7
encoded. Add a flag to indicate that a descriptor node contains
UTF16LE encoded content.
And while we are at it, add a flag to indicate that the SN string
should not be obtained from the hwinfo API.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
There may be more than one context using the same device, for example,
if the shell module is enabled. Check if another context that uses
the same device is initialized.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
At the shutdown of USB device stack we have to cleanup and
remove all registered class instances and string descriptors
from a configuration.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Foobaz interface will be renamed and added as a standalone part
to serve as an API example in a subsequent commit.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The coap client takes requests and provides responses
asynchronously to callback given in a request.
Currently supports only 1 request at a time.
Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
Added Kconfig options to make HAS characteristics that has notify as
optional property selectable and thus optional. These settings are
global, meaning that a chosen notify property will be used for all
registered has instances.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
OS management's reset is optional, therefore only imply reset
instead of selecting it, so it can optionally disabled if not
needed.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Expands a bitfield name from nh_ver to nh_version so it is more
obvious what it is. Also changes the version that goes into the
response to indicate what the maximum supported version of the
protocol is for a device
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
In case recv() call was waiting for data, and the socket was closed from
another thread, the recv() call would not be interrupted, causing the
receiving thread to be blocked indefinitely.
Fix this, by signalling the condvar the recv() call is waiting on
close(). Additionally, close will now set the socket into error mode,
with EINTR as the error condition, allowing the blocked calls to
recognise that the call was interrupted, and return a proper error code
on the event.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
All posix arch boards are required to provide the same
tracing/print API.
So, instead of having a different driver for native_posix and the
bsim boards, let's have a common one which uses this API.
This in turn results in the printk strings being printed in
the same underlaying backend as before with individual drivers.
A part from this, the native_posix console driver was a full
backend for the now long gone Zephyr console shell
(named legacy_shell from 527256501f
until it was retired in fd0b7f7767).
The whole input handling in this driver was dead code
(since 140a8d0c8a)
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Optimize the read procedure when receiving long notifications
by storing the already notified data in the buffer if the
client instance is not already busy. If it is busy we have
no way to store it, and will just need to read the entire thing
later.
This also modifies when we reset the ATT buffer. Instead of reseting
when we want to use it, we reset it when we are done using it.
The reason for this is to avoid making state checks before calling
long_ase_read to determine whether it should reset the buffer
or not.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for long notifications ASE notifications
by doing a long read if the notification has length of
the maximum MTU.
This behavior is currently not defined by the BAP spec,
so may not work with all devices.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for long writes for the unicast client and server.
This reuses the ATT buffer for long reads.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The function is optionally used by the module, and should be
guarded to avoid compiler warnings about unused functions.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
After removing the high default for MCS, it was discovered that
the TBS client requires a significant amount of buffers to work
properly as well. Added the requirement as a build assert that
depends on which optional TBS client features are enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A recent change in MCS significantly reduced the requirement
of L2CAP_TX_BUF_COUNT and should now work with any value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This reworks the UDP transport to resolve some issues with object
interactions and streamlines the code.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
No reason to continue zcbor encoding of slot information for image
list when already failed at encoding version.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Image list should also flag pending slot as permanent.
This follows the image list for swap configuration where slot
confirmed for next boot is marked as permanent.
The difference is that in DirectXIP mode it is still possible
to erase slot marked as pending and permanent, before restart
happens.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Adds callback checks to other fs_mgmt group file access functions
which allows for file access control, and moves where the callback
is triggered for uploads and downloads to prevent getting the
callback multiple times for the same file. The callback struct has
been modified so applications using the previous signature will
need to be updated.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Use the bt_bap_stream_ops sent callback and not a timeout
while streaming the sine tone in the bap shell to avoid
jitter when the shell is busy.
Signed-off-by: Lars Knudsen <lakd@demant.com>
Events in the power-management policy context are defined as any source
that will wake up the system at a known time in the future. By
registering such event, the policy manager will be able to decide wether
certain power states are worth entering or not.
Events will bypass the ticks argument received by the policy manager if
they occur earlier.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Latency is always specified in microseconds, so apend `us` to the
relevant variables. Also, make it clear that latency request structures
are private (they are just exposed publicly to allow static allocation).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Added a guard before attempting to access
svc_insts[cur_inst->idx + 1], as that code can only ever be value
if CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES > 1.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Guarding code that uses __ASSERT with IS_ENABLED seemingly
does not work, and still gives unused variables (rank_1 and
rank_2). Modified the guard.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Split the CAP initiator broadcast start API into a create
and a start. This will allow users to create the broadcast source
without starting it immediately, making it possible to get the
BASE etc. without an active advertising set.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This is an alternative API for the L2CAP receive functionality. It
allows an application the receive L2CAP segments directly and manage
credits explictly. The API is guarded by an experimental kconfig option.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/57485
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Variable declarations are moved to the beginning of the block in
which they are visible to ensure consistency with the remainder
of the code base.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The encryption-only security level has been removed from the
spec, see IEEE 802.15.4-2020, 9.4.2.2 Security Level field.
The standard provides the following explanation (ibid):
"This security level is deprecated and shall not be used in
implementation compliant with this standard. Devices that
receive frames with security level 4 shall discard them, as
described in 9.2.4. The counter mode encryption and cipher
block chaining message authentication code (CCM) used allows
trivial changes to the underlaying encrypted data unless
data authenticity is provided, thus using data confidentiality
only is not useful. In the case of TSCH mode, security level 4
allows higher security level frames to be downgraded to
security level 4 frames."
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
See IEEE 802.15.4-2020, 7.2.2.11 Source Addressing Mode field and
7.2.2.9 Destination Addressing Mode field, table 7-3: The
previously deprecated "Simple addressing mode" was removed
from the spec.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Currently the insertion of an authentication tag requires a memcpy() call
and breaks encapsulation.
This change removes the need for memcpy() and improves the encapsulation
by calculating and reserving the required headspace early on while
keeping insertion where it belongs in the outgoing security procedure.
This is also a preparation for improved standard compliance of the
outgoing security procedure which is scheduled for a later commit.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The naming of variables and arguments containing the authentication
tag length was inconsistent:
* Naming inconsistency between header "length" vs. authtag "size"
in the same API calls
* "Tag" rather than "Auth[orization ]Tag" in external API calls
which is too generic from a compliance and readability viewpoint.
This is in preparation to zero-copy authentication support.
Almost all call sites will be subject to required structural changes
later on so no relevant git blame noise/history loss will be introduced
by this naming change in the long run.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Over time, some non-standard concepts and extensions were introduced
into the stack (in KConfig, in drivers, in the internal API and into the
implementation) which makes introduction of additional standard-
compliant extensions like TSCH (and others) unnecessarily difficult.
To introduce extensions like TSCH it is required for the IEEE 802.15.4
stack to become more structurally aligned with the standard again which
will be the focus of some of the upcoming preparatory changes.
One way to check and prove standard compliance is to reference the
standard from within the source code. This change therefore introduces
inline references to the IEEE 802.15.4-2020 standard wherever possible.
Deviations from the standard are documented with TODO or deprecation
labels to be addressed in future changes.
In the future, new code introduced to the IEEE 802.15.4 stack should
be documented and reviewed for standard-compliance to avoid further
divergence. Most importantly:
* MAC/PHY configuration (via net mgmt, radio API, devicetree or
KConfig) should always be directly linked to well-defined MAC/PHY
PIB attributes if visible to the MAC API or the end user.
* Net management/shell/radio API commands should have a documented
reference to the corresponding MLME action from the standard.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The unicast client did not properly clear the receiver_ready flag
when going out of the streaming or enabling state. This caused
incorrect behavior when attempting to restart streams.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The BT_CTLR_DF_SUPPORTED KConfig was a wrapper for DF related features
set that are supported by Zephyr's BLE Controller. At the same time the
KConfig is used by Host in compound build to enable BT_DF. That makes
the whole thing a bit coupled with Zephyr's controller.
External implementations of controller must provide same feature set
as Zephyr's Controller or there will be an error during build.
The PR moves the Zephyr's Controller DF supported features set to
Kconfig.ll_sw_split, where it is included only when BT_LL_SW_SPLIT
is selected. BT_CTLR_DF_SUPPORTED is now a top DF_SUPPORTED KConfig
option that enables possibility to select actual DF features.
That allows to select individual set of DF features by any controller
implementation and makes possible to enable BT_DF and build selected
DF Host features.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add implementation of the Telephony and Media Audio Service, as well as
two sample applications.
tmap_central reflects a smartphone implementing the Unicast Media Sender
and Call Gateway TMAP roles.
tmap_peripheral reflects an earbud implementing the Unicast Media
Receiver and Call Terminal TMAP roles.
Upon connection, tmap_central starts an audio stream using CAP Initiator
APIs.
CCP, MCP and VCP are discovered and used to send example commands.
Future improvements: 2-earbud support, add TMAP Broadcast roles,
update with new CAP Acceptor/Commander APIs as they become available
Signed-off-by: Silviu Petria <silviu.petria@nxp.com>
atomic_inc(&buffered_cnt) return previous count of log messages,
should use current count to compare with threshold config value.
Signed-off-by: Dong Wang <dong.d.wang@intel.com>
Signed-off-by: Qipeng Zha <qipeng.zha@intel.com>
According to RFC768 UDP packets with zero checksum are allowed with IPv4.
Enable this by default.
For example, some routers use zero checksum in DHCP packets.
Signed-off-by: Nils Ruf <nils.ruf@endress.com>
The current approach of failing the build on ztest with no optimization
broke coverage builds, and generally raised some concerns about being
too aggressive.
Downgrade the error to a warning and rework the option to inhibit the
warning, while also dropping it automatically for POSIX (that are not
really affected by stack size) and coverage run (that always runs with
no optimization).
Will reconsider this down the road if we still see issues filed for the
tests broken with no optimization and no further tuning.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Changes the warning from being text in Kconfig for filesystem
management as a whole to being a cmake warning which is displayed
if the user has not enabled file access hooks with a link to the
documentation on how to set them up.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add a config to decide if a new dedicated thread for Host Command is
created during initialization.
If not, the ec_host_cmd_task has to be called by another thread to
handle host commands.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
The command at most takes 11 args. argc = num of args + 1 (command
name) => 12. We substruct 3 from argc (cmd name, mod id, addr). This
gives argc = 9 when all args are provided for vendor model.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The scope for the burst number for tx and rx is currently at module
level in both lll_central_iso.c and lll_peripheral_iso.c
This PR puts the scope to the lll level
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Many tests are known to fail when built and no compiler optimizations.
Add a CMake check to error out when building a ztest based test with no
optimization, ask not file issues about it but also adds an opt-out
option to bypass the error for tests are actually designed to work in
this setup.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The current implicit MAC payload length algorithm (based on
an otherwise irrelevant footer pointer) produces invalid
(non-standard) values for beacon and command frames.
This change produces standard-conforming MAC payload length
values and simplifies access to payload length.
It would have been possible to fix the current footer pointer
based approach but there are arguments in favor of the new
approach:
- The footer pointer is used nowhere in the current code
base and makes length calculations rather non-obvious.
- The new approach does not use more memory and is easier
to understand and use.
- This change is a first step to support of IEEE 802.15.4
information element (IE) support. At a later stage the
distinction between MAC payload length and frame payload
length will be introduced and become relevant to
distinguish between header and payload IEs. At that point
the current implicit length calculation algorithm will
break down anyways.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current IEEE 802.15.4 stack would not accept beacons
unless hardware filtering was active.
This change fixes the bug.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The shell command calling the IEEE 802.15.4 scanning procedure
did not properly release its net management event callback.
This change fixes the memory leak.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Active and passive scanning requires the channel and PAN to
be set temporarily.
This change ensures that the temporary configuration will
be reverted even when the scan is aborted due to an error.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Beacon and command frames are consumed by the IEEE 802.15.4
stack internally and should therefore be released before
returning control to the generic net stack.
This change fixes the resource leak.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This makes it explicit that enabling `BT_PRIVACY` will make the device
_use_ private addresses.
The device can still resolve RPAs when `BT_PRIVACY=n`.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
`bt_mesh_settings_store_schedule` should be called only when
CONFIG_BT_SETTINGS is enabled.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
The minimal value of BT_CODEC_MAX_DATA_LEN is 1, so it
is always > 0.
Includes to audio.h in shell bt.c was removed as audio.h
should only be included if BT_AUDIO=y.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The Kconfig option was not used anywhere besides some checks
that should have checked against CONFIG_BT_CODEC_MAX_DATA_LEN
instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In certain scenarios, it may be necessary to get values of additional
options from the application layer. With this patch, this can be
accomplished by registering a callback with the DHCP client.
This change has been tested using the posix build in qemu.
Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
Add a new endpoint callback that is used to report the found
ASEs during BAP discovery, rather than calling
the discovery callback with optional values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new pac_record callback that is used to report the found
PAC records during BAP discovery, rather than calling
the discovery callback with optional values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the BAP unicast client specific discover parameter struct.
This make the BAP discover work more similar to the other
profiles.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The direction has been moved to a function parameter instead,
and we keep a local copy of the value in the stack instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix BT_CTLR_SW_SWITCH_SINGLE_TIMER to correctly disable the
PPI group used to switch radio Tx/Rx. The issue was
uncovered when adding coverage in BabbleSim test.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Prepare to replace HAL_RADIO_ENABLE_ON_TICK_PPI with
independent use of HAL_RADIO_ENABLE_TX_ON_TICK_PPI and
HAL_RADIO_ENABLE_RX_ON_TICK_PPI.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Allow to periodically initializes/disables the modbus interface.
Switch from modbus line discipline to serial and switch back to modbus.
This can be required when the serial is shared by two sensors
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
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: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This fixes invalid conn unref that happens in ACL disconnected callback
context. When the ACL disconnects, the implementation waits for CIS to
be disconnected if connected. If the client won't disconnect the
CIS, the implementation initiates the disconnection by itself, from
delayed work context. Thus the ACL conn object has to be remained at
that time because it indicates whether the ASE object is in use or not.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Once the ACL disconnects, the implementation releases the related
endpoints. The ops->released callback is called once ASE enters IDLE
state, thus there is no need to call it explicitly.
This fixes repeated ops->released callback call.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This change splits the IEEE 802.15.4 test into two separate
test profiles, one with and one without sockets enabled to ensure
that both configurations work correctly.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current IEEE 802.15.4 stack assumes that drivers will
not provide more than one fragment in incoming packages.
This change exposes and enforces the pre-existing assumption
made by the implementation.
So far this is not a limiting restriction as MPDUs with more
than 127 bytes are not supported yet. It will probably have to
be changed as soon as larger payloads (as allowed by PHYs
introduced more recently into the spec) might want to allocate
smaller fragments.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
When changing IEEE 802.15.4 security settings or setting security
to 'none' then the previous session must be cleaned up to avoid
resource leaks.
This change introduces proper clean-up of the security session.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
LittleFS may be used not only for Flash devices, we can use it for
block devices too.
Add possibility of building LittleFS for case when
CONFIG_FLASH_MAP and CONFIG_FLASH_PAGE_LAYOUT are disabled.
Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
LittleFS may be used not only for Flash devices, we can use it for block
devices too. So, I have changed dependency rules and remove dependency
on flash map from FILE_SYSTEM_LITTLEFS.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
There is a check in bt_conn_auth_cb_overlay function which validates
if content of the callback structure is correct, but there is no
NULL-check on the structure pointer itself, which could result in
NULL pointer dereference.
It should be possible to set the callback structure pointer to `NULL`
using bt_conn_auth_cb_overlay function if the application requires
ex. Just Works pairing for one Bluetooth identity and global
callbacks are configured for advanced pairing scheme (like Passkey
Display) for other Bluetooth identity.
Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
This implements the deferring of characteristic value notifications to
be sent from system work queue thread context. Notifications issued from
Bluetooth Rx thread might not be sent if there are no L2CAP Tx buffers
available, as the operation is non-blocking to prevent deadlock while
waiting for free buffers.
The same operation issued from other thread context is blocking,
meaning that the thread waits until L2CAP Tx buffers become available.
Thus it's guaranteed the notifications will be sent.
With this patch, the control point operations become blocking until the
control point response is sent. Meaning there might be only one
pending operation waiting for completition. This might be further
improved by queuing the operations if needed.
Fixes: #57444
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Uses the new error system to report an error if the user provides
an invalid format for the OS info command.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
The general handler may provide buffers for a backend. Use ranges to
check if the provided buffer is used, because the backend may shift the
beginning of the buffer to make space for preamble.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Add a separate config to enable autoinitialization of the host command
subsystem, called by the chosen backend.
It allows setting the chosen backend without autoinit.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
The application code may need inside information about the host command
e.g. the thread id. Add a function that returns the main host command
structure which contains such data.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
For debug usage is added backend for memory window.
Coredump is being dumped in raw data. It needs to be converted to
ACSII for later analysis. Data is written to telemetry slot
in memory window which is a space where is located all debbug
information.
Signed-off-by: PawelX Dobrowolski <pawelx.dobrowolski@intel.com>
This change makes VCS Volume Flag characteristic Notify property
optional and selectable through Kconfig.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
Shifting "timeout <<= conn->zwp_retries" by more then 63 bits results in
undefined behaviour.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Universal Serial Bus Mass Storage Specification For Bootability requires
that device shall accept Bulk-Only-Transport bCBWCBLength of 12 for all
commands documented in the specification. Allow padding for commands
documented in Bootability specification, but leave others intact.
This fixes Request Sense on Windows 11 which previously failed due to
bCBWCBLength being 12 instead of 6.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Image list will only report active flag for active image and pending
flag for other slot, but only if image in that slot has higher
version than currently running image.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
If a socket has DSCP set then the packets from the socket should also be
marked with appropriate priority in case traffic classes are used in
networking stack.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
This is needed for applications that rely on WPA supplicant being
in disconnected state before issue subsequent commands (e.g., issue scan
immediately after disconnect fails, until disconnect is completed).
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
Fix Central CIS SN and NESN for skipped events during CIS
setup. It is possible that CIG event may overlap the ACL or
other events at the CIS create instant, and hence have non
zero lazy value during the CIS setup events until CIS is
established.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix CIS offset_min calculation to consider that ACL interval
and ISO interval can be dissimilar and the offset value has
to be compensated for the latency until the instant at which
the offset is used.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix SN value on Peripheral CIS event abort. Adjust the SN
value based on the burst number such that the ISO data where
transmitted as normal.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
- Add a new API `rtio_sqe_cancel` to attempt canceling a queued SQE
- Add a new syscall `rtio_sqe_copy_in_get_handles` which allows getting
back the SQE handles generated by the copy_in operation so that they
can be canceled.
Signed-off-by: Yuval Peress <peress@google.com>
The idle state was never set, thus providing a poorly
implemented state machine. Updated the code so that unused
code was removed and so that the idle state is properly set.
Optimized the way that a state is set for all endpoints
for a broadcast source with a new function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In the FIN_WAIT_1 any incoming data is dropped, but anknowledged. Add a
check to see if the data is already acknowleged to prevent double
acknowledging of the data and bringing the acknowlegde counter out of
sync. When the acknowledge counter gets out of sync, the connection will
never properly terminate any more.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Fix peer ISO feature support check, by using feature support
bit instead of whether locally supported bit value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use swapped role specific features bit to calculate features
usable by local device, on feature exchange procedure.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Central ISO assetion failure on being established due to
regression in commit a53d89450a ("Bluetooth: controller:
fixing CIS establish flow for refactored LLCP") that
required changes due to Create CIS LLCP being refactored.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The phy was converted both when reading from the event
and when reading from the sync, leading to incorrect
value in the synced callback.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The calculation in interval_to_sync_timeout did not take into
account that the periodic advertising sync interval was in units
of 1.25ms, and not ms.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
STRUCT_SECTION_ITERABLE cannot be used with arrays, because of
preprocessor tokenization issues.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Converts the list of functions for registering an MCUmgr SMP
transport from function arguments to a single list which contains
the function pointers.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds a new map to responses that command handlers can use to
return result codes of functions themselves, unrelated to SMP
error codes. This is achieved by adding an optional "ret" map
which contains a 16-bit "group" and 16-bit "rc" error code,
this map will not be included if the "ret rc" is 0 (which
implies success).
In order to allow this, a new version of the protocol has been
which can be indicated for use by setting a bit in the header.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
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>
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>
The function gets the the BLOCK1 option from a received message
and extracts the block number, block size and has-more flag from
it.
Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
The function adds a block option to a CoAP message. If the message
is a request the BLOCK1 option is added. Otherwise (response) the
BLOCK2 option is added.
Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
Add support for long writes to the control point
to handle e.g. metadata that's larger than the MTU.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Increase the size of the ase_buf to support
the maximum size of the Codec Configuration
and Metadata.
The ase_buf is not also guarded by a semaphore, so no
more than one thread will use it at any time. This is
needed as ase_status_changed can be called from multiple
threads.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for long read by adding a read_buf and store
the data when long data is being read.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of using the read by UUID, we do a "proper"
discover by UUID. The reason for this is that read by
UUID is not mandatory in the BAP specs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of using the read by UUID, we do a "proper"
discover by UUID. The reason for this is that read by
UUID is not mandatory in the BAP specs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of using the read by UUID, we do a "proper"
discover by UUID. The reason for this is that read by
UUID is not mandatory in the BAP specs, and that we need
to do a long read on the PAC records anyhow, and that
cannot be done with the read by type/UUID.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new struct unicast_client to hold all the conn-specific
data for the Unicast Client implementation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The maximum size of the characteristic is BT_ATT_MAX_ATTRIBUTE_LEN.
The previous size limited the size of the characteristic to
the maximum possible MTU, thus not utlizing support for the
Read Long procedure.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a semaphore to guard the read buf. The reason for this
is that the read buf is populated from either the BT RX
thread, or the workqueue thread. The semaphore ensures
that both threads will never have attempted to
add any data to the buffer at the same time.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
On connection clean-up release nodes held by LLCP. These are released
in two steps, first on LLCP terminate (in local/remote) by moving
to rx/tx_node_release chains, and then on conn_cleanup_finalize
nodes are released back to appropriate mem-pool/queue.
Rename abort functions to refer to terminate.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Instead of using the node ref used for TX ack for storing a TX node
pre-allocated in case of NTF RX node availability delay, introduce a
separate store to TX node. This to avoid misunderstanding on clean-up
in terminate flow.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Latest modification to LLCP removed 'monitoring' of cis->established
flag in LLCP, relying instead on signal through ULL.
For this to work properly the signal must also be generated, so this is
introduced. Note - checking of cis->established flag could be removed
if caller ensures only calling once (on establish condition)
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
When possible re-use the already allocated RX node for notifications.
Store (retain) RX node and Link element on RX if NTF could occur.
Pass link element to LLCP (ull_cp_rx()) together with RX node.
New RX node type RETAIN introduced to signal retention
When no RX node is available allocate one and hold off TX on procedures
until such time that a node is available for NTF.
In case waiting for NTF buffer avail is needed, allocate and store TX
node to use for TX once NTF becomes available.
CIS Established (incl. timeout handling) is now handled entirely as a
specific event driven by ull_conn_iso - ie removal of procedure check
of cis->established and cis->expire, as this is doubling mechanism
in the conn_iso context.
Unit test and helpers updated to handle new node type.
Function ull_cp_release_ntf() was used only in unit test, so moved to
helper context.
Updating release_ntf to handle the fact that with piggy-backing in test
context the node used for NTF can be from two different memory pools
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Use iterable sections to handle devices list. This simplifies devices
implementation by using standard APIs.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Add a trailing _ to the section iterable name. This is useful, for
example, to implement numeric sorting like this:
SORT(.z_device_LEVEL_?_)
SORT(.z_device_LEVEL_??_)
Without the trailing _ it would not be possible to use the ?? wildcard
without triggering into trigraphs issues, because linker-defs.h header
is included in C files as well.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
While it may be useful in some contexts, this information can be
obtained at compile time. Removing this command allows to migrate the
device infrastructure code to standard iterable sections, done later.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
It is no longer possible to select image for test or confirm
when MCUboot has been configured for DirectXIP.
MCUboot flags, in image trailer, are now ignored in DirectXIP
mode allowing to use entire slot for image upload.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Image management is now disabled by default if MCUboot
is configured for single application mode.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds img_mgmt_set_next_boot_slot function which uses
boot_set_next, from MCUboot/bootutil, to set application slot
for next boot.
The img_mgmt_set_next_boot_slot is intended to replace
img_mgmt_state_confirm and img_mgmt_state_set_pending.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds img_mgmt_active_slot() which allows to get
active (running) slot for given application image.
Added img_mgmt_active_image() allows to get number of image running
on current MCU core.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
There is no need to store the RPA in bt_addr_le_t structure, as the
bt_addr_le_t.type is unused anyway. Both bt_rpa_create and
bt_id_set_adv_random_addr take bt_addr_t as parameter.
Saves 1 byte of address type.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes uninitialized RPA value for BT_ID_DEFAULT.
The regression has been introduced in
8d6b206064.
As the result, the private address was not created and the advertising
was started with 00:00:00:00:00:00 address.
In case of the other advertising ID's, those are initialized
from id_create context.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The bt_gatt_indicate() expects its parameters to remain valid while the
indicate procedure is active. But the `sc_range` variable was local to
the function. It is assigned to the `data` field and passed on to
bt_gatt_indicate(). The memory associated with `sc_range` goes out of
scope as soon as the function returns thereby breaking the contract of
the API. This dangling reference will lead to undefined behavior.
This is now fixed by making the `sc_range` array static and further
making it an array of arrays, as the sc_range may have different values
for each connection.
Found as violation of MISRA C:2012 and CERT DCL30-C by sonarcloud.
Signed-off-by: Balaji Srinivasan <balaji.srinivasan@nordicsemi.no>
BT Core Spec states that feature exchange should be initiated if
not already performed. So in this case initiate feature exchange
and 'abort' enqueued CIS create if peer doesn't support CIS peripheral
feature
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
A request to set alternate zero for a non-existent interface
would succeed because of the inappropriate order of checks.
Move the check if the desired alternate is the same as the
current one after the check if interface exists.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Correct the return type of the helper function to get/set
current interface alternate value.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Check that the length of the packet is at least the size of
the descriptor head. Otherwise there may be unpleasant side effects.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
I imagine that expression (req != 0 || req != 1) is always true. Fix
it changing '||' to '&&'.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Rather than raise error on connect if iface is down, just take the iface
up.
Rather than raise error on disconnect if iface is down, just ignore the
disconnection request.
Adjust tests and documentation accordingly.
This should make the API easier to use for applications and is more in
line with the original L2 agnostic connectivity RFC.
Also replace some instances of net_if_flag_is_set with
net_if_is_admin_up, which is cleaner and identical in function.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
The current method for handling DAD directly tracks a DAD state for each
iface.
This does not reflect the fact that each individual IP has a separate
DAD state.
This also does not align with the logic in conn_mgr_initial_state, which
instead uses net_if_ipv6_get_global_addr(NET_ADDR_PREFERRED, ...).
Thus, the current approach falsely reports IPv6 ready when DAD adds
the link_addr, and also fails to report IPv6 ready if DAD is disabled.
This commit removes DAD tracking completely, and relies solely on
net_if_ipv6_get_global_addr(NET_ADDR_PREFERRED, ...), fixing both
problems, and simplifying the event tracking.
For consistency, slight modifications to IPv4 handling as well.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Currently, conn_mgr fires L4_CONNECTED and L4_DISCONNECTED events for
every individual iface that gains or loses connectivity.
After this commit, these events are only fired when the first iface gains
connectivity, and the last iface loses connectivity, respectively.
This is so that applications can rely on conn_mgr as a simple way to
track whether connectivity is available.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Adds a flag to allow ifaces and L2s to be ignored.
This is so that applictions have better control over what ifaces they
want connectivity management for.
Enabling the flag forces conn_mgr to consider the iface
unready.
Also increase NET_CONNECTION_MANAGER_PRIORITY default value from 0 to 1
so that applications can register SYS_INIT callbacks that fire just
before conn_mgr initializes. This allows ignored ifaces to be configured
before conn_mgr starts, if needed.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
In preparation for altering the conditions under which conn_mgr
fires NET_EVENT_L4_CONNECTED and NET_EVENT_L4_DISCONNECTED,
refactor the event logic without changing its behavior.
These changes do not alter the behavior of conn_mgr. They merely change
how that behavior is expressed so that it is easier to understand, and so
that upcoming changes are easier to implement.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Current implementation does not prevent the net_mgmt thread from
preempting during state change handling and generating more
state changes. Add a mutex to protect internal state of conn_mgr
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Relocate conn_mgr_if_get_binding to conn_mgr_private.h so that it
can be used by test suites.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Since conn_mgr is a subsystem rather than a library, relocate it
directly into subsys/net rather than subsys/net/lib/
Rename header files to better match their function.
Remove net_ prefix from conn_mgr types, API, and files, since it is
unnecessary.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Fix peripheral CIS receive window to consider that the
peripheral ACL could drift at the instant the CIS is being
established.
Hence add additional EVENT_TICKER_RES_MARGIN_US as receive
window length.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add CDC Ethernet Control Model class implementation for the
new experimental USB device support based on the existing
implementation subsys/usb/device/class/netusb/function_ecm.c.
The implementation forms virtual ethernet connection between
USB host and USB device and requires two corresponding MAC
addresses, one for the virtual interface on the device side,
and other for the host which is described by a string descriptor.
With upcoming changes it should also possible to use a real
ethernet controller as media access on the device side.
CDC ECM implementation supports multiple instances which are
specified using DT. The number of instances is limited by the
number of endpoints on the controller, two to three should usually
be possible.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add check to see if RPA is already generated for adv sets
with same id. If generated use the same address for all adv sets
with same id else create new RPA.
Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
Add proper validation check for the number of subgroups
attempted to be added to the broadcast source.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implement profile-agnostic broadcast source and broadcast
stream structs, similar to the unicast stream struct.
The purpose of these are to be able to use the same structs
for multiple profiles such as BAP, CAP and TMAP.
Since only the BAP shell implements broadcast support at this
moment, the changes are minimal, but makes it easier to implement
broadcast support for other profile shells.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Provide an extra struct net_if * iface parameter to
net_if_ipv*_maddr_join/leave functions, so that the corresponding
interface context, the mcast address belong to, can be locked for the
operation.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As `net_if_get_link_addr()` returns a pointer to the link layer
structure, some extra protection is needed to prevent its contents from
being changed while accessed. Using the mutex lock associated with an
interface should do the trick.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Instead of having a single global mutex, covering, in most cases
unrelated, access to all network interfaces, introduce a separate mutex
for each network interface.
Wherever interface function operates on an individual interface context
data, use local mutex protection instead. The global mutex remains only
to protect access to shared resources (IPv4/6 context pool, timer lists
etc.).
Finally, rework the timer expiry handlers, to prevent interface
functions from being called while the global lock is held (the global
mutex has to be held when iterating over the timer list, as lists are
not thread safe). The reason for this is to avoid possible deadlock
scenario. The global mutex is sometimes being locked, while inside
interface function (protected by a local mutex), so if it was allowed
the other way as well, a deadlock could occur.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fixed issue when performing the ordered access procedure on
a set of devices where none had the lock characteristics.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The set info returned by the Set Coordinator did not contain
information about the lockable state. Furthermore the
set info was not properly initiated, as it was missing the
rank, which was set somewhere else.
This commit adds the lockable state to the set info.
This commit removes the rank from internal structure,
and uses a reference to the set info instead, and only
store the rank there.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The set size and rank validation did not allow setting e.g.
rank = 2 and set_size = 0, which should be allowed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Whenever a CSIS instance is registered with
bt_csip_set_member_register we now properly check if the
set size, rank and lock characteristics should be present.
If not, then remove them from the service declaration.
It is done this way, as it is easier (read: possible) to
remove characteristics from the service declarations,
than it is to add the optional characteristics, as the
optional characteristics may be present in some CSIS
instances, but not in others.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_csip_set_member_register function would register
the connection, and connection auth info, callbacks for
each CSIS instance, which could give errors when/if the
callbacks are called too many times. In any case, they
should not be registered multiple times.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
LLDP start timer is executed when iface is up
at startup, then once more when iface up event
is received.
When iface is up before net_lldp_init call, then multiple
entries are added to the lldp_ifaces related to the
same iface.
That leads to continuous loop execution within
lldp_tx_timeout.
This commit checks if lldp tx_timer_start is set and
doesn't append new entry into the slist.
The tx_timer_start is set at startup and reset on
down event.
Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
Since the provided callback can be NULL which would
break things, add a check and a return value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The number of streams for a broadcast sink is maximum 31,
or the maixmum number of BIS we support.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Reworks the zephyr macros and pools to be objects in their own right. Each
pool can be statically defined with a Z_ private macro. The objects can
then be initialized with an rtio instance statically.
This cleans up a lot of code that was otherwise doing little bits of
management around allocation/freeing and reduces the scope those functions
has to the data it needs.
This should enable sharing the pools of sqe, cqe, and mem blocks among rtio
instances in a future improvement easily.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Rather than the rings, which weren't shared between userspace and kernel
space in Zephyr like they are in Linux with io_uring, use atomic mpsc
queues for submission and completion queues.
Most importantly this removes a potential head of line blocker in the
submission queue as the sqe would be held until a task is completed.
As additional bonuses this avoids some additional locks and restrictions
about what can be submitted and where. It also removes the need for
two executors as all chains/transactions are done concurrently.
Lastly this opens up the possibility for a common pool of sqe's to
allocate from potentially saving lots of memory.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Fix use of uninitialized ticks_slot value in calculation of
cis_offset_min when creating CIS. Calculate the ticks_slot
value earlier when committing the CIG parameters.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not enqueue node rx buffers for generating invalid ISO
data from Tx ISR while supplying the node rx buffer to
Radio. This causes node rx pool corruption and also MIC
failures in the central ISO LLL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix peripheral ISO data ack mechanism to correctly update
the SN when PDUs fail to be received.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When there is an active CIG for a new CIS create, then use
strict cis_offset_min/cis_offset_max so that the new CIS
is scheduled inside the active CIG event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
'ps_wakeup_mode' is used to set the wake up interval
to either 'dtim or 'listen_interval'. By default the
sta wakes up every dtim interval.
With 'ps_wakeup_mode' set to 'listen_interval' sta
will wake up for every listen interval period configured.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
listen interval is the time periods the STAs may be in idle
without listening beacons.
By default STA wakes up for every DTIM period.
If listen interval based power save is used
STA uses configured listen interval period(default 10
beacon intervals) to wake up.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
Fix ztress_execute() out-of-bounds in case it is called with timer
and for maximum number of threads allowed (CONFIG_ZTRESS_MAX_THREADS).
Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
Add shell based on sip_svc subsystem to access the SDM mailbox in
EL3 layer using ASYNC sip_svc request.
Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
Introduce a new SiP SVC subsystem to provide ARM Silicon Provider based
supervisory call services. SiP SVC service provides the capability to
send SMC/HVC call from kernel running at EL1 to hypervisor/
secure monitor firmware running at EL2/EL3 and also added SiP SVC shell
commands to exercise the service.
Signed-off-by: Mahesh Rao <mahesh.rao@intel.com>
Prevents verifying the image has been uploaded successfully using
the hash provided at the start of the upload if the hash is not
the correct length of an SHA256 hash.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Cast `dhkey` to `void*` to avoid a warning from the logging subsystem:
```
<wrn> cbprintf_package: (unsigned) char * used for %p argument.
It's recommended to cast it to void * because it may cause misbehavior
in certain configurations
```
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
This allows to move flash operations from the context that triggered
IVI update to the mesh settings work item that runs on the system
workqueue. After this change, the outdated RPL entries will be removed
in the setting work item triggered by store_pending function in
mesh/settings.c. This is required to for a case where the mesh settings
work item is running on a separate thread instead of the system
workqueue to unblock the system workqueue eventually.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Bitsets across byte boundaries does not work properly for big-endian;
Converted to use two uint8's instead
Signed-off-by: Troels Nilsson <trnn@demant.com>
As we are using a generic validation function for limits, due to data
type mismatch the check for TWT interval overflow and fails.
Fix the data type and accordingly the maximum value in the help.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
Add command to add a source by the broadcast ID. This will
initiate scanning for the broadcast ID, making it unnecessary
for the user to keep track of both the broadcast ID, the SID
and the address, and just focus on the (properly) known
broadcast ID.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The cmd_bap_broadcast_assistant_broadcast_code used decimal, instead
of hex, for the broadcast code, making it a lot harder to use.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Always print/log the 24-bits (as hex) of the broadcast ID to better
use it with e.g. the shell.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If starting the discovery procedure multiple times, the
subscribe function returns -EALREADY which needs to be handled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Moved the implementation of the pa_decode_base to a public
function, and modified it to return better error codes.
The implementation was moved to be publically
accessible, rather than internal in the Broadcast Sink,
as e.g. a Broadcast Assistant need to be able to decode the
BASE too. This wil also allow an application to decode it
itself, if it so wanted to.
This also adds a log module for the audio.c file, as logging
would otherwise not be supported.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Verify that PAST would be possible before providing
BT_BAP_BASS_PA_REQ_SYNC_PAST as the PA sync value to the
Scan Delegator.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make the `pa_sync` field of the
bt_bap_broadcast_assistant_add_src_param and
bt_bap_broadcast_assistant_mod_src_param to boolean
instead of uint8_t, as it represents a boolean value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix possible NULL dereference at net_pkt_cursor_operate() and
resolve 'Dereference after null check' warnings from the Coverity
static code analysis.
Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
Added paired_ep to bt_bap_ep_get_info, which would allow to check
whether an endpoint is paired with another endpoint, this would
indicate that its coupled to a bidirectional iso.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
TFM is not the only provider for PSA API, which means
the PSA config shouldn't depend only on it.
Signed-off-by: Piotr Jasiński <piotr.jasinski@nordicsemi.no>
The receiver_ready field can only be set while in the enabling
state, and is a requirement to go into the streaming state.
If for any reason we go into a state that is not enabling
or streaming, then the receiver_ready field should be
cleared, as the circumstances are changed.
This also fixes an issue where if the CIS disconnects,
then we go from the streaming state to the
qos configured state, without clearing it, causing
incorrect behavior if we attempt to connect the streams
again.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change fixes check for upgrade-only to ensure that the the new image
version is greater than version of the currently running image.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Mesh models may have a data that needs to be stored persistently.
Currently, the models should call bt_mesh_model_data_store and the store
will happen in the calling context. Most likely that it will be called
in BT RX thread as this is the context from which model's opcodes
handlers are called. Thus, the thread will be blocked until the store is
finished.
Another issues is that some models may have states that changes
frequently. Triggering the store on every state change may wear out
flash. Therefore, the models need to implement some postpone mechanism
to reduce the flash wear out.
The mesh stack has already implemented the mechanism of deferred store
with its own settings. The models could use it instead of implementing
their own mechanism.
In combination with the mesh settings workqueue, the models can store
their data without blocking the stack work.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Currently mesh settings are stored in the system workqueue context.
Most of other stack functionality, such that advertisements (incl
relay), loopback, transport sar, beacons transmission, etc. is also
processed in the system workqueue context. When a massive amount of
data needs to be stored and in particularly when page erase needs to
be triggered by GC of NVS subsystem to allocate flash pages, the
execution of the stack (and other functionality that uses the system
workqueue) will be blocked until storing is finished. For example,
right after the provisioning of a erased device, a node may not be
responsive for up to 400ms before it can continue sending messages.
The waiting time may increase if there is a GATT connection in the
mean time.
When write or erase operation is triggered, the flash driver waits for
Bluetooth controller to allocate a time needed to perform the operation.
During the whole operation, the context from which the operation was
triggered is put to sleep. This allows other threads to run until
Bluetooth controller finds the time for the flash driver. In other words,
every settings_save_one or settings_delete should be considered as
rescheduling points.
Considering this, Bluetooth mesh can use another thread to store its
settings, thus releasing the system workqueue for other tasks including
the operation of the stack itself.
The consistency of the data to be stored is guaranteed by the current
implementation where the data is copied to another struct before calling
settings_save_one. The pending flag of a particular module is dropped in
settings.c before starting to store the corresponding data. Thus, if
during the sleep the node receives a message that triggers a change in a
module which data is currently being stored, the pending flag will be
restored and the new change will be stored eventually.
Having this option enabled including with the partial erase, will make
the node more responsive in the described situations.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The generic BT shell header, bt.h, contained quite a few things
related to audio, which should be put in the audio.h shell header
file.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Updated nRF5 Series LLL implementation to support multiple
peripheral CIS establishment from peer central devices.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Central multiple CIS create implementation using advanced
scheduling to find the active CIG events and calculate the
CIS offset to be used in the LL_CIS_REQ PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use accumulated connected ISO LLL prepare callback latencies
to check supervision timeout.
Also use the accumulated connected ISO LLL prepare callback
latencies to adjust SN and NESN values.
Connection establishment can cause short prepare callbacks
inserted before Connected ISO group prepare callbacks, that
cause the Connected ISO group prepare callbacks being
cancelled while being in prepare pipeline. Hence, it is
necessary to accumulate prepare callback latencies wherein
ticker callbacks are executed but prepare callbacks are
cancelled in the prepare pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation of preliminary Central with multiple CIS
create support in Lower Link Layer. Uses a simple CIS
offset calculation that works when ACL are created with
connection interval that is multiple of CIG ISO interval.
Each ACLs are offset using BT_CTLR_CENTRAL_SPACING hence
having the same CIG sync delay values for all the ACLs.
Advanced Scheduling to setup CIS in any order of ACL and
CIS combination, ACL placed anywhere in timeline and CIS
creation will come therein will be implemented in later
Pull Requests.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Include ticker expire remainder value when calculating the
cis_offset to acheive fine timing in scheduling the CIG
radio events relative to its associated ACL radio events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the ticker_start_us() interface for Central and Central
ISO setup to acheive fine timing for the first expire
timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
To acheive microsecond or fine timing for first expire
timeout, pass remainder value of the coarse tick to a new
ticker_start_us() interface. The new interface is available
with BT_TICKER_EXT feature enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation of CIS Null PDU Indicator use to meet the
BT Specification statement, that, if the source of the data
fails to provide a payload in time for a CIS subevent, then
the link layer shall transmit a CIS Null PDU instead.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is re-introduction of Extended, Periodic Advertising
and Broadcast ISO using ticker expire info feature to get
the aux, sync and BIG offsets.
Relates to commit 714d74b77b ("Bluetooth: controller: Use
new ticker feature to get offsets").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Ticker remainder and lazy get depends on match get interface
provided by BT_TICKER_NEXT_SLOT_GET_MATCH.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove redundant range and default for BT_CTLR_ADV_AUX_SET
when supporting BT_CTLR_ADV_PERIODIC.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
BT_TICKER_EXT is not supported with BT_TICKER_LOW_LAT.
Remove redundant select of BT_TICKER_EXT for
BT_CTLR_ADV_EXT.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add the labels from the device tree fixed flash partitions
as a column to the flash_map list shell command.
Signed-off-by: Maurits Fassaert <maurits.fassaert@sensorfy.ai>
Start/pause encryption should not be initiated on ACL with CIS
established (BT Core Spec 5.4, Vol 6, Part B, Sect. 5.1.3)
Adding test for the added procedure peek function
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Clean up log_const to utilize macros for handling sections.
Update database_gen.py to match naming convention change.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Use BT_CONN_TX_USER_DATA_SIZE when defining pools of buffers that will go
through `bt_conn_send_cb()`.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
MTU doesn't count against the ISO and ISO data headers.
Then a config with CONFIG_BT_ISO_TX_MTU ==
CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE should not fragment SDUs over HCI.
Also set the TS_Flag bit if a timestamp is present.
Fixes#56749
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This change to the shell API enables the user to retrieve the
return code of the most recently run shell command. This is
useful both for users wanting specific information beyond the print
statements in a command, but especially for automated users
that prefer a simple return code to parsing human readable text.
This was tested using all default shell commands, as well as
eeprom, flash, and i2c, where specific errors could be forced.
In all cases, the correct return value was returned by the new
retval command.
Signed-off-by: Hunter Searle <hsearle@xes-inc.com>
If the broadcast sink is already stopped (i.e. the streams have
all been disconnected), then we can return a more useful
error code than EINVAL.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds a Kconfig symbol which contains the default controller TX power
directly in dBm. This allows code to directly display/use the configured
power, instead of having to manually iterate over all the
`BT_CTLR_TX_PWR` options.
```
LOG_INF("BT controller configured for %ddBm TX power",
CONFIG_BT_CTLR_TX_PWR_DBM);
```
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
It was previously assumed that the 'sys_mem_blocks' struct would maintain
information about contiguous blocks allocated so the release API only
took the starting address. This led to an issue where allocating 2+
blocks would end up with a memory leak because any block not being the
first would never be released.
Add the buffer length as an argument so the correct number of blocks can
be released. Also, ammend the tests to match and verify.
Signed-off-by: Yuval Peress <peress@google.com>
Print new NET_IF_IPV6_NO_ND and NET_IF_IPV6_NO_MLD flags when
the "net iface" command is used.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
OpenThread networks do not use ND or MLD as they have their own set of
protocols to cover this functionality. So far, the use of OpenThread
with Zephyr relied on disabling those protocols support statically with
Kconfig, which prevented OT interfaces from being used along with other
IPv6 interfaces.
With the new network interface flags, it's now possible to disable ND
and MLD on individual interfaces, therefore disable them for OT
specifically.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add new network interface flag, which allows to disable Multicast
Listener Discovery protocol from being used on the interface. This
allows to interfaces that do not support ND (like OpenThread) to
coexist with other IPv6 interfaces.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add new network interface flag, which allows to disable Neighbour
Discovery protocol from being used on the interface. This allows to
interfaces that do not support ND (like OpenThread) to coexist with
other IPv6 interfaces.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This allows to move flash operations from the context that triggered
storing device key candidate to the mesh settings work item that runs
on the system workqueue. This is required to for a case where the mesh
settings work item is running on a separate thread instead of the system
workqueue to unblock the system workqueue eventually.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This allows to move flash operations from the context that triggered
bt_mesh_provision or bt_mesh_reprovision to the mesh settings work item
that runs on the system workqueue. This is required to for a case where
the mesh settings work item is running on a separate thread instead of
the system workqueue to unblock the system workqueue eventually.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
If the icmsg backend is sending the data from many
contexts, the send buffer must be accessed only by one
context at a time. Ensure that by adding mutex when
sending.
Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
Clearing of shared memory by one side of the communication
is no longer required after
commit 0620cb1fe1
("ipc: ipc_service: icmsg: Increase reliability of bonding")
was merged.
Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
The LOG_ERR was printing the wrong variable. `type` always has the value
`BT_BUF_H4` here, so there is no point in printing it.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Remove all enabling of CONFIG_EMUL_.* in favor of automatically enabling
peripheral emulators based on the compatible string presence in the device
tree and the one true CONFIG_EMUL.
Zephyr has long since moved to a model of enabling drivers based on the
presence of their associated IC's compatible string in the final devicetree
overlay. There is no reason that emulators can't align in just the same
way, and probably ought to to remove superfluous enabling of configs.
Signed-off-by: Aaron Massey <aaronmassey@google.com>
This deduplicates a code a bit by reusing existing bt_bap_stream_reset
function to unbind and detach the stream object.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This removes redundant bt_ascs structure pool that held the list of
ases per connection. The memory usage can be reduced by moving the conn
reference to bt_ascs_ase structure. This change reduces flash and RAM
memory usage.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The PAwR sync can receive a connection request from the PAwR
advertiser and become peripheral.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
This is known as the Periodic Advertising Connection Procedure.
The PAwR advertiser can initiate a connection to a synced device and
become the central.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Prevent referencing inactive CISes by clearing state variables
after teardown. This was seen as necessary when having CISes on
different ACLs, and disconnecting ACLs in random order.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Transmit errors must be treated differently than Protocol Errors.
This change sets a flag that informs the stack of a Message
Transmit error.
Signed-off-by: Sam Hurst <sbh1187@gmail.com>
In the broadcast sink when the streams disconnected (without
the PA disconnecting), the streams were not properly
removed from the sink's list of streams. This allowed
the same stream to be added to the list twice, which
would cause a infinite loop as the stream would
point to itself as the next.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The reassembly buffer for periodic sync was not initialized
if the sync was established via PAST.
Move the initialization of the reassembly buffer to a common place.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Adds API for Periodic Advertising with Responses - Scanner:
- Synchronize to a PAwR train
- Choose which subevents to synchronize to
- Receive advertising reports from subevents
- Send responses
The support is enabled by CONFIG_BT_PER_ADV_SYNC_RSP, and requires
a controller that selects CONFIG_BT_CTLR_SYNC_PERIODIC_RSP_SUPPORT.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Adds API for Periodic Advertising with Responses - Advertiser:
- Configure parameters
- Receive subevent data requests
- Set subevent data
- Receive response reports
The support is enabled by CONFIG_BT_PER_ADV_RSP, and requires
a controller that selects CONFIG_BT_CTLR_ADV_PERIODIC_RSP_SUPPORT.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Fix dhcpv4_create_message() dereferenced NULL return value from
net_pkt_alloc_with_buffer() in case of no memory available.
Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
In case when CONFIG_MCUMGR_SMP_LEGACY_RC_BEHAVIOUR=n then
the image erase command would incorrectly return MGMT_ERR_EMSGSIZE,
even though no such error occurred.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fix net_ipv4_send_fragmented_pkt() dereference of NULL return value
from net_pkt_get_data() possible with non contiguous packet data.
Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
The ATT_PENDING_SENT flag was still not being cleared in all cases.
Also reset `data->att_chan` when not able to send on a given channel.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The API doesn't allow the stack to make any guarantees about the number of
available buffers that the app has.
Only send 1 credit at a time, as that is the only guarantee the stack can
give to the peer.
We can send MTU/MPS's worth of credits once we have acquired an SDU buffer
from the application (that is, on the first PDU of the SDU). Though we
still have to cap that to the buffer size we have just acquired.
------
The testcase added here shows a scenario where the relationship
between the number of credits and the number of available buffers does not
hold true any more:
In this test, the app only has one buffer in its pool.
The central will queue SDUs that are bigger than the stack's
buffers (so the user allocator is necessary) but lower than the
channel's MTU.
The device receiving the SDU keeps a reference to the buffer before
returning from the `recv` callback. It releases that reference after a
small delay.
The central will still have credits, so it will queue another SDU, but the
peripheral will not be able to receive the next SDU (as the allocator will
fail) and will close the channel.
To see the test fail, just revert the `l2cap.{c,h}` changes.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Turns out the [first bugfix] was too naive: there is a case where resuming
all channels will not work on all queued SDUs, and the work handler will
give up and wait for the next sent SDU instead of trying to resume again.
This happens when the number of credits and conn contexts is very low for
the amount of data to send.
Always reschedule with a delay to avoid that situation.
[first bugfix]: https://github.com/zephyrproject-rtos/zephyr/pull/50476
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined. To fix this add needed ifdef'ry.
Build various network samples that utilize ethernet but don't have
CONFIG_NET_PROMISCUOUS_MODE will get a link error for:
Error: L6218E: Undefined symbol
net_mgmt_NET_REQUEST_ETHERNET_SET_PROMISC_MODE
(referred from ethernet.o).
Fix by adding ifdef protection around promisc code.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
TWT flow id is of 3 bit value(maximum mnumber of flows
supported is 8). Flow id range limited to 0 to 7.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
This fixes loop over arrayed metadata/cc parameters. The paramaters have to
be pulled from the buffer, because in case the ASE_ID is invalid or in
invalid state, the next loop iteration would read invalid data.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add configurations where CONFIG_BT_AUDIO_TX and CONFIG_BT_AUDIO_RX
are disabled.
Fixes issues found in the BT shell implemented caused by these
configurations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the BT_AUDIO_TX guard so that it does not cover the
verification functions for valid_codec and qos, as they
are also relevant for receivers to verify what remote
devices send.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix tcp_send_zwp() retransmission timeout calculation to avoid sign
extension on bit shift operation: the uint16_t value was implicitly
promoted to 32-bit signed type with sign extension to uint64_t.
Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
Fixes the compiler error that occurs when attempting to build
the SNTP library with CONFIG_NET_SOCKETS_POSIX_NAMES=n, while
using native_posix.
Closes#57133
Co-authored-by: Chris Friedt <cfriedt@meta.com>
Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
This adds callbacks for Secure and Private Network Beacons.
SNB callbacks are called after `secure_beacon_authenticate` ends
with success, and Private Beacon callback after Private Beacon
payload is decrypted succsessfully.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
This removes opcode from ascs_cp_rsp_add function parameters and moves
response buffer initialization to be done in Control Point write
function context.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Mounting the disk in a global function can lead to an issue
where fatFS cannot be mounted due to it not being registered beforehand.
To solve this problem, fatFS is now initialized in POST_KERNEL,
just like the littleFS initialization function.
fatfs_init must be called before attempting to mounte the disk.
Signed-off-by: Sihyun Noh <awake_noh@naver.com>
Refactoring. All occurences of `atomic_test_bit((.*)->flags,
ATT_ENHANCED)` are replaced with `bt_att_is_enhanced($1)`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The EATT MTU in Zephyr is static. We know it at channel creation time,
so we should communicate the MTU as part of channel creation.
Side note: With this approach, it should no longer be neccessary or
useful to do a channel reconfigure.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The previous approach with `cap_eatt` was flawed. It would overwrite
`le_chan->tx.mtu`, losing its true value. (It is supposed to be the
L2CAP MTU as reported by the remote side.)
The previous approach worked out for UATT because the locally triggered
exchange always carries the remote MTU in the response, so we did not
need to keep track of the remote MTU.
But, unlike the UATT MTU exchange, the L2CAP reconfigure only exchanges
the MTU in one direction. If the remote does the first reconfigure, we
would correctly cap the ATT MTU to our local MTU. But, we would
incorrectly store this as the remote's MTU. When we then increase our
local MTU using `bt_eatt_reconfigure`, we correctly set and send our
MTU. But we have an incorrect notion that the remote MTU is the value
that we ourselves limited. And mistake would incorrectly limit the
negotiated ATT MTU locally.
The simplest solution is to not mess with `le_chan->tx.mtu` and just
calculate the ATT MTU like Spec intended.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
This is a refactor. There is no behavioral change because
`BT_LOCAL_ATT_MTU_UATT` is `BT_LOCAL_ATT_MTU_EATT + 2` is
`BT_ATT_BUF_SIZE` is the old `BT_ATT_MTU`.
The old `BT_ATT_MTU` was wrong for EATT bearers. EATT MTU is two bytes
less because of ECRED overhead.
Instead of the old `BT_ATT_MTU`, we define one for each bearer type. We
also define the max of them to use as a convenience for allocating
buffers that fit either.
To avoid confusion, 'LOCAL' has been added to the name. This is to
differentiate it from what the spec calls 'ATT MTU', which is a
negotiated property. (It is the minimum of the two side's local ATT
MTU.)
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
There is an assert that `req_psm` is the same for all channels in the
same connection request because HCI requires this. The same is true for
`req_mtu`. This adds the obviously missing assert.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
This is a refactoring, only visible inside `att.c`.
Give the expression `chan->chan.tx.mtu` the name `bt_att_mtu`. Use it
when the intention is to get the ATT MTU property of a channel.
This is done in preparation a more complex expression for `bt_att_mtu`,
since the expression currently incorrect. The fix will come in a later
commit in the same PR.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The function should be used to reset map decoding state
between calls to zcbor_map_decode_bulk, while using the same map
for different buffers.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Due to broken logic in img_mgmt_state_confirm failure to confirm
was not reported to caller.
If hooks were enabled confirmation event would be passed regardless
whether it has been successful.
Fixes#56617
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Adds a command which can be used to enter mcuboot's serial recovery
mode when the retention subsystem is enabled.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds a boot mode system which allows for redirecting the boot
target of a device depending upon the state of a retained value.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds a retention system which builds on top of retained_mem
drivers to allow partitioning of areas and data integrity with
magic header prefixes and checksum of stored data.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
The dummy header was an opt-in feature to allow testing without a
real image but since we support testing on Qemu in CI which
supports flash partitions, there isn't a need for this option. Not
being deprecated as Kconfig would only have been used as part of
CI, not user applications.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Function allows to check whether given key has been found
during map decoding with zcbor_map_decode_bulk.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This moves ASE Control PDU length validation before request processing.
If the PDU length is not as expected, the operation shall be considered
as invalid. Thus shall be rejected.
ASCS_v1.0; 5 ASE Control operations
"A client-initiated ASE Control operation shall be defined as an invalid
length operation if the total length of all parameters written by the
client is not equal to the total length of all fixed parameters plus
the length of any variable length parameters for that operation"
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes sending proper Response_Code in ASE Control Point
notification in case the client initiates Receiver Start/Stop Ready
operation on Sink ASE.
The response that shall be sent according to the specification is
"Invalid ASE direction", while the implementation sent "Invalid ASE state"
instead.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The possible control endpoint MPS for USB 2.0 FS devices is
8, 16, 32, or 64 bytes. Typically, USB2.0 compliant devices support MPS
up to 64 bytes, and we have not had the need to support other MPS.
This patch implements a mechanism to fall back to the minimum allowed
MPS when a controller is likely a USB 1.1 compliant device and does
not support control endpoint MPS of 64 bytes.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Cleanup linker scripts for net_buf_pool section to use the linker
script related iterable section macros.
Also replace _net_buf_pool_list with macro's instead to complete
iterable section usage.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Add verbose output of scan data to output all received data types as
hex values. This is turned off by default and can be toggled using
the bt scan-verbose-output <on|off> command.
Signed-off-by: Martin Rieva <mrrv@demant.com>
This commit simplifies the arguments for sending dns responses
and fixes an issue where both the ipv4 and ipv6 member of a header
union were accessed.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Duplicate logging prints make it hard to find the origin.
This commit does a cleanup of the debug messages printed.
Also change the level of an invalid record to debug as this
is out of our control.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
For offloaded iface net_tcp_get is never called, so context->tcp
is always NULL. In that case net_tcp_tx_sem_get will return wrong pointer.
For pollout k_poll will be called with NULL semph,
which cause HardFault.
Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
Change the default value of past_preference to true, to prefer
PAST by default when using the scan delegator.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When copying the stream specific codec configuration data,
the value pointer in the bt_data struct was not properly
updated, causing possible invalid data access.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_cap_initiator_unicast_audio_update function was missing
NULL and 0 checks for input parameters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Use the minimum supported cis_offset_min considering that
ACL radio event does not overlap with CIG event. Use the
calculated maximum of local and remote cis_offset_min in the
Response PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
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>
Convert handling of shell_root_cmds, shell_subcmds, and
shell_dynamic_subcmds to use iterable section macros.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Allows L2s to declare generic association/connection routines
that can be bound by name to ifaces.
Allows L2-agnostic control over connectivity/association for
iface that support it.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Commit adds experimental support mbedtls psa as crypto
backend for ble mesh. It were run only on bsim tests.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Commit gets rid of host dependency to generate DH key.
Mesh uses its own function for it that has synchronous
behavior and correct endianism. It simplifies the provisioning
state machine since it doesn't require waiting for the host HCI
handler.
Also, it removes hidden cross-dependency between BLE Mesh and
SMP in the aspect of competition for the same DH key
(https://github.com/zephyrproject-rtos/zephyr/issues/23292)
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Commit splits mesh crypto module on security library dependent
and independent parts.
Independent part includes security toolbox implementation.
Dependent part includes security algorithms usage based on
API third party security library.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Calls put instead of unref on net contexts
in the socket accept function.
Mere unref didn't subtract the reference
count of net context which leaves
it in used state. This situation happens
in case of accepting already
closed connection.
Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
Added a feature of socket connect
being asynchronous. If socket is set
to nonblock with O_NONBLOCK flag,
then connect() is non-blocking aswell.
App can normally poll the socket to
test when the connection is established.
Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
This reverts commit cd7461495f,
introduced to fix possible deadlock as result of changes in
commit f206170c65
("usb: device: Do not call callback when transfer is cancelled")
which is now reverted.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This reverts commit f206170c65
introduced as workaround for nRF USBD device controller in PR
https://github.com/zephyrproject-rtos/zephyr/pull/16193.
This commit may be reverted due to changes made in
commit e326c58399
("usb: device: Do not cancel transfers on suspend").
Signed-off-by: Nickolas Lapp <nickolaslapp@gmail.com>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Fix Advertising PDU size calculation when direction finding
feature is enabled and PDU fragment count includes the
maximum CTE PDU chained. Fix removes redundant PDU count
included for Extended Advertising. Only Periodic advertising
PDUs chain CTE requires number of additional PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When ISO Central is enabled it is allowed to configure many CISes at
once. For this a large command buffer is needed. This is also tested
by HCI/CIS/BI-05-C.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Fixes#56657, incorrect TCP MSS calculation for IPv6.
Previously the supported MSS would incorrectly returned as the MTU if it
was less than the MTU, probably to account for the case where
the network interface MTU check returns 0.
New behaviour is to return the supported MSS as MTU minus header length,
using default MTU for this calculation if network interface MTU check
returns 0.
Signed-off-by: Kenny Johansson <wirehell@gmail.com>
If device running BLOB Server called `bt_mesh_blob_srv_recv`,
but rebooted before it received `XFER_START` message from BLOB Client,
it was wrongly "recovered" into Suspended phase, which would lead to
Server try to resume transfer on `XFER_START`. It would not be possible,
because `srv->state.xfer` was not set with acual values yet.
Set phase again to BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_START, which will
allow to accept new transfer.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Corrected printed message on failing test with expected or received
NULL pointer in ztest_check_expected_data.
Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
A case of an invalid PDU was seen leading to a hit on this ASSERT, ie
this COULD happen. Refactoring of the state handling re. expectedness
in remote vs local request machines combined with ensuring the local
request machine ceases to expect PDUs when remote procedure 'takes over'
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Fix regression in refactored LLCP using uint16_t instead of
uint32_t in storing the win_offset_us value. This caused
connection update to fail with incorrect window offset being
used to schedule the connection radio events.
Regression since commit e1c2c36f56 ("Bluetooth: controller:
llcp: set refactored as default").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined. To fix this add needed ifdef'ry.
Fixes#56630Fixes#56628
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.
Most of these changes were automated using coccinelle with the following
script:
@@
@@
- void
+ int
main(...) {
...
- return;
+ return 0;
...
}
Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.
Signed-off-by: Keith Packard <keithp@keithp.com>
The audio code utilizes BT_CONN so ensure its only built if
CONFIG_BT_CONN is set. This is to fix a build issue we see
with arm-clang for:
sample.bluetooth.broadcast_audio_source
which fails to link since bt_conn_get_info is missing.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Fix window offset calculation which is missing the radio
rx ready delay timing be subtracted because the connection
offset from the start of the radio for scan window to the
end of the ADV_IND PDU includes the radio rx ready delay
timing, where as the determined window offset by advanced
scheduling calculates the offset from the ticks_at_expire
of the scan window to an active central connection's
ticks_at_expire.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update Advanced Scheduling implementation to use remainder
value in precisely calculating the connection request window
offset in microseconds.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the use of rx chain delay value used to calculate the
window offset into lll_scan_prepare_connect_req() instead of
current two places, one for legacy and other for extended
connection setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Find and match only Central role ticker when applying the
BT_CTLR_CENTRAL_SPACING value.
Use the EVENT_TICKER_RES_MARGIN_US value as +/- jitter
margin when ticker advanced scheduling is used to group
radio events.
When using CONFIG_BT_CTLR_CENTRAL_SPACING, do not add the
+/- jitter to the ticks_slot.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Included consideration for the packet sequence number and time stamps
together with the SDU interval in matching the event for fragmentation
of SDUs to unframed PDUs.
Implemented:
-- Increase in kconfig limit of BT_CTLR_ISO_TX_BUFFERS to allow full 32
buffers to be available for LL/CIS/PER/BV-39C
-- ISO-AL microsecond time wrapping exposed to be used externally to
adjust incoming Group Reference Points and Time-stamps where required
-- Function that handles adjustment of payload number according to
incoming SDU exposed for external use to allow next payload number to
be accessed by ISO transmit tests
-- Changed internal fragmentation source identification parameter from
the source structure pointer to the source handle so that only the
source handle needs to be used for external calls
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
This new configuration option, SHELL_BACKEND_RTT_BUFFER, allows selecting
an alternative buffer for the Shell's RTT backend. By default buffer 0 is
used, which conflicts with the default logging subsystem RTT backend
buffer.
This option is the counterpart to the logger's LOG_BACKEND_RTT_BUFFER.
Signed-off-by: Maurits Fassaert <maurits.fassaert@sensorfy.ai>
Private Beacons are mesh-1.1 feature and without mesh-1.1 spec enabled,
the node shall not process such beacons.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Private Beacons and Secure Network Beacons are not mutually exclusive by
spec. This means both beacons can be sent simultaneously. For both
beacons spec defines their own observation intervals and related
parameters, which means we need to monitor both beacons types
separately.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Since we enable -fshort-enums for arm-clang we get the following
warning:
subsys/bluetooth/mesh/pb_adv.c:139:40: warning: cast to smaller
integer type 'enum prov_bearer_link_status' from
'void *' [-Wvoid-pointer-to-enum-cast]
Fix this by first casting to an int to grow the size of the type.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
it is too late to set ctx->state to ISOTP_TX_WAIT_FIN after send_sf
because send_state_machine could be called just between `send_sf` and
`ctx->state = ISOTP_TX_WAIT_FIN;` in extremely case. like below:
```c
ret = send_sf(ctx);
-> send_state_machine (irq handler)
ctx->state = ISOTP_TX_WAIT_FIN;
```
it will cause isotp_send never return.
Signed-off-by: Jiapeng Li <mail@jiapeng.me>
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>
This changes so that generation of RSI now uses LE arrays instead of
uint32 words. Both input and output of rsi and sih genration now uses
LE. This also fixes the generation of RSI for BE systems, which
wasn't working.
Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
Fix checkpatch issue: UNNECESSARY_INT: Prefer 'unsigned long' over
'unsigned long int' as the int is unnecessary
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Many areas of Zephyr divide and round up without using the DIV_ROUND_UP
macro. Make use of it, so that we make use of a tested system macro and
at the same time we make code more readable.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
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>
Fix the BIG handle in the HCI LE BIG Sync Established event
when BIG Create Sync operation is cancelled by Host.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This fixes missing ISO connection state check, as there might be no ISO
connection when Receiver Stop Ready has been received. This might happen
on ASE state transition from Enabling to Disabling.
Without this check the code asserts in ascs_disconnect_stream_work_handler.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Aligns Bluetooth mesh shell parameter documentation to use the
same syntax, abbrevations and formating.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Changes the implementation and documentation in config client shell
command for Config Model Publication Set and Config Model Publication
Virtual Address Set to accept period resolution and period steps as
separate arguments to make it more user friendly.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Currently, the handshake operation could only be fully blocking or
non-blocking. This did not play well if SO_RCVTIMEO was set for DTLS
server, as the recv() call where the blocking handshake was used, could
block indefinitely, ignoring the timeout parameter. Fix this, by
allowing for the handshake operation to timeout.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As the underlying socket operations for TLS/DTLS are now non-blocking,
it's no longer possible to rely on the underlying socket timeout
handling. Instead, implement SO_RCVTIMEO/SO_SNDTIMEO at the TLS socket
layer.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As for TLS, switch to use non-blocking operations on underlying socket.
This is a bit tricker for DTLS, as there were not truly blocking bio
(binary input/output) function for DTLS, as timeout had to been
implemented. It is possible though to implement non-blocking mbedTLS bio
function instead, and handle timeout outside of mbedTLS context, which
has been done in this commit.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Switch TLS sockets to use non-blocking socket operations underneath.
This allows to implement the socket blocking outside of the mbedTLS
context (using poll()), and therefore release the mutex for the time the
underlying socket is waiting for data. In result, it's now possible to
do blocking TLS RX/TX operations simultaneously from separate threads.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Implement ZFD_IOCTL_SET_LOCK so that TLS socket layer gets access to the
mutex protecting socket calls.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Make `BT_LOG` and `BT_LOG_LEGACY` hidden Kconfig symbols.
They should not be used by the user to configure the Bluetooth logging
system. If the user want to completely disable Bluetooth logging, they
should use `BT_LOG_LEVEL_OFF=y`.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
When we receive `RPR_OP_LINK_CLOSE` message with reason other than
`SUCCESS` we should fail NPPI refresh procedure, not complete it.
Dropping `COMPLETE` flag will result in calling `reprovision_fail`
in `prov_link_closed`, not `reprovision_complete`.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
TCP packet allocation timeout is currently 100ms, but there are cases
where it is not enough and as a side effect, the kernel internals are
printing some errors on the log before retrying again, create a
Kconfig parameter to be able to tune this value.
Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
We should clear the bt_dev.sent_cmd pointer after using it to allocate a
new HCI event buffer in the bt_buf_get_cmd_complete() function.
Otherwise, there is a risk of reusing the same stored net_buf for
multiple consecutive HCI events in case the controller sents duplicate
or invalid event packets.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Added command to terminate the PA sync as the scan delegator.
This can also be used to cancel any pending PA syncs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add callback to notify the application about which
BIS it should sync to when requested by the Broadcast
Asssitant.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support to create a broadcast sink from a PA sync, rather
than using the broadcast sink scan functions.
This allows for the scan delegator implementation to
autonoumsly add broadcast sinks.
This refactors how the broadcast sink uses flags, to
ensure thread safetyness.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This integrates the Scan Delegator functionality with the
Broadcast Sink functionality. The Broadcast Sink will
automatically update the receive state for the PA and BIG
sync values, based on state of the Broadcast Sink.
Similarly, a request to terminate the BIG or PA sync from
a Broadcast Assistant will terminate the Broadcast Sinks'
PA or BIG syncs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add bt_bap_scan_delegator_foreach_state and
bt_bap_scan_delegator_find_state to support finding
specific receive states.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The field is added/modified by bt_bap_scan_delegator_add_src
and bt_bap_scan_delegator_mod_src. This makes it easier
to modify the BIG sync state, without worrying about
the encryption state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the cmd_bap_scan_delegator_rem_src to remove
receive state sources locally as the Scan Delegator.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add cmd_bap_scan_delegator_mod_src to modify a BASS
receive state source as the scan delegator in the
shell.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The scan delegator attempted to put the subgroup pointer into the
metadata data, instead of the metadata.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a test case that tests the scan delegator and
broadcast assistant features when the scan delegator
syncs to a PA without being asked to by the
broadcast assistant.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The check did not work when aggregated_bis_syncs
was 0. Also modfied the function to be more readable.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for adding a source from the scan delegator itself.
This is useful if e.g. the broadcast sink syncs to a PA.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_bap_scan_delegator_remove_source failed due to invalid length,
as the buffer supplied to scan_delegator_rem_src should not
contain the opcode.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The requested_bis_sync value is not part of the BASS receive
state. Moving the field makes it possible to use the
recv_state struct in more situations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The scan delegator will no longer be responsible for
handling the actual synchronization of the periodic
advertisers, and will offload this to higher layers.
The reason for this, is that scanning is a global state,
and should be avoided autonousmly by the stack. The
application is much better suited for handling this.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the receive_state_updated callback for the scan delegator.
This callback will be called whenever a receive state is updated
by any means, giving the upper layers the option to always know
the latest changes.
This commit also refactors the name used for the internal
receive state (which contains additional information), for
the sake of readability.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The Scan delegator will rely on upper layers calling
bt_bap_scan_delegator_set_bis_sync_state instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_bap_scan_delegator_set_sync_state has been refactored
to bt_bap_scan_delegator_set_bis_sync_state, as it will,
going forward, only be used to set the BIS sync states,
and not the PA sync state. The PA sync state will, in a future
commit, but autonousmly handled by the scan delegator
based on the PA sync callbacks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The set sync state will be used for upper layers to set the BIS
sync state. This is due to the fact that the scan delegator cannot
automatically get this information from the ISO layer, unlike
the PA sync state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Per the BAP specification, if the Broadcast Sink role is
supported, then the Scan Delegator shall also be supported.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
- Introduce a new Kconfig to enable mempool in RTIO
- Introduce a new RTIO_DEFINE_WITH_MEMPOOL to allocate an RTIO context
with an associated memory pool.
- Add a new sqe read function rtio_sqe_read_with_pool() for memory pool
enabled RTIO contexts
- Allow IODevs to allocate only the memory they need via rtio_sqe_rx_buf()
- Allow the consumer to get the allocated buffer via
rtio_cqe_get_mempool_buffer()
- Consumers need to release the buffer via rtio_release_buffer() when
processing is complete.
Signed-off-by: Yuval Peress <peress@google.com>
Update the policy such that every completed sqe has a parallel cqe.
This has the primary purpose of making any reads in the sqe visible
to the consumer (since they might have different buffers).
Signed-off-by: Yuval Peress <peress@google.com>
For ztest twister would parse the symbol information that was
generated as part of the build (zephyr.symbols). However the format
of the zephyr.symbols files is highly dependant on the toolchain.
Move to using pyelf to parse the symbol information directly from
zephyr.elf instead so that this works regardless of toolchain.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
By default there is only CONFIG_LOG_FUNC_NAME_PREFIX_DBG=y enabled. When
both Bluetooth (CONFIG_BT=y) and logging (CONFIG_LOG=y) subsystems are
enabled, then other CONFIG_LOG_FUNC_NAME_PREFIX_{INF,WRN,ERR}=y options are
pulled in as well using an 'imply' Kconfig command indirectly from
`CONFIG_BT_LOG`. This behavior was introduced recently as part of
commit af01a0f313 ("Bluetooth: Logging: Move all logging symbols
together") with no explicit reason provided.
Pulling in LOG_FUNC_NAME_PREFIX_* options automatically with (CONFIG_BT=y
&& CONFIG_LOG=y) blows up flash usage. As an example of downstream project
(nRF52840-based, with Bluetooth and WiFi connectivity), it increases flash
usage from 473668 bytes to 487856 bytes. This seems "only" 3% difference,
but this is actually a lot when there is no good reason why this happens.
Downstream users quite often compare flash sizes of subsequent Zephyr
releases and this 3% footprint increase might be a blocker at some point.
Additionally, it is not trivial to find the root cause of footprint
increase for most (non-expert) users.
The reason why there is so much footprint overhead because of
CONFIG_LOG_FUNC_NAME_PREFIX_*=y is because each function in the
codebase (be it Zephyr or downstream application) that contains logging
macros (LOG_{DBG,INF,WRN,ERR}()) is bloated because the function name has
to be included in the output image.
Remove 'imply LOG_FUNC_NAME_PREFIX_*' commands from 'menuconfig BT_LOG'
option, so that flash usage does not increase too much. Those logging
options are not enabled by other subsystems, so Bluetooth should not be an
exception here.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
RPR Client doesn't send RPR_OP_LINK_REPORT and therefore it can't wait
for it using ack ctx. It should have been RPR_OP_PDU_OUTBOUND_REPORT
to cover a case where Outbound PDU transmission failed. But in this case
the link status will be non equal to BT_MESH_RPR_SUCCESS (see pb_error in
rpr_srv.c) and the link state will be set to idle. And the client will
reset the link together with ack ctx.
When bearer user (provisioner.c) sends an Outbound PDU, it uses the
callback (see bt_mesh_prov_send in provisioner.c) to send a next PDU,
but it doesn't check the error code even though it is provided through
the callback. Therefore calling the callback with error code would
require error handling in provisioner.c.
With ordinary provisioning PB-ADV doesn't call the callback in case of
error, but closes the link by timeout if doesn't receive ACK (see
prov_send_adv in pb_adv.c). PB-GATT always calls the callback with
error code 0 once the PDU is transmitted (see buf_send in pb_gatt.c).
Thus this change aligns RPR Client implementation with other bearers.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
When central is sending SMP Pairing Request is it unknown if
pairing will be legacy or LE SC so set OOB flag if any OOB
data is present and assume to peer device provides OOB data
that will match pairing type.
This was affecting following qualification test cases:
SM/CEN/OOB/BI-01-C
SM/CEN/OOB/BV-01-C
SM/CEN/OOB/BV-03-C
SM/CEN/OOB/BV-09-C
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Secure Channel Base Key (SCBK) is a secret key used to derive the session
keys used to encrypt and decrypt OSDP packets. Secure coding practice
requires us to clear such sensitive data from stack once we are done
needing it. This patch addresses this issue.
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
OSDP secure channel message blocks are terminated with a 0x80. This means
that even for zero length messages, we would have at least one block of
encrypted data to decrypt (since message blocks are rounded up to the next
16 byte boundary). The current length assertion checks for 16 byte
alignment but a malicious peer could send a specially crafted packet with
zero length blocks. Fix this issue by adding check for length == 0 case.
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
HID readers are responding to a KEYSET command with an ACK in plaintext
instead of using the current session keys to acknowledge this command
(which is the reasonable thing to do as the command itself was received
encrypted with the old key). Since the spec doesn't say anything about
this, both methods are technically correct.
Make changes to CP so it allows ACKs in plaintext for KEYSET command in
particular and make the PD implementation do this too as it makes the code
look cleaner there (perhaps HID did it for the same reasons :D).
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
If command or reply has no data, PD "should" use secure message types
SCS_15 or SCS_16. But some PD seem to not implement this correctly. We
will be tolerant towards those faulty implementations.
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
OSDP command KEYSET is used to set the secure channel base key for all
connected PDs. This key is then used to derive the session keys for each
secure channel session. When the app wants to set the this key, it has
to issue a command and then both the CP/PD has to be notified of this
change so they can store this key in a non-volatile medium for future
operations across power cycles.
The current implementation of OSDP had limited support for key
management. This patch adds all the bells and whistles needed to handle
keyset command/event in the CP/PD application.
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
Hoisting a `length--` helps simplify a lot of code which has ad-hoc -1s
in a bunch of places. Also, fix some formatting issues and remove
unnecessary log lines.
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
Struct sh_telnet should be initialised before first function call.
Right now there is a possibility that telnet_accept function will
be called before memset.
Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
Add a new backend for Host Commands that uses UART. The backend bases
asynchronous UART API.
The UART backend is mainly used by FPMCU.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
There were a missing NULL check for the track segment in
paused_state_command_handler when performing the segment
operations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The discovery parameters may contain values from previous
discovery calls. The simply and future proof solution to
this is to simply memset it before using it.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If the subscribed callback is called with value_handle = 0,
then it should not be treated as a subscription complete.
This will happen when bt_mcc_discover_mcs is called, as
reset_mcs_inst unsubscribed to all characteristics before
discovering again.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add macro BT_MCS_VALID_OBJ_ID to verify the OTS Object
ID before attempting any OTS operations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
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>
This patch allow to use isotp use_fixed_addr feature
with CAN identifier which not match SAE J1939 format.
Signed-off-by: William MARTIN <william.martin@power-lan.com>
Extend the invert command to run cfb_invert_area when given four arguments.
Make a change to invert the screen immediately in case of run invert
without arguments.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
Add the `draw text` command to execute the `cfb_draw_text()` API.
The command is similar to the `print` command. The difference is
`draw text` can render to coordinate that is not on tile boundaries.
The command is not run `cfb_framebuffer_clear()`,
So it allows rendering appendiceal with keeping already drawn image.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
Add cfb_draw_text() API for rendering text.
It is similar to cfb_print(), the difference is cfb_draw_text() accepts
coordinate that is not on tile boundaries and don't wrap the line.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
Implements dot-by-dot font rendering to make cfb_print() able to
draw text even at a coordinate that is not on tile boundaries.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
cfb_print does not modify either address and contents of
the pointer that is pointing drawing text.
Thus, it can add a const modifier.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
cfb_framebuffer_finalize() invert the framebuffer, and it still
leave as inverted after executing the function.
It restores the framebuffer at the end of the cfb_framebuffer_finalize()
for the continued drawing.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
dev and clear_display parameter are unused and only
the framebuffer was cleared. A condition which calls
cfb_framebuffer_fanalize when clear_display is
true is implemented. Then not only the buffer,
but buffer and display are cleared.
Signed-off-by: Dölker Kim <KDoelker@baumer.com>
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>
Fail compilation when incorrect configuration is detected, i.e. when
SHELL_BACKEND_SERIAL_CHECK_DTR is set but UART_LINE_CTRL is not set.
Use periodic timer to wait for DTR instead of waiting in uart callback
to prevent blocking caller workqueue and/or sleeping in ISR.
DTR check was only ever supported with interrupt driven backend so add
appropriate depends on to Kconfig.
Fixes: e9f238889b ("shell: uart: Add waiting on DTR signal before
sending data")
Fixes: #47120Fixes: #54705
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
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>
Various bluetooth tests fails to link because bt_le_ext_adv_set_data
can't be resolved. Solve this by adding a check CONFIG_BT_EXT_ADV
around use of bt_le_ext_adv_set_data.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Instead of passing the test parameters to the websocket function, by
casting the pointer to integer (which may not work on 64-bit platform
due to int/pointer size mismatch), let the test allocate a file
descriptor, and initialize it with test context. The tested functions
expect a file descriptor as an argument anyway, so it's a more intuitive
approach.
The conditional test code within WS implementation can retrieve the test
context by using FD APIs to obtain the object represented by the FD.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Added using LOG_DEFAULT_LEVEL kconfig option in log module
template for assigning the default log level to newly created
module instance, instead of assuming always INFO level.
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
C only permits labels on statements, not declarations. Separate the
declarations from the assignments so that the labels can target
statements instead.
Signed-off-by: Keith Packard <keithp@keithp.com>
Some cases, especially those dealing with faults need to inject output
manually, so provied a macro for special case.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
When lfs mount fails and there is no formatting requested, the return
code must be translated to errno before being passed to the application
layer.
Additionally, only log a warning that the FS will be formatted, when the
system is not read-only.
Fixes#56378
Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
The PAST sender needs to support periodic advertising
and the PAST receiver needs to support periodic advertising
sync.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The check is very unlikely to be needed, but fixing
warning about assigning ARRAY_SIZE to an uint8_t value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
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>
This feature adds support for using a custom function to format
the timestamp used for all logging backends. When the kconfig
option LOG_OUTPUT_FORMAT_CUSTOM_TIMESTAMP is set the custom
formatting function will always be used.
Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
Many/most LE Audio services are dynamically registered,
but have been enabled without BT_GATT_DYNAMIC_DB.
Add select BT_GATT_DYNAMIC_DB for the services. Select
was used instead of depends on to make it simpler
to enable them.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds new hidden compilation flags that indicate whether the
implementation is configured to be able to receive/transmit audio data.
The flags are profile agnostic to loosen dependencies between
modules/services.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This vastly increases the performance of file transfers using the
fs_mgmt group over MCUmgr by allowing the file handle to remain open
between commands instead of having to open, feek, read/write then
close the file handle for each invocation.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
There was a bug in the BLE backend when it was the only enabled
backend. Instead of using the API `log_backend_activate` to
activate the backend, the logger requires the first time to be
enabled with `log_backend_enable`.
Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
This commit removes the possible race condition when notifying
the bonding request.
When the race condition appears there is possibility that
one of the cores would never send notification for bonding.
This change makes it sure that the notification would be sent
at least once.
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
Added a new logger backend to recieve data over a BLE
notification characteristic.
The characteristic is based on the UUID from the Nordic connect SDK
service NUS, which allows to have a UART shell over BLE.
The idea behind this, is that this logger can be used directly
with the NRF apps or any other BLE UART terminal app.
Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
This change fixes the deregister functionality for
icmsg backend. There are two changes:
Memory access layer was not initialized properly
when the endpoint was registered again. This lead to
memory fault when attepmt to write to the buffer was
done.
Mbox driver was initialized before memory access layer
was initialized. This could lead to race condition
where immediately after the mbox driver was initialized,
the receiving work is scheduled due to pending interrupt.
In that case an attempt to read from garbage address will
occur.
Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
Adds the transceive op which is needed for full SPI support. Notably
in RTIO transceive is expected to be a balanced buffer pair of the same
length and have non-null tx/rx bufs.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Adds a callback op to RTIO enabling C logic to be interspersed with
I/O operations. This is not safe from userspace but allowable in kernel
space.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
When sending small buffers out it makes sense to copy rather than
reference to avoid having to keep the small buffer around for the
lifetime of the write request.
Adjusts the op numbers to always be +1 from the previously defined op
id making it easier to re-arrange if needed in the future.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
When demand paging is enabled, only a minimal set of functions
are available at boot. Anything not marked as boot functions
would not be loading in memory at boot which would result in
page faults when jumping to those functions. However, at early
boot, demand paging has not been enabled yet. So we need to
mark necessary functions as boot functions so they are placed
in the correct linker section where they are loaded at boot.
Fixes#56414
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Remove unnecessary guarding. With `BT_DEBUG` removed, those conditions
were not needed anymore.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
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>
This commit adds new API functions for AICS
Setting automatic/manual only gain modes
Setting mute disabled
Use new functions in btp.vcp
Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
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>
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>
Adds a device pm_toggle shell command which calls pm_runtime_device
functions put and get to toggle the runtime power state.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Store information from the biginfo in a
broadcast_sink->codec_qos struct, and add a reference to that struct
when syncing, so that the stream->qos contains a valid struct
with properly initialized information.
This also adds a guard for the codec_qos.latency as that
is not set nor used by the broadcast sink (as it is
not available).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove Kconfig symbol `BT_DEBUG`. It was not useful anymore with the
previous logging updates.
Replace it, where it was used, by the file local debug symbol.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Add the `zephyr,pm-device-runtime-auto` flag to `pm.yaml` and
`struct pm_device`.
This flag is intended to signify to the boot system that device runtime
PM should be automatically enabled on the device after the init function
has run.
Only run `pm_device_runtime_auto_enable` function on a device if
initialisation succeeded. This prevents actions being run on devices
that are not ready.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
conn->le.keys are set on-demand when actual security action happens and
it is possible that permission check needs to happen before those.
This fix regression in following qualification test cases:
GAP/SEC/AUT/BV-23-C
L2CAP/LE/CFC/BV-25-C
L2CAP/ECFC/BV-32-C
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
When FPU is enabled for Arm64, the saved_fp_context must be tracked by
thread info to visualize correctly the FPU context of threads.
Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
As name suggest upgrade only should allow image upgrades onlu, but due
to greater or eqal sign used in version comparison, upgrade actually
also accepted current version.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Adds an optional feature that can be used to time out a partially
received MCUmgr packet over the shell interface. Prior to this
change, if a header was received, then the whole shell would be
unavailable until the module is rebooted or additional full MCUmgr
packet was sent.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Returning an error code when PM is not supported for a device only makes
writing drivers harder, as instead of checking for failures with `< 0`,
they also need to check for `-ENOTSUP`.
From the point of view of a driver, an `-ENOTSUP` return value is
equivalent to success, as if the device it is trying to turn on doesn't
support PM, by definition it is already enabled. This is equivalent to
the API behaviour when `CONFIG_PM_DEVICE_RUNTIME=n`.
Whether a device supports PM or not can still be determined at runtime
by inspecting the return code of `pm_device_runtime_enable` if
necessary.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Only run `pm_device_runtime_put` on the dependent domain if the original
claim operation succeeded. This fixes unbalanced operations when running
```
pm_device_runtime_get(dev);
pm_device_runtime_put(dev);
```
On a device that does not have PM enabled but does have a power domain.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Both L2CAP and GATT have same requirements with regards to error code
on no encryption when LTK is or isn't present.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
“Insufficient Encryption” shall be returned only if link is not
encrypted and proper LTK is present, otherwise “Insufficient
Authentication” shall be used.
Core Specification 5.4 Vol. 3 Part C 10.3.1
"If neither an LTK nor an STK is available, the service
request shall be rejected with the error code
“Insufficient Authentication”.
Note: When the link is not encrypted, the error code
“Insufficient Authentication” does not indicate that
MITM protection is required.
If an LTK or an STK is available and encryption is
required (LE security mode 1) but encryption is not
enabled, the service request shall be rejected with
the error code “Insufficient Encryption”."
This was affecting GAP/SEC/AUT/BV-11-C qualification test case.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This moves duplicated bt_bap_iso_unbind_ep function call to
be handled when ASE enters BT_BAP_EP_STATE_IDLE state.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes possible double bt_bap_stream_detach() function call.
The bt_bap_stream_detach() called from ascs_ep_set_state
state BT_BAP_EP_STATE_IDLE handler.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The fact of having such extern in iso_internal.h forces the source files
that include this header to include conn_internal.h. This breaks the
encapsulation of conn object.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes incorrect behavior of ISO server listen that was not handling
the case of two endpoints sharing the same CIS/CIG and the endpoints
belonging to different connections.
Fixes: #51552
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This moves the ISO server registration to bt_ascs_init.
When the ASCS gets cleaned up (the callbacks are unregistered), the ISO
server gets unregistered.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This cleans up the code a bit by replacing the occurences of
SYS_SLIST_FOR_EACH_NODE with SYS_SLIST_FOR_EACH_CONTAINER(_SAFE)
so that the explicit CONTAINER_OF() usage is not needed.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes invalid Unsupported Opcode Response_Code that
happened to be sent in ASE Control Point notification
as the response to operation initiated with Mandatory opcode
to support.
When the Unicast Server callbacks are not registered, every
operation that is initiated by client will fail with
Unspecified Error instead.
Fixes: #56139
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes ASE that is not returned to pool when Codec Config
operation failed. The ASE is allocated in Codec Config operation
context. With this fix, if the operation failed to complete,
the ASE is returned back to the pool, so that it can be allocated
again by this or other client.
Fixes: #56138
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This removes redundant bt_ascs_ase_get_from_slab function and moves it's
functionality to ase_new(). It's sane, because the ASE shall be
allocated from ase_new() function context only.
bt_ascs_ase_return_to_slab() has been renamed to ase_free() to follow
the naming convention. Furthermore, few logs have been fixed/added.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The ID is ensured to be valid before ase_new() function is called, as
the client request is already validated.
On the other hand, if function is called from server initiated procedure
context, the assert shall occur as it indicates stack issue.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds cleanup of ASCS that is called when upper layer unregisters
it's callbacks. Without callbacks registered, the service is unusable.
The ASE's that were in non-idle state stay in this state, because the
implementation returns an error on every operation that is performed by
the client. The cleanup added moves all the ASE's to idle state.
Fixes: #56111
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Mode affects access to flash aread for `block_start`. When mode is set
to `BT_MESH_BLOB_READ` function return early, and because
`BT_MESH_BLOB_READ = 0` this is default behaviour. For write flash area
must be erased to allow driver to write there new data - bits can only
be pulled down, so overwrite will not be permitted.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
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>
Deprecate Kconfig symbol `BT_DEBUG_LOG`. With the new `BT_LOG` having
the same effect, `BT_DEBUG_LOG` is not useful anymore and shouldn't be
used.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Move all Kconfig symbols related to Bluetooth logging into the newly
created `Kconfig.logging`. The logging symbols are now grouped by into a
menu "Bluetooth logging". Closely related symbols are grouped with each
others. For example, audio related logging symbol are found behind a
submenu "Audio" inside the "Bluetooth logging".
The deprecated logging symbols have also been moved in a submenu of
"Bluetooth logging", it's easier to avoid them so.
Behavior of the Bluetooth logging system:
When `LOG` symbol is selected, if Bluetooth is enabled (`BT` symbol
selected), the Bluetooth logging is enabled.
If the user does not set any log level, the Bluetooth logging symbols
will inherit the log level of `BT_LOG_LEVEL`. If the user does not set
the level of `BT_LOG_LEVEL`, the default log level will be the one
defined by the logging subsystem. Which currently is `LOG_LEVEL_INF`.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
PR adds 2 acknowledgment contexts to RPR client to handle
scanning and provisioning in parallel.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Consistently process BIS data, codec data and codec metadata.
Range check count of data received so that buffer overflow cannot occur.
Signed-off-by: Chris St John <chris_st._john@bose.com>
Socketpair functionality has matured enough to be used in a
consistent way now regardless of architecture or platform,
even on `native_posix`.
Remove the experimental status to reflect that.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
When receiving extended advertising reports with incomplete
data status, it is not necessary to mark for recovering from
currently assembled fragments, but rather drop them and
start a fresh assembly of subsequently received extended
advertising reports.
Timing changes in the Controller cause Periodic Advertising
PDUs AUX_SYNC_IND + AUX_CHAIN_IND to be placed between
primary channel ADV_EXT_IND and AUX_ADV_IND. This causes the
Controller to generate alternating incomplete and complete
data status reports, exposing the Host bug that is fixed in
this commit.
Relates to commit ba09a252ec ("bluetooth: host: refactor
bt_hci_le_per_adv_report data reassembly").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add automatic adding of the CAP Acceptor Set Member AD data.
This also moves the CAP Acceptor service data into the
cap_acceptor.c shell implementation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add an input device to take input key events as an input and generates
short press or long press devices as output.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fix ticker to explicitly trigger worker when ticks_to_expire
is less than or equal to elapsed time.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update ticker implementation to reschedule unreserved ticker
that use ticks_slot_window.
This will avoid unreserved ticker from continuously
overlapping with reserved tickers. And the change is
required to reduce processing overheads before reserve
ticker timeout callback executes.
Unreserved tickers with ticks_slot_window will always yield
to any colliding reserved or unreserved tickers.
The implementation moves unreserved tickers (no ticks_slot
value, in this case continuous scan window) to end of a
colliding reserved/unreserved ticker so that reserved
tickers (like central role) do not have high overheads due
to unreserved ticker's prepare (scanner) be preempted
everytime before reserved ticker's prepare (central).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add check to the Remote Provisioning Client model init call
that verifies that the model is located at the root element.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
This allows us to get the result of synchronous transfer without
any hacks, just from the net_buf structure.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The ISO hci_le_cis_req event handler was missing
calls to bt_conn_unref and bt_iso_cleanup_acl to properly
clearn up the reference counters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added missing bt_conn_unref where bt_conn_lookup_handle is
called, but where the function returns without providing the
conn pointer to the caller.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When we supply the conn pointer of the remote device that
provides the PAST information, we do a lookup on the
conn_handle using bt_conn_lookup_handle which takes a
reference count. This count is never dereferenced again.
This commit adds calls to bt_conn_unref to ensure that we
do not keep the reference count after the function
returns.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
"The (ATT attribute read) callback can also be used locally to
read the contents of the attribute in which case no connection
will be set."
This means that callback may be called with NULL conn. Since
for ascs_ase_read NULL conn object have no meaning just return
error.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This adds ascs_cleanup() function guarded by ZTEST_UNITTEST. The purpose
of it is to clean up the ASCS between the tests.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fixes a bug where goto statement results into network layer skipping
the forwarding of unicast message on the ADV bearer, if the message
gets succesfully sent on the GATT bearer. This is undesirable. Node
has no knowledge of which external entity has which unicast address.
It may be possible that Proxy node can deliberately add unicast
addresses of other nodes to the whitelist to receive some traffic
for sniffing.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
From now app layer is able to return explicit response code and
reason that will appear in ASE Control Point notification.
Fixes issues of ASCS/SR/SPE/BI-(07/08/09)-C PTS test cases, where
PTS was receiving wrong response codes and reasons.
Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
Updated the 3 places in extended advertising where the ticker was
previously inquired about the expiration of another ticker ID in a
separate mayfly (adv_aux, adv_sync and adv_iso). It will now use the
new ticker feature where another ticker IDs expiration info will be
added to the callback.
Channel map updates are now handled in ticker_cb and applied immediately
if the ticker is not running
Signed-off-by: Troels Nilsson <trnn@demant.com>
It is now possible (via the extended ticker interface) to ask for
expiration information for another ticker ID to be returned in the
ticker callback. This utilises the extended ticker interface and a
callback function with a different context to keep the current ticker
interface as unchanged as possible.
Signed-off-by: Troels Nilsson <trnn@demant.com>
Deprecated Health client and server API has been deprecated for two
releases: 3.2.0 and 3.3.0.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Unit test project for bt_pub_key_gen().
This is part of subsys/bluetooth/host/ecc.c unit testing.
Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
Move newly added `bt_data_get_len` and `bt_data_serialize` from `ead.c`
to `data.c`.
Also, removed unnecessary include of `zephyr/kernel.h`.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
In case native IPv6 is disabled, Kconfig entries related to native IPv6
stack should not be enabled. Otherwise, circular dependencies can be
created if native stack is disabled, as in case of recent changes in
NET_IPV6_RA_RDNSS option (where a dependency for a native stack module
was enabled).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Create a new Bluetooth library and add Encrypted Advertising Data to it.
Encrypted Advertising Data is a new feature from the Bluetooth Core
Specification 5.4. It provides a way to communicate encrypted data in
advertising, scan response and EIR packets. To do that it introduce a
new advertising data type called `Encrypted Advertising Data`. Also, it
introduce a new characteristic called `Encrypted Data Key Material`,
this provides a way to share the key material.
The library add two main functions `bt_ead_encrypt` and
`bt_ead_decrypt`.
Two helper functions are added to `bluetooth.h`. `bt_data_get_len` and
`bt_data_serialize`, the first one allow the user to get the total size
of a set of `bt_data` structures; the second one generate a spec
compliant bytes array from a `bt_data` structure. The last one is useful
because `bt_ead_encrypt` take as input those kind of bytes array.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Move the SoC Flash nRF sync ticker implementation into
Bluetooth Controller Subsystem folder, as internal headers
are included.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the Bluetooth Controller's CMakelists.txt to
consistently use zephyr_library_sources_ifdef() and
zephyr_library_include_directories_ifdef().
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This fixes ASE release from QoS configured state.
The `ops->released` callback was not called and the `bt_ascs_ase`
was not returned to the pool, because `stream` object was already
detached.
Fixes: #55900
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes possible dereference of free'd bt_ascs_ase object.
The ASE without ISO connection that goes to Releasing state will be
automously transitioned to Idle state. Thus, the `ase` object might not
be vaild anymore.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This moves ASE Control PDU length validation before request processing.
If the PDU length is not as expected, the operation shall be considered
as invalid. Thus shall be rejected.
ASCS_v1.0; 5 ASE Control operations
"A client-initiated ASE Control operation shall be defined as an invalid
length operation if the total length of all parameters written by the
client is not equal to the total length of all fixed parameters plus
the length of any variable length parameters for that operation"
Fixes: #55747Fixes: #55748
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fix a memory issue when calling boot_read_bank_header the length should be
the size of `struct mcuboot_img_header`.
Fixes#54459.
Signed-off-by: Joel Guittet <joelguittet@gmail.com>
Add new helper functions to increase readability and to
ensure correctness when aborting procedures.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the same unicast streams and group for the BAP and CAP
shell commands. This results in maximum flexibility, as well
as the niceness of use from CAP, as well as less memory usage.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When performing the CAP Unicast Start procedure, the remote
server(s) may change the state of the ASE before the procedure
is complete.
If the state change is unexpected, we stop the procedure and
call the callback, and then the caller can decide what to
do after that (presumably call the stop procedure for the
streams that may be setup).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implements the CAP unicast stop procedures, which is used
to stop (either disable or release) multiple streams.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implement the CAP unicast metadata update procedure.
The procedure lets an application update the metadata of one
or more CAP streams in a single function call, while also ensuring
that the provided metadata follows the requirement from CAP.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This modifies the audio.c shell module to support
multiple connections.
This adds support for the cap_initiator unicast-start command,
which supports multiple endpoints on multiple devices.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implement the CAP unicast start procedure, which
will put one or more CAP streams from the idle state
to the streaming state, across or more ACL connections.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the input listener section declaration in common-rom-misc.ld
instead of using a custom input.ld file. This seems to be the common
practice for upstream iterable sections and seems to solve a
compatibility issue where the section was getting allocated incorrectly
on esp32 based platforms.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add check in CMake files to prevent resource overlap for
TIMER0, TIMER1, RTC0.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
In general, RTC and TIMER driver implements counter API but there
are exception when those peripherals are used in a custom way
(e.g. for system timer or bluetooth). In that case, system must
prevent using counter based on a reserved instance. Previously,
it was managed by Kconfig options but that cannot be maintained
when switching to devicetree configuration of the counter driver.
A new approach removes Kconfig options and instead adds static
asserts in the files which are using direct peripherals. Those
asserts check if given node is not enabled in the device tree.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The TX timeout configured with SO_SNDTIMEO on a socket did not work
properly. If the timeout was set on a socket, the TX would work as if
the socket was put into non-blocking mode. This commit fixes this.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The timeout recalculation logic was duplicated across several routines,
therefore it makes sense to make a helper function out of it,
especially, that the same functionality would be needed for the send
routines.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
SO_RCVBUF option processing at the TCP level was broken. The option
value was only checked once, when the TCP context was allocated. This
made little sense, as at this point the option would not even get a
chance to have custom value. If the user modified the option after the
socket (net_context) was created, it had no effect on the TCP operation.
This commit fixes this, by checking the option value whenever new packet
is processed, so that the configured window size is updated at the TCP
level before we report it in the TCP ACK. In order to achieve this,
introduce a new helper function, to refresh the configured window sizes,
to avoid bloating `tcp_in()` even further.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Some systems can support only legacy OOB pairing while others only
LE SC OOB pairing.
The existent API function "bt_set_oob_data_flag" was removed.
Two new API functions were added:
* "bt_le_oob_set_legacy_flag" to signal that legacy OOB pairing is used
* "bt_le_oob_set_sc_flag" to signal that LE SC OOB pairing is used
The code will now advertise the presence of OOB flag depending
on the type of pairing method(SC vs legacy)
Signed-off-by: Sebastian Panceac <sebastian.panceac@ext.grandcentrix.net>
User can now use self-defined BLOB ID for transfer instead of using
random one each time. This allows to send multiple FW Update Start
messages with same BLOB ID, for example to resume previous one.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
If device rebooted while in `BT_MESH_DFU_PHASE_TRANSFER_ACTIVE` phase
we should not recover into it, but set `BT_MESH_DFU_PHASE_TRANSFER_ERR`
instead. It's because we no longer remember which block is currently
transfered so new FW Update Start must be received and transfer
restarted.
If device rebooted while in `BT_MESH_DFU_PHASE_VERIFY_OK` it means
we didn't manage to apply image before reboot. We should enter
`BT_MESH_DFU_PHASE_VERIFY_FAIL` phase, which will allow to verify it
again and possibly apply. This is with agreement to specification
regarding receiving FW Update Start when FW is already received.
This commit also alligns handle_start with specification: when
FW is already received, we should set phase to
`BT_MESH_DFU_PHASE_VERIFY`, send Status message, then proceed to Verify.
Previously, `verify` was called before sending status, so status
contained phase set to `BT_MESH_DFU_PHASE_VERIFY_OK` or
`BT_MESH_DFU_PHASE_VERIFY_FAIL`. This would prevent DFU Client
enter refresh procedure.
`blob_recover` also expects BT_MESH_DFU_PHASE_TRANSFER_ERR now.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
These targets already received FW so there is no point to transfering
it again. What's more, these targets will not accept transfer and will
be dropped by DFU Client. If FW is already received DFU Client should
skip transfer and proceed to refresh procedure.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Move all audio related shell implementations to the
audio directory, to use the same structure as Mesh.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds dummy link layer for offloaded ifaces, allowing
ifaces to directly receive l2_enable calls
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
In order to take granular input use micro seconds as input for TWT
intervals, this helps us in providing inputs such as 65.28ms without the
need of using floating points.
This also expands the TWT wake interval range to 262.144ms, earlier as
we want to use uint8, limited to 256ms.
Also, remove the units from the variable names, this is unnecessary and
also avoids doing breaking changes.
Update release notes as this is a breaking change, both type and
variable names are changed.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
Remove ad-hoc `CHAR_SIZE_MAX` in favor of `BT_ATT_MAX_ATTRIBUTE_LEN`.
The maximum size of an attribute is the same as the maximum size of a
characteristic.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The commit changes the fs_mount to not allow mounting same system,
with the same private data pointer, at two different mount paths.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The pending_sqe logic to track where in the ring queue the concurrent
executor had left off was slightly flawed. It didn't account for starting
all sqes in the queue and ending back up at the beginning.
Instead track the last SQE in the queue, from which the next one in the
queue will the one to start next.
If we happen to sweep the last known SQE in the queue, reset it to NULL
so the next time prepare is called we start at the beginning of the queue
again.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Transactional submissions treat a sequence of sqes as a single atomic
submission given to a single iodev and expect as a reply a single
completion.
This is useful for scatter gather like APIs that exist in Zephyr already
for I2C and SPI.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Implement a custom abort_cb callback to perform Tx and Rx
flush and adjust the SN/NESN values.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ull_prepare_dequeue to not skip events when preempt
does not match the event in the head of the prepare queue.
The head of the prepare queue does not match when
ull_prepare_dequeue has put the head of the queue to the
last of the queue when it is calling lll_resume interface.
This happens when there is already an active event which
needs a preempt timeout to be setup and there is another
non-resume event in the pipeline which now becomes the
head. The fix ensure to restore the order of the events
if a preempt timeout was to be setup.
Currently ull_prepare_dequeue loops through all events
before stopping at the original way the queue was. This is
not efficient and is a scope for improvement in future.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Connected ISO time reservation that was missing the
event start and end overhead values.
Fix missing event end overhead values in ACL connection
time reservation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Calculate CIS offset of secondary CIS(es) using CIG reference point.
This fixes issue with e.g. two CISes associated with separate ACL
connections.
Signed-off-by: Morten Priess <mtpr@oticon.com>
This commit enables having multiple CIS/CIG setups/connects and
teardowns in sequence.
- For central, cig->lll.num_cis is initialized to cis_count and
untouched until ll_cig_remove. The value shall indicate number of
allocated instances, to ensure correct CIG traversal.
- Keep CIG/CIS instances for central until ll_cig_remove
- Initialize CIS instance state vars in ll_cis_create, similar to the
peripheral flow.
- In ll_cig_remove, always release streams and CIG instance. Do not
remove paths, as this is done from host at bt_iso_chan_disconnected.
- Remove unsued cis_count member in ll_conn_iso_group.
- Use correct function ull_iso_lll_ack_enqueue at LLL flush to have
data path respected.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Some recent PRs included conditional compilation for
KCONFIG_BT_LL_SW_LLCP_LEGACY, which must be removed.
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
The slot reservation code is only valid for the refactored LLCP;
a guard was in place to ensure that it was not compiled in for
legacy controller code. This commit removes this guard
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
This commit removes the code related to advanced scheduling from
ull_sched.c, since this code only works for the legacy controller.
Implementing advanced scheduling for the refactored LLCP is tracked
in its own issue
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
The code that was added for delaying notifications to the host,
which was only implemented for legacy controller, is removed
in this commit
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
This commit removes the legacy LLCP code including the
Kconfig option
It also updates the babblesim tests, and removes the
tests for the legacy controller
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
The copying from the presets to the stream codec and qos
structs were not done in a way that worked. Fixed by doing
a more proper and deeper copy.
This also fixes a small issue with using the wrong
default preset.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
After commit 3486f133e9
GATT Proxy service registration is broken because it is registered from
settings_load() in mesh_commit(). Because mesh_commit() is called before
sc_commit() is called in gatt.c, bt_gatt_service_register() can't be
called yet.
Use k_work to postpone the service registration.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The BT_BAP_UNICAST_CLIENT_PAC_COUNT is there due to a merge conflict
gone wrong. Removed again.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove redundant use of local variable chan_idx in the
lll_chan_iso_subevent() function.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
For ISO-subevents channel selection must use remap table always
-regardless of channel is a mapped or unmapped channel.
Signed-off-by: Henrik Møller <heml@demant.com>
Ensure that the stream released callback is only called after
the CIS has disconnected. Since the ACL disconnect event
may come before the CIS disconnect event, we use the
unicast_client_ep_idle_state in the unicast_client_reset
function to use the existing state verification, and only
after both the ACL and CIS has disconnected, we
finalize the reset of the stream and call the released
callback, assuming that the CIS can be disconnected.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The BT_ISO_STATE_DISCONNECTING was never set when the
CIS was actually in the disconnecting state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Previously we assumed only a single stream, and deleted
the unicast group on the first stream released.
Now we wait for all the streams to be released before
deleting the group.
This still assumes that all streams are initiated by us
as the client, and will not work if using the
BAP unicast client and server role concurrently.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove a bad LOG_ERR that should never have been merged.
Added the valuet that was logged to the debug log statement.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The conditions of the assert were incorrect compared to the
text, and caused an assert to happen when it shouldn't.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
We get compile warnings of the form:
drivers/console/uart_console.c:508:8: 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 returns an int, change check to an explicit test against
the return value.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Add supplementary header <zephyr/fff_extensions.h>. Add macro
to fff_extensions.h for simplifying definition of custom fake functions
needing call-unique information for producing desired output data.
When an array of custom fake context structures is defined and
the return field within the first structure instance is registered
with the standard SET_RETURN_SEQ() macro of FFF, the
RETURN_HANDLED_CONTEXT() macro provides the inverse logic to
recover the context structure for this called instance. The body of
the custom fake handler is provided to the RETURN_HANDLED_CONTEXT()
macro for appropriate execution and access to the custom fake
parameters.
A test suite is also provided to verify macro implementation and
illustrate usage. It is at:
zephyr/tests/subsys/testsuite/fff_fake_contexts/
This code was verified by:
1. (Pass) west build -p always \
-b unit_testing tests/subsys/testsuite/fff_fake_contexts/ && \
./build/testbinary
2. (Pass) west build -p always \
-b native_posix tests/subsys/testsuite/fff_fake_contexts/ && \
./build/zephyr/zephyr.exe
3. (Pass) ./scripts/twister -p unit_testing \
-T tests/subsys/testsuite/fff_fake_contexts/
4. (Pass) ./scripts/twister -p native_posix \
-T tests/subsys/testsuite/fff_fake_contexts/
5. (Pass) cd doc && build html-fast
Fix#55246
Signed-off-by: Gregory Shue <gregory.shue@legrand.com>
The timeout used upon opening the link with the server relates to the
PB-Remote Link Open procedure, but not to the whole provisioning
procedure. For the provisioning procedure, the timeout should be at
least 60 seconds as explained in section 5.4.4.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit fixes an issue where the RPR Client gets stuck after sending
PDU to RPR Server (even with segmented flag), but doesn't hear anything
back from the server.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit fixes an issue, where the RPR Client gets stuck forever
until reboot if it doesn't receive Link Status or Link Report message
when openinig the remote provisioning link.
The RPR_CLI_LINK_OPEN flag was used to control the remote provision link
and protect against receiving an unexpected message, but it didn't cover
a case when neither of messages were received from the RPR Server.
cli->link.state only changes by Link Status or Link Report message and
is set to BT_MESH_RPR_LINK_IDLE when opening the link. Therefore, when
the RPR Client's timer timed out, the client didn't reset its internal
states.
This commit adds an additional state to cover this intermediate state
when the client initiated the link opening but didn't receive any
response.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
To enable Bluetooth controller coexistence feature, there is
implementation of ticker task, which aborts any ongoing radio events
during assertion of the grant pin. This solves the co-existence issue
in the role of the subordinate transceiver.
Signed-off-by: Tomáš Beneš <tomas@dronetag.cz>
Remove redundant EVENT_IFS_US used in Control PDU timing
calculation. The BIG radio event ends with Control Subevent
and hence there is no need to add EVENT_IFS_US at the end
of the BIG event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ISO Sync Receiver PDU reception to enqueue towards ULL
any PDUs that where received before the BIG event in
unreserved timespace is aborted due to overlap with other
radio events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In the case of a constrained system that uses dynamic channels (ie, not
much initial credits), the user's log would be flooded with those three
messages.
This is not really an error per se as the stack will handle it properly and
reschedule the sending of the buffers as soon as more credits arrive.
Thus downgrading the severity of
- the l2cap messages, as they are only compiled when dynamic channels are
enabled
- the conn message. Reporting the error belongs in the upper layers.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Currently the zperf_tcp_receiver can handle only one TCP connection
each time, modify the code to poll and handle multiple connections.
Take the occasion to unify the bind and listen part of the code
between ipv4 and ipv6 part using a structure introduced to handle
the multiple connections.
Now in case the zsock_recv fails, we can't stop every connection
and fail through the error label, so just print the error message
and report the failure through the callback.
Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Reduce the scope of in4_addr_my and in6_addr_my pointer variables
that are currently global, but they are used only inside
tcp_receiver_thread.
Take the occasion to fix a typo in one error message.
Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
This moves bt_data_parse function outside of hci_core.c.
Having it in separate file makes unit testing easier as the
function do not use kernel objects, thus can be used in unit tests
without a need for adding any mocks.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Avoid the use of weak functions and call the respective functions only
if vendor-specific data path is supported. The weak dummy functions
will not implement the desired behavior anyway. This change makes it
explicit that these functions need to be implemented by the vendor.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
When releasing a stream as the unicast client, we may get
either the ASE state notification with state idle or
the control point notification first. If we get the
ASE state notification first, we pretend we get the
CP notification first, and call the release callback.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the unicast client operation callbacks to the shell, simply
printing the values sent by the server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add callbacks for control point notifications sent by the
unicast server. These will allow the upper layers to know
if and why a specific operation failed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The "Invalid Length" response code was called truncated,
which does not match the spec definition.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implemented:
-- Released framed padding PDUs when data received in SDUs for a given
event do not fully utilise BN.
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
When building with an LLVM toolchain get the following warning:
bluetooth/mesh/pb_adv.c:774:4: error: expression which evaluates to zero
treated as a null pointer constant of type
'void *' [-Werror,-Wnon-literal-null-conversion]
PROV_BEARER_LINK_STATUS_SUCCESS);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix by adding a cast to (void *).
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Adds persistent storage for SAR server RX and TX set cmd parameters.
Also ensures that SAR RX and TX parameters are set back to default values
upon reset of the mesh device.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Fix NULL dereference when dereferencing txing_stream, which was used
instead of default_stream.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Cast pointer to `void *` for `%p` parameter.
Otherwise lots of warnings in the log like below:
`<wrn> cbprintf_package: (unsigned) char * used for %p argument.
It's recommended to cast it to void * because it may cause
misbehavior in certain configurations. String:"%s: (%p): >>
length:0x%08x cur:%p, end:%p" argument:3`
Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
Inherit BT_ISO_TX_BUF_COUNT value when BT_ISO is enabled
to set BT_CTLR_ISO_TX_BUFFERS count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing radio configuration that limits the maximum PDU
len on reception to consider that Control PDU can be larger
than the max PDU size in the BIS parameters.
Use dedicated PDU buffer for transmission and reception of
BIG Control PDUs so that it is independent of maximum ISO
PDU length which can be less than BIG Control PDU length.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This fixes "Conditional jump or move depends on uninitialised value(s)"
error seen in valgrind.
The stream object that is allocated by application has to be initialized
as it may contain invalid data.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The word "valid" is already in use to mean slots that return true for
`bt_mesh_dfu_slot_is_valid`, whereas `bt_mesh_dfu_slot_foreach` iterates
over all added slots.
Signed-off-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
This moves net_buf_simple related code to separate source file.
Having those in separate file makes unit testing easier as simple
network buffers do not use kernel objects, thus can be used
in unit tests without a need for adding any mocks.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
As there is dedicated NET_BUF_SIMPLE_* logging macros set,
NET_BUF_SIMPLE_DBG shall be used in this place instead.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add support for setting the location value
(BT_CODEC_CONFIG_LC3_CHAN_ALLOC) in the codec configuration.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The function is now called get_named_preset and only
returns a named preset. The QoS parameter handling
has been moved to a new function, cmd_stream_qos,
which can be used to set specific QoS for a stream.
The get_named_preset does also no longer set the default
preset, and cmd_preset must be used for that now.
This means that a function like cmd_config no longer
has any side effects, thus making it easier to set up
multiple streams with different presets.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The hacky handle_metadata_update that copied the metadata to
a variable, since stream->codec->meta could not be modified,
has been replaced with a proper solution now that
stream->codec->meta can be modified.
It still only supports settings the streaming context, but
it is much easier to expand now.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make the BAP shell presets constant. This reflects more
what they represent, and make it not only possible, but also
easier, to modify the individual streams QoS and Codec
configurations, without affecting other streams.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Most of this struct is bookkeeping for the dynamic channels.
This isn't needed for e.g., a simple peripheral using GATT.
With a peripheral_hr build for nrf52840dk_nrf52840, we save
280 bytes of RAM.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
In dns_resolve_reconfigure() check if the DNS servers already exist
before cancel all ongoing queries. This will solve an issue with
getaddrinfo() returning DNS_EAI_CANCELED when receiving a retransmitted
DHCP offer and when receiving a IPv6 Router Advertisement.
Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
Mutex and double-linked list can be statically initialized.
This removes a little bit of boot time overhead.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
When a stream for a sink ASE goes into the enabled
state we automatically execute the receiver start ready
operation as the unicast server.
This makes the shell easier to use as the server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bap send command would set txing_stream but the
pointer would never be reset.
The txing_stream is mainly to handling the start_sine,
so only {start|stop}_sine commands now sets this.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit enables zephyr to configure the FatFs FF_FS_REENTRANT
option and support fs actions from multiple threads.
CONFIG_FS_FATFS_REENTRANT enables the option and provides zephyr
mutex wrappers.
Signed-off-by: Nicola Ochsenbein <Nicola.Ochsenbein@husqvarnagroup.com>
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>
NVS cache was used only in read function. This commit add the usage of
NVS cache in write and gc functions.
Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
Add opcode information for cmd timeout assert,
since BT_DBG usually not show in real product,
however we can't see any information just from
assert message.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When vendor specific commands are disabled by setting
BT_HCI_VS=n the host still calls bt_read_static_addr,
but that function is not compiled in, resulting in a
build error.
Fixed by moving the code in controller/hci/hci.c
outside of the conditional compile
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Package length was previously stored on 10 bits which limited
package size to 1023 bytes. Descriptor which contained package
length field had one unused bit which can be used to increase
package length field to 11 bits doubling the maximum package
length.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
When packacge exceeds the limitation warning log is printed
and message is dropped.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Some internal macros were still using 2 suffix which comes from
time when there was v1 and v2. Cleaning up by removing the suffix.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Reschedule dedicated relay adv sets immediatey after finishing
advertising of the previous relay message. This allows a node to
relay messages as fast as possible when Relay Retransmit Count state
is zero using less relay adv sets.
When Relay Retransmit Count state is non-zero, the delay doesn't do
anything as the time between pushing a relay message to the host and
triggering adv_sent callback will be greater than this delay. In this
case the relay adv set will send a next message immediately.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The unicast client would attempt to send the
receiver start ready opcode to the server for
source ASEs before the CIS was connected, which
is a spec violation.
The code has been refactored to set a boolean,
and then send the receiver start ready opcode on
CIS connection instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This fixes compilation errors of BabbleSim tests generated by gcc-12
when MOD_REL_LIST_SIZE is zero.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
A subscription check was still being done in the
gatt_notify_multiple_verify_params() fn, regardless of the value of
CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION.
This could lead to getting this warning if BT_GATT_NOTIFY_MULTIPLE is
enabled, and the notifications not being sent to unsubscribed peers.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
[216/319] Building C object zephyr/subsys/bluetooth/controller/
CMakeFiles/subsys__bluetooth__controller.dir/hci/hci.c.obj
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:
In function 'hci_vendor_cmd_handle_common':
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:5459:17:
warning: implicit declaration of function 'vs_set_min_used_chans';
did you mean 'll_set_min_used_chans'? [-Wimplicit-function-declaration]
5459 | vs_set_min_used_chans(cmd, evt);
| ^~~~~~~~~~~~~~~~~~~~~
| ll_set_min_used_chans
....
zephyr-sdk-0.15.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../
../../../arm-zephyr-eabi/bin/ld.exe: zephyr/subsys/bluetooth/controller/
libsubsys__bluetooth__controller.a(hci.c.obj): in function
`hci_vendor_cmd_handle_common':
zephyrproject/zephyr/subsys/bluetooth/controller/hci/hci.c:5459: undefined
reference to `vs_set_min_used_chans'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Once the bt_ascs_ase is taken from the mem_slab, it has to be memset to
override the junk data.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The z_set_timeout_expiry() function is a wrapper provided in the
timeout subsystem that has some corrections for timelicing. But the
suspend code doesn't care; by definition there are no active threads
that might be timeslicing at the point where the OS is suspending.
Use the lower-level timer driver API instead.
(z_set_timeout_expiry() is also about to disappear)
Signed-off-by: Andy Ross <andyross@google.com>
1. `zsock_socket()` gets the right packet familiy.
2. `inet_pton()` returns 1 on success.
This should address #55193.
Signed-off-by: Sebastian Arnd <sebastianarnd@gmail.com>
Provide a means of declaring zero or more HTTP services, each
with zero or more static HTTP resources.
Static HTTP resources are those which have fixed paths[1] which
are known prior to system initialization. Some examples of
static http resources would be
* a forwarder from '/' to '/index.html'
* a REST endpoint with fixed path '/api/foo' and detail
pointing at some implementation-specific function
* a Javascript file in string form with fixed path '/js/util.js'
* a 'construction' image with path '/res/work.png'
* a gzip-compressed 'Hello' HTML file at '/hello.html'
Without describing in any detail how static HTTP resources are
organized or served by any given HTTP server, we can describe
what static resources exist on a system in a common way that
does not require any optional facilities (e.g. filesystem) and
relies only on addressable memory.
Additionally, for the purposes of simply allowing others
to implement custom HTTP servers in a consistent way, or
benchmarking implementations, or having a consistent testsuite
to use across multiple implementations, it is helpful to have
a common method to declare HTTP services and static resources
for Zephyr.
[1] https://en.wikipedia.org/wiki/URL
Signed-off-by: Chris Friedt <cfriedt@meta.com>
In the unicast client we should reset the stream before calling
the released callback. This is so that we can reuse the stream object
in the released callback.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
USB Mass Storage Specification for Bootability requires MODE SENSE(10)
command. MODE SENSE(6) and MODE SENSE(10) generally access the same data
but differ in the maximum allocated length and LLBAA support. However
there is no point in extracting common handling because there no mode
pages are supported now.
Fail MODE SENSE requests if asking for anything other than supported
page codes (to which the essentially hardcoded response is valid).
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Several places used the bt_audio prefix where it shouldn't.
Also moved the BAP documentation to its own file.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added a new header file bap_lc3_preset.h which contains
the definitions of the LC3 (pre)sets defined by the
BAP spec.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename the bt_audio_unicast_client API to bt_bap_unicast_client
and move the API to bap.h
Also adds the _bap_ infix to the bt_unicast_client functions.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename the bt_audio_audio_server API to bt_bap_unicast_server
and move API to bap.h.
This also adds the _bap_ infix for bt_unicast_server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This fixes compiler unused variable error
warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
461 | struct bt_ascs_ase_status *status;
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Mass Storage Class allows device to either silently discard OUT endpoint
data after receiving invalid CBW or to STALL the OUT endpoint (and keep
it STALLed regardless of host clearing halt) until Reset Recovery.
Switch from silently discarding to STALL in order to allow host realize
that device waits for Reset Recovery without transferring complete OUT
data.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
While both the server and client are allowed to terminate
the CIS when a stream is released, it is, per the BAP spec,
the client's responsibilty. This commit modifies it so that
the client will actually get a chance to do its responsibilty
by adding a small delay before our ASCS disconnects the CIS.
The CIS disconnection has kept with a delay, rather than
removed, in case that the Unicast Client is not properly
performing it's responsibility.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix scan window value corruption due to modification of
stored ticks_window value when enabling continuous scan.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Removes the unused pac_pache from the unicast_client.
This moves the storing of the PAC records (in the form of
struct bt_codec) from the stack to the upper layers.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The thread analyzer cannot be really used with the
POSIX architecture.
As:
* Code takes 0 simulated time to execute.
So the analyzer will report 0 cycles being used.
* The stack allocated by Zephyr is not actually used
(except for a tiny part used by the arch code itself
to do a bit of thread bookkeeping).
The POSIX architecture uses a separate stack
(from an underlying Linux pthread) which Zephyr is blind
about. So the thread analyzer is going to only report
a tiny stack utilization.
Prevent users from selecting them together to avoid confusion.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>