Use a union to capture all big NET event structures with a default size
of 32bytes, this makes maintenance easier.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
NAK message should be processed in the RENEWING state just like in
REBINDING, not ignored.
Additinonally, NAK processing should include the rejected IP address
removal from the nework interface, otherwise the IP address will remain
on the interface indefinitely (i. e. until removed manually), which
might disturb further operation.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
It could happen, that the requested IP address, stored in the dhcpv4
config structure in the network interface, could get overwritten with an
unexpected message, for example NAK from the DHCP server. In result, the
DHCPv4 module was no longer able to remove the requested address from
the network interface, as it simply no longer remembered what the
address was.
Fix this, by setting the requested address only when it's actually
provided by the DHCP server, i. e. when handling the OFFER message from
the server. Accordingly, the requested address will be cleared when the
SELECTING stage is entered, where all of the cleanups should've already
be done.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
bt_id_del() was setting the bit 'BT_KEYS_ID_PENDING_ADD' instead
of setting the bit 'BT_KEYS_ID_PENDING_DEL'
Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
Increment the number of identities after a successful execution
of id_create() by checking if the return value is 0.
Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
The function is no longer used, as its functionality has been replaced
with net_if_carrier_off().
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Align virtual L2 with interface state handling update. Introduce
net_virtual_enable() function, which gets called whenever a network
interface is brought up (operational). This, combined with already
existing net_virtual_disable() function, can be used to update the
carrier state on the virtual interface, based on the underlying
interface status.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Align PPP drivers/L2 with interface state handling update. Use the
carrier on/off notification instead of bringing the interface up/down to
update the interface state.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Align netusb driver with interface state handling update. Instead of
bringing the interface up/down from the driver level, use carrier on/off
notification to update the inteface state.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Align OpenThread L2 with interface state handling update. Use the
dormant flag to indicate whether an interface joined a Thread network.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Align Bluetooth L2 with interface state handling update. Use the dormant
flag to indicate whether interface has a Bluetooth connection or not.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Align Ethernet/Wi-Fi drivers/L2 with interface state handling update.
For drivers, that did not support carrier detection, no changes are
needed.
Driver that did support carrier detection, are updated to set the
carrier state to OFF by default, instead of setting the
NET_IF_NO_AUTO_START flag. This allows to postopne the actual
NET_EVENT_IF_UP notification until driver detects that carrier is ready.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When packet is passed to transmit at the net_if level, verify the
carrier state (NET_IF_LOWER_UP) instead of administrative state
(NET_IF_UP).
The administrative state is checked anyway at higher level (net_context)
so no need to verify it again. This will allow to still transmit control
packets for example when interface is in a dormant state.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Introduce a new interface state management scheme, according to
RFC 2863. This includes the following changes:
* Introduce a new interface flag: NET_IF_LOWER_UP, along with
corresponding helper functions. The flag should be set/cleared on an
interface by a network driver/L2 to signalize physical readiness of an
interface to transmit data (for example cable plugged in).
* Introduce a new interface flag: NET_IF_DORMANT, along with
corresponding helper functions. The flag should be set on an
iterface when the interface is not ready to transmit application data,
for example still not joined a Wi-Fi network.
* Introduce a new interface flag: NET_IF_RUNNING, indicating that
interface is ready to transmit application data.
* Update the meaning of the NET_IF_UP flag - it now singnalizes whether
an interface has been brought up/down by the application (admin
up/down).
* Introduce operational state of an interface, derived from above. It
reflects the internal interface state.
The meaning of net_if_is_up() function and NET_EVENT_IF_UP/DOWN events
remains unchanged to retain backward compability - they reflect the
interface readiness to transmit application data.
To verify the administrative up/down state, a new function
net_if_is_admin_up() has been introduced, along with
NET_EVENT_IF_ADMIN_UP/DOWN events.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Socket offloading was not taken into consideration when network
interface was put down. Fix this by introducing a helper function, to
verify whether an interface is offloaded or not.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Document `bt_irk.rpa` as "Cache for `bt_keys_find_irk`. Not reliable as
"current RPA"!".
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Improve the zperf upload/upload2 commands, by allowing to specify
DSCP/ECP fields for outgoing packets. The introduced -S option is
compatible with Linux iperf3 utility.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Improve the parse_arg() helper function used with shell ping command,
by allowing to parse arguments provided in hex.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add new option to the net shell ping command, which allows to specify
the DSCP/ECN values for an outgoing ping request. The option is
compatible with Linux ping command.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add support for setting DSCP/ECN values for an outgoing ping request.
Additionally, copy DSCP/ECN values from an incoming ping request into
the ping response, like Linux does.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add support for setting DSCP/ECN values for an outgoing ping request.
Additionally, copy DSCP/ECN values from an incoming ping request into
the ping response, like Linux does.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add new socket options IP_TOS and IPV6_TCLASS which allows to set
DSCP/ECN values on a socket for an outgoing packet IPv4/IPv6 headers.
The options are compatible with Linux behaviour, where both DSCP and ECN
are set with a single socket option.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
SOL_SOCKET and IPPROTO_TCP levels were missing the break statement at
the end of their processing logic, which could cause unexpected
fallthrough on unhandled optname value.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add a new net_context option, which allows to set DSCP/ECN values on a
net context. Those values are then encoded into outgoing packet
IPv4/IPv6 header.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add new fields to the net_pkt structure, representing IP-specific
Differentiated services code point (DSCP) and Explicit Congestion
Notification (ECN) values. Those values are encoded in legacy
Type of Service (IPv4) and Trafic Class (IPv6) header fields.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add NULL checks when registering the media_proxy_pl_calls.
Currently the media player expects all of them to be set.
In the future, ideally the callbacks would mostly be
optional and reflect which of the optional
characteristics that there is in the MCS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Convert model_ackd_send and model_send from health_cli.c to a common API
to get rid of code duplication in other client models that implement
synchronous messages' sending.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
There should be functional equivalence between these two forms. And the
'_eq'-form is more readable.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Spin locks held for any lengthy duration prevent interrupts and
in a real time system where interrupts drive tasks this can be
problematic. Add an option to assert if a spin lock is held for
a duration longer than the configurable number of microseconds.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Adds check to verify that the audio stream is actually
in the streaming state before handling the
audio data. As per the BAP spec, a stream that
is not in the streaming state shall not send
any data, and this check is to handle any
remote devices that are not working correctly.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Cosmetic change: the zst was short for zephyr_smp_transport,
now it is just smp_transport so smpt makes more sense.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The MCUMgr library is now part of Zephyr, so there is no point
to prefix SMP functions with Zephyr.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This change implements part two of the program laid out in the TSCH RFC,
see #50336#issuecomment-1250250154 :
> Consolidate IEEE 802.15.4 options in net_pkt
This change improves decoupling of generic net core code from
IEEE 802.15.4 internals. It also simplifies IEEE 802.15.4
attribute cloning and thereby makes it easier to maintain and less
error prone (and probably even faster as individual bits are no longer
copied over separately).
This enables us to extend and design IEEE 802.15.4 L2 attributes inside
the package in isolation from the net core code which will no longer
have to be changed when introducing changes or additions to the flags.
This flexibility will be built upon in later change sets to model the
IEEE 802.15.4 attributes closer to the spec.
The solution is inspired by Linux's sk_buff->cb attribute which addresses
the same concern as the attribute introduced in this change set:
https://elixir.bootlin.com/linux/v6.0.1/source/include/linux/skbuff.h#L871
As the inline comment says: The cb attribute can be made a union or even a
uint8[something] in the future, if further L2s need a control block, too.
Right now such full indirection would make the code overly abstract, so
I chose to compromise with maintainability in mind.
Care has been taken to ensure that this changes does not introduce
additional padding into the net package. To maintain zero-padding, future
changes to the net packet struct will have to ensure that the
IEEE 802.15.4 struct is 4-byte aligned (iff the IEEE 802.15.4 struct
continues with max uint32_t scalar members) which is no deviation from
the previous implementation.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
The IEEE 802.15.4 L2 now sets the ll protocol in the packet to a
specific value. This corresponds to the respective solution in Linux and
is required to validate access to IEEE 802.15.4 specific attributes of
the packet.
Later change sets will rely on this value to ensure that IEEE 802.15.4
specific package content can only be accessed on IEEE 802.15.4 packages.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
The net packet structure contains pointers to link-layer source and
destination addresses. Usually, these structures do not point to
separately allocated memory but directly into the packet's data buffer.
In case of a deep package clone (which includes copying the buffer) the
copy of the ll addresses continued to point into the old package
(contrary to a rather misleading inline comment). This was proven by an
additional failing unit test assertion.
As the original package may be unreferenced while the cloned package is
still being accessed, the ll address pointers of the cloned package may
become invalid.
The fix consists of two parts:
* First it is determined whether a given ll address actually points into
the buffer and if so at which logical cursor offset it is located.
* If the address points into the package buffer then the cursor API is
used to determine the corresponding physical memory location in the
cloned package. The ll address of the cloned package is then patched
to point to the cloned buffer.
Additional assertions were introduced to the existing unit test to ensure
that the newly generated address points to the correct content of the
cloned package.
The solution is implemented in a generic way so that the previously
redundant implementations were consolidated into a single one. The code
includes a check that ensures that the ll address check and manipulation
will be skipped in case of shallow package copies.
The change also addresses problems related to the "overwrite" flag of the
package:
* Package cloning assumes the overwrite flag to be set. Otherwise it
will not work correctly. This was not ensured inside the clone method.
* Package cloning manipulates the overwrite flag of the cloned package
but does not reset it to represent the same state as the original
package.
The change introduces a fix and unit test assertions for both problems.
Fixes: #51265
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Most IEEE 802.15.4 drivers do not support promiscuous mode, some do.
There is a dedicated L2 flag to signal this capability to clients.
Unfortunately the IEEE 802.15.4 L2 stack does not announce this flag
even for drivers that correctly expose it in their HW capabilities.
Some clients (notably the OpenThread L2) even uses promiscuous mode
without checking whether the driver actually supports it.
This change lets the vanilla IEEE 802.15.4 L2 check the driver's
HW capabilities to announce promiscuous mode on its 'get_flags()'
interface if supported.
The OpenThread L2 uses a constant (potentially incorrect) response
to 'get_flags()'. Fixing the OpenThread L2 is out of scope of this
change. This change just introduces TODO messages to the OpenThread code
so that the OpenThread team may fix the issue (or delete the TODO if they
deem it irrelevant).
Fixes: #51263
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Change linkage for ctx_shell and default_key in shell.c to external to
share their usage in other places.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commits renames `health_cli.c` and `cfg_cli.c` under `mesh/shell`
folder to `health.c` and `cfg.c` accordingly. This is to create a
generic pattern for the future, when not only clients, but server models
will also expose some API through shell commands. This means that server
models' shell commands should be located in the same file as client
commands to avoid cluttering `mesh models` subcommand.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This code is a boulerplate that will be needed for many models in mesh
shell module. This commit adds a special macro designed to improve
readability of the code and helps to avoid potential bugs when
copy-pasting identical code.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Not all shell commands may be needed for an end application even if a
certain feature is enabled. In that case they will just occupy flash
space without being used. This commit adds a separate Kconfig for each
feature to make possible to selectively disable some mesh shell commands.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Move mesh shell related options to a new file to avoid cluttering of
the main Bluetooth Mesh Kconfig file when extending it with new options.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Header lora.h and lorawan.c files make use of types defined
in kernel.h without including it.
The types.h is no more relevant with inclusion of kernel.h
Explicitely including <stdint.h>, even if the kernel.h includes
the stdint.h, this is an implementation detail. "If Kernel
decides one day to drop usage of stdint.h (unlikely),
lora.h users be in trouble."
Signed-off-by: Francois Ramu <francois.ramu@st.com>
Added link that sends messages over ipc_service. It uses
log_link_remote and will talk to log_backend_ipc_service based
on log_link_backend.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added backend that sends messages over ipc_service. It uses
log_backend_remote and will talk to log_link_ipc_service based
on log_link_remote.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added implementation of link and backend that are intended to
complement each other. Both requires transport function hooks
to be provided.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add support to multidomain case where source field contains
ID and not address of the source structure.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Adding multidomain support by introducing log_link module which
acts as a receiver of log messages created by another domain.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
log_cache is capable of storing fixed length byte arrays
identified by a generic ID. If entry identified by given ID
is not found in cache, the least recently used entry is evicted
from cache.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The cmsis implementations of osMutex was trying to inspect internal
k_mutex state (the owner and lock count) in the process of trying to
acquire the lock. This is unfixably racy, by definition other
contexts will be trying to do the same on the unsynchronized data.
As far as I can tell, the only purpose was to be able to synthesize
osMutex's specified error behavior, which we can do with the existing
return codes from k_mutex_lock(). Add similar logic to osSemaphore,
which didn't have the race but was likewise abusing access to kernel
internals.
Signed-off-by: Andy Ross <andyross@google.com>
The "limit" field of struct k_sem was in use in two places in the BTLE
host code, in one it was being used as a duplicate placeholder for the
"iso_max_num" field received in read_buffer_size_v2_complete[1]. In
another, it was just being tested for zero[2].
Those are pretty clear abuses of internal data, provide minimal value
beyond a few bytes of memory in struct bt_dev_le, and in any case
won't work with zync, where that field doesn't have the same name and
may not even exist depending on app configuration.
Copy the limit value into the struct where it belongs, and use it from
there.
[1] I strongly suspect there is a bug lurking there if the semaphore
maximum is being used to implement the kind of "packet buffer" this
code looks like. Calling k_sem_give() on a "full" semaphore WILL NOT
BLOCK. It will just drop the increment on the floor and return
synchronously. Semaphores aren't msgqs or ringbuffers! But disabling
the max value feature in zync does not result in test failures, so
maybe this usage is safe.
[2] Again, this seems suspicious; a valid k_sem should never have a
zero in that field. Presumably this is really a test for "is
initialized", and so implies there's a mixed up initialization path
somewhere?
Signed-off-by: Andy Ross <andyross@google.com>
The bridge subsystem was written with a ETH_BRIDGE_INITIALIZER that
assumed it could initialize a k_mutex with a zero-filled initializer.
That never worked. Unlike semaphores, mutexes have always required a
runtime call to k_mutex_init(). What happened instead is that
k_mutex_un/lock() returned error codes, which were ignored by the code
here. So no locking was happening.
This was discovered while migrating to zync, where an attempt to
unlock an unlocked mutex is a panic condition (and where zero-filled
initializers are legal, but represent an unfair semaphore and not a
mutex, so deadlock correctly).
Signed-off-by: Andy Ross <andyross@google.com>
This is a public API for the subsystem, can be called from app
context, unlocks the local k_mutex on one of its three exit paths, and
it's quite clear that nothing ever locks that mutex!
The code used to work because k_mutex simply returned an error if you
tried to unlock an unlocked object. Now zync will panic (when
CONFIG_ZYNC_VALIDATE=y) if you try that.
Signed-off-by: Andy Ross <andyross@google.com>
Zephyrs Host has by default enabled automatic resume of advertising
in case of disconnection when peripheral role is enabled.
The feature becomes a bit problematic in case of multirole usage.
For example assume a use case where a device is working as peripheral
and central, where it may establish single connection for each role.
In case there are two connections established and connection in
central role is dropped by peer, Host will automatically resume
advertising. After that an application can resume scanning, e.g.
in disconnected callback. That should not happen.
If one of connections was used for central role, it should not
be stolen by Host to run peripheral role. Host should verify
if a disconnected connection role was peripheral and then resume
advertising.
This approach will not break backward compatibility and change
correct resume behavior. What more, Host will follow an application
decisions about use of connection objects.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The `audio init` should only initialize the audio (BAP)
stack. Furthermore, given that the `bt init` may do more
than just calling `bt_enable` it is generally for the best,
and more future proof, to let that command be the exclusive
way of calling `bt_enable` in the shell.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
It was possible to enter a state where setting the QoS
for a source stream after having released a sink stream
as the unicast client would cause a segmentation error.
This issue is related to how the unicast shell is using
the unicast group.
A fix has been added for it, and a check for
whether or not `audio init` (to register the needed
callback) has been added. This check has also been added
for the broadcast sink.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If user has not specified any DNS servers in
CONFIG_DNS_SERVER_IP_ADDRESSES, then the DNS resolver will not be
initialized properly. So fix this by always calling dns_resolve_init()
so that DNS mutex get properly initialized.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Adds proper support for having more than one PDU pool for the advertising
PDUs (to save memory)
- Introduces lll_adv_aux_data_init, lll_adv_aux_scan_rsp_alloc and
lll_adv_sync_data_init to indicate if the PDU is a primary/legacy PDU
or secondary/auxillary PDU
- Scan response PDUs are initialized later, since the correct pool to draw
from depends on whether the advertising is extended or legacy
Signed-off-by: Troels Nilsson <trnn@demant.com>
The device_service shell was missing the capability to list devices
registered in the EARLY init level.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Not all C compilers understands how to use the address of a return
value as an argument to a function call. At least not our compiler.
Fix the issue by adding a variable to hold the converted value
before passing it to the function call.
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
This fixes the output below by moving the closing bracket to "<Security
type (optional: valid only for secure SSIDs)>" after the enumeration of
security types "0:None, 1:PSK, 2:PSK-256, 3:SAE".
Fixes:
uart:~$ wifi
wifi - Wi-Fi commands
Subcommands:
connect :Connect to a Wi-Fi AP
"<SSID>"
<channel number (optional), 0 means all>
<PSK (optional: valid only for secure SSIDs)>
<Security type (optional: valid only for secure SSIDs)>
v----------------------^
0:None, 1:PSK, 2:PSK-256, 3:SAE
(...)
Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
Return to line after the first parameter to:
- have the second parameter in a single line (not splitted) and
- start every parameters from a brand new line (easier to read)
Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
This fixes the output below by adding the missing closing bracket to
"<MFP (optional): 0:Disable, 1:Optional, 2:Required":
Fixes:
uart:~$ wifi
wifi - Wi-Fi commands
Subcommands:
connect :Connect to a Wi-Fi AP
"<SSID>"
<channel number (optional), 0 means all>
<PSK (optional: valid only for secure SSIDs)>
<Security type (optional: valid only for secure SSIDs)>
0:None, 1:PSK, 2:PSK-256, 3:SAE
<MFP (optional): 0:Disable, 1:Optional, 2:Required
^-------------------------------------------------^
(...)
Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
This fixes the output below by returning to line after "Connect to a
Wi-Fi AP":
Fixes:
uart:~$ wifi
wifi - Wi-Fi commands
Subcommands:
connect :Connect to a Wi-Fi AP"<SSID>"
^------^
<channel number (optional), 0 means all>
(...)
Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
When calling bt_audio_discover, the discovered PAC records
were just added to the pac_cache. If called multiple times,
the PAC records would just be duplicated.
This change reset the pac records for the direction when
called.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
bt_audio_stream_config should not be called with a stream
that is already configured to another connection.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This caused the sink to attempt to sync to more stream
for each call to bt_audio_broadcast_sink_sync as the
stream count was stored in the struct bt_audio_broadcast_sink
but never reset.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is no reason for the previous limitation.
The limit of 255 for the ASEs is based on the ASE IDs
which is a uint8_t, so there is a maximum of 255 of
each ASE type.
The limit of 73 * 2 = 146 is based on the maximum size of an
GATT attribute (512), and the minimum size of a PAC record (7)
makes it a total of 73 PAC records for each direction.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is access to the procedure context after a potential release
of the context, which (in theory) can lead to incorrect behaviour
There is no good way of testing this with a unittest without adding
specal debug code to the ull_llcp_local module
After code-inspection no other location has been found with
potential access after context release
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
This refactors how the BAP broadcast source handles the
extended and periodic advertising.
First it removes the start and stop of the extended
advertising, and instead expects the application
(or upper layers) to do this.
Second it exposes API functions to get the
necessary advertising data from BAP (service data and
the BASE), which the upper layers will then also
be responsible for setting and updating.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The metadataa_updated callback has existed for a long
time, but was never actually used. The metadata is set
or updated in the enabling and streaming state.
Added checks to see if the state actually changes when going
into these states, and if not, then it means that the
metadata was updated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Without pkt_unref(), the shell command "net udp bind" will fail to
receive after a few packets ("net allocs" shows that memory is still
allocated).
Signed-off-by: Andreas Müller <andreas.mueller@husqvarnagroup.com>
Adding the new Kconfig (enabled by default) to make a failed assumption
mark the final result as failed. This change has the following benefits
which have been asked for by the Zephyr community:
1. A failed assumption does not go silent. In this example, the failed
assumption will still mark the test as skipped, but the final result
will be to mark the full test run as failed. This would allow
blocking the CI when an assume fails.
2. Normal test skipping via the ztest_test_skip() is unaffected by this
change. Those tests will be marked as skipped, but the binary will
still pass.
Signed-off-by: Yuval Peress <peress@google.com>
If bt_audio_stream_connect didn't fail, we would just return
without sending the receive start ready command.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Since the net cache is accumulated in positive order, the net
cache uses reverse order traversal, which can filter duplicate
messages more effectively.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Since in bt_mesh_net_recv will call msg_cache_add
and if lpn reject this message, should remove this cache.
But this function sequentially and will not be interrupt
by any thread so, we no need a copy var to save this value.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Our application (posix-naive/debug) ran into segmentaion faults,
because the socket was closed between the "wait for sockets" and the
second if in the first loop. Added the check also to line 690
and 720.
The other uses of sock_ctx[i] are already checked against NULL
Signed-off-by: Peter Tönz <peter.tonz@husqvarnagroup.com>
According to Core 5.3 Vol 4, Part E, section 7.8.82 slot_durations,
switch_pattern_len and ant_ids are used only for AoA and do not affect
reception of AoD CTE.
To improve interoperability checking of correctness of these parameters
is not required. It will not affect lower link layer in case the AoA
CTE reception feature is not enabled in Kconfig.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This function exposes list pointer, so that it allows the user to modify
the internal list. This adds bt_audio_foreach_capability iterator finction
that can be used instead.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The LLDN frame has been obsoleted in IEEE 802.15.4-2015f. This change
removes it from the code, introduces frame types from current spec
levels and updates the frame validation rules in accordance with the
spec.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Several attributes in the ieee802154_context struct may potentially be
accessed from different threads and/or ISR context. Only some of these
attributes were properly guarded against race conditions.
This may not have been to problematic in the past but as other changes
in this PR introduce additional attributes and mutate several attributes
in a single atomic transaction, leaving such changes unprotected seems
dangerous.
This change therefore introduces systematic locking of the
ieee802154_context structure.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
IEEE 802.15.4 short address support is incomplete in several places.
This change improves short address support without claiming to fix
it everywhere. Future iterations will have to continue where this change
leaves off.
The purpose of this change was to:
* use the short address returned by association responses,
* automatically bind IEEE 802.15.4 datagram sockets to the short
address if available,
* use the short address in outgoing packages where applicable,
* improve validation of association/disassociation frames,
* model association more closely to the spec by tying it to the
existence of a short address in the MAC PIB thereby removing
redundancy in the PIB (which makes race conditions less probable),
* keep both, the short and extended addresses, of the coordinator.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
This changes fixes several bugs and inconsistencies in the IEEE 802.15.4
L2 implementation. These bugs were revealed while documenting intended
endianness of driver, IP, socket and L2 attributes (see previous
changes).
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
This is a preparatory change that fixes one aspect of short address
handling before fixing endianness so that the endianness fix can be
applied consistently in this method.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
The IEEE 802.15.4 L2 code stores representation of attributes like
PAN id, short address and extended address in different encodings:
* big endian for extended address and CPU byte order for everything
else whenever such attributes enter user space (except for IP/socket
link layer addresses which are always big endian - even in case of
short addresses - to maintain POSIX compatibility).
* little endian for everything that is close to the radio driver as
IEEE 802.15.4 frames are little endian encoded.
Endianness was almost nowhere documented which led to several bugs and
inconsistencies where assignments of different byte order were not
converted (or sometimes converted, sometimes not).
This change documents endianness wherever possible within the realm of
the IEEE 802.15.4 L2 code. Conversion bugs and inconsistencies that were
revealed by the improved documentation will be fixed in a separate
commit.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Some minor housekeeping prior to adding an http server
implementation. There are already a number of http headers
and that number will likely increase with subsequent work.
Moving them into a common directory cleans up the
`include/net` directory a bit.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Changes in device_service have triggered MISRA 5.7 violation CI error
(Tag name should be unique). Renamed shell to sh, same as some other
modules.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The _SYS_INIT_LEVEL* definitions were used to indicate the index entry
into the levels array defined in init.c (z_sys_init_run_level). init.c
uses this information internally, so there is no point in exposing this
in a public header. It has been replaced with an enum inside init.c. The
device shell was re-using the same defines to index its own array. This
is a fragile design, the shell needs to be responsible of its own data
indexing. A similar situation happened with some unit tests.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This is a follow up to commit bb86f8b967.
Also custom IEEE 802.15.4 based L2 implementations may need to use
packet handling without the IP layer. Add support for such cases.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
By using CONFIG_LWM2M_VERSION_1_0, the function
lwm2m_engine_get_binding() returns the binding
and the queue mode bytes. Therefore the buffer
must be tree bytes long.
The issue is caused by the two inconsistent defines:
lwm2m_registry.c:
#define BINDING_OPT_MAX_LEN 3 /* "UQ" */
lwm2m_rd_client.c:
#define CLIENT_BINDING_LEN sizeof("U")
Signed-off-by: Peter Tönz <peter.tonz@husqvarnagroup.com>
Enable the statistics subsystem shell by default if both statistics and
shell are enabled.
Have the statistics shell imply enabling named statistics as this takes out
a lot of guesswork regarding which statistics counter is which.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
With the incoming removal of kernel.h/types.h from init.h, lots of files
start to show compile errors because they relied on indirect
definitions, including errno.h.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The sys* ops like sys_clear_bit are indirectly included via arch CPU
header. Other stuff like find_msb_set end up included via this header as
well.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This was all done as part of the soc and called from the soc. Define
this type of console under drivers/console and use it in the SoCs
supporting that via SYS_INIT instead of calling the console code
directly.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
If a file write was attempted with a file that does not exist, over
the shell/UART when logging was enabled, it would output a fs_unlink
error, this works around the issue by checking if the file exists and
needs truncating before performing that action. It also imrproves
flash endurance slightly by performing a truncate operation instead
of a delete, but will fall back to a delete if the truncation
operation fails. This issue can be also be mitigated by altering
logging settings or adjusting the SMP thread priority.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Allows filling up struct lwm2m_obj_path by a macro.
For example:
struct lwm2m_obj_path p1 = LWM2M_OBJ(MY_OBJ);
struct lwm2m_obj_path p2 = LWM2M_OBJ(MY_OBJ, 0, RESOURCE);
Similarly, some function calls accept the structure, so it can
be initialized from stack and given by a pointer
lwm2m_notify_observer_path(&LWM2M_OBJ(obj_id, 0, RESOURCE_ID));
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
I need to register a service for the pull-context so I can
safely close the socket context. Otherwise the socket loop
would crash, because context would be closed while going through
the list where it was located.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Minor change, the semaphore is freed by a caller so it was always
free, but just for being correct, it should be a blocking call,
so any errors would clearly block.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
CoAP layer handles retrying so having a second layer of retry
in the pull-context does not make sense. If we need more retrying
it should be done in CoAP layer.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When URI is written, we must first set the state to DOWNLOADING
so when any error happens on the initialization phase, the
result written on a callbacks are correctly reflected and the state
changes correctly IDLE -> DOWNLOADING -> IDLE (result written).
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Allowing locking the registry from commandline allows
us to test composite observation and observation of
object instances, etc. where multiple values are changed
before the notify message triggers.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
For some reason, running sys-t with catalog message on
Cortex-M0 would result in hard fault in mipi_catalog_formatter()
if log_output_syst.c is complied before the backends (and weird
enough, only with SIZE optimization). This new ordering was
introduced in commit f5587552bb
as it was to group all backend source files under a single
directory.
Workaround the issue by compiling file later after backends
as this issue is causing CI failures. Actual root-cause is TBD.
Relates #50941
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
- Account for the added random delay when updating remaining duration
- Re-worked JIT re-scheduling update a bit to keep the random delay
information and remaining duration correct
Signed-off-by: Troels Nilsson <trnn@demant.com>
- Remaining duration is now in us instead of ticks to avoid
overflow when ticks have higher resolution
- First advertising event should not reduce remain duration
Signed-off-by: Troels Nilsson <trnn@demant.com>
Add EVENT_OVERHEAD_START_US to ticks_anchor when enabling
advertising, so the first advertising event is not late due
to calculations for aux packets etc.
Signed-off-by: Troels Nilsson <trnn@demant.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Tune the EVENT_OVERHEAD_START_US for typical usecases on
nRF52833 SoC using the central_gatt_write and
peripheral_gatt_write samples.
Manually run the samples for over 30 mins without any
assertions and use the actual profiled value that would
otherwise be printed on assertion.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When ticks_to_expire is in the past, i.e. ticks_to_expire is
0, perform an explicit trigger of ticker worker instead of
setting up the compare which delays the trigger by the
minimum ticks offset margin. The changes reduce latencies
of the O(n) ticker_resolve_collision by upto the minimum
ticks offset margin (3 for nRF SoCs) for each resolution.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When an event's prepare is delayed due to ULL scheduling or
ISR latencies, check and have a verbose assertion that logs
the actual EVENT_OVERHEAD_START_US required.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Bring back Kconfig option which was previously removed by
9cd5086407 (previously named LOG_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS).
Renamed to shorten and be more descriptive. It can be useful for
external backends or frontends.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Instead of using "select" on certain EC configurations, which is
considered unsafe for various reasons, use a "depends on" and rely on
the user to set a proper configuration in the config file.
Update the respective project configurations to comply with the new
configuration scheme.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Conditional compile ticker interfaces like ticker_update
which are not required when individual state or role samples
are build.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the BIG event counter calculation from stored payload
counter. Event latency should not be multiplied by burst
count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing includes and rearrange header includes to be able
to build a full feature set Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is a follow-up to commit a418ad4bb4.
Since the path to zephyr_mbedtls_priv.h is added to include directories
only when CONFIG_MBEDTLS_BUILTIN is enabled, the inclusion of the file
needs to be done under the same condition. Otherwise, an error occurs
when socket_tls.c is compiled without CONFIG_MBEDTLS_BUILTIN.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
added `audio start_sine` and `audio stop_sine` to start/stop
sending an LC3 encoded sine tone.
This code is heavily inspired from the sine tone implementation
from the unicast_client sample implementation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add printing of the broadcast source advertising address in the
scan callback. Also rename the scan callback to make
it more clear that it is for broadcast scanning.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When the PA sync is lost, we clear the received_base so
that once we resync to the PA, we get the BASE again.
This is to make it easier to decode and use the BASE again
if the sync was lost, as the previous BASE may have
been printed a long time before.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In the unicast client, it is possible for the unicast server
to send a notification for ASE when it is in the codec
configured state after a reconnect. In that case, the
unicast client does not have a coupling between the ASE
and the audio stream.
This caused a BT_ERR to trigger, but it is not really an
error, but rather a state that the current unicast client
cannot handle, so the BT_ERR has been replaced with
a BT_WARN.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the stream->conn instead of the iso->acl, as the iso->acl
may already have been free'd by the ISO layer when the
disconnected callback is called.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This patch fixes invalid ASE state transition,
ASE now waits for Receiver Start Ready before
going into Streaming state.
Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
If the CIS was connected before the sink endpoint was
in the enabling state, it never autonousmly went into
the streaming state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
To enable custom formatting of the log output while still using existing
backend, this commit adds the `log_output_custom` feature.
To use, register a commit with `log_custom_output_msg_set` then set the
log backend format set using `log_backend_format_set` with
`LOG_OUTPUT_CUSTOM`
Signed-off-by: Lucas Denefle <lucas.denefle@converge.io>
bt_ascs is per connection, so the control point attribute pointer
should not be part of this structure.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The direction is used to identify the list to append the registered
capabilities. There is no need to keep it in the bt_audio_capabilities,
it can be provided as a function parameter instead.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The return check for adding MPL objects in OTS with
bt_ots_obj_add was incorrect, as only negative values
indicate an error, and a positive value returns the ID.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
No longer needed, since smp_streamer has smpt pointer to
zephyr_smp_transport, it can directly call smpt->zst_output.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
There are no more functions directly using the type, so it
has been removed and its contents have been moved to
smp_streamer.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit removes declaration of functions
mgmt_streamer_trim_front and mgmt_streamer_init_reader
as they no longer have definitions.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit drops empty parameter from img_mgmt_flash_check_empty
and img_mgmt_flash_check_empty_inner and uses the return code
instead.
Both functions now use negative errno codes instead of MGMT_ERR_
type codes.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This adds a hash check when the CONFIG_IMG_ENABLE_IMAGE_CHECK Kconfig
option is enabled that will check the underlying image hash to see if
it is the same as the one provided by the mcumgr client, and if so,
will prevent erasure/uploading the same image data.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This adds the dummy shell buffer size to the shell_mgmt
configuration to allow ease of changing it.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This fixes the compiler warning "comparison of integer expressions of
different signedness: 'int' and 'unsigned int' [-Werror=sign-compare]"
Signed-off-by: Benjamin Gwin <bgwin@google.com>
DFU on Windows with WinUSB driver failed with "Lost device after RESET?"
error because WinUSB does not support host initiated resets. USB Device
Firmware Upgrade Specification Revision 1.1 attribute bitWillDetach can
be used to overcome WinUSB reset limitation. When bitWillDetach is set,
it is the device responsibility to detach and reattach itself to the bus
after receiving DFU_DETACH request.
Add and enable by default USB_DFU_WILL_DETACH configuration option,
because it is the only way to support WinUSB driver. WinUSB driver is
preferable because it can be automatically installed on Windows 8 and
later if USB device implements WCID descriptors.
Fixes: #49821
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Set the correct number of Ctrl Tx buffers used for the new
implementation, so that the ACK-fifo gets the correct size
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Conditionally compile the legacy control procedure defined
control Tx buffers that is not required in the new control
procedure implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Zephyr doesn't seem to allow on adding route to the device from
which it received Router Advertisement without SLLAO field set
(in particular device that doesn't include Link Layer address).
Changes done:
* Added creating new NBR without Link Layer address set on RA
reception (LL is added only if SLLAO option is set, otherwise
NBR doesn't have LL address, but exists in the table and has
valid IPv6 link local address).
* Removed two asserts preventing from adding route to the NBR
that doesn't have Link Layer address set.
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
Extend SenML-JSON content format for handle cached data
timestamp API for basetime and timestamp label's.
Added support for write historical data for static resource
size's: Float (v) and Boolean (vb).
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Added support for historical data encode by adding base time (bt)
and time (t) label. New labels are needed for Encoder so Decoder
is not regenerated.
Added support for SenML-CBOR to write time series data.
Use "bt" base time and "t" timestamp labels for data cache.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
New API for enable Historical data storage for LwM2M resource.
Data cache is only supported at resource which resource size is
static and well known.
Extend output writer for write cached data timestamp.
Enable cache support for Resource set and Read operation.
Added possibility for for drop latest or oldest data from cache.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
The codec->path_id supplied to the capabilities
were not being used for the endpoint codec.
Important note: This only works if there is a single
capability per codec ID per direction. This limitation
is also an existing limitation in the current
implementation of capabilities.c.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixed an issue with syncing to multiple BIS as the broadcast
sink in the shell. Also changed a check in the broadcast
sink implementation from an assert to a `if` to provide
a better way of handling bad input.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds support for handling fragmented advertising data over HCI when
CONFIG_BT_CTLR_ADV_AUX_PDU_LINK is not enabled
- Added support for appending advertising data to ull_adv_aux_hdr_set_clear
and ull_adv_aux_pdu_set_clear via ULL_ADV_PDU_HDR_FIELD_AD_DATA_APPEND
- Updated ll_adv_aux_ad_data_set and ll_adv_aux_sr_data_set to
handle fragmentation ops without CONFIG_BT_CTLR_ADV_AUX_PDU_LINK
Signed-off-by: Troels Nilsson <trnn@demant.com>
Gives the application a two way mapping between array index
and a per_adv_sync object instead of current only per_adv_sync
obj -> index using bt_le_per_adv_sync_get_index.
Signed-off-by: Jakob Krantz <jakob.krantz@u-blox.com>
Update fff.h to the pending PR upstream which allows for using a custom
function signature. This enables the use of C++ std::function as the
mock.
Signed-off-by: Yuval Peress <peress@google.com>
When an application is waiting on a completion it may be expecting,
rightfully so, that a new submissions slot is available.
Frees the submission queue event prior to enqueuing
the completion queue event in the simple executor.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Show function names for all BT_xx logging levels when BT_DEBUG_LOG is
enabled. This makes it easier to find the problematic lines.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
- Downgrade the warning emitted when we run out of channels.
- Only log a warning when failing to establish channels and the error is
not -ENOMEM.
- Add a debug log message in that case to hint what might've happened.
This should make it less confusing to the average user not aware of the
stack internals.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This is a scary-looking warning for users, and should only really matter to
stack developers. It will eventually show up in the wild for embedded
devices that don't get updated to the latest and greatest.
Reword it to make it clear we are rejecting it, and it doesn't impact the
stack in any way.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This makes it more user-friendly, in case no failed cb has been
registered so this error is printed out of context.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Reword the scary-looking `bt_hci_core; Malformed data` warning to show
where it is originating from.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This fixes GTBS index used in API. The index that is exposed to the
application is 255 in case of GTBS.
The code has been reworked to remove redundant booleans and index that
was kept inside instance.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
By design, adv main set can use to send relay mesh messages
but here adv main set is invoked.
Add in the ended, so, adv main set only can be used when all
relay adv sets busy.
and this way does not cause too much delay for adv main set,
due to local message will process firstly.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Adds feature that deletes the shell CDB node after perfoming a config
client reset of another node.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Remove redundant assertion check, and minor indentation fix
to correct the alignment of function call.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Alters several provisioning related features to allow commands to be
functional with application defined Provisioning properties &
capabilities.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Update the existing ASE EP state checks to be more correct
and aligned with the ASCS specification.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Enable ticker ticks slow window extensions implementation
when broadcaster role is enabled. This feature moves the
primary channel advertising event within the specified
window when overlapping with other roles.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable 4 bit bus width for high speed cards, so that host and card
combinations that cannot use UHS mode will still benefit from the
speed increase of using 4 data lines.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Implemented:
-- Combining segments from multiple SDUs in a single PDU for TX
-- Release of PDU based on remaining capacity below threshold
-- Release of any PDUs in production on receiving a timeout for the
upcoming event
-- Release of PDUs in production if source if destroyed
-- Synchronization flag to exclude multiple contexts in ISO-AL
-- New Kconfig BT_CTLR_ISO_TX_SEG_PLAYLOAD_MIN to allow definition of
minimum TX segment size
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Implements:
-- SDU fragments can be buffered in the ISO-AL so that the correct size
of the SDU can be computed such that it can be released for inclusion
in the first fragment's header
-- Changed SDU emit interface to allow the same structure to be used to
buffer as well as release fragments
-- New configuration BT_CTLR_ISO_RX_SDU_BUFFERS to specify the number of
SDU buffers for each sink
(Buffering disabled when BT_CTLR_ISO_RX_SDU_BUFFERS=0)
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Implemented:
-- Storing information required to service HCI_LE_Read_ISO_TX_Sync
request
-- Implemented interface to retrieve information
-- Cleared ISO-AL source and sink state on deallocation
-- Renamed cig_ref_point to grp_ref_point as it serves a common purpose
in both CIS and BIS
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Improvement for IAL/CIS/FRA/PER/BI-01-C & IAL/CIS/FRA/PER/BI-02-C
-- Test appears to fail as the transmitted PDU is packed with less data
than is indicated in the segment headers.
-- Guards were included to verify that sufficient data exists in the PDU
before extracting the segment.
General
-- Updated timestamps in error SDUs to better approximate the expected
timestamps if time information is missing.
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Accept now from bootstrap trigger from any state expect ongoing
bootstrap process.
Free also possible on going RD client message. There was a chance
that update message response change state and bootstrap proces
not started.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Updated message handler that it free possible old allocated
message. Added message free also to RD stop and idle state.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Renamed LWM2M_RD_CLIENT_EVENT_REG_UPDATE_FAILURE to
LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT.
Changed reported event type for registration timeout to
LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT from
LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE.
LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE should be only
reported case when server reject by response registration.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
In case a connection update complete event reports an error, the
parameters reported should be the ones active on the connection and not
the ones requested
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Some variables shadow global, which is difficult to handle when
porting to other platforms with shadow warnings turned on.
https://github.com/zephyrproject-rtos/zephyr/pull/50581
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This removes the callbacks from capabilities. The callbacks are used for
unicast server role only, while the capabilities are used for the
broadcast sink role as well. Thus the callbacks can be removed as there
is another bt_audio_unicast_server_cb API that is specific for unicast
server role.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fixes the discovery function that handles GTBS only discovery. The
discovery stops when there is no space left for another instance. The
function has been split to improve the code readability and avoid
unnecessary UUID comparison.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
C++20 standard added [[nodiscard]] attribute to operator new
definitions. In case value returned by operator new is ignored,
compiler emits a warning.
The commit adds the attribute to operator new definitions.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
C++17 delivered another specialization of a new operator,
that allows to allocate a memory with requested alignment.
The commit adds these specialziations to C++ subsystem.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
C++ subsystem defines exception throwing operator new.
Though the implementation never throws an exception.
If used by an application it should verify if requested
memory was allocated. This is against C++ standard.
If an application does not support exceptions or does not
want to call throwing new operator, it should use a
specialization of a new operator that makes sure it
never throws bad_alloc exception. The cpp subsystem
does not provide this specialization.
The commit adds missing operator new specializations.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Adds Kconfig option for the Mesh Shell Health server.
The shell implementation of Health Server test commands is
dependent on the user adding and initializing the shell Health
Server instance in their application to make the commands functional.
To prevent any confussion about how these commands work, a Kconfig
option has been added to allow conditional compilation of these
commands. In this way the user must actively enable this feature, making
the conditional requirements more clear.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
This function allows the application to close an ipc_service instance.
It is intended for use when the remote agent it is communicating with
has gone down and allows for cleanup.
It first checks that the endpoints have been separately deregistered
with the instance using the deregister_endpoint function before
calling into previously added functions in ipc_static_vrings.c
and ipc_rpmsg.c to close those instances.
Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
This function deinitialises the static vrings used by the ipc_service
instance. It acheieves this by tearing down the initialised
virtqueues before closing the various aspects of libmetal which
are in use.
Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
This function does the opposite of the ipc_rpmsg_init function and
allows the rpmsg instance to be torndown in the case that the application
wishes to do so. It is intended to be used by the ipc_service subsystem.
Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
LE Write Suggested Default Data Length and LE Set Data Length commands
are suggestions from host and should be validated only as per HCI
specification regarding internal setting of LLCP.
LLCP is allowed to use other values if needed.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Due to the diverse coding styles and lack of preprocessing when
scanning for test cases, there were many unintended combinations
of yaml test scenarios and C test functions with the regex-based
test case discovery, which caused an inaccurate test plan and test
result stats.
As the new ztest fx is used, the test cases of a test instance can
be accurately determined via zephyr.symbols file.
Because the zephyr.symbols file is not available until after build,
test cases determination is placed right after the build stage of
the pipeline and before the runtime test collection.
For those test instances that don't go through the build stage,
such as those with "Skip filtered" (statically filtered) reason
before entering the pipeline, they are not affected.
This patch also adjust the stats logic because the zephyr.symbols
file is generated after build. So ExecutionCounter update is split
and some must be postponed until test execution pipeline is completed.
Some concepts:
A test instance = a yaml scenario + a platform
"Test instance" and "test config" are synonyms in twister, unfortunately
excessive IMHO...
A test instance can be filtered or skipped in 3 ways.
Let's define "runtime" as "after entering the execution pipeline".
1) statically filtered (before runtime)
Such test instance is filtered by analyzing the yaml and never
enters the execution pipeline.
2) cmake filtered (runtime)
Such test instance enters pipeline and is filtered at cmake stage.
3) build skipped (also runtime)
Such test instance enters pipeline and is skipped at build stage.
All the test instances that enter the execution pipeline will go
through the report stage, where ExecutionCounter is further updated.
The meaning of the fields of ExecutionCounter are:
.skipped_configs = static filtered + cmake filtered + build skipped
.skipped_runtime = cmake filtered + build skipped
.skipped_filter = static filtered
.done = instances that enter the execution pipeline
.passed = instances that actually executed and passed
Definition of the overall stats:
total_complete = .done + .skipped_filter
total = yaml test scenario * applicable platforms
complete percentage = total_complete / total
pass rate = passed / (total - skipped_configs)
Signed-off-by: Ming Shao <ming.shao@intel.com>
This is mainly to reduce clutter in `subsys/logging`, but also to make
backend management slightly easier.
Signed-off-by: Christopher Friedt <cfriedt@fb.com>
The memory used for Tx buffers and procedure context must
be aligned on a word boundary, otherwise it is possible
to get unaligned memory access
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
This change fixes a bug where the second use of shell command `gatt
exchange-mtu` would trigger an assertion failure in the stack. The BT
API `bt_gatt_exchange_mtu` asserts `params->func != NULL`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Fix radio_tmr_start_us to be soft realtime, if the requested
start in microseconds is in the past, setup the next
earliest expiry. This is to prevent radio not being started
and not let the LLL hanging. When setup to receive auxiliary
PDU in LLL scheduling, is_aux_sched is set and if radio does
not start and the window is requested to be pre-empted, then
it is blocked from being preempted due to the is_aux_sched
flag remaining to be set. This stalls the scanning
infinitely until explicit scan disable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing is_aux_sched flag being reset before resuming to
scan for new advertising PDU in the same scan window after
having received an earlier primary channel PDU and auxiliary
channel PDU using LLL scheduling.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix receiving spurious overlapping ADV_IND and SCAN_IND PDU
when LLL state expects to receive SCAN_RSP PDU. Explicitly
check that these PDUs are not processed when in active
scanning and waiting for SCAN_RSP PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If scan is being disabled, rx could already be enqueued
before coming to ull_scan_aux_rx_flush. Check if node rx is
not the last in the list of received PDUs then add it to the
list, else do not add it to the list to avoid duplicate
report generation, release and probable infinite loop
processing of the list. It is possible that node rx has not
be already added in case of last PDU in the chain, under
this case when scan is being stopped add it to the list
before auxiliary context is flushed.
Add the node rx to aux context list of node rx if not
already added when coming to ull_scan_aux_rx_flush. This is
handling a race condition wherein the last PDU in chain is
received and at the same time scan is being disabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix scan aux context leak on Periodic Sync Terminate. On
Periodic Sync Terminate the `is_stop` flag is set to prevent
the ULL from assigning an aux context to the sync context,
but the acquired aux context was neither assigned to sync
context nor was being released back to the aux context pool.
Fixed by releasing the aux context if not assigned to the
sync context when `is_stop` flag is set.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If a device sends an MTU that is bigger than our maximum tx buffer size,
that could cause assertion failures down the line.
This PR limits it to the maximum we support (CONFIG_BT_L2CAP_TX_MTU).
The issue has been observed with a gatt discovery procedure, but is likely
present in other places in att.c.
To reproduce it, we need two zephyr shell devices, with one having a larger
MTU than the other:
- connect
- do data length update to the bigger MTU
- set security to 2, EATT channels get connected
- launch a gatt discovery from the device with the larger MTU
- observe kernel panic on the other device when it attempts to add too much
memory to a net buf.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Log the LE Secure Connection (SC) LTK in a pairing procedure without
bonding when CONFIG_BT_LOG_SNIFFER_INFO is enabled.
Fixes: #50691
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
With introduction of refactored LLCP was also introduced an error
re. calculation of initial slot reservation in connection setups.
Due to this error a bigger slot was reserved, leading to failure due to
connection overlaps in multiple.sh test.
Also the removal of this 'overhead' in slot reservations calls for
bigger time-allowance for l2pcap_stress test.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
The unicast client should never need to set the state of the
endpoints directly, without an notification from the server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the support for caching ASEs on release.
This is mainly due to the 2-stage design in Zephyr: We
have the bt_audio_stream and the bt_audio_ep, where the
the latter represents an ASE in most cases.
However, once the endpoint goes into the codec configured
state, then a stream must be bound to it. This would be fine
(although a stream is technically not established at this point),
except that a stream is also, for unicast, specified for a
specific ACL. Once the ACL disconnects, the stream technically
becomes invalid, and if the stream is invalid, so is the endpoint.
Based on that, there's no reason (or even option) to keep the
endpoint in a codec configured state, as it would not
have a valid stream associated with it.
If we want to support an ASE going into the codec
configured state on ASE release (or ACL disconnect),
the relationsship between ASEs and streams needs to
be redefined.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixed unstable thread state read for detetect engine thread
state.
Fixed engine missing socket conrext add.
lwm2m resume now do update also from network error state
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
When getting a channel timeout, l2cap_chan_destroy is called from the
rtx_work work item.
In that function we attempted to cancel the current work item, and sync on
it being cancelled. The kernel API says that this will block until the work
item completes execution, hence a deadlock.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Fix implementation to not reset the ticks_slot_id_previous
when ticker yields its reserved slot, only reset if ticker
was stopped.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ticker worker from checking the ticks_slot_id_previous,
only ticks_slot_previous be checked as previous slot id
would be assigned to TICKER_NULL if the ticker was stopped.
The ticks_slot_previous value should be used to check that
a slot is reserved even if the ticker has been stopped.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If LwM2M engine was paused at ENGINE_UPDATE_SENT it was not
able to resume lwm2m engine properly. There was also missing
RD client Pending message free which could also affect a issue.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
RD client was not closing socket socket when Update registration
timeout. It fail new connection open. There is added a flag for
detect a case when Registration state need to be re-open a socket
for new connection.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Some testsuites dump lots of output very fast where some systems are not
able to capture the complete output from the tests. Add a slight delay
between each test in the suite.
New kconfig CONFIG_ZTEST_TEST_DELAY_MS is added to ztest.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Add in Kconfig, select DEPRECATED, to warn at build time
that the LLCP legacy implementation is deprecated and the
refactored LLCP enabled by BT_LL_SW_LLCP Kconfig option be
used instead (which is the default now).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This callback allows use-cases where the SDU is much larger than the l2cap
MPS. The stack will then try to allocate using this callback if specified,
and fall-back on using the buffer's pool (previous behavior).
This way one can define two buffer pools, one with a very large buffer
size, and one with a buffer size >= MPS, and the stack will allocate from
that instead.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
See the code comments.
SDUs might enter a state where they will be blocked forever, as a
workaround, we nudge them when another SDU has been sent.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
There was an edge-case where we were sending back too much credits, add a
check so we can't do that anymore.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Fix BIS max PDU size used in calc of sub_interval, use the
minimum of supported maximum BIS PDU size and the requested
SDU size. This will avoid wasted air time between subevents
when SDU size is less than maximum supported PDU size, where
only 150 us tIFS is mandatory between subevents.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When calculating the offsets between primary advertising
PDU, auxiliary PDU, Periodic Advertising PDU, and BIS PDU,
the values used as anchor points for starting the periodic
interval for auxiliary, periodic and BIG events, should be
ensured to have the minimum auxiliary frame spacing T_MAFS
between the PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use a local variable to assert check on auxiliary context's
release.
Add missing volatile qualifier to the parent field of the
auxiliary scan context.
Under race condition a released aux context can be allocated
for reception of chain PDU of a periodic sync role, hence
fix the assertion check to consider that the released
context can be allocated to other roles.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase the BIS PDU access address receive timeout, use the
+/- 2 us jitter for each subevent.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix inifinite loop in ll_rx_get() when both ISO Broadcast
and ISO Receive features are enabled in a build. Missing
conditional compile prevented the ack_last index that
maintains a relation between number of packets complete and
the received data packets was unassigned.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
According to Bluetooth 5.3 Vol 4, Part E section 7.7.65.21 the
Controller should send an IQ report with Packet_Status set to 0xFF
and Sample_Count to 0x0, to inform Host that it is not able to
store IQ samples for all received Constant Tone Extensions and has
failed to sample at least once.
This commit adds handling of such situation for direction finding
in connectionless mode in lower link layer. It includes:
- lack of node_rx_iq_report to store IQ samples,
- lack of free node_rx to report received advertising data (generates
an advertising data report with indication "incomplete, no more to
come" and cancels reception of chained PDUs,
- cancellation of chained PDUs reception due to other scheduling
reasons.
In all of these situations CTE reception must be enabled and number of
received CTEs is smaller than requested by Host.
If there is not sufficient number of node_rx_iq_report nodes and
report was generated, the CTE will not be samples in a given
periodic advertising synchronization event. The CTE will be
sampled again in next event if there are node_rx_iq_report available.
End user applications may check periodic advertising sync event
counter when use of the reports to be sure about sync event
the received report is connected with.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The img_mgmt_erase could return MGMT_ERR_EOK even when
img_mgmt_impl_erase_slot failed.
Fixes#50522
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The GCC/GCOV version over 12 has slight format change of the gcno
and gcda. Make some adaption in the gcov dump function to fix the
code coverage report.
Mainly two places change:
1. Added the checksum in the struct gcov_info. This fix the crash
in qemu_x86, and mps2_an385 when run with --coverage.
2. Adjust the GCOV_TAG_FUNCTION_LENGTH accroding to gcov-io.h. It's
length unit is caculated by bytes now.
Fixes#50255.
Fixes#50257.
Signed-off-by: Enjia Mai <enjia.mai@intel.com>
Fix incorrect use of stream handle instead of connection
handle to enqueue Tx ISO Data, and use stream index to get
stream instance.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When the node is part of only one subnet, it starts Network ID
advertisements with infinite timeout. It is not an issue when using
legacy advertising and extended advertising with shared set for local
messages and GATT because any message will stop advertisements. However,
when a separate adv set is used for GATT advertisements,
`struct bt_le_ext_adv_cb.start` callback won't be called, but the
implementation relies on that callback to switch to a next subnet.
Calling `bt_mesh_adv_gatt_update()` stop GATT advertisement so that the
implementation can switch to the next subnet.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Reduce advertising duration to `max_timeout` when advertising node
identity for multiple subnets. This will let the node to interleave
subnets for NODE_ID_TIMEOUT.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
`struct bt_le_ext_adv_start_param.timeout` resolution is in 10ms. When
duration is less than 10ms, division will be evaluated to zero, which
will result in indefinite timeout. Set timeout to 10ms to avoid
indefinite timeout. The advertisement will end earlier anyway after the
event is finished.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Fixes an issue with img_mgmt whereby the if check for a slot3
partition is using the wrong case for the partition name.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add error message logging for Advertising enable/disable at
RPA timeout when the resolvable address is updated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix resolvable address update after RPA timeout with
Extended Advertising support enabled. As Extended
Advertising HCI Commands are being used to start legacy
advertising, incorrectly the local random address was being
used instead of using the random address populated in the
Extended Advertising set. BT_DEV_RPA_VALID is not cleared
when Extended Advertising HCI commands are used, hence the
local random address is not updated and the incorrect use
of it did not make any change to the advertising when
disabled and enabled at RPA timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enforce next_is_older only when current has equal force as
with the next ticker.
Added Kconfig to disable priority feature in ticker that is
currently not used by Zephyr Bluetooth Low Energy
Controller.
The priority feature if enabled then a custom ULL is needed
by vendors to avoid repeated skipping of overlapping events
as next_has_priority check uses lazy value that would be
always lazy_next > lazy_current as currently skipped event
becomes the next event with lazy value incremented by 1.
Regression in commit 3a9173afe1 ("bluetooth: controller:
Revised ticker for improved conflict resolution") due to
Zephyr Controller does not implement any vendor specific
priority logic.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This fixes possible memory violation by using the index outside of an
instance array by tbs_client_common_call_control.
This basically fixes the get_inst_by_index function to return NULL if
the index is invalid. The function calls have been guarded to catch the
returned NULL.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When switching from a secure network to open network, the previous
parameters are not reset which causes the open connection to fail.
Remove the unnecessary "static" storage and reset to zero for params.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
Fixed missing '_CONFIG' prefix when enabling
LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT_MULTIPLE and
CONFIG_LWM2M_FIRMWARE_UPDATE_OBJ_INSTANCE_COUNT through prj.conf
Signed-off-by: Henrico Brom <henrico.brom@vention.nl>
Reduce the number of times cntr_cnt_get() is called in
ticker implementation as call to this function halts the
CPU inorder to access the RTC count in the 32KHz clock
domain.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This fixes a bug with ARP and multiple outgoing packets with an IP
that needs to be resolved, causing the first packet to go out and
all others to be dropped after the timeout by having a FIFO of
pending packets instead of a single packet.
Signed-off-by: Jamie McCrae <spam@helper3000.net>
Moves a .h file added outside of the zephyr include folder to be
within the zephyr include folder.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fix Extended Scanning assertion check when using Ticker
Low Latency Implementation where the failure to schedule
a ticker timeout is returned inline compared to deferred
failure in the operation callback.
Auxiliary PDU is received using a single-shot ticker
timeout with ticks_slot reservation. This single-shot
ticker is allowed to fail if it is overlapping another
event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This fixes crash that happened during source ASE QoS by setting
the tx path that was left uninitialized.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This header provides original BOOT_MAX_ALIGN definition.
This definition is used indirectly by the code this
patch modifies.
Let's use it instead of copy from mcuboot.h
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
This header provides original BOOT_MAX_ALIGN definition.
This definition is used directly on indirectly by the code this
patch modifies.
Let's use it instead of copy from mcuboot.h
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The LE Accept/Reject CIS Request commands shall return Unknown
Connection Identifier if the handle is not a CIS handle or does not
exist. If the CIS already has been established, the commands shall
return Command Disallowed.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
The broadcast sink did not allow codec config data to exist
in both the subgroup and in the individual BISes, which
not only doesn't make sense to not allow, but would
also cause interoperability issues.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The options should enable verbose responses in error responses
to SMP command processing, but has been broen when the code
has been ported to zcbor.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fix incorrect data type int32_t local variable used for lazy
value which is uint16_t type.
Other minor code refactor done.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing conditional compile of structure members not
required with BT_TICKER_SLOT_AGNOSTIC is enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add 'U' to a value when assigning it to an unsigned
variable.
MISRA-C rule 7.2
Relates to commit b97db52de7 ("misra-c: Add 'U' to
unsigned variable assignments in subsys/").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect use of stream index (application selected list
of BIS stream) instead of BIS index when checking for
whether the received PDU is to be stored and to be
dispatched as ISO data to ULL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing Broadcast ISO Synchronized Receiver terminate
reason initialization that caused Sync Lost immediately on
a new Sync Establishment due to previous Sync terminate
reason not being reset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing implementation to correctly to use data channel
index for subevents when previous subevent of previous BIS
stream where skipped.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ISO broadcast implementation to flush stale ISO data for
all BIS streams and like wise generate acknowledgements for
all BIS streams that had its ISO data transmitted at its
reference anchor points.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Restrict the calculated possible Pre-Transmission subevents
count to a maximum of 1 so that the full ISO interval is
not fully occupied by the BIG event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix a leak in generation of Number of Completed Packets when
more than one handle has acknowledgements to be processed.
The loop exited for the current handle by dequeueing the
node tx element of the next handle leading to lost Number of
Completed Packets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When radio event prepare is cancelled due to preemption by
overlapping radio events, the extra done event processing
was missing and hence the use of accumulated prepares'
skip/latency count.
This caused the check for supervision timeout and sync
lost not be aware of the elapsed events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add 'U' to a value when assigning it to an unsigned
variable.
MISRA-C rule 7.2
Relates to commit b97db52de7 ("misra-c: Add 'U' to
unsigned variable assignments in subsys/").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add the missing ticker resolution margin when calculating
the ticks_anchor to be used to get non-overlapping BIG
events.
Relates to commit fab4511164 ("Bluetooth: Controller: Fix
overlapping advertising events").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add missing dependency since log_output_syst.c is calling functions
from log_output module.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
If the is no update from the server, the _links will be NULL.
Check if it is NULL before trying to LOG these strings.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
There are warnings when building fs_mgmt with hash/checksum
functionality enabled due to array access and a wrong variable type
being used.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
The lwm2m exec erroneously checked the previous return value
instead of checking if the resource existed. This caused exec
to try to get and execute the execute callback from NULL and caused
a reboot.
Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
Cbprintf has new feature where it can distinguish between
character pointers used for %p and %s. It is enabled by
flag CBPRINTF_PACKAGE_CONVERT_PTR_CHECK.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
this changes adv_new_legacy to adv_get_legacy.
without this fix the function would return NULL if BT_EXT_ADV is enabled.
Signed-off-by: Jonas Woerner <jonas.woerner@online.de>
Sharing the same pool for both, local and relayed messages has some
disadwantages. In a high-traffic environment the relayed messages may
occupy the whole pool without letting the node to send own messages,
neither to process segmented messages. The vice versa situation is
possible when local messages takes the whole pool so that the node is
not able to relay other messages. Another thing is that it doesn't let
to controll amount of local and relayed messages that the node can send
at once. Controlling the number of messages that the node can relay may
help to reduce the message latency.
This change adds separate net_buf_pool for the relayed messages that
helps to avoid problems described above.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Since db11fcd174 [net/net_pkt: Fully
separate struct net_pkt from struct net_buf], net_pkt_compact() can not
fail anymore.
This commit acknowledges this and simplifies the API accordingly.
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
After magic is read during bound procedure, trigger an
initial data read. This is to ensure data is not missed
when piggybacked on magic's exchange interrupt.
Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
When CONFIG_ZTEST_SHUFFLE is enabled and ASSERTS are disabled
`start_pos` becomes an unused variable leading to a compile error.
Cleaned-up shuffling algorithm to not need a `start_pos` check.
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
Allocated, but undersized packets must not just be logged, but also
unreferenced before returning an error.
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
If `struct bt_mesh_prov::unprovisioned_beacon` callback is not set,
don't process the beacon.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
zcbor supports native zcbor_size_ functions for some time now,
so there is no need to have local zcbor_size_ definitions.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
For the encryption procedure exists a flag used to indicate that the
procedure expects all PDUs to be delivered to the procedure STM.
This flag was not cleared during creation of new procedure. This could
lead to unexpected PDUs being passed to local procedure STM
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Fix compile error when BT_CTLR_JIT_SCHEDULING is enabled but
BT_CTLR_ADV_EXT is disabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When friend entry is cleared by `friend_clear` after an adv buffer has
been sent to that friend in `friend_timeout`, another friend request
coming after this may reuse the same entry. It is possible that
`friend_timeout` will be scheduled twice: once by the friend request
and once by `buf_send_end` of the previously sent buffer.
In that case, the code will assert on line friend.c:1234. It is not
possible to cancel an adv buffer for the friendship that is to be
cleared, therefore, we need to ensure in correctness of the pending_buf
value in start and end callbacks.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
When local node enter iv recovery procedure, should clear
replay list at first due to avoid possible wrong replay attack.
At present, `bt_mesh_rpl_clear` schedule a timer to clear rpl,
this would cause local node unable precess mesh message(IV Updated).
Also, in `bt_mesh_rpl_pending_store` also not clear rpl, which check
`BT_MESH_VALID` flag, always valid for iv recovery.
So, Add `rpl_clear_pending` work handler process rpl clear.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Casting the value byte to char may result in it being a negative
number. On some platforms this could lead to either UB, or a crash.
Signed-off-by: Dennis Sitelew <dennis.sitelew@grandcentrix.net>
When the websocket_prepare_and_send is called from websocket_send_msg,
the header length is subtracted to retrieve the transmitted payload length.
Make an exclutsion to prevent the return code of
websocket_prepare_and_send being modified in case of 0 or a negative
return code.
This avoid confusion with modificated error codes
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
The CDB module is a mandatory part of provisioning features in BTM, and
can not be regarded as experimental anymore.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
method_from_code() signature has changed to return error and
the method. In case of an invalid code it returns -EINVAL and
causes coap_handle_request() to return -ENOTSUP.
Fixes: #49498
Signed-off-by: Sagar Shah <sagar.shah@legrand.us>
Using the passed address is incorrect since the passed address can be
zero to find the lowest available address.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
According to MshPRFv1.0.1, section 3.10.7, the Provisioner shall only
use reuse addresses of the deleted nodes after IV Index is updated.
This change prevents CDB reusing addresses of the deleted nodes until IV
Index is updated. Due to a high range of the unicast addresses, CDB only
stores the highest deleted address once a node is deleted. This creates
a limitation where allocating a node with the high primary unicast
address and then deleting it will make CDB skip big range of address
until next IV Index update.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Used the registry lock in the functions lwm2m_registry_lock() and
lwm2m_registry_unlock() to make the registry lockable through a public
API. If writing to multiple resources that are composite-observed,
locking will halt the main thread until every resource is written to,
ensuring that only one notify message will be sent. Updated
the documentation in lwm2m to include this addition.
Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
When periodic advertising with chaining is re-enabled after
changing interval or just re-enabled then the chain PDUs
where not duplicated causing the LLL to assert detecting the
presence of aux pointer but no linked chain PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP cannot be selected unless one of
the enumerated backends is selected. Add the ADSP_MTRACE backend to the
list, so timestamp formatting can be selected when only this backend is
enabled in the build.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Fixes an issue with outgoing mcumgr frames that are larger than the
transport MTU size whereby they would wrongly be split up into multiple
frames with multiple start frame headers, which affected SMP over
console transports.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Allow using log_output without the logging subsystem. It can be
used in the situation where external messages are processed.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The lib/transport directory has been moved up, directly under the
subsys/mgmt/mcumgr, and all transport files have been moved to
that directory.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
On GICv3, when we send an IPI interrupt, aff3, aff2 and aff1 should
be assigned a value corespond to a PE for which interrupt will be
generated. target_list only corresponds to aff0.
On real hardware, aff3, aff2, aff1 and aff0 should be treated as a
whole to determine a PE.
Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
In the function find_available_port() a port is randomly selected. Because
the random value is always >= 0x8000, it is redundant to check if it is
<= 1023 afterwards.
This commit removes the redundant check.
Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
This commit removes the requirement for msg parameter in zassert_*
and zassume_* macros. It will allow to use them without sending NULL
as the last parameter.
The default messages look like:
void* beauty_ptr = NULL;
zassert_not_null(beauty_ptr);
=>
Assertion failed at main.c:20: suite_test: beauty_ptr is NULL
void* ugly_ptr = (void*)0xbaadf00d;
zassume_is_null(ugly_ptr);
=>
Assumption failed at main.c:23: suite_test: ugly_ptr is not NULL
int apple = 3;
int tomato = 9;
zassume_equal(apple, tomato);
=>
Assumption failed at main.c:27: suite_test: apple not equal to tomato
Signed-off-by: Michał Barnaś <mb@semihalf.com>
This commit adds intermediate macros that will allow to use the
zassert and zassume macros without setting the msg parameter as NULL
if it isn't used.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
Fixes an issue introduced when the mcumgr code was simplified whereby
the newer compressed free function call wrongly passes a pointer to a
pointer instead of the pointer itself.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes an issue with the connection reference not being decremented
at the end of the outgoing notification function resulting in an
ever-increasing connection count.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add a new command, connect-name, which takes a string
as the single input and uses that to setup a scan filter
and connect to the first device that matches the name.
This command is thus basically shorthand for
bt scan-filter-set <name>
bt scan on
bt scan off
bt connect
bt scan-filter-clear-name
The idea of this command is to not only make it easier
find and connect to devices in a crowded environment,
but also to more easily connect to devices that changes
their advertised address.
The implementation is minimal as it uses existing
shell commands.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
As per BAP_v1.0, Section 5.6.3.1:
If HCI is used when setting up their respective audio data paths,
and if the codec in use resides in the Bluetooth Host of the device
using the LE Setup ISO Data Path command, the Unicast Client and/or
Unicast Server shall:
* Write the LE Setup ISO Data Path command Codec_Configuration_Length
parameter with the value 0x00.
* Write octet 0 (Coding_Format) of the LE Setup ISO Data Path command
Codec_ID parameter with the value 0x03 (Transparent).
We can assume the codec in use resides in the Bluetooth Host default.
Signed-off-by: Hang Fan <fanhang@xiaomi.com>
During initialization of the FS backed, the oldest
file is always deleted.
Fix this to prevent throwing away useful historic logs.
If there is space left in the newest file, append to it instead
of creating a new file and removing the oldest.
Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
The static function img_mgmt_flash_check_empty is only used if
CONFIG_IMG_ERASE_PROGRESSIVELY isn't set.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This adds a dummy SMP backend which can be used for unit testing or
virtual interface purposes.
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
Refactor to revert back the terminate check condition to
check the connection role first.
Reverts legacy code changed in
commit 8b1d50b981 ("Bluetooth: controller: llcp: fix issue
re. missing ack of terminate ind").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not use lazy value to prioritize ticker with ticks slot
window that yield to other tickers. Primary channel PDUs
use ticks slow window to nudge themself after an
overlapping ticker within the ticks slot window, but such
ticker may be skipped to next interval. At the next
interval if they again overlap with other tickers then
lazy value shall not be used to prioritize but rather
continue to yield again. This is required to avoid BIG
events from being skipped.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The timestamp is not part of the SDU, and should
thus not be used to get the maximum SDU size.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use XOSHIRO random number generator if target has entropy generator.
Some entropy generators may have limitations (e.g. only thread context)
which would conflict with ztress usage.
Added Kconfig.defconfig for testsuite.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added a workaround to call random generator once during the
initialization. It is done to handle XOSHIRO generator limitation
which performs initialization in the first sys_rand32_get call.
And for some entropy generators it cannot be done from an interrupt
context and it happens if k_timer context is used which expires first.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix BIG Create implementation from silently failing on
values of RTN and SDU_interval that lead to BIG events that
cannot be acheived when using sequential or interleaved
subevents by the Controller Implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a Kconfig for Advertising Data Chaining in Extended and
Periodic Advertising, permitting AD data lengths of upto
1650 bytes. The implementation is experimental and needs
further testing.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BT_CTLR_ADV_DATA_LEN_MAX and other Kconfig dependencies,
and clean up the use of PDU_AC_LL_SIZE_MAX which is used to
allocate scratch packet to be atleast able to accommodate
the minimum 31 bytes AD data such that it is sufficient to
transmit and/or receive scan response PDUs when either
broadcaster or observer alone is supported.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Additional testing showed that when using printk the logger would start
sticking and spitting out nulls which is wrong. This made it appear as if
the firmware had locked up. The issue seems to have been caused by the
initial ipc message to read all the dma buffers on the host.
Removing that, the issue seems to have been solved.
This also improves the test case to ensure printk with LOG_PRINTK=y
works as expected. It also adds a last log message between some
timeouts of the flush timer length to ensure the padding and timer
flush are working properly.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
This commit splits out the model related commands from mesh shell to
separate shell modules. The purpose of this alteration is to make model
commands more flexible by letting the application itself define the
model instances.
- Move Health Client commands to separate shell module.
- Move Config Client commands to separate shell module.
- Remove Health Client instance from shell.c.
- Add Health Client instance to mesh_shell test application.
- Add util library for Mesh shell.
- Some refactoring of shell menu layout.
- Update Mesh shell documentation.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Moves shell.c to shell subfolder. Done as a separate step to preserve
diff between previous and new revision of shell.c.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Allow requesting any TX power in SDC via kconfig. This enables easily
setting higher TX values when using a FEM.
Signed-off-by: Timothy Keys <timothy.keys@nordicsemi.no>
`wait()` returns the retval of `zsock_poll()` which can be
negative but is currently unhandled.
This patch make sure that the error will be handled.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Minor MISRA-related fixes so that the conditionals are boolean
and precedence of statements are explicit.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
- Fix ISO TX data pool corruption due to multiple calls to
tx_cmplt_get, without removing the nodes
- Added missing release of TX node link in case of ISOAL error
Signed-off-by: Morten Priess <mtpr@oticon.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ISO Tx PDU memory pool corruption due to duplicate ISO
Tx PDU buffers repeatedly released into the memory pool.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the removal of BIG context association with the
Periodic Advertising context to when the BIG streams are
release and BIG terminate message is generated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If the mtrace buffer gets full, the entries are dropped. This
is however not reflected in the "bytes_written" argument passed
to the hook function used to notify of new data in the buffer.
This behaviour becomes problematic in the case there is no
active consumer of the mtrace logs. To allow the client that has
registered the hook function, to act correctly in this case,
the bytes_written should reflect the actual bytes that have been
added to buffer.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Adds the runtime tick count of threads to mcumgr's taskstat response,
if CONFIG_SCHED_THREAD_USAGE is enabled, which reports the number of
execution cycles that each thread has been running for.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes an issue with Bluetooth notification sending whereby it does
not wait for buffers to become available and can error out if
unable to get a buffer once.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes an issues where the system work queue can become a source of
contention and cause a deadlock by moving MCUMGR SMP processing to its
own dedicated work queue.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
The Kconfig for MCUMgr management source code (service registration,
group registration, and so on) has been moved to the sub-dir with
the code.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
By default, thread priorities in mcumgr task stat responses are
unsigned, whilst in zephyr, thread priorities are signed. This means
that clients get obscenely large numbers for priorities that make no
sense. The fork of mcumgr has been in zephyr long enough now that
this should be changed to use signed thread priorities by default
instead of sticking with the old mcumgr default.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
The commit removes declarations of:
zephyr_smp_rx_req, zephyr_smp_alloc_rsp, zephyr_smp_free_buf
from include/zephyr/mgmt/mcumgr/smp.h, as these are MCUMgr internal
functions used in SMP processing and should be not exposed
from header file that provides interface for SMP transports.
The declarations have been moved to smp_internal.h, which is
visible within MCUMgr.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Tests with shell commands will fail if they are started
before the shell backend is initialized or started.
Adding API function: shell_ready indicating shell readiness.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
The current implementation of provisioning features is dependent on CDB
to compile, which is reflected poorly in the Kconfig options for mesh.
This commit alters the Kconfig options for provisioning to be dependent
on the CDB option to compile.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Use c99 format specifier macros to remove build warnings when building
for `native_posix[_64]`.
Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
If a L2 link has been established, then the DHCP is taking too long as
it has to go through its capped exponential backoff timers to trigger
discover (The DHCP starts immediately during init, this is itself wrong,
it should start on a link UP notification) that delays the DHCP for
few seconds to a minute.
And if we do stop and start DHCP then also it goes through the initial
delays (though configurable), which is also not ideal.
Add support for restarting DHCP without any delay, i.e., release and
send discover immediately.
This is also useful in case L2 switches to a different subnet, in this
case Zephyr doesn't restart DHCP automatically, this API can be used by
L2 apps/drivers to restart DHCP to get new subnet IP.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
Added implementation to use the BIS array parameter and
selectively synchronize to subset of multiple Broadcast
Isochronous Streams in a Broadcast Isochronous Group.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix calculation of BIS subevents that was missing num_bis
when calculating the PDU latency.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect conditional compile to disable Controller
advanced scheduling feature which is required for Broadcast
ISO implementation.
Regression in commit 6fe1299c33 ("Bluetooth: controller:
llcp: fix CI tests for new LLCP").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In a Host plus Controller combined build for ISO feature
restrict the maximum ISO Tx PDU size to minimum of 251 bytes
and Host ISO Tx MTU. This will allow controller to use
reduced Tx time (subevent interval).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The conditional block linking mbedTLS for checksum calculation
in FS commands have been moved to CMakeLists.txt responsible
for compiling these commands.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
* reduced cyclomatic complexity
* group validation by family to make the validation easier to understand
and extend
* change preprocessor markup where possible to allow for complete code
elimination when features (esp. IP) are disabled
* renamed net_context_get/set_ip_proto() to net_context_get_proto()
While the latter is formally part of the public API and might therefore
have to be deprecated rather than renamed, it is considered internal API
by the net developers, see
https://github.com/zephyrproject-rtos/zephyr/pull/48751#discussion_r942402612
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
The net_core:process_data() and connection:net_conn_input() methods are
the central network packet reception pipeline which:
1) guide network packets through all network layers,
2) decode, validate and filter packages along the way and
3) distribute packages to connections/sockets on all layers.
This code seems to have grown complex and rather cluttered over time as
all protocols, layers and socket implementations meet there in one single
place.
The code also reveals its origin as a pure IP stack which makes it hard
to introduce non-IP protocols and their supporting socket infrastructure
in a modularized way.
For an outside contributor it seems almost impossible to add another
protocol, protocol layer, filter rule or socket implementation without
breaking things.
This change doesn't try to solve all issues at once. It focuses
exclusively on aspects that maintain backwards compatibility:
* Improve modularization and encapsulation on implementation level by
disentangling code that mixes up layers, protocols and socket
implementations.
* Make IP just one protocol among others by removing assymmetry in
protocol handling logic and introduce preprocessor markup so that
IP-specific code can be eliminated by the preprocessor if not needed.
* Use preprocessor markup to delineate hook points for future
modularization or expansion without introducing structural changes (as
this would almost certainly break the API).
* Reduce cyclomatic complexity, use positive rather than negative logic,
improve variable naming, replace if/elseif/else blocks with switches,
reduce variable span, introduce inline comments where code does not
speak for itself, etc. as much as possible to make the code overall
more human-friendly.
Background: These are preparative steps for the introduction of IEEE
802.15.RAW sockets, DGRAM sockets and sockets bound to PAN IDs and device
addresses similar to what the Linux kernel does.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Introducing additional socket implementations is rather involved right
now due to some more or less convoluted code that had grown over time.
This change introduces an additional configuration variable in preparation
for additional socket API drivers. The idea is to reduce redundant code
and make existing code more readable by better exposing its actual intent.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
The code contained several repeated composite IPv4/v6 and UDP/TCP
preprocessor statements that can be simplified by introducing a hidden
NET_IP preprocessor constant that captures what probably is actually
"meant" by this code.
While we were on it we also used the new constant to further isolate
IP-specific code from non-IP specific generics.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.
The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.
NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Add option to control formatting of the logging timestamp. By default
formatting is enabled which maintains backward compatibility.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This PR adds a `*_cli_*` infix to the Config Client API to match
the changes in Health Client. The old API is marked as deprecated.
Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
Add macro for logging raw formatted string. It is similar to
LOG_PRINTK macro but contrary to LOG_PRINTK it should not append
carriage return character to any new line character found in the
string. LOG_PRINTK processed by log_output module has that to
mimic printk behavior.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
bt_keys_find_addr() is used to find key by both ID and address.
Following checks must continue to compare ID and address as well.
Or, we can compare key references which is faster.
Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
Fix include order to avoid redefinition of `ARRAY_SIZE`, because
`sys/util.h` and `zcbor_common.h` both define it, but `sys/util.h` does
not protect against redefinition.
Signed-off-by: Fabio Utzig <utzig@tumenibits.com>
Changes to code:
1. Renamed CAVS_IPC API from common/include/cavs_ipc.h to
common/include/intel_adsp_ipc.h. Renamed all API functions and structs -
added "intel_adsp_" prefix.
2. Moved definitions from intel-ipc-regs.h and ace-ipc-regs.g to SOC
specific headers include/<soc_name>/adsp_ipc_regs.h.
3. Added new common intel_adsp_ipc_devtree.h header with new
macros to retrieve IPC and IDC nodes and register addresses.
Put those new macros in code replacing hardcoded values outside of
devicetree.
4. Changed documentation of IDC and renamed IDC register struct
to have common name between all intel adsp socs.
5. Removed excessive docs description on cAVS IPC protocol.
Changes to Devicetree:
1. Renamed in all CAVS boards .dtsi files content in IPC nodes:
- "cavs_host_ipc" node labels to "adsp_ipc" labels.
- compatible "intel,cavs-host-ipc" renamed to
"intel,adsp-host-ipc".
2. Added (previously missing) yaml file for "intel,adsp-host-ipc"
compatible.
3. Renamed in all CAVS boards .dtsi files content in IDC nodes:
- "idc" node labels to "adsp_idc" labels.
- compatible "intel,cavs-idc" renamed to "intel-adsp-idc"
4. Renamed intel,cavs_idc.yaml file to intel,adsp_idc.yaml
so it is suitable for both CAVS and ACE SoC family.
Moved it from ipm bindings to ipc bindings where it belongs.
Changes to Kconfig:
1. Renamed existing Kconfig option CONFIG_CAVS_IPC to
INTEL_ADSP_IPC.
2. For renamed INTEL_ADSP_IPC addded default value based on
status of the "adsp-ipc" and "adsp-ipc" node.
Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
Add support for setting a vendor specific data path using
the BAP API, instead of only support the HCI data path.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The CC/Codec Configuration in bt_iso_chan_path was
defined as an array of size 0. This meant that the
CC always had to be allocated right after the
bt_iso_chan_path struct.
This does not give a very flexible API, and also makes
it impossible for two bt_iso_chan_path to share the same
CC.
The API is modified so that the CC is simply a pointer
to a an array now.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
coap_packet_parse() returns different values depending on error.
It now returns
-EINVAL for invalid input arguments,
-EBADMSG for malformed coap header,
-EILSEQ for malformed options error.
Fixes: #48960
Signed-off-by: Sagar Shah <sagar.shah@legrand.us>
Allows selecting which slot will be erased, will default back to
slot 1 as it would do in previous versions if the optional parameter
is not provided
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
add user data for adu callback, which helps in passing
socket and relevant application parameters.
Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
NSEC_PER_MSEC should be defined along with the rest of the
per-sec macros in sys_clock.h. Currently, it's defined
multiply in a few separate locations.
Signed-off-by: Christopher Friedt <cfriedt@fb.com>
When shell was used as a log backend it did not enabled log_output
module used for string formatting. Adding missing dependency.
Original commit (b0072e1cea) was
reverted, reappling.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
log_output.c was added in two places: unconditionally when logging
is enabled and when CONFIG_LOG_OUTPUT is set. Cleaning up to add
source file only when module is enabled.
Original commit was reverted. Now it is reapplied.
Original commit:af31cad8366c82a35e8749e6488252e394ce158d
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
`bt_l2cap_chan_send_cb()` overwrote the buffer user data for internal
use. In the case where sending fails, this would be visible for the
caller. If the caller relied on the buffer user data to be unchanged,
this could cause unexpected behavior.
L2CAP tx metadata was also not freed in the error case.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The `%i` format specifier is for `int` and is equivalent to
`%d` for printf formatting.
However, for `size_t`, the correct format specifier is `%zu`.
Fixes#49825
Signed-off-by: Christopher Friedt <cfriedt@fb.com>
This prevents the shell command response code conflicting with the
mcumgr response code, which are 2 distinct variable types
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes a race condition when listing task status using mcumgr whereby
if a thread status changes, it could cause unpredictable output for
the command.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Reduces the level of indirection for functions by calling the zephyr
functions directly as support for multiple operating systems is no
longer required with mcumgr being forked and placed into the zephyr
tree. Saves 60 bytes flash when compiling smp_svr on an ARM Cortex
M4 board.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Switches to using Zephyr's single linked list implementation for
group management objects instead of duplicating functionality for
mcumgr only.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Resolves an issue with processors that do not support unaligned memory
access when using img_mgmt functions, e.g. ARM Cortex M0, by marking
structures as packed.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fix prepare pipeline preempt timeout stop from stopping a
a prevously started timeout for the next in pipeline event.
The preempt timeout started prior for the current event that
has its prepare that is invoked is to be not explicitly
stopped. If there is a next prepare event in pipeline, then
the prior preempt timeout if started will be stopped before
starting the new preempt timeout. Refer to implementation in
preempt_ticker_start().
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation in Periodic Sync LLL abort to use near
fair scheduling to ensure overlapping multiple Periodic
Sync set each get to use the radio and not lead to Sync
Loss.
The implementation is used when overlap in radio event
happens in unreserved time space of the event. An abort
count is maintain in each Periodic Sync instance and is
used to decide whether the current event or the next
event is to be aborted when they overlap.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add Kconfig to use minimal time reservation for auxiliary
and sync PDU reception. A peer device could be scheduling
multiple advertising sets in a short duration with small
PDUs hence using the minimal time reservation would avoid
skipping closely scheduled reception of multiple auxiliary
PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The reorder process in rather complicated. Add a runtime check to always
check afterwards if the reordering queue is still consistent. When this
test fails, discard the contents of the complete reorder buffer.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
When all the data of the new packet is already present in the
queue_recv_data, make sure the packet is discarded.
This commit adds a test line that reproduces the issue and implements a
fix.
Also in appending the packet, call the official net_buf_frag_add function
instead of updating the last net_buf pointer, since the net_pkt_remove_tail
called in between, might have removed the last net_buf.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
TCP is a streaming protocol, this means it can set the packet boundary
at an arbitrary location. Therefor a re-transmitted packet may have the
packet boundary at a different location from the original missing segment.
The reordering logic should be able to deal with this situation and
throw away the overlapping data. This fix clears the out of order queue
when the queued data is not relevant.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
TCP is a streaming protocol, this means it can set the packet boundary
at an arbitrary location. Therefor a re-transmitted packet may have the
packet boundary at a different location from the original missing segment.
The reordering logic should be able to deal with this situation and
throw away the overlapping data. Now also for data that needs to be added
to the existing queue
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
TCP is a streaming protocol, this means it can set the packet boundary
at an arbitrary location. Therefor a re-transmitted packet may have the
packet boundary at a different location from the original missing segment.
The reordering logic should be able to deal with this situation and
throw away the overlapping data.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Instead of waiting for the retransmit timeout, retransmit as soon as
missing data is deduced based on a triple-duplicate ACK.
Increase the number of buffers in the testcase, to allow for at least 4
packets in flight to trigger the triple-duplicate ACK.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
When out of order data is received, send out a duplicate ACK to notify
the sender that there is data received out of sequence, so it can
retransmit the missing section.
Also avoid sending acknowlegdement to acknowlegdement messages that are
having an out of order sequence number.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
This commit clears cached random address in bt_dev when calling
bt_disable(). This change makes future calls of set_random_address()
function possible with previously used address value, after BLE stack
re-initialization. Without this change no HCI command was sent, see this
condition in set_random_address():
/* Do nothing if we already have the right address */
if (!bt_addr_cmp(addr, &bt_dev.random_addr.a)) {
return 0;
}
Signed-off-by: Adam Augustyn <adam.augustyn@hidglobal.com>
Additional uncontrolled delay for transmitting segack affects throughput
of the segmented messages. Though the best throughput can be achieved
with the smallest allowed values, move them to Kconfig option so that
the segack delay can be controlled by a user.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
When CONFIG_KERNEL_COHERENCE=y, it's illegal to place shared
data(like ztress_context_data in this test case) on the stack,
because that memory is incoherent with respect to other CPUs
in the system.
In this specific case, it will cause PC register to load invalid
handler function pointer and crash the Xtensa processor.
Make it static.
Signed-off-by: Ming Shao <ming.shao@intel.com>
The IEEE 802.15.4 security implementation had several severe bugs:
* A regression introduced by 6ea225e34a
(net/ieee802154: Finally removing usage of ll_reserve in L2)
introduced a buffer leak (reading/ writing beyond the end of the frame
buffer) and led the security implementation to malfunction in all but
the simplest cases (i.e. encryption/authentication: none).
* Encryption vs. authentication modes were not properly implemented i.e.
encryption was always active even if not required by the chosen
encryption level.
* Nonce endianness was not correctly handled on decryption of packets
which led to authentication failures.
* The frame counter was not checked for overflows.
* The encryption output buffer limit (out_buf_max) was not correctly set.
* Setting an invalid key mode led to a NULL pointer deref.
* We use CCM rather than CCM* as crypto.h does not provide access to
CCM*. CCM does not support encryption-only operation, though. This
condition was not checked by the code.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
This change makes the packet socket and ieee802154 l2 drivers aware of
AF_PACKET sockets, see https://github.com/linux-wpan/wpan-tools/tree/master/examples
for examples which inspired this change.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Some IEEE 802.15.4 specification constants must be made available in
userspace as they will be needed to use IEEE 802.15.4 RAW/DGRAM sockets
which will be introduced in this changeset.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Zephyr IEEE 802.15.4 drivers and L2 stack use the same constant names
for different MTU definitions. The intent of this change is to introduce
a consistent MTU definition which can be used everywhere in zephyr to
avoid confusion, bugs and name conflict.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Newly introduced Coverity scan throws a warning about duplicate tag as
per MISRA coding standards, so, use a unique tag name in the existing
code for "shell".
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
Networking statistics framework is used to define handler and the data
structure, Wi-Fi management layer implements the handler and also adds a
new offload API to get statistics from the Wi-Fi driver.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
A new net_mgmt command and event are added for interface status,
depending on the implementation the status can be returned when polled
or an unsolicited event can be send by driver whenever there is a change
in status.
This is planned to be implemented only by upcoming wpa_supplicant,
offload implementation is left for driver developers.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
This commit replaces API that became deprecated with the release
of nrfx2.9 - see CHANGELOG in zephyrproject-rtos:hal_nordic repository
Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
Created the mutex registry_lock to:
- protect read and write operations
- protect the registry.
Only partially finished as the functions like lwm2m_engine_get_obj
warrants a larger refactoring to completely thread safe the registry.
Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
LwM2M was not reported properly case when message "Accept"
coap option was not not supported. In that case LwM2M transport
specification define 4.06 "Not Accepted"
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
When AUX_ADV_IND or AUX_CHAIN_IND auxiliary channel PDU scan
radio event overlaps Periodic Sync radio event in unreserved
time space, let the Periodic Sync radio event be aborted so
that the auxiliary channel PDU can be received to generate
Extended Advertising Reports. Added a new Kconfig to enable
this.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Set the location in the init command. Also updates the
available context to the CONTEXT macro value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The update result is supposed to indicate success only after a firmware
update has been applied. The bug here was that the success was reported
already when the update image download was done.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
Implements a logging backend implementing the mtrace protocol
to relay log messages over SRAM. This protocol is implemented
by the SOF Linux driver ("mtrace" debugfs interface).
This implementation follows example of the ADSP HDA logger implemented
in commit 6913da9ddd ("logging: cAVS HDA based logger").
Cc: Tom Burdick <thomas.burdick@intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Current ztress design supports both timer context and thread
context. The timer context always uses the first element of
several global array variables like exec_cnt[] and backoff[].
But progress_timeout() is using the last element of exec_cnt[]
to calculate the progress of timer context. It is not right.
Signed-off-by: Ming Shao <ming.shao@intel.com>
Increase deafult value of SHELL_ARGC_MAX configuration.
This allows users to utilize deeper nested shell menus without
risking maxing out the number of allowed arguments.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Tests with KERNEL enabled perform their cleanup logic after the suite's
after and test rules are executed. Unittests should do the same.
Signed-off-by: Yuval Peress <peress@google.com>
Updates the implementation when KERNEL is available to safely bail on
the test when the test calls fail, skip, or pass during invalid test
phases. Print a detailed message, and skip all other tests. The test
run will be marked as failed.
Signed-off-by: Yuval Peress <peress@google.com>
Move the function used for printing the phase name up so its available
for both unittest and KERNEL mode of tests.
Signed-off-by: Yuval Peress <peress@google.com>
When not running in setup, before, or in the test. Calling fail, skip,
or pass is invalid and should be considered an error. Properly handle
these cases by printing a more detailed error message and bailing the
process.
Signed-off-by: Yuval Peress <peress@google.com>
When KERNEL was not defined (unittest), the call to init_testing was
used to set a longjump target using 'stack_fail'. When triggered,
this was actually causing a segfault, because longjmp is only valid
if going directly up the stack. Since init_testing returned, it was
no longer on the stack. Instead, that logic MUST be inlined.
Signed-off-by: Yuval Peress <peress@google.com>
* Adds a default hook and init function for cavstool.
* Adds an optional padding on flush feature to ensure all data is written.
* Fixes an error in cavstool.py for correctly wrapping the ring buffer.
* The test case now ensures wraps and flushes occur numerous times.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Normal usage for Bluetooth applications are getting close to or
already overflowing the default BT RX stack size of 1024.
For example:
- Discovery using the fixed ATT channel used 984 bytes.
- Discovery using an enhanced ATT channel used 1048 bytes,
which would lead to stack overflow using the default BT RX thread
stack size.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
At some point, package copy function was extended and renamed
to cbprintf_package_convert. However, flags used by this
function were not renamed and used contained COPY idiom.
Deprecating flags with COPY and replacing them with flags
with CONVERT idiom to match function which is utilizing them.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
When using periodic advertising list and receiving
hci_le_per_adv_sync_established event from controller with
an error code the bt_le_per_adv_sync_term_info would be
incorrectly populated with le_addr and sid. This is because
the current pending advertising sync object is not populated
with any le_addr and sid from bt_le_per_adv_sync_create as
those are not used when option
BT_LE_PER_ADV_SYNC_OPT_USE_PER_ADV_LIST is set.
Instead the bt_le_per_adv_sync_term_info shall be populated
with the le_addr and sid coming in the event from controller.
Signed-off-by: Jakob Krantz <jakob.krantz@u-blox.com>
Re. peripheral phy update procedure: UNKNOWN_RSP from central was not
handled, leading to stall of procedure and subsequent procedure timeout
Proper handle and unit test for case added.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Multiple places we assumed that we could simply just do
sink_stream->iso == chan without checking if sink_stream
was NULL.
This commit fixes that by adding proper NULL checks for that,
as well as additional checks before defaulting to the
source_stream.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
log_output.c was added in two places: unconditionally when logging
is enabled and when CONFIG_LOG_OUTPUT is set. Cleaning up to add
source file only when module is enabled.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
When shell was used as a log backend it did not enabled log_output
module used for string formatting. Adding missing dependency.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The Bluetooth address constants (BT_ADDR[_LE]_ANY, BT_ADDR[_LE]_NONE)
are currently defined as the address of the local anonymous structs
that are initialised to the corresponding address values, and assigning
them to a variable whose scope is greater than that of a function may
end up creating dangling pointers (for instance, as done in the
`bt_conn_get_info` function).
This commit defines the Bluetooth address constants as global constant
variables that are placed in the read-only data section, and modifies
the Bluetooth address constant macros to use the address of these
variables instead.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit adds the `const` qualifier to the `addr` parameter of the
`bt_monitor_new_index` function because this parameter is and should
never be modified within this function.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit adds the `const` qualifier to the `addr` parameter of the
`find_sc_cfg` function because this parameter is and should never be
modified within this function.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
The current zassert macro uses implicit conversion to boolean which
has implication on analysis tools like clang-tidy-14. This add an
aditional step to create a boolean value for the evaluation instead
use the string direct which allows run analysis tool without this
warning/error.
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
Fix regression in overlapping 1M and Coded PHY scan window
by considering rounding margins when checking for same
interval and same window durations.
Relates to commit c14bde45b6 ("Bluetooth: Controller: Fix
overlapping 1M and Coded PHY scannning").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix spelling in sdmmc_decode_csd to use count instead of cout. Shortening
the variable name here was needlessly confusing.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
The unicast_client_pacs_avail_ctx_notify_cb had a direction
check that was a leftover copy from the location notification.
However the context notification is always for both sink and
source, and thus does not need any direction checks (in fact
the dir variable was unused).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This fixes invalid check, which is redundant in fact as the length
is already checked in ascs_parse_metadata function.
The check be test 'greater than' only, as 'equal' condition is valid.
Moreover this fixes return value from ascs_verify_metadata function.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Swaps response scheme for Fault_test command so that it
aligns with description of the documentation.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
When AD data length of greater than 191 bytes support is
enabled then default to using the back-to-back PDU chaining
feature in the Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising and Periodic Advertising's parent
PDU's aux ptr field to contain correct aux offset value to
its chain PDU.
Uninitialized pointer reference to aux ptr in the parent PDU
was used before the pointer reference was returned by the
function adding the aux ptr fields in the parent PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use local variable to update current PDU's Common Extended
Header Format flags instead of updating it directly in the
PDU buffer. This is required to be able to non-destructively
be able to manipulate the PDU's header flags and contents
many time before a final commit of the updated PDU.
In order to calculate overflowed AD data length, PDU is
manipulated couple of times to determine the overflow length
and next to be able to add aux ptr field when chain PDU is
appended.
The changes are now consistent with how Periodic Advertising
PDU's Common Extended Header Format is manipulated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in adding ADI in scan response PDU introduced
in implementation adding support for AD data fragment
operation.
Setting scan response data with ADI failed with too long
data error. This was caused by a bug in calculating the
offset to the overflow length returned back by the call
to set_clear function.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Adds missing feature so that the config client is able to receive
odd number of app index entries.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
When building for 64-bit platform (tested on native_posix_64), there
was a cast warning for different sizes.
A void * is used to store a simple ID, fixed by using uintptr_t instead.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Previous code provided incorrect argc value to handlers when a command
used SHELL_OPT_ARG_RAW option.
Fixes#48380
Signed-off-by: Eric Johnson <eric.johnson2@walgreens.com>
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).
Automated using:
```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The commit is a minor refactor of the common Host and Controller
Kconfig. There were used "default n" that should be avoided.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In case Controller reports to Host insufficient resources to store IQ
samples, according to BT 5.3 Core spec. Vol 4, Part E, sections
7.7.65.21 and 7.7.65.22:
1) packet_status shall be set to BT_HCI_LE_CTE_INSUFFICIENT_RESOURCES
2) sample_count shall be set to zero.
That means there should be no IQ samples stored in IQ report.
HCI implementation stored single IQ sample with value BT_HCI_LE_CTE-
_REPORT_NO_VALID_SAMPLE.
The commit fixes that. No additional memory is added to event buffer
and no IQ sample is stored if sample_count is zero.
Also there is added code that handles situation where ULL provides
IQ report with packet_status indicating valid IQ samples report
but sample_count is zero. In such case Host event stores single IQ
sample with value BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE.
In case of vendor specific counter part of the event the value is
BT_HCI_VS_LE_CTE_REPORT_NO_VALID_SAMPLE.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Bluetooth Controller has a vendor specific extensions that allows it
to send IQ report events with IQ samples that are 8 bits or 16 bits
signed integer. To use that functionality, there is added common
handler of vendor specific events.
Vendor specific events handling is prioritized to be done by user
provided event handler. If that is not available, then Host generic
implementation enters.
Added vendor specific events that are handled by common Host code
are BT_HCI_EVT_VS_LE_CONNECTIONLESS_IQ_REPORT and BT_HCI_EVT_VS_LE-
_CONNECTION_IQ_REPORT.
The only difference between regular IQ report events is size of
IQ samples, hence implementation of IQ report events is changed to
use the same user callback. To avoid differentiation of user callbacks
new member sample_type was added to bt_df_per_adv_sync_iq_samples-
_report. Also sample member is changed to be a union, to allow easy
access to IQ samples without type casting.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add vendor specific IQ samples report that holds IQ data in 16 bits
signed integer format. Thanks to that we preserve complete accuracy of
IQ samples provided by Nordic Direction Finding Extension in Radio
peripheral. That helps to maintain better accuracy of evaluated
angles with use of reported IQ samples.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
We had two bugs:
- we didn't check the subscription, only the fact that the passed chrc can
be subscribed to.
- that check only worked if we passed the chrc descriptor handle, not its
value handle.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This introduces a new option that allows the user to disable the
subscription checking when notifying or indicating.
Some users might have use-cases where they would like to send notifications
or indications without the peer having to go through the subscription
process, as that is allowed by the Bluetooth specification.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
To avoid compilation issues when including tbs.h header file when
CONFIG_BT_TBS_MAX_URI_LENGTH is not set, just pass the URI pointer
instead of an array in bt_tbs_client_call structure.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
If LPN loses Subscription List Add Confirmation it repeats
Subscription List Add frame. Friend doesn't check both
transaction number and presence addresses in the list.
That causes situation when Friend fills the same address
full list.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
With extended advertiser a precision of transmission becomes high.
The first frame is emitted quite quickly. The scanner latency
config option to enable scanner a bit in advance is not sufficient.
Sometimes replays on Friend Poll are lost.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The function will be used to update the RSI value. The returned value
can be later used in advertisement data for set identification. This
removes the need of specific bt_csis_advertise function so that the user
can call the API to generate new RSI once needed (e.g. on RPA change).
This allows the user to manage the advertisement data to fit it's needs.
< HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
Extended advertising: Disabled (0x00)
Number of sets: 1 (0x01)
Entry 0
Handle: 0x00
Duration: 0 ms (0x00)
Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4
LE Set Extended Advertising Enable (0x08|0x0039) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 33
Handle: 0x00
Operation: Complete extended advertising data (0x03)
Fragment preference: Minimize fragmentation (0x01)
Data length: 0x1d
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported
Unknown EIR field 0x2e: 16e61d64dc45
Name (complete): audio test shell
> HCI Event: Command Complete (0x0e) plen 4
LE Set Extended Advertising Data (0x08|0x0037) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7
Advertising handle: 0x00
Advertising random address: 4E:21:29:F8:94:93 (Resolvable)
> HCI Event: Command Complete (0x0e) plen 4
LE Set Advertising Set Random Address (0x08|0x0035) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
Extended advertising: Enabled (0x01)
Number of sets: 1 (0x01)
Entry 0
Handle: 0x00
Duration: 0 ms (0x00)
Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4
LE Set Extended Advertising Enable (0x08|0x0039) ncmd 1
Status: Success (0x00)
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When sending an ATT packet, do not just try to send the first packet in
the queue, but find the first one that can be sent using the channel.
This makes sure that eg. packets that shall be sent on an unenhanced ATT
channel are not blocked by packets that shall be sent on enhanced ATT
channels.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
bt_eatt_connect was documented to return -EINVAL if conn is NULL, but
this was not the case. Instead it lead to undefined behavior.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Disallow trying to send requests or notifications on only EATT channels
if no EATT channels are connected or the link is not encrypted. In these
cases the operation will always fail, so it should not be queued.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
A channel option field has been added to the bt_gatt_*_params structs.
This allows the application to choose wether Unenhanced ATT, Enhanced
ATT, or Any ATT channel shall be used for the
request/command/indication/notification.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
It is frequent to find variable definitions like this:
```c
static const struct device *dev = DEVICE_DT_GET(...)
```
That is, module level variables that are statically initialized with a
device reference. Such value is, in most cases, never changed meaning
the variable can also be declared as const (immutable). This patch
constifies all such cases.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Initialize monitor UART device at compile time so that device pointer
can be constified.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Wire this up the same way ASAN works. Right now it's support only by
recent clang versions (not gcc), and only in 64 bit mode. But it's
capable of detecting uninitialized data reads, which ASAN is not.
This support is wired into the sys_heap (and thus k_heap/k_malloc)
layers, allowing detection of heap misuse like use-after-free. Note
that there is one false negative lurking: due to complexity, in the
case where a sys_heap_realloc() call is able to shrink memory in
place, the now-unused suffix is not marked uninitialized immediately,
making it impossible to detect use-after-free of those particular
bytes. But the system will recover cleanly the next time the memory
gets allocated.
Also no attempt was made to integrate this handling into the newlib or
picolibc allocators, though that should hopefully be possible via
similar means.
Signed-off-by: Andy Ross <andyross@google.com>
This had bitrotten a bit, and didn't build as shipped. Current
libasan implementations want -fsanitize=address passed as a linker
argument too. We have grown a "lld" linker variant that needs the
same cmake treatment as the "ld" binutils one, but never got it. But
the various flags had been cut/pasted around to different places, with
slightly different forms. That's really sort of a mess, as sanitizer
support was only ever support with host toolchains for native_posix
(and AFAICT no one anywhere has made this work on cross compilers in
an embedded environment). And the separate "gcc" vs. "llvm" layers
were silly, as there has only ever been one API for this feature (from
LLVM, then picked up compatibly by gcc).
Pull this stuff out and just do it in one place in the posix arch for
simplicity.
Also recent sanitizers are trying to add instrumentation padding
around data that we use linker trickery to pack tightly
(c.f. SYS_INIT, STRUCT_SECTION_ITERABLE) and we need a way
("__noasan") to turn that off. Actually for gcc, it was enough to
just make the records const (already true for most of them, except a
native_posix init struct), but clang apparently isn't smart enough.
Finally, add an ASAN_RECOVER kconfig that enables the use of
"halt_on_error=0" in $ASAN_OPTIONS, which continues execution past the
first error.
Signed-off-by: Andy Ross <andyross@google.com>
There is a typo in argument for the STATS_NAME_INIT_PARMS macro.
This causes an error during build.
The correct reference should be "pm_stats".
Signed-off-by: Steven Slupsky <sslupsky@gmail.com>
This adds the bits to pin the GCOV sections to the pinned
sections so they can be accessed during boot when demand
paging is enabled. Or else accessing them would result in
page faults.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds an ALIGN statement to the rodata linker snippet
for coverage. Without this, sometimes the section is not
aligned, but __init_array_start indicates an aligned
address, resulting in incorrect function pointers.
So align it.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit introduces a dedicated unit testing board.
Today, a dedicated Zephyr unit testing scheme exists but is different
from how a Zephyr build generally works.
For example Kconfig is not possible, resulting on various different
hacks to pass Kconfig settings from test cases / testcase.yaml through
CMake to the code.
Some directly as compile definitions, some as header files with forced
inclusion on sources, some with wrapper flags which again results in
different define being enabled. There is even cases where a second
forced header inclusion undefines previous defines.
Unit test often does a manual check for the right boards, like this:
> if (NOT BOARD STREQUAL unit_testing)
> message(FATAL_ERROR "This project can only be used with...")
> endif()
Introducing a dedicated unit_testing board under `tests/root` allows
us to use Kconfig in unit test samples, and thus proper `prj.conf` and
extra Kconfig fragments.
Generation of autoconf.h so the overall architecture follows regular
Zephyr builds.
Proper and uniform error messages when invalid board is selected.
The unit_testing board and arch is located under: `subsys/testsuite` so
that it is only available when find_package(Zephyr COMPONENTS unittest)
is used, and not available for regular Zephyr builds.
Kconfig generates autoconf.h which is applied as compile flag to
test binary which means that kconfig defines placed in ztest.h can now
be removed.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Initialize the `hints` struct to a known value so that it won't
cause undetermined behavior when used in `getaddrinfo()`.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This new option prevents the Host from using Controller-provided
identity roots. This potentially increases privacy.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Move the flagging of `BT_DEV_STORE_ID` to a separate if-statement.
This clarifies the meaning of the code, and paves way for wrapping the
if-statement with the call to `bt_smp_irk_get` in another conditional.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The write block size has been gathered from device pointed by
chosen 'zephyr,flash', while it should be taken from a device
a target image flash area resides on.
The write block size has been used to check if write buffer
is properly aligned.
The check is only possible on devices that have write-block-size
property in DTS, so in case of SPI connected devices this property
may not be available - when device does not have the property,
the check is not performed.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
When registering VOCS callbacks via bt_vcs_client_cb_register
it could fail if the application did not reset the
vocs_cb.discover as that is set internally.
This commit adds a simple check to also allow the
vocs_cb.discover to be the callback VCS expect/want it to be.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When registering AICS callbacks via bt_vcs_client_cb_register
or bt_micp_mic_ctlr_cb_register it could fail if the application
did not reset the aics_cb.discover as that is set internally.
This commit adds a simple check to also allow the
aics_cb.discover to be the callback they expect/want it to be.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
introduce a small wait between probing and initialization OCR. This
delay fixes a failure to initialize seen on some SD cards
Fixes#47238
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
bt_csis_lock would call write_set_lock with `attr` set to
NULL, which was dereferenced to get the bt_csis instance.
This commit modified the functions such that we instead have
common function to handle changes to the lock value, called
from either the GATT write callback function, or the
bt_csis_lock, so that we have a clearer separation of what
the individual functions do.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds client support for switching the active preset along with bsim
tests implementation.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The unicast client would simply reset all existing ISO QoS
when there was a state change to the QoS state (and only
update the stream QoS).
This caused issue with some ISO check later, as well
as wrongly resetting the data path too.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Verify that the HCI ISO data packet is smaller than
the maximum SDU size we support, based on the group
settings.
Since we do not yet support fragmentation we also
verify that the data length is smaller than the
HCI ISO buffer size.
For the ISO peripheral is it not possible to know
the SDU, and we are forced to not send any value larger
than the PDU size.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds a Trusted Credential storage backend using the PSA
Protected Storage API, permitting storage of the credentials
offering a trusted long-term storage with integrity checks.
This implementation tries to fit the actual tls_credentials
implementation, with some slight differences:
- the buffer pointer returned by credetial_get & credential_next_get
is dynamically allocated and differs from the one given to
tls_credential_add since it's extracted from the storage at runtime.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
In the case that an endpoint goes down, it needs to be deregistered
from the ipc_service for cleanup. This function deregisters the endpoint
from the ipc_rpmsg instance and sets the endpoint to zero.
Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
On MCU with bank swap capabilities, the offset of the storage area is
not the same before and after a bank swap. This commit introduce a weak
function which returns the default flash area of the storage partition.
On MCU with the bank swap capability the user can define its own
function to get the proper flash area depending on which bank the fw is
run from.
This commit is a workaround for #47732
Signed-off-by: Nicolas VINCENT <nicolas.vincent@vossloh.com>
Per the HCI spec it is not possible to send the
HCI_LE_Create_CIS command while an outstanding request
is pending. To avoid failing the command we can
check and verify if any ISO connections are in the
pending state.
Since multiple ISO channels can be connected
in a single request, the solution implemented was
to iterate over all ISO connections and see if there was
any unicast ISO channels in the connecting state.
It also checks for the encryption pending state, as
we should not start the encryption procedure if we know
that the connect ISO command cannot be completed afterwards.
This adds a new return value to bt_iso_chan_connect,
and decided to properly document the return values the
function can return.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A pointer is not properly declared properly which causes the
build to fail.
flash_map_shell.c and flash_map.h do not include device.h so
the device struct has an incomplete type hence the build error.
Including device.h resolves the problem.
Also fixes a Wformat warning when referencing fa_off which is a pointer.
Cast the pointer to an uint32_t.
Fixes#48722
Signed-off-by: Steven Slupsky <sslupsky@gmail.com>
Decouple the zephyr/net/socketcan.h and zephyr/drivers/can.h header files
by moving the SocketCAN utilities to their own header.
This is preparation for including the SocketCAN types defined in
socketcan.h in a native posix (Linux) SocketCAN driver context without name
clashes.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Rename the SocketCAN header from socket_can.h to socketcan.h to better
match the naming of the functionality.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Rename the SocketCAN utility functions to reflect the new naming of the CAN
controller API and SocketCAN API data types.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Remove the "z" prefix from the public CAN controller API types as this
makes them appear as internal APIs.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Rename the SocketCAN data types to "socketcan_*" in preparation of renaming
the low-level CAN controller API data types.
This breaks the naming compatibility with the similar SocketCAN data types
from the Linux kernel, but Zephyr and Linux SocketCAN are not 100%
compatible anyways (only the structure fields are compatible, extended
functionality such filtering, error reporting etc. are not).
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT is defined by default and the
value ranges from 1 to 255.
So, checking if this parameter is defined seems to be redundant
Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
This new implementation of pipes has a number of advantages over the
previous.
1. The schedule locking is eliminated both making it safer for SMP
and allowing for pipes to be used from ISR context.
2. The code used to be structured to have separate code for copying
to/from a wating thread's buffer and the pipe buffer. This had
unnecessary duplication that has been replaced with a simpler
scatter-gather copy model.
3. The manner in which the "working list" is generated has also been
simplified. It no longer tries to use the thread's queuing node.
Instead, the k_pipe_desc structure (whose instances are on the
part of the k_thread structure) has been extended to contain
additional fields including a node for use with a linked list. As
this impacts the k_thread structure, pipes are now configurable
in the kernel via CONFIG_PIPES.
Fixes#47061
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Add a detailed docstring to the zassume() macro that describes what it does
and how its usage is different from zassert.
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Swaps response scheme for Fault_get & Fault_clear command so that it
aligns with description of the documentation.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
MCC need to check characteristic properties before subscribe as not all
MCS characteristics support notify.
Signed-off-by: Hang Fan <fanhang@xiaomi.com>
As per ASCS_v1.0
If a client requests a Config QoS operation for an ASE that would
result in more than one (Sink/Source) ASE having identical CIG_ID
and CIS_ID parameter values for that client, the server shall not
accept the Config QoS operation for that ASE.
The server shall send a notification of the ASE Control Point
characteristic to the client, the server shall set the Response_Code
value for that ASE to 0x09 (Invalid Parameter Value), and the server
shall set the Reason value for that ASE to 0x0A
(Invalid_ASE_CIS_Mapping).
Fixes: ASCS/SR/SPE/BI-{15,16}-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
SD stack requires a larger stack size than the default value for the
mass storage stack thread. Increase the default stack size to 768 when
the SD stack is enabled.
Fixes#49057
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Add user configurable LOG_MIPI_SYST_ARGS_BUFFER_SIZE Kconfig
option to use it for macro MIPI_SYST_PCFG_PRINTF_ARGBUF_SIZE.
Moving macro definition of MIPI_SYST_PCFG_PRINTF_ARGBUF_SIZE
from mipi-sys-t library to platform.h which defaulted to 1kb
and resulted in stack overflow in some applications.
LOG_MIPI_SYST_ARGS_BUFFER_SIZE gives flexibilty to users when
maximum log length is known.
Fixeszephyrproject-rtos/mipi-sys-t#10
Signed-off-by: Aastha Grover <aastha.grover@intel.com>
mbedTLS library threshold initialization was done in native TLS socket
implementation (which tends to use mbedTLS now) and inside mbedTLS
benchmark test. Move that to mbedTLS module initialization, as this is a
global setting.
Update description of CONFIG_MBEDTLS_DEBUG_LEVEL to clarify when
mbedtls_debug_set_threshold() is called.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
So far there was a debug log hook installed in TLS socket implementation.
However, mbedTLS (with debug enabled) might be used outside from TLS socket
and even outside from networking context.
Add new module, which implements debug log hook and makes it available
whenever CONFIG_MBEDTLS_DEBUG is enabled.
Note that debug hook needs to be installed for each mbedTLS context
separately, which means that this requires action from mbedTLS users, such
as TLS sockets implementation.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Currently, if a bluetooth peripheral sends a connection parameter update
request to a Zephyr central while the central is in the process of
disconnecting and has sent a connection terminate command in the same
connection interval, the central will try to reply, resulting in an
error being printed in the console.
This commit adds a check in le_conn_param_update_req that catches this
state before the central considers this request, preventing the unneeded
error being printed.
Fixes#48813
Signed-off-by: Ivan Herrera Olivares <ivan.herreraolivares@uantwerpen.be>
Add an initial bare-bones functionality sbs_gauge emulator that only
supports register reads tested by the current sbs_gauge driver tests and
what the sbs_driver currently supports.
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Extended Advertising is no longer experimental, it has been now
extensively tested and is fully qualifiable and usable in production.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
* Convert device_get_binding to DEVICE_DT_GET
* Convert Kconfig RPMSG_SERVICE_SHM_BASE_ADDRESS and
RPMSG_SERVICE_SHM_SIZE to DT_REG_ADDR/DT_REG_SIZE
Signed-off-by: Kumar Gala <galak@kernel.org>
The LE Audio related profiles define specific security requirements that
client have to met to gain access to related characteristics. This
introduces internal wrapper API for GATT characteristics and CCC
descriptors to ensure the security.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This makes the server endpoint to store the ASE pointer instead of
handle. This way, there will be no need to "mock" attribute when
notification is sent.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This extends the bt_conn_info with security information. This is needed
by LE Audio profiles to check if security requirements are met.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The bt_conn_get_security and bt_conn_enc_key_size do not
modify the conn thus the parameter can be guarded with const modifier.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Adds flag indicating the pairing that was completed using OOB method.
The flag is needed for checking 128bit entropy pairing required by LE
Audio services.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes crash that happened when client initiated Release operation
on ASE in Idle state. In such case the operation shall be rejected with
Invalid ASE State Machine Response_Code.
Fixes: ASCS/SR/SPE/BI-10-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Persist timer should implement exponential backoff, as per RFC 1122:
The transmitting host SHOULD send the first zero-window
probe when a zero window has existed for the retransmission
timeout period (see Section 4.2.2.15), and SHOULD increase
exponentially the interval between successive probes.
Implement this, by following Linux behaviour, and simply double the
timeout or each probe transmission.
Additionally, prevent reseting the persist timer in case an
acknowledgment is received with zero window size, and the timer is
already running.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Setting the new LLCP as default exposed errors in CI tests, which
are fixed here
Note that advanced scheduling needs to be disabled. Work is in
progress for implementing this for the new LLCP
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Per spec, the CCCD doesn't necessarily have to be located immediately after
the characteristic value. This commit fixes that assumption when checking
for subscriptions.
Fixes#48880.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
In case peer does not send the MSS option, the TCP stack should assume
default peer MSS value of 536, as per RFC 1122:
If an MSS option is not received at connection setup, TCP
MUST assume a default send MSS of 536.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Although it is possible to simply use the interface number,
it has proven convenient to use the names for the interfaces
in the samples.
Migrate to DEVICE_DT_NAME().
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Those files do not contain anything of relevance since
fa90b5c243 [emul: spi: bmi160: Move to
top-level directory].
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
Change increases long workqueue stack size to prevent stack
overflows while processing GATT database hash.
CONFIG_BT_HCI_ECC_STACK_SIZE is removed, because the configured
stack was removed.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Add duration stats at both suite level and unit test
level into test summary. The duration is at second
level. Since the new ztest fx can execute a test suite
for multiple times, the worst/longest test duration is
collected.
Note that even a skipped test can have a duration greater
than 0 because the skip operation itself is not free.
Signed-off-by: Ming Shao <ming.shao@intel.com>
Previously, unit test duration is collected within the
TC_START and Z_TC_END_RESULT macros. With existing tests,
the TC_START macro can be invoked by both the ztest fx
and the tests themselves. And the TC_START macro definition
went lengths to avoid the interference when it is invoked
within a unit test. This commit decouple the time collection
and the TC_STRAT/Z_TC_END_RESULT macros to fix this issue.
Now only the (old) ztest framework is responsible for the
test duration measure. The test duration stats of new ztest
fx is different from this btw.
Signed-off-by: Ming Shao <ming.shao@intel.com>
Add test summary after all test suites finish running.
The summary can be one-line or verbose, which is configured
with CONFIG_ZTEST_VERBOSE_SUMMARY. The one-line summary covers
overall suite stats. The verbose summary covers each test
function within the suite besides the one-line summary.
The new ztest output ultimately go through the printk. If
printk go through the logging subsystem, there may be log
messages dropped. And if log_panic is invoked, log messages
can be flushed in a mess. So several explicit log flush
are used when printing summary to ensure no content is lost
and content is in good shape.
Some macros are shared between old and new ztests. Such as
TC_START_PRINT and TC_END_PRINT. The are defined accordingly.
Signed-off-by: Ming Shao <ming.shao@intel.com>
Support verbose or one-line summary at test suite level.
Support verbose or no output at test function level.
Totally 4 combinations configurable:
- function verbose + suite verbose
- function verbose + suite oneline
- no function output + suite verbose
- no function output + suite oneline
Signed-off-by: Ming Shao <ming.shao@intel.com>
Change fixes value returned by db_hash_commit. Returning positive
value leads to settings load failure.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Client Registration update process may be reject by server
and this commit fix a case that it will jump to new state
which send registration message. Earlier RD client try
allocate message before only possible one was released.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Queue mode without TLS cache was loosing buffered messages at
wake-up process from idle state. Now client context linked list
are initialized at rd client start process only 1 time.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Changing mkfs options from FM_FAT to FM_ANY so that on larger storage
FAT32 instead of FAT16 is automatically created.
Signed-off-by: Nahal Farhi <nahal@whisper.ai>
This commit adds the `CODE_UNREACHABLE` hint at the end of the
assertion failure branch so that the compiler takes note of the assert
function not returning when an assertion fails.
This prevents the compiler from generating misguided warnings assuming
the asserted execution paths.
It also introduces the `ASSERT_TEST` Kconfig symbol, which indicates
that the "assert test mode" is enabled. This symbol may be selected by
the tests that require the assert post action function to return
without aborting so that the test can proceed.
Note that the `CODE_UNREACHABLE` hint is specified only when the assert
test mode is disabled in order to prevent the tests from crashing when
the assert post action function returns.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Change introduces authentication callbacks used only for specified
BLE connection. The feature can be used by devices that require
reporting specific bonding capabilities only when pairing using
vendor-specific procedures.
If per-connection authentication callbacks are defined for given
connection, they are used instead of global authentication
callbacks. SMP latches authentication callbacks during the first
access to prevent updating the callbacks while pairing.
Fixes: #38336
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Add `OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE` to Kconfig.
Also set the number of children to minumum possible for MTD builds
in order to save some resources (~512B of RAM).
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Remove NET_CONFIG_IEEE802154_DEV_NAME in favor of DT based choice using
zephyr,ieee802154.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Use DT choice zephyr,ieee802154 as CONFIG_NET_CONFIG_IEEE802154_DEV_NAME
is being phased out.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
In order to make the zperf to work regardless of the POSIX configuration
in the system, convert the socket API usage into Zephyr's native
zsock_* API.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Make a library out of the zperf shell sample. This makes to enable the
module in any application, not only the dedicated sample.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
ppp_send_pkt() function can be called with NULL fsm parameter (when
PPP_PROTOCOL_REJ packet was sent), howerver this was not taken into
consideration when ppp_context was retrieved. In result, this could lead
to NULL pointer dereference an crash.
Fix this, by moving the ppp_context extraction directly where it's
actually used (PPP_CODE_REJ packet type handling). In such case, fsm
point should not be NULL.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Updates the ztest_test_fail() function to allow failures in setup.
When executed, a failed assert will fail every test in the suite owning
the setup function. This was verified by adding a suite which asserts
in the setup function and has a test that should pass. During
exeuction, ztest marks the test as failing.
In order to verify exection I also added 2 new APIs:
- ZTEST_EXPECT_FAIL(suite_name, test_name)
- ZTEST_EXPECT_SKIP(suite_name, test_name)
Signed-off-by: Yuval Peress <peress@google.com>
In scenarios where test_main is overridden ztest_run_all
may be invoked multiple times leading to the verify check to
fail inadvertently.
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
This commit adds a check, in the `dns_read` function, before
dereferencing the query index returned by the `dns_validate_msg`
function.
This fixes the warnings generated by the GCC 12 such as:
error: array subscript -1 is below array bounds of
'struct dns_pending_query[5]' [-Werror=array-bounds]
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This fixes state transition to QoS Configured state triggered by
client-initiated Receiver Stop Ready operation on ASE that has no ISO
attached.
Fixes: ASCS/SR/ACP/BV-12-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The def command Indicates that a comment block contains documentation
for a #define macro. This is useful if the comment block documents a
macro not adjacent to it, e.g.
```c
/**
* @def MAX(x,y)
* @brief Computes the maximum of @a x and @a y.
*/
#ifdef XXX
#define MAX(x,y) ...
#endif
```
However, it is not necessary if the comment is adjacent to the
definition, e.g.
```c
/**
* @brief Computes the maximum of @a x and @a y.
*/
#define MAX(x,y) ...
```
This patch removes all unnecessary def entries in-tree.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Skip IP header checksum calculation when the network interface reports
support for this feature.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
If the test is run with the config NO_OPTIMIZATIONS enabled then the
stack size usage increases by around 80% for ARM platforms.
Increase the stack size used in test cases that enables building with no
optimizations for ARM.
Update description on TEST_ARM_CORTEX_M since it was outdated and said
it was only used for a single purpose.
Fixes: #47930Fixes: #47929Fixes: #47855
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Wi-Fi protocol uses EAPoL ether type frames for authentication, so, add
support for that ether type so that they are not dropped.
Though we have NET_ETHERNET_FORWARD_UNRECOGNISED_ETHERTYPE to allow
unknown frames to be passed up the stack, but this might cause
performance penalty.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
When string and opaque types are uninitialized, we should
allow their data length to be zero. However, most content
formatters seem to calculate the string length separately
so replace the pointer of empty data into a static string
that is guaranteed to be empty.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
If LPN lost Friend node (all Poll attempts didn't succeed)
no reason to send Friend Clear to the Friend node.
This makes LPN powersupply inefficient usage.
During Friend Clear sending LPN rejects any frame from
primary subnetwork.
Specificastion doesn't mandate that LPN would send Friend Clear
if polling didn't succeed.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
For most of the times it is not necessary to do a full registration
once a connection is established after a network error. This is in
particular not needed if lifetime is not yet expired and the server
does not refuse a registration update.
Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
Separate closing lwm2m context from closing socket. This patch is required
for the rd client to take more control over lwm2m context and the socket.
The goal is to close the socket and to keep the lwm2m context if this is
needed.
Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
Registration should only be updated if update of the registration was
succesful.
Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
The signal handler needs to return gracefully. When multiple
tests assert, the first assert will raise SIGABRT and the signal
handler will run and the test will stop running.
The second assert will raise SIGABRT but the signal handler
will not be called, therefore the test PASS/FAIL status is not
updated correctly.
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
According to RFC 793, ch 3.9 Event Processing, receving SYN flag after
the connection has been established is an error codition:
If the SYN is in the window it is an error, send a reset, any
outstanding RECEIVEs and SEND should receive "reset" responses,
all segment queues should be flushed, the user should also
receive an unsolicited general "connection reset" signal, enter
the CLOSED state, delete the TCB, and return."
Currently TCP stack ignored such event, causing interoperability test
failures. Fix this, by verifying if the SYN flag is set in a packet in
any state other than TCP_LISTEN and TCP_SYN_SENT.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The dfu subsys is theoretically agnostic to the particular bootloader,
even if MCUboot is the only bootloader currently supported. Include the
dfu folder based on the parent symbol `IMG_MANAGER` instead of the
specific `MCUBOOT_IMG_MANAGER`.
The MCUboot specific files are already gated by the Kconfig in the
`boot` and `img_util` folders.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Fix SMP check of existing local keys when attempting to start security
with required security mode 1 level 4. The logic for checking the
conditions was wrong, leading to a situation where encryption would be
attempted to be started by the central instead of initiating a new
pairing procedure. This would fail when the connection was encrypted and
the connection would be disconnected.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This fixes sending invalid ATT Request Not Supported error code as a
response to Control Point write request.
ATT Request Not Supported error code is used to inform that
"ATT Server does not support the request received from the client",
so it should not be sent in this case.
If the requested opcode is unsupported, ASCS mandates to send ATT
Notification from Control Point with Unsupported opcode Response_Code
only. If the request received from the client is properly formatted,
ATT Write Response can be sent to complete the ATT transaction.
Fixes: ASCS/SR/SPE/BI-01-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
BT_ERR() should really be reserved for local errors only,
thus BT_WARN() is the right choice whenever a remote peer
sends something invalid that we cleanly handle.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
As per ASCS_v1.0
"A client-initiated ASE Control operation shall be defined as an
invalid length operation if the Number_of_ASEs parameter value is
less than 1".
Fixes: ASCS/SR/SPE/BI-{02,03,04,05,06}-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
While a previous change had already decoupled the IEEE 802.15.4 L2 from
IP upper layers, this only worked when at least one other interface of
the device supported IP.
This change removes this requirement and thereby fixes a build error
that occurred when disabling IP support while maintaining IEEE 802.15.4
L2 support.
Fixes: #48718
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Clear pointer to the le_adv_recv() stack frame before returning to the
calling function. This fixes a potential compiler warning newer gcc
versions.
zephyr/subsys/bluetooth/host/scan.c: In function ‘le_adv_recv’:
zephyr/subsys/bluetooth/host/scan.c:463:20: error: storing the address
of local variable ‘id_addr’ in ‘*info.addr’ [-Werror=dangling-pointer=]
463 | info->addr = &id_addr;
| ~~~~~~~~~~~^~~~~~~~~~
zephyr/subsys/bluetooth/host/scan.c:439:22: note: ‘id_addr’ declared here
439 | bt_addr_le_t id_addr;
| ^~~~~~~
Fixes#48459
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The prpa cache is now exposed through the ull_filter_lll_prpa_cache_get()
function (as the resolve list already is). This is needed to be
able to reply to AUX_CONNECT_REQ within the required time when
using SW-based RPA resolving
Signed-off-by: Troels Nilsson <trnn@demant.com>
net_if_up() unconditionally calls iface_ipv6_start() and
net_ipv4_autoconf_start(). This is not correct for interfaces that do
not support IPv4/v6.
This patch therefore introduces a check on the interface's flags before
proceeding.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
This change makes the files which are part of this changeset comply to
the project's coding style rules as defined in .clang-format.
This required addition of some forward declarations and additional
dependencies into header files as some of them depended on the order of
header inclusion which was changed due to alphabetical ordering of
includes.
Background: .clang-format states "SortIncludes:true" which will force
re-ording of include-statements which in turn might break the build if
header file inclusion is not order-independent.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
6LoWPAN fragmentation is not related to IEEE 802.15.4 proper but is just
part of its IPv6-specific L3-adaptation layer. To make this more obvious
we rename all resources related to 6LoWPAN fragmentation.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
This change decouples the IEEE 802.15.4 (L2) layer from all IPv6 (L3)
concerns.
Applications may now choose to set CONFIG_NET_6LO=n and
CONFIG_NET_L2_IEEE802154=y at the same time.
Setting CONFIG_NET_6LO=n will build a vanilla IEEE 802.15.4-2006 specs
compliant L2 layer without any reference to 6LoWPAN or IPv6. This allows
application developers to design custom non-IP protocols on top of
IEEE 802.15.4-2006 and thereby makes the L2 layer much more re-usable.
Fixes#48585.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
This change contains some merely editorial changes to inline comments
plus updates references from the IEEE 802.15.4-2003 spec to
IEEE 802.15.4-2006 which corresponds to the implementation level of
the module.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Most existing TODO markers (as well as VSCode default settings) favor
TODO over ToDo - so let's make this a little bit more consistent in the
IEEE 802.15.4 module.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
New API for suspend and resume LwM2M engine.
New event LWM2M_RD_CLIENT_EVENT_ENGINE_SUSPENDED for indicate
application that engine is suspended.
Simplify stack suspend and resume state same time for queue mode.
New CONFIG_LWM2M_RD_CLIENT_SUSPEND_SOCKET_AT_IDLE for enable skip socket
close at RX_OFF_IDDLE state that socket is only suspended and close is
called only when connection is resumed.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
A test case may invoke run_all multiple times, causing
logic for listing tests to run tests on second call.
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
Scanner was disabled after Friend Clear command. LNP didn't have
chance to receive Friend Clear Confirmation command back.
If option BT_MESH_LPN_ESTABLISHMENT is off then scanner is left
disabled and next Friend Offer after Friend Request
cannot be received.
PR fixes this.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Direction finding functionality does antenna switching during CTE
reception in AoA mode and CTE transmission in AoD mode. Antennas are
switched according to user provided antenna switch pattern. If a CTE
length is enough to exhaust all antenna ids in a switch pattern then
Radio should loopback to reference antenna and continue from switching
from it.
Current implementation loops back to wrong antenna due to wrong index
used in GUARD_REF_ANTENNA_PATTERN_IDX. It was set to one instead of
zero. Zero is the index of reference antenna in Host provided antenna
switching pattern array.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Added define PDU_AC_EXT_AD_DATA_LEN_MAX, maximum AD data
length possible in AUX_ADV_IND when all Common Extended
Header Format fields are populuted.
Updated function description to explain the added ADI and
Aux Ptr fields support in updating the auxiliary PDUs.
Remove the redundant CTE info population code unnecessary
for new chain PDU as a result of AD data overflow.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use minimal time reservation for auxiliary and sync PDU
reception. A peer device could be scheduling multiple
advertising sets in a short duration with small PDUs hence
using the minimal time reservation would avoid skipping
closely scheduled reception of multiple auxiliary PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor DF implementation to add aux offset in the aux
pointer field of the parent PDU when chain PDU is added
and/or is duplicated when PDU contents are updated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to support Extended Scan Response Data
fragment operation of first, intermediate, last, unchanged
and complete data operation using the HCI LE Set Extended
Scan Response Data Command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor refactor of scan response implementation to rename sr_pdu
to sr_pdu_prev, and aux_pdu to sec_pdu_prev etc.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to support Extended Advertising AD Data
fragment operation of first, intermediate, last, unchanged
and complete AD data operation using the HCI LE Set Extended
Advertising Data Command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename Kconfig BT_CTLR_ADV_PDU_BACK2BACK to
BT_CTLR_ADV_AUX_PDU_BACK2BACK to represent use of
back-to-back for Extended Advertising PDU chaining support
similar to BT_CTLR_ADV_SYNC_PDU_BACK2BACK that is used to
represent the use of back-to-back for Periodic Advertising
PDU chaining support.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update ull_adv_sync_pdu_set_clear() to return aux_ptr
reference so that aux_ptr field for chain PDUs can be
pupulated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor PDU chaining implementation to add aux offset in
the aux pointer field in the parent PDU when duplicating
chain PDUs.
By adding the aux offsets in the ULL execution context the
LLL prepare execution in Extended and Periodic Advertising
does not need to have a O(n) while loop in LLL execution
context.
This will reduce CPU use in the highest priority ISR
compared to current implementation where chain PDUs where
duplicated in ULL execution context and aux offset populated
in LLL execution context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Cleanup Periodic Advertising Chain PDUs auxiliary pointer
population, populate the back to back auxiliary pointer
field in thread context. Also, removed an unused code for
filling data.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the ull_adv_aux_hdr_set_clear function so that the
caller of the function will enqueue the auxiliary PDU when
enqueuing the primary PDU.
This change is required to support chaining of AD Data where
parent auxiliary PDU will be added with aux ptr fields when
chain PDUs are appended.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising Synchronization from being
preempted by an overlapping Auxiliary PDU scan event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix skipped Periodic Advertising Sync radio events due to
increased CPU use during pre-emption in LLL from a Scan
radio event to Periodic Advertising Sync radio event by
increasing EVENT_OVERHEAD_START_US value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix to prevent a transmitted CONNECT_REQ PDU from being
aborted mid-air when initiator is using continuous scan
window that do not use time reservation. A different state
or role that overlaps the connection initiation requesting
for an abort should be denied when CONNECT_REQ PDU has been
enqueued for tranmission by the radio.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When directed advertising and continuous scanning are
simultaneously active, and a connection request is received
by the directed advertising state then the connection was
not established due to the done event not being generated.
Done event from the directed advertising state was not
generated because the prepare pipeline only had resume
event which does not get scheduled when there is prepare
event of the continuous scan state.
The fix is to explicitly abort all pending prepare and
resume event in the pipeline for the directed advertising
state when connection request is received.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Make the option TEST_EXTRA_STACK_SIZE depend on Tests, otherwise it will
appear in each generated .config file.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This config option is only used with ztest, so move it under ztest.
Otherwise it appears in .config when you build ANY application.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Current API allowed to get notified when the maximum system latency
changes, however, a single callback was allowed. The design was intended
for SoC specific actions when latency changes. However, in some cases
drivers may also want to know the current maximum latency to perform
local actions if other parts of the system modify it.
This patch updates the API with a pair of subscribe/unsubscribe calls to
achieve such goal. Tests have been updated to show how the API can be
used.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
When new latency requirements are introduced/updated, the microseconds
value gets converted down to ticks. Ticks usually have a coarse
resolution compared to the microseconds scale. This is fine for making
PM state change decisions, however, when getting notified about latency
changes, we may want to know the real value in microseconds, even if the
system rounds to ticks internally. This patch stores the value in both
us and ticks (in ticks to cache the conversion, really), so that the
user will get notified with precise latency values.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Network connection was not unregistered properly for packet socket,
which resulted in dangling connection when net_context was dereferenced
(i. e. when packet socket was closed). This could lead to a crash on a
consecutive incoming packet.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Nordic Radio Direction Finding Extension provides 12 bits wide IQ
samples. The Bluetooth Core Specification 5.3 Vol 4, Part E sections
7.7.65.21 and 7.7.65.22 limits IQ samples to be 8 bits wide.
There are other way to convert 12 bits IQ samples into Bluetooth Core
specification compliant 8 bits IQ samples than ordinary 4 bits right
shift. If one is sure that samples will never go over 10 bits or 8
bits then, it is allowed to use 2 bits right shift or even 8 least
significant bits of 12 bits IQ samples.
The commit introduces a possibility to choose which approach is used
for IQ samples conversion in HCI layer while Host IQ report events
are created.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add the "zephyr/" prefix to various #include statements that are
preventing the CI form running with LEGACY_INCLUDE_PATH=n.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Added API function +int settings_storage_get(void **storage)
which allows to get storage instance used by the
settings backed to store its records.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Boolean options are not allowed to start with "Enable...".
BT_HCI_VS_FATAL_ERROR started with "Enable..." making some PRs fail due
to compliance checks.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Provide common helper functions to create extended extended Zephyr
Fatal Error functionality in HCI common code.
Use the implementation in hci_rpmsg sample.
The sample didn't provide an information about Controllers assert
or system fatal error to an application code while run with nRF5340
SoC. The goal for hci_rpmsg sample change is to enhance user experience
for conformance testing of the Bluetooth Controller while executed with
nRF5340.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Review rework of the fix to remove the jitter in aux offset
and sync offset values.
Force select BT_TICKER_REMAINDER_GET and BT_TICKER_LAZY_GET
features when Extended Advertising and Periodic Advertising
is supported.
Rename ticks and microsecond offset value struct members
for primary PDU event offset (to auxiliary PDU event).
Converted HAL_TICKER_REMOVE_JITTER and HAL_TICKER_ADD_JITTER
macro to functions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use remainder value in scheduling the periodic auxiliary
PDUs and use the ticker next slot get interface with
remainder value to fill the auxiliary offsets with
microsecond precision in the primary channel PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated ticker implementation to return remainder value for
a ticker when enumerating active tickers with time
reservations.
This is required to find offsets and to use the remainder
value to correctly calculate auxiliary offsets to the
microsecond resolution.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix overlapping 1M and Coded PHY scanning that caused idle
radio time when both PHY use same scan interval and sum of
their scan window duration equals the interval.
Implementation now will use continuous scanning and offset
the start of Coded PHY by the window duration of the 1M
scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The initialisation of DLE parameters for the peripheral
was done before the intialisation of the PHY settings.
Since the DLE parameters depend on PHY settings this
can result in incorrect parameters for tx/rx time and
octets
One scenario is where a previous connection set the PHY to
2M or CODED, then when a new connection is established
it uses the same memory-locations for connection settings as the
previous connection, and the (uninitialised) PHY settings will be
set to 2M or CODED, and thus the DLE parameters will be wrong
This PR moves the initialisation of DLE parameters after
that of PHY settings
EBQ tests effected include LL/CON/PER/BV-77-C.
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Now that we properly destroy the tx context in `bt_conn_process_tx`, we
need to make sure the context is really valid.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Symptoms were that a disconnect happening when a buffer was enqueued but
not sent resulted in a meta-data memory leak.
This is problematic because it seemed (as per the OP) that it resulted in
the whole host getting locked up when a device sending long L2CAP packets
was prone to disconnect-reconnect cycles (e.g. in a bad RF environment).
Fixes#47649
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Code was limiting observations to resources and
resource instances without any reason.
Also if resource is written, and the whole object is observer
it should trigger. Path does not have to be matching on the
same level, if parent is observed.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
The expression for the condition for using host-based RPA resolution now
simplifies to "Use host-based when we need to resolve more identities
than the controller can handle.".
Proof:
X=((bt_dev.le.rl_entries > 0) && (!bt_dev.le.rl_size ||
bt_dev.le.rl_entries > bt_dev.le.rl_size))
X=(a > 0) && (!b || a > b)
a>=0, b>=0, because they are cardinal / size_t.
If a=0:
// X evaluates to false. (0 > b)=(a > b) also always evaluates to false.
X=false=(0 > b)=(a > b)
If a>0:
X=(!b || a > b)
If b=0: X=true=(a > 0)=(a > b)
If b>0: X=(false || (a > b))=(a > b)
The expression is equivalent with (a > b) for all values of (a,b).
QED.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Mesh Profile Specification errata 11310
Section 4.4.4.1
"This model shall support model publication, as defined in Section
4.2.2 of the Mesh Profile specification and model subscription,
as defined in section 4.2.3 of the Mesh Profile specification."
Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
Move from using Kconfig GDBSTUB_SERIAL_BACKEND_NAME to a devicetree
chosen property ("zephyr,gdbstub-uart"). This is similar to a number
of other functions like "zephyr,shell-uart" or "zephyr,bt-uart".
Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
The packet socket implementation did not fill the address structure
provided by the application. This commit fixes this.
Note, that the implementation needs to cover two cases: SOCK_RAW and
SOCK_DGRAM. In the first case, the information is extracted directly
from the L2 header (curently only Ethernet supported). In latter case,
the header is already removed from the packet as the L2 has already
processed the packet, so the information is obtained from the net_pkt
structure.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The L2 protocol type information is not carried to the upper layers.
This is problematic for packet sockets, as the address structure in
recvfrom() is supposed to provide this information.
Fix this by adding ll_proto_type field in the net_pkt structure.
Set the protocol type in the Ethernet L2 when packet is processed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The mandatory minimum PDU length conformance test was failing
because the LLCP did update the effective rx/tx times (and
corresponding notification to host).
This was due to a missing test condition.
This PR adds the missing conditions.
Note that with this change the refactored controller code is
similar to the legacy code; relevant code is in ull_conn.c,
in the function event_phy_upd_ind_prep
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Driver function was called with wrong parameter, which resulted
in filter being added instead of removed
Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
This commit removes the resource pointer NULL check inside the resource
enumeration loop of the `coap_well_known_core_get` function because the
expression `(resource + 1)` will never evaluate to NULL (aka. 0).
This fixes the "comparison will always evaluate as ‘true’ for the
pointer operand" warning generated by the GCC 12.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
It can happen that two similar stacks enter a retransmission cycle
due to a packet collision. If the transmission timeout is the same
both stacks will retry at the same moment resulting in another
collision.
By introducing a randomized retry timeout, the chance of
a second collision is reduced and it reduces furter the more
retransmissions occur.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Apply an exponentially increasing wait time between tcp retries. This
is a good balance between reacting fast to single lost packets and reduce
the network load when an outage takes a little longer. It also allows the
connection to survive a longer interruption with less retransmissions.
Update the test to accommodate for the increased socket closure timeout
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Secure Connection Only mode requires use of LE Security mode 1 level 4
which mandates 128 encryption key size.
Defaults in Kconfig are set from top-to-bottom and this resulted in
7 bytes key being forced. What is worse, user cannot override this
from prj.conf file since BT_SMP_MIN_ENC_KEY_SIZE is hidden config
if BT_SMP_SC_ONLY is enabled.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This fixes issue where the ASE state stuck in Releasing state instead of
going to Idle/Codec Configured as test requires.
Looks like there was a race condition possible where the ASE
notification work was run before the stream was detached, so there was
no transition to idle state triggered.
Fixes: ASCS/SR/ACP/BV-24-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The server should not perform Release operation on ASE in Releasing
state. This fixes crash that might happen in ASCS when ACL gets
disconnected while ASE is in Releasing state so that server tries to
dereference NULL stream.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The data_host variable in the emul_espi_host_send_cw function should be
assigned the espi host emulator data and not the espi_emul data.
Assign the variable to correct reference.
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Fix compilation warning in GCC 12 when it's not obvious that we want to
compare the adresses of the first elements of two arrays
Signed-off-by: Hristo Mitrev <hr.mitrev@gmail.com>
This commit removes the NULL check on the idle thread array
(`idle_tid`) because it is statically declared and will never be NULL.
This fixes the "comparison will always evaluate as ‘false’" warning
generated by the GCC 12.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Add test summary after all test suites finish running.
The summary can be one-line or verbose, which is configured
with CONFIG_ZTEST_VERBOSE_SUMMARY. The one-line summary covers
overall suite stats. The verbose summary covers each test
function within the suite besides the one-line summary.
Signed-off-by: Ming Shao <ming.shao@intel.com>
Support verbose or one-line summary at test suite level.
Support verbose or no output at test function level.
Totally 4 combinations configurable:
- function verbose + suite verbose
- function verbose + suite oneline
- no function output + suite verbose
- no function output + suite oneline
Signed-off-by: Ming Shao <ming.shao@intel.com>
Add support in Bluetooth Host to enable Periodic Advertising
ADI support feature when supported in the Controller to
include ADI in Periodic Advertising AUX_SYNC_IND PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
According Mesh Spec 1.0.1:
Upon receiving and successfully authenticating to
Secure Network beacon for a primary subnet whose
IV Index is 1 or more higher than the current known IV
Index, the node shall set its current IV Index and its
current IV Update procedure state from the values in
this Secure Network beacon.
Look like test_iv_index.c:81
``` C
(bt_mesh_net_iv_update(TEST_IV_IDX + 1, BCN_IV_IN_IDLE));
```
This test case already exists, but the wrong testcase
to test wrong code.
Move `is_iv_recovery` into `bt_mesh_net_iv_update`.
First check whether it is IV recovery, and then carry out
the subsequent IV normal update procedure.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fix redundant node rx reservation when receiving Periodic
Advertising Sync chain PDUs. Only the reception of first
pdu in chain, AUX_SYNC_IND PDU, needs extra node rx
reservation to be allocated for generation of incomplete
data status in case of incomplete reception of chain PDUs.
Co-authored-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix hang on chain PDU allocation by replacing K_FOREVER use
by a timeout. Hang occurs when configured number of
advertising data buffers is low.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If we're disabling certain features and instead providing function stubs,
it doesn't make sense to use macros for those routines that return values
that the user may check unless we want to provide them with vague errors
like:
src/coap-server.c:101:55: error: expected expression before ';' token
101 | ret = net_ipv6_mld_join(iface, &mcast_addr.sin6_addr);
When a function we're mocking up returns a value, use a static inline
stub.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
These two macros just change the name of function call
* NOTIFY_OBSERVER
* NOTIFY_OBSERVER_PATH
I don't see any benefit of those, so I dropped them.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Although there is nothing wrong with the existing code,
it doesn't permit individual bits to be set (or cleared).
This makes further changes slightly awkward.
Use a mask to restrict the bits set in an event.
Signed-off-by: Andrew Jackson <andrew.jackson@amd.com>
PHY update control procedure has to send a notification towards
Host when the PHY is actually changed, when the instant happens.
Control procedures are handled in a prepare phase of a connection
event, hence notifications are send towards host to early.
The fix for that is to postpone send of a notification.
New state has been introduced to remote requested PHY update
control procedure: RP_PU_STATE_WAIT_INSTANT_ON_AIR.
Also new event has been introduced: RP_PU_EVT_NTF, that is used
to inform the PHY update state machine that notification may
be send.
There are two places where the notification events may be generated
ull_conn_rx, just before first received PDU is send towards Host
or ull_conn_done, in case there were no PDU received.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
If the call to net_send_data() fails, for example if the forwading
interface is down, then the pkt will leak. The reference taken by
net_pkt_shallow_clone() will never be released. Fix the problem
by dropping the rerefence count in the error path.
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
If the device was not paired, the conn->le.keys is NULL, so
conn->le.keys will cause NULL pointer dereference.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Move from using Kconfig OSDP_UART_DEV_NAME to a devicetree
chosen property ("zephyr,osdp-uart"). This is similar to a number
of other functions like "zephyr,shell-uart" or "zephyr,bt-uart".
Changed the integration platform for the osdp samples to
stm32_min_dev_black as it already has zephyr,osdp-uart set.
Signed-off-by: Kumar Gala <galak@kernel.org>
Starting the pasive scanner so host can resolve addresses
shouldn't be nessesary when the resolving list is empty.
Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
The `name` parameter is redundant, as the `name` and `name-ad` options are
available already as `adv-create` and `adv-param` command parameters.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add function which formats a logging string from input parameters
and not from logging message. This function is more flexible since
it does not require data to be placed in the log message.
Converted a function for message processing to used this new function
internally.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Before this, on flashes with a write alignment greater than one, the
padding bytes had no defined value.
The effect of this non-deterministic code made it hard(er) to verify
data written by FCB.
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
Change doc of CONFIG_BT_PRIVACY to explicitly say it's needed for both
generating and resolving RPAs.
Disable host-based RPA resolution in `bt_conn_le_create` when
!CONFIG_BT_PRIVACY.
Update doc of `bt_conn_le_create` to document that CONFIG_BT_PRIVACY is
a requirement for resolving RPAs. Also explictly say that this function
will resolve private identities. Also explain the expected effect of
Network Privacy on this function.
Reduce coupling to `bt_le_create_conn_ext` and
`bt_le_create_conn_legacy` in `bt_conn_le_create` by just use
`resp_addr` when it's set, instead of "knowing" when it had been set.
The alternative would be to also update `bt_le_create_conn_ext` and
`bt_le_create_conn_legacy` to have `(IS_ENABLED(CONFIG_BT_PRIVACY) &&
(!bt_dev.le.rl_size || bt_dev.le.rl_entries > bt_dev.le.rl_size))`
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Move from using Kconfig TRACING_BACKEND_UART_NAME to a devicetree
chosen property ("zephyr,tracing-uart"). This is similar to a number
of other functions like "zephyr,shell-uart" or "zephyr,bt-uart".
Signed-off-by: Kumar Gala <galak@kernel.org>
Rework the <BUS>_emul_register calls to not pass the name param. The
name param is only used for logging and we can get it from the
struct <BUS>_emul instead.
Signed-off-by: Kumar Gala <galak@kernel.org>
The bus_label is not used and is using DT_INST_BUS_LABEL which is
now deprecated and thus causes an error when running CI.
Signed-off-by: Kumar Gala <galak@kernel.org>
DT nodes aren't guaranteed to define a label property. But emulated bus
controllers currently make use of this property to dispatch to the
associated emulator.
Have emulated bus controllers use DEVICE_DT_GET(node_id) to dispatch to
right target peripheral emulator. This also change makes emul_get_binding
and device_get_binding synonymous in behavior with respect to their
parameters.
This also strictly enforces a 1:1 correspondence between invocations of
DEVICE_DT_DEFINE and EMUL_DEFINE.
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Some paramaters in prior emulators have historically referred to instances
of struct emul as "emulator" or "emul". The proper parameter name for this
type is "target" as it designates the struct emul instance is the emul
bus (e.g. emul_i2c) controller's target peripheral for dispatch.
Do a small refactor renaming some of these parameters to "target".
TEST=twister on accel, espi, and eeprom drivers tests
Signed-off-by: Aaron Massey <aaronmassey@google.com>
In several locations of the emulator code there are unused function
arguments that were never caught.
Declare these as unused or remove the unused function parameters entirely.
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Allow emulator creators to write an init function that can be used
across multiple busses so as to reduce the boilerplate and cognitive
load in creating an emulator.
Part of this change includes allowing access to the emul struct from a
field in a {bus}_struct api (e.g. i2c_struct), which removes the need for
sporadic usages of CONTAINER_OF to access the emul struct.
Overall, this change simplifies and reduces the amount of boilerplate
code to get a device emulator up and running, thus reducing excise work
to writing tests.
TEST=twister on accel,espi, and eeprom drivers tests
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Run clang-format on all files touched by improved emulator API pull-request
that allowed access to the target device emulator from its bus api without
CONTAINER_OF usage.
drivers/i2c/i2c_emul.c
drivers/spi/spi_emul.c
include/zephyr/drivers/emul.h
include/zephyr/drivers/espi_emul.h
include/zephyr/drivers/i2c_emul.h
include/zephyr/drivers/spi_emul.h
subsys/emul/emul.c
subsys/emul/emul_bmi160.c
subsys/emul/espi/emul_espi_host.c
subsys/emul/i2c/emul_atmel_at24.c
TEST=twister on accel,espi, and eeprom drivers tests
Signed-off-by: Aaron Massey <aaronmassey@google.com>
The unicast client will now read the PACS location value
during the discovery procedure, as well as subscribing to
it.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The code in unicast_client.c was guarded by
CONFIG_BT_AUDIO_UNICAST_CLIENT but the file is only
compiled if CONFIG_BT_AUDIO_UNICAST_CLIENT is enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename the cache from "cache" to "pac_cache" to avoid
name clashes with local cache variables.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added possibility to enforce that a LE Secure Connection is required
for reading and writing characteristics, i.e. providing a more fine
grained check that allows services that requires secure connection
to co-exists with those that doesn't.
Signed-off-by: Lars Knudsen <larsgk@gmail.com>
Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
Extend the `vcs init` command with optional parameters to set the
initial VCS state including volume level, mute state and step size.
This is needed to pass qualification test cases listed below:
VCS/SR/CP/BV-01-C,
VCS/SR/CP/BV-02-C,
VCS/SR/CP/BV-02-C,
VCS/SR/CP/BV-04-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Shell command "bt init sync" now correctly enables Bluetooth
synchronously, and "bt init" enables Bluetooth asynchronously.
Fixes#47860.
Signed-off-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>
The sys_snode_t nodes are used internally, and we use the
convention of the "_" prefix to indicate that this is
an internally used value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the broadcast sink to use a list of streams instead
of an array. This removes the requirement that the array
of stream pointers shall be static, and makes the
broadcast sink API and implementation more similar
to the unicast group and broadcast source.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify from array to list. The list approach is easily
implemented as it is used for the unicast groups, and
using the list approach instead of an array does not
require the array to be static.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Any project with Kconfig option CONFIG_LEGACY_INCLUDE_PATH set to n
couldn't be built because some files were missing zephyr/ prefix in
includes
Re-run the migrate_includes.py script to fix all legacy include paths
Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
There is a potential, corner case scenario, where a deadlock can occur
between TCP and socket layers, when both ends of the connection transmit
data.
The scenario is as follows:
* Both ends of the connection transmit data,
* Zephyr side send() call gets blocked due to filing the TX window
* The next incoming packet is data packet, not updating the RX window
on the peer side or acknowledging new data. The TCP layer will
attepmt to notify the new data to the socket layer, by calling the
registered callback. This will block the RX thread processing the TCP
layer, as the socket mutex is already acquired by the blocked send()
call.
* No further packets are processed until the socket mutex is freed,
which does not happen as the only way to unblock send() is process
a new ACK, either updating window size or a acknowledging data.
The connection stalls until send() times out.
The deadlock is not permament, as both threads get unlocked once send()
times out. It effectively breaks the active connection though.
Fix this, by unlocking the socket mutex for the time the send() call is
idle. Once the TCP layer notifies that the window is available again,
the mutex is acquired back.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Documentation now includes:
- How to create a test suite
- How to use predicates
- How to use setup/before/after/teardown
- How to use test rules
- Direct people to use FFF instead of ztest mock
Fixes#47420
Signed-off-by: Yuval Peress <peress@google.com>
This fixes bt_pacs_context_available so that it gets available
contexts from capabilities that hold the value.
This removes redundant available_context that were held
(and not updated) in pacs.c.
Fixes: HAP/HA/STR/BV-01-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This API now becomes a low-level API, in the sense that it should only be
used if the app developer knows what he is doing and wants to ensure a
ATT_MULTIPLE_HANDLE_VALUE_NTF PDU goes on-air.
For the other 99% of use cases, `bt_gatt_notify` should instead be used, as
it will automatically upgrade to ATT_MULTIPLE_HANDLE_VALUE_NTF when
possible.
One can disable the batching of notifications when using `bt_gatt_notify`
by setting CONFIG_BT_GATT_NOTIFY_MULTIPLE_FLUSH_MS=0 .
This API doesn't support lookup by UUID any more.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
In the case a call to `bt_gatt_notify_cb` gets its attribute data
batched with others to form an ATT_MULTIPLE_HANDLE_VALUE_NTF PDU, the
application developer would still expect one callback per API call.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Sending ATT_MULTIPLE_HANDLE_VALUE_NTF containing only one handle doesn't
seem forbidden by the spec, but peers might find it unexpected.
This change morphs a ATT_MULTIPLE_HANDLE_VALUE_NTF into a
ATT_HANDLE_VALUE_NTF right before sending it, if it detects this
condition.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The intended behavior is that calling `gatt_notify_mult` in a loop will
result in a `BT_ATT_OP_NOTIFY_MULT` containing all the handles and their
data.
What was happening instead is that the caller thread was a lower priority
than the system workqueue, and thus multiple `BT_ATT_OP_NOTIFY_MULT` PDUs
were being sent over the air instead of one.
Submitting the work item with a delay side-steps this particular issue.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Created the variable CONFIG_LWM2M_SERVER_DEFAULT_SSID to be
the default ssid when not using bootstrap. Needed for access control.
Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
Implementation of the access control object. Core object (obj_id 2).
If used without bootstrap, the default value in
CONFIG_LWM2M_SERVER_DEFAULT_SSID will be used as access control owner.
Enable/disable ac control with CONFIG_LWM2M_ACCESS_CONTROL_ENABLE.
Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
`bt_gatt_unsubscribe` was pending a write to the CCC and then immediately
canceling it.
Fixes#47682 .
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
irq_lock() returns an unsigned integer key.
Generated by spatch using semantic patch
scripts/coccinelle/irq_lock.cocci
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
HDA is a common IP used across the entire ADSP line and deserves
a name respecting that alongside similiar IP drivers such as the
ADSP GPDMA driver.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
This fixes an issue where IV index stage counting timer is not
started after the node is provisioned. This would have prevented node
from performing IV index updates.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
This change makes the optional procedures in the TBS Client optional
and configurable through Kconfig.
Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
Currently, it is possible to call various ipc_service functions
which take in an endpoint pointer (such as send, get_tx_buffer)
with an endpoint which has not been registered with the instance.
This leads to dereferencing a NULL pointer when the function tries
to access the api field of ept->instance.
This patch adds in multiple checks to ensure that the endpoint is
registered before continuing, one in the frontend, when ensures
that the ept->instance pointer is not NULL and one in the backend
which checks the value of the token pointer. If either of these fail,
we return -ENOENT.
Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
Mayfly by design uses a memq for storage of its jobs. The memq
requires head and tail to track the content. It is considered
empty is head equals tail.
When memq instance is initialized then there is a new link
instance stored in head and tail, nevertheless the memq is
still empty.
When new job is enqueued to a memq, the inilial link is used
to store the job. New link, provided by enqueue call, is stored
in the tail for future enqueue.
When enqueued job was served and is dequeued, the link it was
assigned to is returned and stored in the job object.
That link will be used in future for call to enqueue.
Now lets consider a situation when we are just after initalization.
Some default initial link is in empty memq. We enqueue and dequeue
a job. After dequeue, the job object stores the initial link object.
The one that was put into the memq during initialization.
Next Bluetooth stack is disabled and enabled again.
The job is enqueued again, but it still stores the initial link
address. After enqueue the memq head points to initial link object,
that stores new job. Tail points to link deliveded by enqueue call,
that is also the initial link object. The memq is considered to be
empty, nevertheless there was a successful enqueue operation.
The issue is casued by lack of re-initialization of a job object
on init. In most cases these objects are static members of some
functions, hence there is no re-initialization after bt_disable
and bt_enable calls.
The problem is fixed by re-initialization of mayfly only once
on bt_enable() call. Then it doesn't matter what links are stored
in dequeued objects and there is no need to re-initialized mayfly
job objects.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The problem is visible after call to bt_disable when there was
a connection. On a next bt_enable call when hc_tx_thread starts
it is possible that the conn_change object internals are not
re-initialized entirely and the function fails during k_poll call.
The commit changes explicit assignment conn_change object to
a k_poll_signal_init that does proper initialization.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
While execution of bt_disable there is missing de-initialization
of per_adv_sync_pool. If there was a sync in progress, (flags set
to BT_PER_ADV_SYNC_SYNCING) before bt_disable, then when the stack
is re-enabled by bt_enable new sync create fails.
The commit fixes the issue by new function that clears flags for
all per_adv_sync_pool entries. The function is executed by bt_disable.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
We cannot implement configure API because there is
no notification of configuration changes provided
for the Abstract Control Model and the UART controller
is only emulated.
However, it allows us to use CDC ACM UART together with
subsystems like Modbus which require configure API for
real controllers.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Move the CAN bus network driver from drivers/can to drivers/net as it
implements a network driver, not a CAN controller driver.
Use a separate Kconfig for enabling the CAN bus network driver instead of
piggybacking on the SocketCAN Kconfig. This allows for other
(e.g. out-of-tree) SocketCAN transports.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Struct bt_mesh_send_cb.end is called from the mesh advertiser thread.
bt_mesh_reset now requires more stack size, thus can't be called from
the advertiser thread. k_work instance requires less memory than needed
for bt_mesh_reset.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Upon bt_mesh_reset call, all mesh modules has to clear the privisioning
and configuration data. None of the modules store or erase in settings
subsystem immediately, but put this on the mesh settings work. After the
settings work is scheduled, all stored data will be removed and the
device will eventually be unprovisioned. Until then, the device is not
completely unprovisioned, thus calling bt_mesh_prov_enable,
bt_mesh_provision (and bt_mesh_cdb_create) should not be allowed.
Struct bt_mesh_prov has a reset callback stating that after this
callback is called, the device has been reset and can be re-provisioned
again. Also, bt_mesh_reset API description states that after calling
bt_mesh_reset API, the device needs to reenable the provisioning layer
to be provisioned again. But this is not correct since the settings has
to be cleared before the device can be reprovisionined.
This commit makes bt_mesh_reset flush pending settings so that the
device can be reprovisioned immediately and the API will behave as
written in the description.
The same applies to bt_mesh_cdb_clear.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
In the broadcast sink `scan_recv` which is called when we
scan for broadcast source, we now also provide the entire
AD struct to the application.
The reason for this is that the advertising data may
contain other information that is useful for the application
like the broadcaster device name or any other
vendor/application specific data.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify how the ISO channels are allocated for the audio streams,
as well as how the CIG is allocated for the unicast group.
This fixes an issue where the unicast group could not be
fully allocated before _after_ the bt_audio_streams had been
configured by bt_audio_stream_config, thus making it impossible
to create a unicast group before the connections have been established.
This leaves us with 3 basic data types:
1) Streams allocated by the application
2) Endpoints that represent ASEs
3) Audio_iso which is used to couple streams and ISO channels.
The Unicast Group for the unicast client will now have the same
lifetime as the ISO CIG for the central.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use `kernel log-level modulename severity`
Also enable it for the Bluetooth Shell.
Then one can compile-in a lot of BT modules like so:
CONFIG_BT_DEBUG_HCI_CORE=y
CONFIG_BT_DEBUG_L2CAP=y
CONFIG_BT_DEBUG_ATT=y
CONFIG_BT_DEBUG_GATT=y
And at runtime select only, e.g. GATT
kernel log-level bt_hci_core 0
kernel log-level bt_l2cap 0
kernel log-level bt_att 0
And then re-enable L2CAP if needed later
kernel log-level bt_l2cap 4
And so on..
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Add commands to connect to an l2cap channel using Enhanced Credit-based
Flow Control, and to reconfigure it.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
When invoked without parameters, `bt connect` will now attempt to connect
to the last scanned device. Used in conjunction with the RSSI filter, this
makes the connection process somewhat scriptable.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This adds an RSSI cutoff, so any scanned devices that are below the given
value (in dB) will not get printed out. Very useful in noisy environments.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Add two MEDIA_PROXY group type defines corresponding to the MCS ones.
Update the mpl.c to use the newly added names.
The purpose of the exercise is to get a complete set of MEDIA_PROXY
defines, so that the media player can be made fully independent
(define-wise) of the MCS.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the media player to use the MEDIA_PROXY_* defines rather than the
BT_MCS defines. The media player should not know about the MCS (media
control service).
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The bus_label field of the struct was not used, so remove it. This
lets us remove one of the last users of DT_INST_BUS_LABEL.
Signed-off-by: Kumar Gala <galak@kernel.org>
Check that the device we are trying to use has successfully powered up
when it is on a power domain. If it has not, release the request for the
power domain to be powered to ensure we do not have dangling requests.
As a result of this, `PM_DEVICE_ACTION_RESUME` will not be run on a
device if `PM_DEVICE_ACTION_TURN_ON` has already failed.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Store errors powering up devices in a flag in the PM struct. This is
required as the `pm->state` variable always transitions to
`PM_DEVICE_STATE_SUSPENDED`, even when `PM_DEVICE_ACTION_TURN_ON`
returns an error. Marking the transition as failed will allow the
transition logic in `pm_device_runtime_get` to detect the problem.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Move scripts needed by the build system and not designed to be run
individually or standalone into the build subfolder.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Fix a bug introduced by 658123bb21 where if all backends were
ready prior to logging thread loop, thread was periodically
waken up for no reason. Fix is setting timeout to K_FOREVER
if all backends are ready after the initialization.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added check which ensures that only backends with autostart
flag set are enabled automatically by the logging.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add a new coredump query and command type to retrieve the raw data
stored to the flash backend
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
If the characteristic is non-writtable, the BT_GATT_CHRC_WRITE property
flag shall be unset. Moreover, threre is no point to set
BT_GATT_PERM_WRITE_ENCRYPT permission flag as well if the attribute has
no `write` callback set anyway.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add a new API used by arch to implement suspend-to-RAM (S2RAM).
The API is composed by a single function to save the CPU context on
suspend.
A CPU context is the arch-specific set of registers that must be
preserved on power-off (in retained RAM) to be able to resume the
execution from the point it was suspended without going through the
whole kernel startup stage.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
When switching from Extended Scanning by Extended
Advertising HCI commands back to Legacy Scanning after a
HCI reset it is required that the coded PHY scanning
context is reset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Scanning Address Resolution that incorrectly
checked for Bit Count Comparison which is not to be checked
when explicit resolution is performed in the Rx ISR.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the maximum advertising PDU size time reservation
consider the Advertising Data could be updated from zero to
maximum support size. If maximum time reservation is
disabled then time reservation corresponding to the
Advertising Data present at the time of the start/enable
of Advertising is used.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When multiple advertising sets are support then use advanced
scheduling implementation to place multiple auxiliary PDUs
and periodic advertising PDUs in a non-overlapping schedule.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update the internal power state tracking for `PM_DEVICE_ACTION_TURN_ON`
and `PM_DEVICE_ACTION_TURN_OFF` even when the transition function fails.
Just because the driver couldn't perform some action does not mean the
device is still powered/unpowered.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add state checking to every transition to ensure that the device is in
the state we think it is before running the action.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
In case LWM2M cient wants to change attrs of observed obj,
it needs pointer to client_ctx.
For example:
On observer add, wants to change pmin for some obj path to 1s:
static void observe_cb(enum lwm2m_observe_event event,
struct lwm2m_obj_path *path, void *user_data)
{
struct lwm2m_ctx *ctx = (struct lwm2m_ctx *) user_data;
switch (event) {
case LWM2M_OBSERVE_EVENT_OBSERVER_ADDED:
lwm2m_engine_update_observer_min_period(ctx, "3347", 1);
...
}
Signed-off-by: Kiril Petrov <retfie@gmail.com>
Fix missing recv fifo reset on HCI reset. This fix handles a
scenario where in Rx Prio thread has enqueued a node rx, Tx
thread handles HCI Reset Command, and Rx thread wakes up
from call to k_fifo_get to handle invalid node rx. The
changes here ensure Rx thread does not get any invalid node
rx post HCI Reset Command handled in Tx thread.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a new callback to the Bluetooth Extended Advertising callback
structure. It notifies the application that the RPA validity of the
advertising set has timed out. The user can use this callback to
synchronize the advertising payload update with the RPA rotation.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Synced the start of the advertising sets after each RPA rotation
in the Bluetooth identity module.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
This adds the bits to allow the process thread to notify
backends when it has finished processing pending log messages.
This allows, for example, flash-based backends to group writing
log messages to storage to limit wear, since log_output_flush()
is called per message. Also the backend does not have to resort
to using timer to periodically flush its buffer to storage,
avoiding waking up the device when there are no messages.
Another use of this is for backends requiring DMA transfers.
Grouping all pending log messages into one DMA transfer is
sometimes preferrable.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Give Kconfig choices symbols names so that they can be redefined in
applications that wants to alter the choice's default value without
setting it in the project configuration.
Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
Move OpenThread's glue code along with the Kconfig files that configure
OpenThread stack itself into module directory.
Update the maintainers file to reflect this change.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
We noticed that in the master branch, updatehub fails to start.
That is because of the behaviour change in bin2hex caused by
commit f2affbd ("os: lib: bin2hex: fix memory overwrite").
Fixes: f2affbd973 ("os: lib: bin2hex: fix memory overwrite")
Signed-off-by: Yudong Zhang <mtwget@gmail.com>
Instead of rejecting metadata at the BAP layer, we now
expect the higher layer to provide the verification.
The reason for this is that the higher layer may be better
equiped at determining which metadata it supports.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The CAP acceptor can now be a set member. This allows
the CAP acceptor to register a CSIS instance and include
it in the CAS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add bt_cap_acceptor_ccid_exist that verifies that CCIDs
from the CAP initiator are valid on the initiator based
on what we have previously discovered.
Verification from MCS is still a TODO.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When the CAP acceptor role is enable, ASCS will verify
that the stream context type supplied by the client
matches the PACS available context.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Verify the metadata before copying it. This will allow the
unicast server to verify the data and potentially
reject it without modifying existing metadata.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adding the CAP Acceptor role, which is a quite simple
role. The role instantiates the Common Audio Service (CAS)
The role will later be expanded to properly support
the use the Coordinated Set Member role via CSIS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the CONFIG_BT_AUDIO_DEBUG_STREAM_DATA Kconfig option
to better debug bt_audio_stream without drowning the log
in the data being sent.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the BT_DEBUG_ISO_DATA so that ISO can easier be debugged
without the logs being drowned in the ISO data being sent
and received (which is typically at a low interval like 10ms).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Uses the dt_compat_enabled Kconfig preprocessor to set defaults
for each HDA driver.
Each direction is uniquely selectable which can be useful when building
with SOF where only some directions may wish to be enabled at any given
time.
By default, given the device tree (intel_cavs.dtsi) only the host
directions are enabled but an overlay may adjust that as needed.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Use the same function at discovery complete, whether discovery failed
or succeeded.
Rename the discovery_failure() to discovery_complete(), and use that
also when discovery completes successfully.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The media control client used to subscribe to GMCS characteristics as
the characteristics were discovered, in effect queuing ATT requests.
Since then, the ATT MTU exchange has become automatic, leading to
larger ATT MTUs and more discovered characteristics per ATT response,
which again lead to the client enqueuing more subscriptions and
running out of buffers, with discovery failing as a result.
This commit moves the subscription to GMCS characteristics to a
separate sequence, so that it happens serially after discovery, rather
than in parallel with the discovery.
- Remove separate discovery parameters for the characteristics - they
are no longer needed.
- Add a subscription callback and a couple of subscription functions
The subscription for characteristics for the included OTS has not been
modified. Only two of these are subscribed to, and doing that is
currently not a problem. And I need to better understand the
interaction with OTS and how these subscriptipons are used.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Refactor subscription to get chaining into callback
Move the start of discovery of included services to a separate
function, in preparation for rewriting discovery.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
When bool is typedef'ed to for instance char the cast from 64 bits
is not so good. Now using an explicit 'cast' to true/false
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Implements PDU flow and unittest of CIS Create on Peripheral
Hooks CIS Create into the controller and fixes a few minor
things in ull to allow for running with NEW LLCP
Also handles CONFIG based comilation of CIS Create
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Hooks the CIS terminate into the controller and fixes a few minor
things in ull_conn(_iso).c
Also handles CONFIG based comilation of CIS_TERMINATE
also fixes a minor issue in helpers_pdu
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Add macro Z_TEST_SKIP_IFNDEF which is used when you want to skip test
if configuration option is not enabled.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
It is possible to open provisioning link again after being provisioned.
Though this has no immediate consequences, the node shall not open
provisioning after being provisioned.
Reset link.cb so that any following provisioning advs are dropped.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
cmd_pb_adv and cmd_pb_gatt are only used when provisionee role is
supported. They should not be compiled if provisionee role is disabled.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
llcp_tx_pause_data() calls ull_tx_q_pause_data() for each pause_mask,
while llcp_tx_resume_data() only calls ull_tx_q_resume_data() when
conn->llcp.tx_q_pause_data_mask == 0 leading to an unbalanced number of
calls to ull_tx_q_pause_data()/ull_tx_q_resume_data() which can leave
the data path of the TX Q paused.
Fix such that only the first call to llcp_tx_pause_data() will pause the
data path of the TX Q.
Add unit test to verify correct pause/resume behavior.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
The uart_pipe driver is not dependent on any console driver,
however a serial driver is required.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add the state transition from connecting to disconnecting
as a valid transition for ISO. This can occur if a ISO channel
is disconnected before it is fully connected, of if a BIG
or a BIG sync is terminated before established.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is a brief period between the bt_iso_big_create
and when the ISO channels are established. In this state
it should be possible to call bt_audio_broadcast_source_stop
to stop the BIG from being created.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The addition of the assumption API introduced a bug where a skipped test
would subsequently skip later tests within the same suite. A skipped test
was being treated as an entire skipped test suite.
Keep track of tests being skipped due to skipping in the suite setup versus
being skipped within their test function.
TEST=west build -p -b native_posix tests/kernel/condvar/condvar_api/ -t run
TEST=twister -T tests/ztest -p native_posix
Signed-off-by: Aaron Massey <aaronmassey@google.com>
When LOG_MODE_IMMEDIATE is used, logs processed by the shell
log backend may be intertwined with messages printed by
shell commands running on the shell thread.
It is because the shell uses a mutex while the shell log
backend uses the IRQ lock for synchronization. Switch the
latter to use the mutex as well whenever it's possible.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Removed auto select from LWM2M_DTLS_SUPPORT
* TLS_CREDENTIALS
* NET_SOCKETS_SOCKOPT_TLS
* NET_SOCKETS_ENABLE_DTLS
LwM2M stack shouldn't enforce these options as they
are not needed with socket offloading.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
We are working on phasing out use of the devicetree 'label'
property. We can use DEVICE_DT_GET and drop use of DT_LABEL.
Signed-off-by: Kumar Gala <galak@kernel.org>
Added sequence number and timestamp to the bt_audio_stream_send
function. This allows an application to better
control the audio transmission, as it can schedule
one or more audio streams to send a buffer in a specific
SDU interval (ensuring that e.g. left and right is sent in
the same SDU interval).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This patch fixes an issues where the TX virtqueue is misaligned by
2 bytes due to the way the virtqueue start address is calculated.
It is currently set to immediatelly follow the RX virtqueue:
vr->tx_addr = vr->rx_addr + vring_size(num_desc, VRING_ALIGNMENT);
but the RX virtqueue does not end on an aligned boundary (last field,
avail_event is uint16_t). The resulting misaligned virtqueue causes
alignment faults on architectures that do not support unaligned
accesses (and is suboptimal otherwise)
The fix is to realign tx_addr to requested VRING_ALIGNMENT.
Signed-off-by: Aleksandar Radovanovic <aleksandar.radovanovic@amd.com>
This fix removes the Streaming_Audio_Context LTV from the LC3 Codec
helper macro, and subsequently a faulty exposure of this LTV in the
PAC records used.
Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
Made it more clear that the disable functionality is to
disable the mute functionality, but and not disabling
the microphone device itself.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename struct bt_micp to bt_mic_ctlr as it is only
used ofr microphone controller now.
This also allow cleanup of the bt_micp struct, thus
removing the common internal micp_internal.h header file
and reducing the size of the implementation by not
using a union of the structs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the existing bt_micp API for the
MICP Microphone Device to be more specific
by adding mic_dev as an infix. This follows
the naming scheme used for the MICP microphone
controller (mic_ctlr).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The AICS functionality is also possible via the bt_aics
API, and this was just a way to ensure that the AICS
instance was part of a MICS.
Removing makes MICP much simpler, and we can expect user
to know the context of a AICS.
This also fixes a few bad/missing guards.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename mics => micp_mic_dev (MICP Microphone Device)
Rename mics_client -> micp_mic_ctlr (MICP Microphone Controller)
This does not change any lines in the code.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the profile abbreviation, MICP, instead of the
service abbreviation, MICS, for the MICP implementation.
The server implementation will use MICP and the client
implementation will use MICP_CLIENT for now, as that will
be updated in a future commit.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
PM_DEVICE_ACTION_FORCE_SUSPEND has been equivalent to
PM_DEVICE_ACTION_SUSPEND for a while. Release notes for Zephyr 2.7
mentioned its removal (see 76702e8ff3) but
for some reason it was kept.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
COAP_DEFAULT_MAX_RETRANSMIT and COAP_DEFAULT_ACK_RANDOM_FACTOR
should be configurable to determine the max transmission
timeout of a CoAP packet.
Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
Due to the limitation of the current x86 EFI cosnole implementation,
we skip hte printk which is called by tracing API:
sys_trace_thread_switched_in_user/out_user.
Signed-off-by: Enjia Mai <enjia.mai@intel.com>
Add a EFI console logging backend to support logging sub-system.
To fix those testcases have no log output due to no logging backend.
Signed-off-by: Enjia Mai <enjia.mai@intel.com>
Implement the uart_config_get() API by converting the existing
line coding structure to the struct uart_config format.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Make sure MAC software transmission security is enabled by default
for Thread 1.3 builds as well.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
The syncable callback was called whenever we received the BIGInfo
The BIGInfo is, however, received even while synced (as per the
HCI spec). Add a check to stop calling syncable when synced,
and keep the sink->big value updated based on the ISO states.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Created the file lwm2m_message_handling.c, to include all
code pertaining to CoAP and allocation and deletion of messages
in general.
Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
Created the file lwm2m_observation.c, to include
all code maintaining observations and parameter handling.
Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
Created the file lwm2m_registry.c to include the
getters and setters of values and the creation
and deletion of all lwm2m objects, resources
and instances. Refactored the registry part
of lwm2m_engine.h into lwm2m_registry.h.
Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
This reverts commit f3444ce00b.
The check is not needed anymore, as the EATT channels are available on
encrypted link only.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Core Vol 3, Part G, Section 5.3.2 Channel Requirements states that
"The channel shall be encrypted". It does not mention any additional
security requirements that can be specified bt higher layer profiles.
This enables link encryption requirement for EATT channel.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add an assume API which works like JUnit's. Assumptions can be made
at any point before your test returns (setup, before, and during the
test). If an assumption fails, the test will be marked as skipped.
This helps avoid a cascading affect of failed tests when a base
feature breaks. The feature is expected to have tests and the tests
which depend on it should be skipped (not failed) if that feature
is broken.
Issue #42472
Signed-off-by: Yuval Peress <peress@google.com>
The CSIS SIRK should only require encryption,
as mandated by the CSIS spec, and authentication.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
We attempted to simply store the UUID in a local variable
before sending it to bt_gatt_notify_uuid, but evidently
the `bt_uuid` struct does not work that way, and it
ended up giving errors.
Fixed by providing the BT_UUID_PACS_X UUIDs directly as
arguments, instead of storing in a local variable first.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If we change PACS while not connected, notifying the
change, we would warn about notification not being sent
out, however if not connected that is to be expected.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add option to Kconfig to enable log_output module. It is used
by most of the backends but it is an optional formatter helper
thus it is possible to run logging without it. One example might
be dictionary based logging which does not format log message
to a readable string.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
In the current implementation of segmented messages transmission, the
transport layer will put as many segments as it can into the advertiser
buffer. If a long segmented message is transmitted, there is a chance
that an ack will be received before the transport layer finishes sending
the first batch of segments. This will trigger retransmissions of those
segments that are marked as missing in the ack, that are also the
segments that are scheduled (or about to be scheduled), but not sent
out by the advertiser yet. Thus, the receiver may receive already
received segments.
This commit changes 2 things:
- it prevents rescheduling transmission of missing segments upon
reception of ack. Thus, ack doesn't cause segments duplication in the
advertiser buffer;
- it doesn't put all segments to the advertiser buffer. Thus, ack that
acknowledges all segments can immediately stop rescheduling segments as
they are already received;
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The control flow around the irq-lockout used for fetching from
`tx_complete` has been simplified so that there is exactly one
line with irq_unlock that is unconditionally called.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The cast from `sys_snode_t` to `struct bt_conn_tx` assumes `node` is the
first field in `struct bt_conn_tx`. It's better to future-proof this by
using `CONTAINER_OF` to locate `node`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Add handling for DISK_IOCTL_CTRL_SYNC to SD subsystem. Note that
SD caching is not enabled by the SD stack, so the only required
operation to sync the disk is to wait for any active data programming
to complete.
Fixes#46689
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
If the POSIX API is selected via the POSIX_API option, don't also select
the conflicting NET_SOCKETS_POSIX_NAMES and use the POSIX headers instead.
Signed-off-by: Berend Ozceri <berend@recogni.com>
bt_dev.sent_cmd is unreferenced and assigned NULL within hci_cmd_done().
Calling net_buf_unref() again causes a null pointer dereference
Signed-off-by: Grant Ramsay <grant.ramsay@hotmail.com>
The codec (or rather codec configuration) is now taken from the
previously received BASE. This also means that the BASE (with
the codec configurations) is now also stored statically.
When the application attempts to synk to the broadcaster
the stack will lookup the codec configuration based on the
bis index, as a BASE may have multiple subgroups
with multiple codec configurations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The shell module will now use BT_AUDIO_CONTEXT_TYPE_ANY
instead of BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED as that provides
a more flexible solution.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If CONFIG_BT_PAC_SNK or CONFIG_BT_PAC_SRC was not enabled, the
function would not build due to missing Kconfig
(CONFIG_BT_PACS_SNK_CONTEXT or CONFIG_BT_PACS_SRC_CONTEXT).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The HAS depends on the unicast server, and should be
disabled in the `no_unicast_server` as well as depend
on the CONFIG_BT_AUDIO_UNICAST_SERVER config.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Some functions are only used for the unicast server
but was guarded by CONFIG_BT_AUDIO_UNICAST instead of
CONFIG_BT_AUDIO_UNICAST_SERVER.
Some parts of the unicast-server-only code also had
client specific code that would never be called.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for using PACS and/or capabilities for
the broadcast sink role. PACS and capabilities were
originally only supported for the unicast server
role, so the PACS callbacks were moved their own
struct, as if a device supports both the unicast
server role and the broadcast sink role, it will
only have a single PACS instance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If the number of CSIS instances on a device is
above 1, then each shall be included by another
service.
This creates a bit of a chicken and egg issue,
as we can't really register the "parant" service
before the CSIS instance has been registered,
and we thus can't verify if the parent service
pointer is actually another primary service on this
device. The best we can do is add the proper
type and a NULL check.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When system clock is set globally for the test which is executed
on various qemu platforms it may happen that clock is set too
high compared to CPU clock frequency. In that case test may stuck.
Added check and test skipping in that case.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Updated log_core to use spin lock instead of irq_lock.
Refactored z_log_msg_post_finalize function.
Update thresholds in the log_stack test.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The commit changes fs_mount and fs_unmount to use node fs_mount_t
member to decide whether file system described by given fs_mount_t
object has already been mounted.
Previously there was no such check in case of fs_mount, which
would allow to remount the same object as long as mount path
has been changed.
The fs_unmount has been checking whether API pointer (fs) has been
filled now it checks whether fs_mount_t is linked anywhere,
which is sign that the object is used.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
lwm2m: Regenerate lwm2m_senml code from the CDDL description.
Reapply manual changes.
Create a sh script to perform the regeneration.
tests: zcbor_bulk: Adapt to zcbor 0.5.1
zcbor_new_decode_state() now has no return value.
Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
Don't fail to compile when `fixed-partition`'s exist on a flash device
that is disabled. This does not fix the case where a `fixed-partition`
is on a flash device with `status = "okay"` but with no driver compiled
in.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Remove all usage of `device_get_binding` in the subsys by directly
storing the `const struct device*` in the `struct flash_area`.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Move the `REQUIRES_FULL_LIBC` dependency from `config LORA` to
`config LORAWAN`. The commit that added the `select` (f590d4fa) mentions
that this is required by `loramac-node`, which is only used by LoRaWAN,
not the base LoRa code.
This results in small FLASH savings when compiling the samples, but can
result in larger savings in more complex applications:
```
// With REQUIRES_FULL_LIBC
west build -b 96b_wistrio zephyr/samples/drivers/lora/send/
[162/162] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 37708 B 128 KB 28.77%
SRAM: 8832 B 32 KB 26.95%
IDT_LIST: 0 GB 2 KB 0.00%
// Without REQUIRES_FULL_LIBC
[181/181] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 37444 B 128 KB 28.57%
SRAM: 8832 B 32 KB 26.95%
IDT_LIST: 0 GB 2 KB 0.00%
```
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add early returns from functions which are not used when
there is only one frontend in the system (no backends). This
allows to significantly reduce logging code size in that
configuration.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix radio_tmr_start_now from returning delayed start time
under race conditions where the capture time has elapsed but
the compare has triggered at the same time.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This adds sending Active Index notification and Preset Changed
notifications on connection to previously bonded client.
Fixes: HAS/SR/CP/BV-03-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The implementtaion supports dynamic presets i.e. changing it's name,
registration and unregistration of the presets, thus Dynamic Presets
feature flag shall be set.
Fixes: HAS/SR/FEAT/BV-05-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This handles Write Preset Name operation that is used to change the
preset name. This covers as well changing the preset name by server.
Fixes: HAS/SR/CP/BV-04-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
If preset synchronization is not supported, Preset Sync
Not Supported (0x82) shall be sent in error response.
Fixes: HAS/SR/SPE/BI-04-C, HAS/SR/SPE/BI-05-C, HAS/SR/SPE/BI-06-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The malloc partition may actually be empty, if so, don't try to add it to
the domain as that will generate an error.
Signed-off-by: Keith Packard <keithp@keithp.com>
Send long-running tasks to a dedicated low-priority workqueue.
This shouldn't increase memory usage since by doing this, we get rid of the
ECC processing thread.
This should fix issues like #43811, since the system workqueue runs at a
cooperative priority, and the new dedicated one runs at a pre-emptible
priority.
Fixes#43811
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Workaround for nRF52 anomalies 102, 106, and 107 was applied also for
SoCs that were not affected with those, namely nRF52811 and nRF52840.
Since the side effect of this workaround is reduction of sensitivity,
this was highly undesirable.
This commit uses dedicated functions provided by MDK for checking if
a given anomaly applies to the used SoC (and its actual revision) so
that the workaround is applied only when it is really needed.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Path list was replaced accidentally with free list during refactoring.
This change does fix the issue.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
Picolibc doesn't have the non-standard printf support required for tagged
arguments in cbprintf. Disable this and use the format string parsing code
instead.
Signed-off-by: Keith Packard <keithp@keithp.com>
Some errors can occur in the sending process that have to be handled
in a polling fasion instead of blocking using semaphores. In this case
apply an exponentially growing backoff time. This will allow for fast
reactions in most situations and prevents high system loads in case
resolving the situation takes a little longer.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
The change in this commit is required to avoid regression errors
on EBQ test for the PHY update procedure
When in the peripheral role transmission of data must be resumed
while waiting for the PHY IND response from peer.
In other words: in the LP_PU_STATE_WAIT_TX_ACK_PHY_REQ state
data transmission must resume when acting as peripheral,
but not when in the central role
Following tests are effected
LL/CON/PER/BV-49-C
LL/CON/PER/BV-50-C
LL/CON/PER/BV-52-C
LL/CON/PER/BV-53-C
LL/CON/PER/BV-54-C
LL/CON/PER/BV-55-C
LL/CON/PER/BV-56-C
LL/CON/PER/BV-58-C
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
This PR fixes the PHY update procedures for conformance tests when
being a Central
The problem was that data was in the LLL tx queue and was still being
queued before the PHY IND was queued (with a given instant).
As a result by the time the PHY IND was transmitted over the air the
instant was in the past.
The fix is to ensure that the LLL tx queue is empty, and to stop
queueing new data before queueing the PHY IND
Following tests are fixed:
LL/CON/CEN/BV-49-C
LL/CON/CEN/BV-50-C
LL/CON/CEN/BV-53-C
LL/CON/CEN/BV-54-C
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
The BT_CODEC_LC3_CONFIG_* macros had a hardcoded location
and context, which makes them a lot less usable.
Updates the macro, and the macros that used them.
This also removes the BT_CODEC_LC3_CONFIG and instead
just uses the BT_CODEC_LC3_CONFIG_N macro, which has
then been renamed to BT_CODEC_LC3_CONFIG.
As an addition, the macros and their input has
also been better documented.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Enable pin control support for SWO log backend, by creating a new
ITM node for the ARM instrumentation trace macrocell. Add pin control
properties under this node, and refactor the swo-req-freq property to be
defined within this node.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Schedules I/O chains in the same order as they arrive providing a fixed
amount of concurrency. The low memory cost comes at the cost of some
computational cost that is likely to be acceptable with small amounts
of concurrency.
The code cost is about 4x higher than the simple linear executor
which isn't entirely unexpected as the logic requirements are quite a bit
more than doing the next thing in the queue.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
A DMA friendly Stream API for zephyr. Based on ideas from io_uring
and iio, a queue based API for I/O operations.
Provides a pair of fixed length ringbuffer backed queues for submitting
I/O requests and recieving I/O completions. The requests may be chained
together to ensure the next operation does not start until the current
one is complete.
Requests target an abstract rtio_iodev which is expected to wrap all
the hardware particulars of how to perform the operation. For example
with a SPI bus device, a description of what a read, and write mean
can be decided by the iodev wrapping a particular device
hanging off of a SPI controller.
The queue pair are submitted to an executor which may be a simple
inplace looping executor done in the callers execution context
(thread/stack) but other executors are expected. A threadpool executor
might for example allow for concurrent request chains to execute in
parallel. A DMA executor, in conjunction with DMA aware iodevs
would allow for hardware offloading of operations going so far as to
schedule with priority using hardware arbitration.
Both the iodev and executor are definable by a particular
SoC, meaning they can work in conjuction to perform IO operations
using a particular DMA controller or methodology if desired.
The application decides entirely how large the queues are, where
the buffers to read/write come from (some executors
may have particular demands!), and which executor to submit
requests to.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Add additional user tracing calls for thread states, names
and priorities.
add the following user tracing calls:
sys_trace_thread_create_user
sys_trace_thread_abort_user
sys_trace_thread_suspend_user
sys_trace_thread_resume_user
sys_trace_thread_name_set_user
sys_trace_thread_info_user
sys_trace_thread_priority_set_user
sys_trace_thread_sched_ready_user
sys_trace_thread_pend_user
Signed-off-by: Eugene Cohen <quic_egmc@quicinc.com>
In the function tx_work_handler, a pointer to ring buffer data is given
to usb_transfer then the ring_buf_get_finish is called. So, the data is
mark as read (by ring_buf_get_finish) while the data are not yet
transferred to usb. If later a user send data, the pointer hold by usb
stack could be rewrite.
Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
Fix duplicate ID for systemview. Remove k_timer_user_data_set as it is
not being tracing and uses a duplicate ID like k_sem_reset.
Fixes#46541
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Complete the remote initiated version exchange if a LL_VERSION_IND is
received while already having responded in an earlier version exchange
procedure.
Clarify comment regarding how to handle this invalid behaviour.
This has been seen when running the LL/CON/CEN/BI-12-C test on EBQ.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Calculation of the DLE related parameters (rx/tx octets and time) depend
on the actual phy in use. For this reason the PHY settings must be
initialised before doing the DLE parameter calculations
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
On remote terminate on central the conn clean-up would happen before ack
of terminate ind was sent to peer.
Now clean-up is 'postponed' until subsequent event.
Also now data tx is paused on rx of terminate ind to ensure no data is
tx'ed after rx of terminate ind
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
On disconnect with refactored LLCP, if data tx is paused,
possibly 'waiting' tx nodes would not get released.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Only apply change to effective DLE times if current max times are too
small to accommodate. Similar to legacy implementation
Update unit tests to new DLE ntf behavior
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
When an operation on the socket is not supported by the implementation,
which is the case for some drivers, set errno to a value that reflects
this situation rather than signalling an error with the file descriptor.
Signed-off-by: Ulf Lilleengen <lulf@redhat.com>
The new interface contract guarantees that OpenThread stack uses
otPlatSettingsSet only for aKey which has at most one value at time.
This implies the simplification for key name used by settings subsystem
and decreases the count of records written each time when the value
for specific key is updated. In result non-volatile memory can be used
more efficiently.
It relates to zephyrproject-rtos/openthread commit: ed665e9 .
We still need to make sure that old entries are being removed for the
case with DFU.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
Use the newly added dma buffer alignment device tree property and macro
helper to set the buffer alignment.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
pb gatt server starts fast advertising for the first 60 seconds.
After that, server goes into slow mode.
When pb gatt and pb adv work in parallel pd gatt changes fast to
slow modes after the first tx frame in pd adv (about 110ms)
since they both are handled in the same thread.
Actually, pb gatt never worked in fast mode
if pb adv was enabled (in most configuration cases).
Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
Renaming objects which had 2 in the name to indicate that
it is v2 specific. Once logging v1 has been removed such
suffixes are redundant.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Adds compatibility with Intel ADSP GDB from Zephyr SDK and
from Cadence toolchain to coredump_gdbserver.py.
Adds CAVS 15-25 (APL) register definitions. Implements
handle_register_single_read_packet to serve ADSP GDB
p packets.
Prevents BSA from changing between stack dump printout
and coredump by taking lock. Observed to be necessary for
accurate results on slower simulated platforms.
Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
The iso_rx_qos is only used for unicast audio, as
we do not set the RX QOS for the broadcast sink, nor
can a broadcast source set RX QOS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
So far, TCP cloned a packet with data on an RX path for the application,
leaving the original packet intact. This isn't really needed, as the
original packet is unconditionally freed later anyway, so the TCP can as
well simply queue the original packet for the application, while
informing the network processing core, that the packet was consumed by
the TCP layer.
This allows to improve the download throughput even further, since the
CPU don't waste time on needles packet copying.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The current default of 250ms appears to be too low in case connection
teardown takes place in lossy networks - in case of FIN packet
retransmission, the connection on the Zephyr side could have already
been dismissed due to low TIME_WAIT state delay, resulting in ICMP
Destination Unreachable replies.
Increase the default value to 1500ms - this is still pretty low, but at
least gives the peer some time to retransmit the FIN packet.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case TCP stack enters TIMED_WAIT state (after receiving FIN/ACK reply
from peer), it should stil be ready to reply with ACK for any
consecutive FIN attempts. Othewise, in case the final ACK from Zephyr
side is lost, the connection is not properly closed on the other end,
and peer keeps retransmitting the final FIN packet.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Implement a mechanism, according to RFC 813, which allows to prevent so
called "Silly Window Syndrome" - a scenario where the TCP receiver keeps
reporting small window sizes in the acknowledgments, effectively
limiting the connection throughput. This allows to improve performance
in low-buffer configurations, where the maximum window size is small,
and the issue was hitting quite often.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case NET_MGMT_EVENT module was enabled but w/o NET_MGMT_EVENT_INFO,
the OpenThread integration layer failed to build as the "info" field in
the net mgmt callback structure is not available then.
Fix this by conditionally enabling code processing the event only if
NET_MGMT_EVENT_INFO is enabled. Otherwise, print a warning, as the event
is not really useful if no address information is provided.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Prevent local "addrlen_copy" variable from being used uninitialized in
accept() userspace verification function.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In the sent callbacks we used CONTAINER_OF to get the bt_audio_ep,
but that no longer has the ISO channel, causing these
CONTAINER_OF to return a wrong pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
On X86 platforms, the interrupt trigger method has been
changed to use APIC IPI, we don't use INT command to trigger
interrupt, so remove this unused macro.
Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
On X86 platforms, the interrupt trigger method has been changed
from using INT command to using APIC IPI, we need to make sure
the IPI interrupt is handled before do our check, so add some
nop operations.
Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
`bt_conn_index` has been changed to take a `const bt_conn`
which allows our functions that use this to also take a
`const` parameter.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
the CSIS client now has a ordered access procedure function.
The function implements the procedure as per the CSIP spec,
where it will verify that 1 or more members are unlocked,
and the execture a procedure on each member in ascending
order of rank.
The procedure can be anything (even a non-BT procedure),
and it will be up to the applicaiton to implement
what to do in that.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of getting doing look ups for each member
for the CSIS client procedures, we store the active
members ordered by rank.
This is slightly less efficient in cases of error,
but for some procedures as the upcoming Ordered
access procedure where we need to access each
member twice, ordering them once is more
efficient.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Having the members array being const causes a lot of
limitations in the implementatation, and was
occasionally even disregarded. Removed to make the
implementation more flexible.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When the client receives att error rsp, but the error code
is an illegal value, such as 0, an exception will be triggered.
gatt_read_type --> gatt_read_type_rsp --> parse_characteristic
`switch (rsp->len) {` null address access.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The `iso_qos` was only used for connected ISO, but
was placed outside of the CONFIG_BT_ISO_UNICAST
guard, such that for broadcast ISO-only it was unused.
Move the declaration and renamed to cis_iso_qos.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Disable BT_ECC support in network core to reduce RAM usage.
ECC implementation can instead be supported in the Host
running in the application core.
This is also to keep hci_uart (nRF52 Series) and hci_rpmsg
(nRF53 Series) have the same support features. ECC is not
enabled in hci_uart sample.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As the stack can safely keep allocating data during retransmission mode
there is no need to take the tx_sem during retransmission any more.
Data stored in the send_data buffer will be transmitted upon the ack of
the data for which an ack is pending. This the application being fully
stalled when the TCP connection enters retransmission mode.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
After the window_full function has been fixed by looking at the
send_data_total instead of the unacked_len. There is no risk
in sending data in transmission mode.
This reverts commit 0088aaefa0.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Fix advertising failing to resume with BT_ADV_PERSIST set in
bt_hci_le_adv_set_terminated due to BT_ADV_ENABLED not getting
cleared before bt_le_adv_resume gets called
Signed-off-by: Troels Nilsson <trnn@demant.com>
Sometimes we want to entirely decouple the system PM from the device PM,
leaving the devices to manage its own power states using the runtime PM.
This is currently not possible because the suspend / resume code path is
triggering the device PM hooks even when the runtime PM is enabled.
Introduce a new PM_DEVICE_RUNTIME_EXCLUSIVE symbol to allow the platform
to skip the device PM triggers on suspend / resume.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Encryption request is enqueued in thread context from the Tx
buffer pool, so that it is serialized alongwith the already
enqueued data buffers ensuring they are transmitted out to
peer before encryption is setup. Allocate additional Tx
buffers to accommodate simultaneous encryption setup across
active connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
- Prevent NULL-pointer dereferencing if datapath is created late
- Support SDU fragment complete-counting for framed case
Signed-off-by: Morten Priess <mtpr@oticon.com>
Implemented incrementing TX SDU fragment count such that it indicates
the number of completed SDU fragments in the PDU being emitted for both
unframed and framed transmission.
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
HCI:
-- Discarded data from HCI ISO Data packets from controller to host if
data has been lost
ISO-AL:
-- Corrected iso_interval in latency calculations
-- Updated handling and release of SDUs for error conditions / padding
at the last PDU for the SDU
-- Updated prioritisation of error status in released PDUs
-- Included error spooling exit on based on payload number to SDU
mapping for unframed reassembly
-- Updated sequence number handling for framed recombination
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Do not use ull_ticker_stop_with_mark for ISO one-shot resume ticker, but
stop without checking result. If active this will stop it, otherwise it
is ignored. Also, this prevents calling lll_disable twice.
Signed-off-by: Morten Priess <mtpr@oticon.com>
- Prioritize CIS_REQ handling in (old) LLCP
- Reject if CIS_REQ uses exisiting CIS ID
These fixes prevent assertions in /LL/CIS/PER/BV-38-C.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Added start, stop and update to the shell.
Refactored the event_cb of the rd_client_info struct into the ctx,
as it was needed in the shell script.
Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
The img_mgmt_impl_erase_if_needed was only called when
CONFIG_IMG_ERASE_PROGRESSIVELY is y, and it does nothing anyway;
because the function always returns 0, and does nothing,
neither the function no result processing, from a call to the
function, is needed.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The function is no longer needed with fix provided by commit
aa5d20aaef (storage/flash_map: Return -ENODEV from flash_area_open).
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Image management state, struct img_mgmt_state, has been defining
sector_id and sector_end variables, supposed to be used by
progressive erase feature, that have no use in code.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The img_mgmt_upload has been overriding return codes of several
utility function calls with MGMT_ERR_EUNKNOWN, even though
these utility functions would be returning MGMT_ERR_* type codes
already, overshadowing real reason of failure.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit changes types of image, size and offset elements of
img_mgmt_upload_req structure from unsigned long long to size_t.
This commit also fixes comments and conditional statements, where
these identifiers have been compared against -1, although they have
been clearly defined as unsigned.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
uuid wasn't initialized in the publication setting command.
It caused wrong the configuration clietn behavior.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Recent code change asserts on ECRED psm being consistent in
l2cap_ecred_conn_req. However, the values are compared between
endianness converted value and non-converted value, which fails on BE
archs.
Signed-off-by: Morten Priess <mtpr@oticon.com>
This function retrieves TX sync information
(timestamp, offset, and sequence number)
from controller using HCI command HCI_LE_Read_ISO_TX_Sync.
Signed-off-by: Audun Korneliussen <audun.korneliussen@nordicsemi.no>
The functions for Class C mode are already provided by LoRaMAC layer.
A device in this mode is listening for incoming downlink messages almost
continuously, which results in higher energy consumption.
Class C mode is required for FUOTA.
Signed-off-by: Martin Jäger <martin@libre.solar>
Allocated own message buffer for RD client interface.
This helps to cover if all messages are queued and need to do
registration or update.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
(cherry picked from commit 8dca91109d73a4a697e074c58ee9430d56c01a51)
If Notification build fail there was possible that Notification
are blocked after failure.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
(cherry picked from commit 6dfa242c7d891b3458ab88df46b69b3a9621ee82)
Fixed couple possible place for leak Coap pending entry.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
(cherry picked from commit 3c175951383be56fa9c1451845a15b66df41ff64)
Implementing proper validation of PHY selection for PHY UPDATE procedure
Implement connection termination on PHY UPDATE with instant in the past
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Replace k_sem_take loop used for consuming the remaining
sem give counts with k_sem_reset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix assertion due to multiple mayfly_enqueue calls used
under ZLI when pdu_free_sem_give is invoked from the LLL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit corrects all `extern K_KERNEL_STACK_ARRAY_DEFINE` macro
usages to use the `K_KERNEL_STACK_ARRAY_DECLARE` macro instead.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Lifetimes are really 32 bit values, so the limitation
did not make sense, and it did not allow 24 hour lifetime.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When performing a combined host and controller build, there is no point
in presenting the option to enable a given host feature if the
controller does not support it. This reduces the list of presented
features to enable/disable.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This reverts commit e11ff7df48.
This patch causes some PTS failure.
Another patch to address duplicate device will follow.
Signed-off-by: Azizah Ibrahim <azizah.ibrahim@nordicsemi.no>
_current_cpu is a macro that expands to an assert that checks if the
current context can be migrated to a another cpu. Since this
pm_system_suspend() is called from the idle thread (each cpu has its
own) and with locked this check is redundant. Just use
arch_curr_cpu() to avoid it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
pm_system_resume() can be called from the idle thread with
interruptions unmasked. In this situation, _current_cpu will call
z_smp_cpu_mobile() that will return true and cause an assert.
In this function we don't need to check if the current context can be
preempted, we just need the information about which cpu is executing
it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Remove v1 implementation from log_core and all references in the tree.
Remove modules used by v1: log_list and log_msg.
Remove Kconfig v1 specific options.
Remove Kconfig flags used for distinction between v1 and v2.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The Configure Data Path command must be included when the read Local
Supported Codecs [v2] command is supported. The Configure Data Path
command is needed when vendor-specific ISO data paths are supported,
but not otherwise tied to ISO. The respective weak function is
therefore moved to ull.c.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Introduce configuration options for chosen RPL implementations.
This will allow introducing alternate persistent storage schemes
for the replay protection list.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
When an L2CAP_CREDIT_BASED_RECONFIGURE_REQ packet is received with
invalid parameters, the recipient shall send an
L2CAP_CREDIT_BASED_RECONFIGURE_RSP PDU with a non-zero Result field
and not change any MTU and MPS values.
This fix incorrectly reconfiguring valid channels while responding with
0x003 (Reconfiguration failed - one or more Destination CIDs invalid)
result code.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
TSE18813 clarified IUT behavior and rejecting reconfiguration which
would result in MTU decrease is enough. There is no need to disconnect
L2CAP channel(s).
This was affecting L2CAP/ECFC/BI-03-C qualification test case
(TCRL 2022-2).
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Added test command line arguments to filter
which tests are executed. Filtered tests should follow
suiteA::test1,suiteB::test2 format.
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
When supporting chain PDUs, after HCI reset the first PDU
allocated did not initialize its next pointer causing use
of unallocated PDUs for chaining while a duplicate of such
PDU buffer being allocated for other states/roles. This
causes in certain cases both Extended and Periodic PDUs
having same data, the Extended Advertising PDU being
transmitted at the instant of the Periodic Advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Files including <zephyr/kernel.h> do not have to include
<zephyr/zephyr.h>, a shim to <zephyr/kernel.h>.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Files including <zephyr/kernel.h> do not have to include
<zephyr/zephyr.h>, a shim to <zephyr/kernel.h>.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Use Zephyr coding style for variable names and functions where possible.
The function BoardGetUniqueId has to be kept as is to match LoRaMAC
library declarations.
Signed-off-by: Martin Jäger <martin@libre.solar>
Fix BT_CTLR_RX_ENQUEUE_HOLD implementation that stalled
generating the CONN_UPDATE and PHY_UPDATE when there were
no Rx data or Tx acknowledgements to be processed when
the controller was built with BT_CTLR_LOW_LAT_ULL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
...format to bootstrap registration message with LwM2M v1.1.
SenML CBOR takes precedence, followed by SenML JSON and OMA TLV.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
Write to an opaque resource failed and it has been fixed. Support for
blockwise transfer is still missing.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
This commit aligns openthread radio platform to use `ieee802154_txpwr`
of the packet to transmit instead of setting power through a separate
API call, if possible.
Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
This commit extends the `struct net_pkt` structure with
`ieee802154_txpwr` field that contains signed value of the desired
transmission power of a IEEE 802.15.4 frame in dBm.
Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
idle_rate is uint8_t, sof_cnt is uint32_t. The result is uint32_t, which
is the wrong type for 'abs'. Explicitly cast idle_rate to uint32_t,
subtract sof_cnt and then explicitly cast to int32_t and then use abs,
storing the result in another int32_t which matches the return type for
abs.
This quiets clang warnings about passing unsigned values to abs.
Signed-off-by: Keith Packard <keithp@keithp.com>
This adds checks to avoid setting context that is not indicated as
supported to be available.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Return ret error code instead of always returning zero causing
warnings:
...
subsys/net/lib/dns/resolve.c:975:6: warning: variable 'ret' set but
not used [-Wunused-but-set-variable]
int ret = 0;
^
...
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Fix compilation warnings:
...
subsys/net/lib/dns/dns_pack.c:548:6: warning: variable
'remaining_size' set but not used [-Wunused-but-set-variable]
int remaining_size;
^
...
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
The img_mgmt_upload was getting into loop with requesting
offset 0 from mcumgr, when requested to re-try upload after
write fails.
Because it is not really possible to recover from write fail,
at least currently, the commit changes code to reset upload
state in a case of write error and return an error code.
Now, when write fails, an error will be returned and upload
process will be stopped and reset; upload re-try will behave
as a new upload has been requested.
Fixes#44219
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The offset is checked, for correctness, before the function
img_mgmt_impl_write_image_data is called, so it is redundant to
do the same check within it.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Makes it possible for an application to
handle CSIS RSI advertising by registering a
callback, which will disable the internal
CSIS advertising.
Also fixes registering callbacks in CSIS.
Signed-off-by: Lars Knudsen <larsgk@gmail.com>
Rename the symbols used to denote the locations of the global
constructor lists and modify the Zephyr start-up code accordingly.
On POSIX systems this ensures that the native libc init code won't
find any constructors to run before Zephyr loads.
Fixes#39347, #36858
Signed-off-by: David Palchak <palchak@google.com>
To improve the performance with small chunks send, implement Nagle's
algorithm. Provide the option TCP_NODELAY to disable the algorithm.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
This fixes sending corrupted (incomplete) packets over RTT. Additional
helper buffer has been added to ensure the complete packet before it
can be sent over RTT. Once the complete packet is collected it is sent
to the RTT control block in non-blocking manner. From now there will
be no situation that only part of the packet (e.g. header) is sent
which lead btmon to fail to parse the corrupted data.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes Bluetooth logs that were not sent over RTT.
Minor cleanup has been made to limit the number of ifdefs.
> ACL Data RX: Handle 0 flags 0x02 dlen 11 #1049 83.117000
ATT: Handle Value Indication (0x1d) len 6
Handle: 0x0003
Data: 0100ffff
= bt: bt_att: Unhandled ATT code 0x1d 83.117100
> HCI Event: Disconnect Complete (0x05) plen 4 #1050 84.247700
Status: Success (0x00)
Handle: 0
Reason: Remote User Terminated Connection (0x13)
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add Kconfig option to conditionally enable tickers with slot
window to yield to normal tickers and be placed at the end
of their slot window if possible.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This fixes a minor bug that caused an error if one attempted to encode
or decode INT64_MIN in SenML CBOR
Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
This fixes a bug in the decoding of objlinks. Without this the object
instance id is not retrieved correctly as it tries to read the second id
starting from the colon.
Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
By default, any string or opaque data that LwM2M engine initializes
sets data lenght to same value as given buffer length for that
resource.
However, on run time, engine keeps track how much data is written
to each resource, so when reading from any resource, should only
return data that has been written there. But uninitialized resources
return the content of the whole buffer.
Fixed the problem by introducing macros INIT_OBJ_RES_LEN(),
INIT_OBJ_RES_MULTI_DATA_LEN() and INIT_OBJ_RES_DATA_LEN() that
allows you to give the amount of data existing in buffer when
the resource is initialized. This sets the data_len and max_data_len
variables correctly.
Also introduced new functions lwm2m_engine_get_res_buf() and
lwm2m_engine_set_res_buf() that distinct between data size and
buffer size. Deprecated the previous functions
lwm2m_engine_get_res_data() and lwm2m_engine_set_res_data()
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Extended logging backend API with log_backend_is_ready call which
returns 0 is backend is ready. Logging core will make sure that
all autostarted backends are ready before they are enabled.
This option allows to handle backends which are not yet ready
after init function is called (e.g. usb backend that is not plugged
in). If this is the only backend in the system, logging processing
will not start util first backend is ready.
Function for checking readiness is optional and when backend has
no such function it is assumed that backend is ready after
initialization function returns which makes this feature backward
compatible.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This removes the check that was causing missalignment in
csis->srv.conn_cnt conunting. The csis->srv.conn_cnt was increased for
each connected device while decreased for bonded only. This caused
assertion in csis_connected when reconnected.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Adds a helper function to query whether a device is currently powered.
This can be used to determine if the chip can be initialised now, or if
it needs to be deferred.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add flags option to init call and a flag to use cache.
Add Kconfig choice to pick how to approach cache. Cache can be
enforced in all spsc_pbuf instances, disable in all, or runtime selected
based on configuration flag. Option is added to allow memory footprint
savings.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Move icmsg_buf to lib/os and rename to spsc_pbuf (Single Producer
Single Consumer Packet Buffer). It is a generic module and initially
was created as internal module for ipc service.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
In the function net_tcp_queue_data. When an -ENOBUFS by
tcp_send_queued_data is returned, it throws away the whole block of size
len from the send_data. If the len is > MSS, it could happen that the
first section is transmitted, but at the second an -ENOBUFS occurs.
In that case the data is transmitted, but later on removed from the
send_data.
To circumvent this problem, check if the len + unacked_len is smaller
then the send_data_total. If so, the data can safely be removed from
send_data. Otherwise, just pretend the transmission went OK. The
acknowledgment and retransmit path will eventually take care of it.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
The window full computation was corrected to use the send_total instead
of the unacked_len. This conflicted with the new polling implementation
due to the moment when these values are changed.
Move taking the tx_sem outside of tcp_send_queued_data to handle the
-ENOBUF situation properly in case called from net_tcp_queue_data.
net_tcp_queue_data removes data from the send_data in case the
transmission failed with -ENOBUF. This cause the buffer to be not full
any more.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Log an error to explicitly log a failed buffer allocation in TCP
retransmission. This avoids silently failing retransmissions due to
repeating buffer allocation failures.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
When there was no room to transmit the a next packet to be transmitted,
the -ENOBUFS could cause the retransmission to fail.
Secondly the conn->unacked_len can be set to 0 in the retransmission
process, causing the subscribtion to the transmit timer to fail. Use the
variable send_data_total instead.
Make sure that is the send_data buffer becomes empty the send_timer is
cancelled, but make sure any pending data still keeps on being transmitted.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
The function tcp_data_get tries to update the TCP receive window using
net_context_update_recv_wnd. This function graps the context lock while
the tcp_data_get is called from a situation where it already has tcp lock
is already. Transmission actions do first grab the the context lock and
try to grab the tcp lock afterwards. The combination of both can cause a
deadlock.
By taking the shortcut to directly update the tcp receive window without
going through the net context, the context lock is not required avoiding a
possible deadlock situation.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
In the existing the value received from the other side by the TCP options
is used as MSS for transmission. Since the MSS options are an
announcement rather then a negotionation, it is likely the receiver will
have a different and possibly bigger MSS than allowed by our side.
This allow potentially for different a MSS in the receive and transmit
path.
Directly using the received MSS could cause problems when our MSS is only
allowed to be small. At transmission, for that reason take the minimum of
the received MSS and our desired MSS to find a value compatible to both
sides of the link.
Rename the function to net_tcp_get_recv_mss to net_tcp_get_supported_mss
to better reflect its function in the new situation.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
The HAS sends notifications to paired devices. Thus the client context
has to be initialized once the link has required security.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The Sink Audio Locations and Source Audio Locations characteristics are
optionally writtable as defined in PACS_v1.0.
If the property is not mandatory in the specification it should be
disabled in implementation by default. It is more likely that the
location value will not change over time, as the end-product would
be designed to be used in specific way (in specific location).
If the user wants to make use of the writtable location feature, then
one has to enable it explicitly.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Special function for supporting various types of buffers,
via provided callbacks, is no longer needed when net_buf is the
only type of transport buffer used by mcumgr.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The additional logic of zephyr_smp_trim_front is no longer needed
and net_buf_pul can be directly used to trim front of net_buf
response when fragmenting.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Rename the BT_ISO_INTERVAL_MIN/MAX to
BT_ISO_SDU_INTERVAL_MIN/MAX to avoid confusing this
the the ISO interval which is different from the SDU
interval.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add two new parameters to bt_iso_chan_send:
sn: The packet sequence number which shall be incremeted
per SDU interval.
ts: An optional timestamp value used to synchronize SDUs.
The sequence number in the API uses a 32-bit value even though
the sequence number for the HCI command is 16-bit. This is to
properly handle wrapping of sequence numbers, which is much
easier to do with additional bits allocated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
CONFIG_LOG2_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS was added as
a stop-gap measure to support Sys-T catalog messages. Since
the Sys-T backend has envolved to use tagged argument, this
kconfig and its effect are no longer needed. So remove it.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This extends Sys-T catalog messages support for other architectures,
by utilizing tagged arguments to prepare the catalog messages. So
this is no longer limited to architectures where the printf
argument list has the exact format as the catalog message argument
list.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds support for packaging with tagged arguments for log
messages so that backends can make use of this information
when they process messages.
Note that currently tagged arguments must be used with
CONFIG_LOG2_ALWAYS_RUNTIME where log messages are created via
z_log_msg2_runtime_{v,}create(). For some reason, using C++ on
Cortex-M (mps2_an385) results in an additional empty string
argument being added to the list. This does not happen if only
doing C on mps2_an385, or on other architectures.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
`bt_mesh_rpl_check` stops iterating `replay_list` if either it found an
entry with the requested source address or unassigned address. When IV
index updated, `bt_mesh_rpl_reset` is called. It will set `old_iv` to 1
for all entries with fresh IV index and remove entries with old IV index.
If the entries with old IV index are mixed with other entries, this will
cause fragmentation of `replay_list`. The next time `bt_mesh_rpl_check`
is called, it may stop iterating `replay_list` earlier than it should
because it will meet an empty entry before it iterates over all entries
in the list.
This commit does defragmentatino of `replay_list` on every
`bt_mesh_rpl_reset` by shiting existing entries to the vacated places.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This reverts commit 7f51907fda.
The problem with setting the priority at the highest priority possible
is that when the IPC is under high traffic, the WQ could starve the
scheduler.
Move back to a more sane preemptive priority as default value.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Json library parser modify data so thats why we can't parse same
data again. Now Composite observation handler parse SenML Json or
CBOR resource path which is given to new API composite Read API
which not need any new data parser.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Integrated updated JSON library to LwM2M 1.0 JSON.
Removed Old Json format default choice.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Integrated updated JSON library to SenML-JSON.
This integrate affect that Coap Block wise transfer is not
supported.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
The commit fixes issue where image management would switch to using
heap, whether developer wanted or not, when CONFIG_HEAP_MEM_POOL
gets value greater than zero.
Now when heap is enabled the user can select whether image management
will keep on using static variable, taking static RAM, or will use
heap to allocate the flash image context only when needed.
For this purpose CONFIG_IMG_MGMT_USE_HEAP_FOR_FLASH_IMG_CONTEXT
has been added, which is available when CONFIG_HEAP_MEM_POOL is enabled.
Fixes#44214
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The open source controller did not expose support for shutting it down
via the close() API in the HCI driver. Add support for it, which
completes the support for disabling and enabling the Bluetooth stack in
Zephyr.
Closes#3192.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Allow the controller to be deinitialized, adding the whole chain of
calls:
- ll_deinit()
- lll_deinit()
- lll_clock_deinit()
in order to be able to turn everything off, including the controller's
refcount of the LF clock.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When bt_disable() was introduced, some of the global variables that
handle key aspects of Bluetooth were not converted to be also
re-initialized every time that the stack was disabled and the enabled
again. This meant that the FIFO and semaphore in the device structure
were not reset whenever the corresponding threads using them were shut
down and then restarted.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The ipc_service_get_tx_buffer() has a timeout parameter that can be used
to wait a certain amount of time for a TX buffer to be available.
Unfortunately, for the static vrings backend, an asymmetry
between remote and host exists that makes the usage of this parameter
confusing when the user requests a buffer when no buffers are available
at that time.
When the remote endpoints requests a TX buffer specifying a certain
size and there are no TX buffers available, the function ignores the
parameter and ipc_service_get_tx_buffer() immediately returns -ENOMEM.
The same case on the host endpoint works correctly only when the
specified timeout is <= 15 seconds. All timeouts > 15 seconds simply
returns -EIO after 15 seconds.
This patch is reworking the timeout management trying to behave
correctly in all the cases.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
The current PHY is read only when automatic PHY
update procedure is enabled, 2M PHY is supported and
extended advertising is enabled and this is done after
application is notified about connection. This leads
to invalid connection info PHY data which always returns
1M PHY because when using extended advertising the connection
can be established on different PHY and host does not read
this value from the controller in most cases. In order to
have a current PHY value updated we need to read it in
connection complete event before the user application
is notified about connection.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
The commit replaces direct access to flash_img_context, for the
purpose of checking how much data has been written, with call
to the flash_img_bytes_written.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Recently OpenAMP introduced the possibility to set the sizes for TX and
RX buffers per created instance. Expose this also to Zephyr users by
using a DT property "zephyr,buffer-size".
For the sake of simplicity use the same DT property to set the buffer
size for both TX and RX buffers.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
The automatic elevation of security and retry of ATT requests interferes
with some tests that expect authentication failures.
Affecting GATT/CL/GAR/BI-42-C
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
EATT is not a requirement for the Multiple Variable Length Read
procedure, but previously one had to enable CONFIG_BT_EATT to enable
support for it.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
This fixes Kconfig that allowed to build PACS without support for sink
or source PACS. Few conditionals that no longer apply were removed.
Enabling ASCS support in specific direction enables related PACS
support.
Since PACS does `depends on` anything, it's safe to make use of `select`
statement.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This renames the UUID to follow the same naming scheme as for
BT_UUID_PACS_SUPPORTED_CONTEXT.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The NVS data lookup time grows linearly with the number of
allocation table entries to walk through, meaning that if
some data pair in the NVS changes frequently, access to
other data pairs that change rarely can take a lot of time.
It is particularly visible when the NVS is used as the
settings backend since the backend needs to perform multiple
NVS reads to find a requested key.
Implement a simple cache that stores an address of the most
recent ATE for all NVS IDs that fall into the given cache
position. CRC8/16 is used as a hash function used to
distribute NVS IDs across the cache entries.
The cache entries are only invalidated when an NVS sector
is erased as part of the garbage collector task.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Currently a shallow clone of a packet will bump the reference count on
all the fragments. The net_pkt_unref() function, however, only drops the
reference count on the head fragment. Fix this by only bumping the ref
count on the head buf during shallow clone.
Only bumping the ref count of head is more in line with the idea that
head buf is not responsible for the fragments of its child.
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
The commit adds check, to flash_area_open, whether there is any
device driver attached and returns -ENODEV if there isn't any.
This works around a problem where flash_area_open succeeds but
consecutive read/write causes crash.
It is enough to check the condition, and return error, here as
the flash_area_open has to precede, and be checked for success,
any read/write operations.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Add a pseudo device diver with device tree bindings for coredump.
The device tree bindings exposes memory address/size values to be
included in any dump. And the driver exposes an API to add/remove
dump memory regions at runtime.
Signed-off-by: Mark Holden <mholden@fb.com>
This fixes a bug in the decoding of objlinks. Without this the object
instance id is not retrieved correctly as it tries to read the second id
starting from the colon.
Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
The unicast audio group can not have streams removed after the
CIG has been created as part of the QoS set procedure.
The bt_audio_unicast_group_remove_streams function may
leave the unicast group without streams, and thus the
check for "free" group was not correct, and has been replaced
with a simple boolean value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The unicast client and server will attempt to use a
bidirectional CIS instead of two unidirectional CIS
whenever possible.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the return type of bt_audio_codec_qos_to_iso_qos to
void as it cannot fail, and this will make it easier to use.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add supporting for referercing either a sink endpoint,
a source endpoint or both in the bt_audio_iso struct.
This way a single bt_audio_iso can have references to up
to 2 endpoints.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Moves the bt_iso_chan and bt_iso_chan_qos structs
out from the bt_audio_ep struct, and instead use a
reference.
This is due to the fact that an endpoint can ever
only be unidirectional, and a CIS can be bidrectional.
The support for using a single bididrectional CIS
for two audio streams/endpoints is not implemented
in this commit.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the NULL-check for the iso_server to an earlier point.
There's no need to do anything on the device if no iso_server
has been registered.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The "iso connect" now also takes a security level option like
"iso listen", so that the central can easily encrypt
and connect a CIS in a single command.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The ISO security implementation works by verifying
against the acl (bt_conn) sec_level field. The
bt_conn sec_level field is only available
if CONFIG_BT_SMP is enabled, so this commit
adds guards for all ISO security checks as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If the required_sec_level is lower than the
conn->sec_level, the central will now initialize the
security procecure to ensure that the CIS is encrypted
properly.
The algorithm implemented is as follows:
1) Check security levels for each (acl, iso) pair
2) For those with insufficient security,
call bt_conn_set_security
3) For those with sufficient security, connect the CIS
4) Once the ISO from 2) has been encrypted, connect the
CIS for the specific ACL
The idea behind this was to implement similar support
for autonomous encryption as we have for L2CAP.
It is more complex for ISO as we are dealing with
an array of (acl, iso) pairs, meaning more can go
wrong.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add check for connection and server security
levels, and reject the CIS if the ACL security
level is too low.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The API is documented as being blocking. Making it nonblocking was an
unintentional API change.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The L2CAP channel ops->sent callback was required to call the
l2cap_chan_sdu_sent callback.
Previously, the only difference between the l2cap_chan_sdu_sent and
l2cap_chan_seg_sent callbacks was that l2cap_chan_sdu_sent called
ops->sent. This is no longer true and l2cap_chan_sdu_sent should always
be called when an SDU is sent.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Datagrams should either be fully sent or not sent at all if networking
buffers or network interface MTU does not allow that. So far the behavior
was to truncate outgoing packets, even for datagram sockets.
When there is not enough available payload buffer to fit all requested
data, fail if that happens for datagram socket.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
error: 'CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH' undeclared (first use
in this function); did you mean
'CONFIG_BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH'?
292 | CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| CONFIG_BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH
etc.
This fixes build errors that were seen while building call control
client without server side (`CONFIG_BT_TBS`) enabled.
The options like BT_TBS_CLIENT_MAX_URI_LENGTH and
BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH have been removed because those
were not used in the code. In fact the client implementation used the
common options for BT_TBS_MAX_URI_LENGTH and
BT_TBS_MAX_PROVIDER_NAME_LENGTH that were moved in this patch to the
common Kconfig section.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
To be able to accept DHCP discover/request incoming packets the ip stack
neeeds to accept unspecified src addr if the destination is broadcast
address.
Signed-off-by: Olof Winge <olof@skyshaper.net>
Create the URI resource when creating the object if
PULL support is enabled.
URI write callback should be post-write instead to ensure
the URI value is updated for the resource.
Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
Add Kconfig option to the Ethernet L2 which allows to forward frames
with unknown EtherType further into the stack. This can be useful for
packet sockets, where further frame processing is application dependent.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
It turns out that all of the items listed under TODO section for packet
socket implmeentation has been adressed over time, threfore remove the
obsolete TODO.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Datagram AF_PACKET sockets were not processed properly by the net stack.
Instead of receving a packet already processed L2, and thus with L2
header trimmed, it was receiving a raw, unprocessed packet.
Fix this by calling net_packet_socket_input() for the second time, after
L2 has processed the packet. An updated connection handler module will
forward the packet correctly based on the corresponding socket type and
packet L2 processing status.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Currently, the packet socket implementation in net_context required that
netowrk interface to transmit the packet to was set on every sendto()
call. This spoils the whole idea of binding a socket. Fix this, by
checking first if the net_conext is already bound to a particular
interface, and if so, do not throw an error in case sll_ifindex field is
not a valid interface.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Somehow two files in subsys/mgmt/mcumgr/lib/cmd/img_mgmt/src ended up
using STRINGIFY but nothing in their include path ended up pulling in
zephyr/toolchain/common.h. Include that via zephyr/toolchain.h.
v2:
Use non-internal zephyr/toolchain.h header
Signed-off-by: Keith Packard <keithp@keithp.com>
The macro was remove for the GATT discover callbacks,
as only 2 out of 5 parameters for
BT_GATT_ATTRIBUTE were used.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The description suggested logging information while it never
was the case: it was about adding additional "rsn":value pair
to an SMP response.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Adds few missing zephyr/ prefixes to leftover #include statements that
either got added recently or were using double quote format.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fix Data Length Request CMD parameter checking to not
restrict invalid maximum Tx time values. This addresses
conformance test cases that provide maximum Tx time values
of 2128 us when not supporting Coded PHY in the Controller
implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The request timer started on the first l2cap channel when doing an MTU
reconfiguration has to be stopped when the response is received. Else the
channel will get into a bad state.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
It is possible, in case of two application images, to have no access
to one of devices of the secondary image.
When asserts are enabled, such situation causes crash even though the
image list command can handle it with no problem.
The commit removes the assert and adds additional swap type:
IMG_MGMT_SWAP_TYPE_UNKNOWN to indicate situations where it was
not possible to obtain swap type from boot_util.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
If there is a PHY change on a connection it may happen that effective
RX and TX time changes also. That change is applied after an instant.
Implemented handling of effective time calculation is based on the
maximum PDU length, new PHY and local (default) maximum TX or RX time.
The maximum TX value is set to default one that corresponds to PHY 1M
during the Controller initialization. It can be updated by host to other
value. By default Zephyr Host updates it to max possible TX time for all
supported PHYs. If PHY CODED is enabled, it is the longest possible TX
duration 17040 us.
The maximum RX value is set to default during connection creation.
In case of use of legacy advertising, the value is also related with
PHY 1M. It can be updated by data length extension procedure.
If the maximum RX value is set to some value and there is a change
of a PHY to one that requires more time to send a PDU with the same
length, then the maximum RX value is wrongly calculated.
Function pu_calc_eff_time returns a value that is the default_time
argument. The problem is that the default_time should be adjusted
to new maximum RX time required for a new PHY.
To solve that there should be an evaluation of a new maximum RX and
TX time based on new PHY.
The commit adds missing evaluation.
The problem occurred in DF tests that check collision mitigation
between PHY update control procedure and CTE request control procedure.
There was missing CONFIG_BT_CTLR_PHY_CODED option in CTE request
unit tests. The code was working because the ULL implementation of
PHY change control procedure does not verify if PHY CODED is supported.
When missing support was enabled, tests showed wrong evaluation of
maximum RX time. It also unveiled error in CTE request unit tests
implementation. The default_tx_time was set to wrong value 2120 us
as if PHY CODED was not supported. To fix it, the value was changed
to PDU_DC_PAYLOAD_TIME_MAX_CODED.
There was also added a mock for a feature exchange procedure done
during unit tests setup step. That allows to correctly calculate
maximum TX time by ull_dle_max_time_get function.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix filter accept list and privacy feature Kconfig default
based on whether host has them enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing BT_CTLR_PRIVACY conditional compilations that
included redundant HAL code when Controller privacy is
disabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix PHY update procedure to handle unsupported PHY requested
by peer central device. PHY update complete will not be
generated to Host, connection is maintained on the old
PHY and the Controller will not respond to PDUs received on
the unsupported PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The commit replaces MGMT_ERR_ENOMEM with MGMT_ERR_EMSGSIZE where it
was used to indicate that SMP response does not fit in response
buffer.
Fixes#44535
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fixes issue re. sending packets after sending TERMINATE_IND.
Fixes issue re. erroneous error code on 'timed out' termination (ie
when peer does not ack terminate_ind)
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
On a completion of feature exchange the max DLE times needs to be
updated if Coded PHY has become supported.
For this now also keep a separate store of the default_tx_octets/time
for the sake of re-calculation of local versions of DLE values
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
The commit fixes incorrect value being passed as used stack
information and also prevents compilation error when
CONFIG_INIT_STACKS is n.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Enhance FCB to also work with sectors larger than 16K and
to handle larger flash alignment constraints correctly.
use fcb_len_in_flash when setting the offset of the data
and use buffers sizes of at least the alignment value.
The test in fcb_test_append_to_big has been altered, as it
would otherwise not come to a data length which fits the
fcb on sectors larger than 16K.
Closes: https://github.com/zephyrproject-rtos/zephyr/issues/45345
Signed-off-by: Achatzi Julian <jachatzi@baumer.com>
Fix prepare pipeline from not resuming non-resume events
in pipeline when more than one resume events are present
before a non-resume event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Core v5.3, Vol 4, Part E, 7.8.38
Controller has the option to accept or reject when the same device
is added to RL.
If a remote device has been added to RL before, then local device
change it's advertsing address, and the remote device tries to pair
with the new address, we could end up trying to add the same data to RL.
If a remote device's public/static address is known, this patch deletes
the old entry from RL before adding it.
Signed-off-by: Azizah Ibrahim <azizah.ibrahim@nordicsemi.no>
In other places, img_mgmt_dfu_stopped() is called when
a failure occurs and the DFU cannot be continued. In this
place, however, the function is called on success which
does not seem to be correct.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
When host issue HCI Reset controller should clear LE Static Random
address. Otherwise controller may incorrectly use one from before
HCI reset insread of rejecting HCI commands.
This was affecting following qualification test cases:
HCI/CCO/BI-51-C
HCI/CCO/BI-53-C
HCI/CCO/BI-54-C
HCI/CCO/BI-56-C
HCI/DDI/BI-06-C
HCI/DDI/BI-07-C
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Fragmented data passed to sendmsg() should be sent as a single datagram in
case of datagram sockets (i.e. DTLS connection). Right now that is not
happening now, as each fragment is sent separately, which works fine only
for stream sockets.
There is no mbedTLS API for 'gather' write at this moment. This means that
implementing sendmsg() would require allocating contiguous memory area at
Zephyr TLS socket level and copying all data fragments before passing to
mbedTLS library. While this might be a good option for future, let's just
check if data passed to sendmsg() API consists of a single memory region
and can be sent using single send request. Return EMSGSIZE error if there
are more then one data fragments.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
At least one supported PHY bit shall be set and none of
non-supported or RFU bits should be set.
This was affecting HCI/DDI/BI-05-C qualification test case.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Removes label experimental for direction finding feature in
Bluetooth Controller.
The feature stays disabled by default because it requires additional
dedicated hardware to be used. Besides that it significantly enlarges
amount of memory used by the Controller.
End user has to enable the feature explicitly by use of configuration
options.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix preempt timeout scheduling to not skip first prepare in
pipeline when there are no previous preempt timeout
scheduled already.
Fix related to commit 27b8beaa22 ("Bluetooth: Controller:
Fix to handle relative short preempt timeout").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Maximum number of CTE to be send in a periodic advertising chain is
limited by BT 5.3 Vol 4 Part E, section 7.8.80 and is 16.
Maximum number of samples CTE in a periodic advertising chain is
limited by BT 5.3 Vol 4 Part E, section 7.8.82 and is also 16.
Both values are limited by amount of memory reserved in Controller
by Kcofigs, respectfully: CONFIG_BT_CTLR_DF_PER_ADV_CTE_NUM_MAX and
CONFIG_BT_CTLR_DF_PER_SCAN_CTE_NUM_MAX.
Functions ll_df_set_cl_cte_tx_params and ll_df_set_cl_iq_sampling_enable
check limits against Bluetooth specification provided values.
That can end with memory overwrite if number of requested CTEs is
greater that number provided in configuration.
The commit changes mentioned functions to validate HCI commands
parameters against configuration values.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In case there are pending two control procedures: local and remote,
and remote device sends LL_REJECT_IND PDU then assertion happened.
ull_cp_rx function triggers assertion because LL_REJECT_IND is
considered as expected packet for all local and remote control
procedures.
That is not correct. It does not allow local procedure to handle
a response and stops a device on assert.
A remote device should not send LL_REJECT_IND PDU for locally initiated
control procedures, hence local device should not expect to receive
LL_REJECT_IND PDU to be expected one for pending remote control
procedure.
Remote device is allowed to send LL_REJECT_EXT_IND PDU for a locally
initiated control procedures. The LL_REJECT_EXT_IND PDU has a Reject-
Opcode that identifies rejected control procedure, hence is may be
expected by local device.
The commit provides changes that prevent the Controller assertion
in described case.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CCM during on-the-fly decryption of a received packet starts decryption
when Radio triggers EVETNS_ADDRESS. In case there is possibility a
packet may include Constant Tone Extension, on-the-fly parsing of a
received packet for CTEInfo is enabled.
If there is a PHY 1M enabled the Radio stores received bits with a
delay, that is equal to time required to receive 3 bits. CCM TASKS_CRYPT
related with packet decryption should be delayed by the time the Radio
needs to store received data.
The commit provides changes required to delay start of the CCM
TASKS_CRYPT. It uses NRF_RADIO Bit counter feature. The Bit counter is
configured to trigger NRF_RADIO->EVENTS_BCMATCH on reception of 3rd bit.
The event is connected through PPI with CCM TASKS_CRYPT.
The PPI used is shared with Radio Rate override. That is possible because
direction finding feature is not allowed on PHY Coded and CCM needs a delay
only when used PHY 1M.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
lll_conn_rx_pkt_set function is called before one of radio_switch-
_complete_XXX functions calls in lll_peripheral.c. That prevents
lll_conn_rx_pkt to call any Radio setup related function that touches
NRF_RADIO->SHORTS. NRF_RADIO->SHORTS are assigned in radio_switch_-
complete_XXX functions, hence any change operation on the register done
before is overwritten.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.
Fixes#44108
Signed-off-by: Yuval Peress <peress@google.com>
Add initial support for Periodic Advertising Data fragment
operation support.
This commit is limited to detection of partial data if used
before Periodic Advertising is enabled, which will lead to
HCI error reason of command disallowed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the deprecated BT_WHITELIST Kconfig option. Also,
remove a mention of the deleted bt_conn_create_auto_le API.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When resolving collision if ticks_slot_window is set for
either of the ticker then skip and such ticker be
rescheduled outside the collision within the
ticks_slot_window.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Allow to cancel a firmware update in DOWNLOADED state by writing a
NULL byte as described in the Firmware Update object version 1.1
(urn:oma:lwm2m:oma:5:1.1). Keep object version 1.0 mechanism with
an `empty string`.
Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
[140/235] Building C object zephyr/subsys/bluetooth/controller/
CMakeFiles/subsys__bluetooth__controller.dir/ll_sw/ull_sched.c.obj
In file included from zephyr/subsys/bluetooth/controller/ll_sw/
ull_sched.c:28:
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:
In function 'lll_adv_pdu_linked_next_get':
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:8:32:
warning: implicit declaration of function 'MROUND'
[-Wimplicit-function-declaration]
8 | #define PDU_ADV_MEM_SIZE MROUND(PDU_AC_LL_HEADER_SIZE + \
| ^~~~~~
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:12:11:
note: in expansion of macro 'PDU_ADV_MEM_SIZE'
12 | PDU_ADV_MEM_SIZE - \
| ^~~~~~~~~~~~~~~~
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:197:9:
note: in expansion of macro 'PDU_ADV_NEXT_PTR'
197 | return PDU_ADV_NEXT_PTR(pdu);
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
In the stack both unacked_len and send_data_total track the amount
of data for retransmission. send_data_total actually accounts the
total bytes in the buffer, where unacked_len is used to control the
retransmission progress.
Using unacked_len is sometimes reset to 0, this can lead to more data
being allowd in the send_data buffer. In worse case this can cause
depletion of the net buffers, causing a stall and crash of the connection.
The value send_data_total actually accounts the total amount of data in
the send_data buffer, so it is the proper value to used in the
tcp_window_full function.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Rework instant based procedure complete event generation to be
held until after the on-air instant has elapsed, to have
conditional compilation around the code where the event
generation be held or immediately dispatched so that it
improves readability.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix instant based procedure complete event generation to be
held until after the on-air instant has elapsed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The L2CAP channel section is sorted lexicographically. Make sure
that ATT fixed channel will be placed as the last one to ensure
that SMP channel is properly initialized before bt_att_connected
tries to send security request.
Fixes#45820
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
If peer sents invalid value in DLE request or response just ignore
those and keep using old values when calculating effective DLE.
This was affecting following qualification test cases:
LL/CON/PER/BI-10-C
LL/CON/PER/BI-11-C
LL/CON/PER/BI-12-C
LL/CON/CEN/BI-07-C
LL/CON/CEN/BI-08-C
LL/CON/CEN/BI-09-C
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
In the function tcp_send_data, the variable conn->unacked_len in copied
into a local variable pos. This value is only used in one location and
used mixed with the original conn->unacked_len.
This fix removes pos and switches to use conn->unacked_len everywhere
to reduce the chance of confusion. This does not functionally change the
code.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Terminate connection when Connection Update with instant in the past
Fix type re. win_offset calc in conn update ind pdu decoder
Remove feature bit on unsupported in peer
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Upon collision either the error code for different procedure
collision or same procedure collision must be transmitted,
which is fixed in this PR. Previously always the error code
for same procedure collision was sent
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Add Extended Advertising Type validation when associated
Periodic Advertising is enable, and Extended Advertising
set is re-configured to other advertising types.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There is an error. CTE request control procedure can be run in single
shot or periodic mode. In case of run in single show, it is not
disabled after completion.
The code responsible for the disable was deleted by commit:
ac7d0506f88508e7440288c1ec4319a9f7d0ad44.
The cte_req.is_enabled should be set to zero if the CTE request
completes and cte_req.req_interval is zero.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There was missing code responsible for handling of unexpected response
for CTE request. The commit adds code that will terminate connection
in case a peer device reposnes with unexpected control PDU that is not
a remote procedure reques.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The CTE request procedure should be enabled only if a peer supports
CTE response feature. That information can be obtained by feature
exchange procedure. If there were no feature exchange then CTE
request feature may be disabled if a peer responses with LL_UNKNOWN_RSP
for a CTE request.
The implementation of ll_df_set_conn_cte_req_enable was checking if
CTE response feature is supported only when there was feature exchange.
There was missing possibility to stop CTE request if a peer responded
with LL_UNKNOWN_RSP for an earlier CTE request.
The commit changes the implementation of ll_df_set_conn_cte_req_enable.
The CTE response feature check is moved to ull_cp_cte_req function,
because it belongs more to control procedure than to function that
handles Host request to start the procedure.
Second change is related with use of conn->llcp.fex.features_used.
It stores information about features supported by peer. It does
not depend on execution of the feature exchange control procedure.
By the way, there were removed else statement in ll_df_set_conn_cte_-
req_enable because it was not needed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There was missing handling of LL_UNKNOWN_RSP in CTE request control
procedure.In case there is a pending CTE request and peer responses
with LL_UNKNOWN_RSP then Host should be notified with HCI_LE_CTE_-
Request_Failed event. The pending CTE request procedure should be
completed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix handling of AD Data set with operation type of
unchanged data with respect to invalid parameter and
state of Periodic Advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix nRF51x series advertising channel PDU S1 byte
configuration regression, that causes corrupted advertising
PDUs being reported to Host, by adding the missing bits_s1
local variable initialization.
Regression introduced in commit 1dcbe73cc8 ("Bluetooth:
controller: radio: add setting of S1 byte in radio packet").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement POLLOUT for stream sockets, based on newly introduced tx_sem
functionality of the TCP stack.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Utilize the TCP semaphore monitoring transmit status at the socket
layer. This allows to resume transfer as soon as possible instead of
waiting blindly.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Instead of sending ZWP from send context, when it is detected that
window is full due to zero-window, implement a proper persistent timer,
that is scheduled once zero-window is detected. The timer is responsible
for sending ZWP to the peer and is canceled once non-zero-window is
notified by the peer.
Additionally, in case peer reported zero-window, do not trigger
retransmission from net_tcp_queue_data(), as it won't be transmitted
anyway by the stack.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The semaphore is reset when TCP layer would normally reject transfer
request (either due to TX window being full or entering retransmission
mode). Once data is acnowledged, or the reatransmission is done, the
semaphore is set again.
Upper layers can monitor the semaphore with `k_poll()` instead of
waiting blindly before attempting to transmit again.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Current implementation of ll_sync_create_cancel does not allow to stop
synchronization after ull_sync_setup is called. When that is done,
sync->timeout_reload is not zero and the ll_sync_create_cancel will
return BT_HCI_ERR_CMD_DISALLOWED. That means the Controller is able to
cancel periodic advertising synchronization only in period between
call to ll_sync_create and reception of AUX_ADV_IND that has SyncInfo
field.
The Controller should be able to cancell synchronization until first
AUX_SYNC_IND PDU is received and host notified about synchronization
established.
Complete information about synchronization status is provdied by two
ll_sync_set members: node_rx_sync_established and timeout_reload.
These two members of the structure were used in ll_sync_create_cancel
function to do a proper cancel and cleanup.
The node_rx_sync_established member was not cleared when sync was
established or expired. That was required to get a proper information
about synchronization state.
Besides that, to avoid race condition between ll_sync_create_cancel
and ull_sync_established_report, the latter function was extended
to check if cancel operation or sync lost has happened.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove experimental label from Advertising Extensions and
Periodic Advertising features in the Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This PR sets the refactored LLCP as the default instead of legacy
so that more people will use this, giving us more feedback
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Sometimes it is important to know when the backend fails to send out
data because no memory / buffers are available. Return -ENOMEM in that
case.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Enable HAS shell only if preset support is enabled. Otherwise there are
no functions yet that can be exposed if the preset support is disabled.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fix unused `ccc_cfg_changed` function warning that shows up when
preset support is disabled.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Introduce invisible helper symbol that could simplify and make more
readable condiitional code checks.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Update the users of the "write" callback in the
bt_gatt_subscribe_params to use the new "subscribe" callback instead.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Add a "subscribe" callback in the bt_gatt_subscribe params, and
deprecate the "write" callback.
The purpose of this is to be able to return the subscription
parameters in the callback. The write callback
- (in principle) returns write parameters
- in fact returns nothing - the pointer is set to NULL
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Direction finding functionality does antenna switching during CTE
reception in AoA mode and CTE transmission in AoD mode. Antennas are
switched according to user provided antenna switch pattern. If a CTE
length is enough to exhaust all antenna ids in a switch pattern then
radio should loopback to reference antenna and continue from switching
from that. Current implementation loops back to antenna that is just
after reference antenna in the switch pattern.
The commit fixes that by insertion of the reference antenna
at the end of switch pattern. Radio will operate as it was before,
it will restart switching from the same index in a switch pattern.
At the same time reference antenna will be inserted into the loop
if switching pattern is exhausted. That also means, the maximum
number of antenna ids in a switch pattern has to be decreased by
one.
The commit also fixes lower bound in the BT_CTLR_DF_MAX_ANT_SW_PATTERN-
_LEN that should be equal two. It was set to three, because in the
past the antenna at index zero was used for reception of a PDU.
Now this antenna ID is provided by device tree configuration.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The SYNC_STAT_READY_OR_CONT_SCAN state into two: SYNC_STAT_READY
and SYNC_STAT_CONT_SCAN. The connected state was used for two
cases:
- synchronization with periodic advertising is already established,
- CTE type is wrong but periodic advertising list is used to filter
synchronized devices.
In the past states were connected because there was only one difference
between them. In case of sync already established, Controller generated
sync report notification to host.The sync was not terminated when
Controller was about to continue search for other periodic advertiser.
The state was split because now Controller terminates sync ticker and
continues search for other periodic advertised. The split improves
readability and makes code easier to understand.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In case of use of filtering based on: periodic advertising list and
CTE type, the synchronization can hang. That is possible if a periodic
advertiser uses wrong CTE type. In such situation the sync is not
released in ull_sync_done call. What more the sync->timeout_reload
is not cleared and Host is not able to cancel the synchronization.
The periodic advertising is in a semi-sync-established state.
There are no reports send to Host. Host can't use the sync set to
synchronize with other device. It is only able to terminate the
sync (call to ll_sync_terminate).
To fix the issue following changes should be applied:
- isr_rx_adv_sync_estab should call isr_rx_done_cleanup
with sync_term parameter in case the sync_ok isn't SYNC_STAT_ALLOWED.
In any case the CTE type is wrong, no matter is the periodic
advertising list filtering is enabled or not.
- ull_sync_established_report should set sync->is_term to true
in case the CTE type is not allowed. That change is required for devices
that do not support Direction Finding Extension. For those devices CTE
type based filtering is done in ULL by ull_sync_established_report
function. The sync->is_term should be set unconditionally, hence is
moved up in the function.
With these two changes done, ull_sync_done function will execute
sync_ticker_release in case the CTE has wrong type. ULL, depending on
notifications prepared by ull_sync_established_report, will follow up
on sync termination if required.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Return `-ENOTSUP` on calls to device_runtime functions if the underlying
device does not support power management.
Fixes#45648.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
By default the newlib does not compile with %hhu processing,
to avoid turning on additional options for newlib compilation
this commit changes formatting string to use %hu instead.
The commit fixes problem with malformed version string being
returned, by smp_svr, when CONFIG_NEWLIB_LIBC=y is set together
with CONFIG_NEWLIB_LIBC_NANO=y.
Fixes#45261
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Modify the function slightly to take a different
argument, and add more debugging to the function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Ensure that we don't attempt to send any data to the
controller if `can_send` is not set, and return an
error code to the application instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Besides checking for the rx/tx pointer, we now also validate
the can_send and can_recv values to ensure that we do
not setup a useless data path.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Set the can_send to true and can_recv to false for broadcaster.
Set the can_send to false and can_recv to true for the sync
receiver.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of relying only on the `tx` and `rx` qos pointers,
we extract further information from the
bt_hci_evt_le_cis_established event to properly determine if we
can actually send or receive data.
This is useful to help determine which data paths to setup,
and whether to reject requests to send.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If CONFIG_SHELL_STATS is disabled, shell->stats is NULL and
must not be dereferenced. Guard against it.
Fixes#44089
Signed-off-by: Alexej Rempel <Alexej.Rempel@de.eckerle-gruppe.com>
Remove call to bt_audio_stream_iso_listen which
calls bt_iso_server_register for the unicast client.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bluetooth ISO shell module now supports the newly
added central and peripheral ISO configs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move a few unicast functions around so that we reduce the number
of #if defined guards. No code has changed, but a single
prototype has been added.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add two new Kconfigs: BT_ISO_CENTRAL and BT_ISO_PERIPHERAL
that is used to do central or peripheral only builds,
similar to the BT_CENTRAL or BT_PERIPHERAL Kconfigs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
output of ztest is not easy to ready with many testsuites running in
sequence, make it a bit more readable.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
There is a race condition in a multicore system that happens when the
idle thread in a CPU checks if the state was forced, if not it will
call the policy manager. If a secondary core forces a state after that
this point the value returned by the policy will be rewritten.
Another case is, if a state is forced while a CPU is sleeping,
when this CPU resumes, the forced bit is cleared and the forced state
is never be used.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
In pm_system_suspend there is a goto label that is supposed to be used
to do cleanup before exit the function but it is not doing anything
right now. Just remove it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This extends client implementation with Read Presets Request operation
support.
The implementation can maintain up to BT_L2CAP_TX_BUF_COUNT control
point requests so that user could perform/queue another Control Point
Operation if one is ongoing. E.g. preset can be selected from Read Preset
Response notification context or perform multiple operations if EATT
enabled.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The periodic CTE_REQ disable command, requested by Host, may be locked
until connection is dropped due to missing CTE_RSP from peer device.
That is caused by implementation of CTE_REQ disable and CTE_REQ
control procedure handling.
The procedure is marked as active when CTE request was send to peer
device. It is marked as inactive after completion of the procedure.
That caused locking of CTE disable on a semaphore.
The BT 5.3 Core Spec, Vol 4, Part E, section 7.8.85 says the HCI_LE_-
Connection_CTE_Request_Enable should be considered active on a conne-
ction from when Host successfully issues the command with Enable=0x1
until a command is issued with Enable=0x0 or single LLCP CTE request
has finished (CTE_Request_Interval=0x0). Also there is a clarification
from BT SIG that the command with Enable=0x0 does not affect any
initiated LLCP CTE request. That means Controller is allowed to finish
already started procedure and it is not allowed to start new LLCP CTE
request procedure after completion of the command with Enable=0x0.
Taking that into account, there is no need to synchronize ULL and LLL
in regard of disable the LLCP CTE request while the procedure is
pending. Controller is free to complete the procedure or terminate it.
The change removes all code related with cte_req.is_active, disable
callback and waiting of ULL for LLL to finish the LLCP CTE request.
The ULL will complete the HCI_LE_Connection_Request_Enable with
Enable=0x0 immediately. In case the procedure is disabled in before
the response arrives, then further processing of the response is
dropped and the procedure context released.
The context is not released by the code responsible for disable
handling, to have single place where it is done.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There is an error in the condition that checks if new CTE_REQ should
be started after end of connection event. The condition verifies if
counter req_expire is set to zero. Then new CTE_REQ is started
irrespectively to CTE_REQ being disabled.
req_interval is used to store information if the CTE_REQ is:
- periodic, then value doesn't equal zero,
- single shot or disabled, then value equals zero.
The condition should verify if the req_interval is not zero and
req_expire is not zero. The second part of the if condition is
required to avoid starting next CTE_REQ until last one has been
completed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Some of control procedures has set ctx->rx_opcode in rp_comm_tx
function to values that state there is an expected PDU.
This is not always true. In case of procedures that do not expect
any response from remote device, the ctx->rx_opcode should be set
to PDU_DATA_LLCTRL_TYPE_UNUSED.
In the worst cases scenario, when the same control procedure
is executed locally and remotely, correct response PDU may
cause an assertion in ull_cp_rx. It could happen because
of wrong ctx->rx_opcode value. A packet with opcode that is
set in remote and local control procedure context rx_opcode
will be treated as expected value for both. That is a situation
that cannot happen.
The commit changes the assignments of rx_opcode to fix the problem.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
If the echo flag is disabled the cmd_buff isn't printed and the
characters in it must not be counted in this function.
Signed-off-by: Gerhard Jörges <joerges@metratec.com>
Adds a check that number of records to be encoded does not exceed the
maximum limit configured through Kconfig.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
This commit fixes the build errors for the testcases in
the tests/bluetooth/init folder
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
The tests/bluetooth/ctrl_user_ext test fails due to
compilation errors, which are fixed with this PR
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Make use of the status field, reported by TCP, in the socket receive
callback. This allows to differentiate a graceful connection shutdown
from actual errors at TCP level (transmission timeout or RST received).
In case of error reported from TCP layer, set a new SOCK_ERROR flag on
the socket, and store the error code in the net_context user_data.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Make use of the status argument in the recv_cb() callback function -
instead of blindly reporting ECONNRESET whenever TCP context is
dereferenced, indicate whether an actual error condition happened (by
setting respective errno value) or a graceful shutdown took place (by
setting status to 0).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Previous check in the if-statement would never allow to send last
segment if msg->len + 2 == MTU * x.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Added macro to test that a value falls within a defined range, including
the provided end points.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Get actual keys from references when PSA crypto is enabled.
A more secure method should be implemented once 802.15.4 platforms
support other than clear text keys.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Remove NET_TCP_BACKLOG_SIZE from KConfig and from test,
because it's not present anymore in current version of TCP stack.
Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
This allows an application to inspect a mcumgr img upload command to
provide additional information for acceptance or rejection of it, and
makes the previous private version compare function public so that
application code can call it.
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
Enable ZTEST_DO_THE_SHUFFLE to shuffle the order tests are ran.
Additional configs ZTEST_DO_THE_SHUFFLE_SUITE_REPEAT_COUNT
ZTEST_DO_THE_SHUFFLE_TEST_REPEAT_COUNT specify the number of times
the test or suite is executed.
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
This allows an application to inspect a mcumgr file access command and
either allow it or deny it with a result code.
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
After introducing SO_SNDBUF socket option, a possible deadlock situation
slipped into the TCP implementation. The scenario for the deadlock:
* application thread tries to send some data, it enters
net_context_send() which locks the context mutex,
* internal context_sendto() blocks on a TX packet allocation, if the
TX pool is empty rescheduling takes place,
* now, if at the same time some incoming packet has arrived (ACK for
example), TCP stack enters tcp_in() function from a different
thread. The function locks the TCP connection mutex, and tries to
obtain the SNDBUF option value. net_context_get_option() tries to
lock the context mutex, but it is already held by the transmitting
thread, so the receiver thread blocks
* when TX packet is available again, the transmitting thread unblocks
and tries to pass the packet down to TCP stack. net_tcp_queue_data()
is called which attempts to lock the TCP connection mutex, but it is
already held by the receiving thread. Both threads are in a deadlock
now with no chance to recover.
Fix this, by obtaining the SNDBUF option value in tcp_in() before
locking the TCP connection mutex.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Thread network makes no use of Solicited-node multicast addresses,
thereby do no create them on the interface to save multicast address
entries for important ones.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There is a risk of deadlock in case net_if APIs are used from within
net_mgmt handlers as both module APIs are protected with their own
mutexes.
The scenario observed with OpenThread happend when
NET_EVENT_IPV6_ADDR_ADD/NET_EVENT_IPV6_MADDR_ADD events were processed.
The net_mgmt mutex is locked when both, an event handler is being
processed (from a separate net_mgmt thread) and when an event is raised
(for example when a new address is added on an interface). In case a
net_mgmt handler tried to use some mutex-protected net_if API, we could
end up in a deadlock situation - the net_mgmt would wait for the net_if
mutex to release, while some other thread (in this case main during
initialization) could wait within some net_if function, pending on
net_mgmt mutex to be released to notify the event.
Fix this, by preventing net_if APIs from being used from within OT
net_mgmt handlers.
Additionally, simplify the net_mgmt handlers logic, by making use of
additional info provided with an event. Instead of blindy assuming that
recently added address was the last on the list (which might not always
be the case, if addresses are added/removed dynamically), read the
actual address being added from the net_mgmt_event_callback structure.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The audio stream receive callback now contains a
recv_info struct, which contain crucial information
such as timestamps and packet validity.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The values represent an enum, and it makes sense for the
enum values to follow the enum type name, so an
_DIR_ infix was added to the values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The PAC_TYPE_UNUSED would be breaking
enum rules, as it is setting and comparing
a value outside the enum range.
Instead we check if the `dir` field has been
set to SINK or SOURCE.
The reason why this still works, is that
we memset the struct unicast_client_pac
causing `dir` to become 0. This still
does not really follow the rules of enums, but
it is the best we can do without adding another
value to determine if a struct unicast_client_pac
is unused or not, without adding another value to
public enum struct.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Many functions and struct fields had the directory/type
value, but named in different ways and stored in different ways.
This change updates all uses of it to use the same name
and type.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The enum bt_audio_pac_type does not fully
represent the what the value is used for.
The typical use of it is not for just published
audio capabilities (PAC), but rather describes the
type, or direction, of audio endpoints.
For the unicast client, the type/direction is
relative to the unicast server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The unicast_client_ep_init took a ID value that was
always 0. Moved the initialization to the value to
the function, instead of an argument. The value
is only used for the unicast server, so it can
probably be removed from the endpoint
struct for unicast clients only. To be optimized later.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The endpoint.type field was unused as it was
always LOCAL for the unicast server and always
REMOTE for the unicast client, and the few places
where we actually checked it, we already had a
check for acl->role which gave the same value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The PSM of the first channel in the connection request is used, but the
PSM value is used for all of them on the receiving side.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
There were some errors in the detection of ECRED connection collisions,
so the retry was triggered incorrectly.
The number of channels requested in the retry was wrong in some cases,
using the number of channels from the received request instead of the
sent request.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
This embeds the log message source IDs inside the origin unit
as module IDs in Sys-T messages. This allows Sys-T message
parsers to see where the log messages are coming from.
This is enabled by default if using Sys-T catalog messages as
the collateral XML file contains the information to interpret
the module ID.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Devices using the MCUX FlexSPI flash driver erase their flash too
slowly, causing the usb stack to freeze, and USB DFU utilities to
report a timeout. Enable IMG_ERASE_PROGRESSIVELY for SOCs using the
MCUX FlexSPI driver to prevent this error.
Fixes#45359
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
SDMMC busy wait timeout was incorrectly waiting for
CONFIG_SD_DATA_TIMEOUT microseconds, but should be waiting for
CONFIG_SD_DATA_TIMEOUT milliseconds. Multiply wait value by 1000.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Strictly restrict AD Data length to BT_CTLR_ADV_DATA_LEN_MAX
when there can be free bytes in Advertising PDU with common
extended header format of less that the maximum 64 bytes.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Change bt_audio_broadcast_sink_sync to use an array of pointers
to bt_audio_streams, instead of an array of streams. This makes
the API more flexible, as well consistent with the broadcast
source and unicast APIs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_audio_broadcast_source_create function will now
take an array of stream pointers, instead of an array
of streams. This is to make the API more flexible as
well as more consistent with the unicast API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In bt_audio_unicast_group_create, bt_audio_unicast_group_add_streams
and bt_audio_unicast_group_remove_streams to use an array
of pointers, instead of an array of streams.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This extends implementation with sending Preset Changed
notification/indication when preset changes its availability or is
added or deleted.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The ztest unittest module relies on some headers that fake the real
ones, e.g. <zephyr/arch/cpu.h>. When new header location was introduced,
their path was not updates. This patch fixes this problem and provides
ztest with both, legacy and new include paths so that it can keep
working on both scenarios.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
In a function pu_prepare_instant there is a condition that
checks if there is actual change of a PHY. That condition
was based on ctx->data.pu.tx and ctx->data.pu.rx.
These members store PHY that is or will be used, hence
the condition is wrong. Even there is no actual change in
the PHY, values could be not equal to zero. In such case
the instant value would be set to wrong value.
What more the condition be an 'or' not an 'and' because
one of the values must be different than zero to have the
PHY change and instant different than zero.
After update of the condition, the function call places
must be changed. The ctx->data.pu.c_to_p_phy and
ctx->data.pu.p_to_c_phy are set in pu_prepare_update_ind
function, hence pu_prepare_instant should be called after
that.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
- ISO TX data path for HCI and support for vendor path
- ISO-AL segmentation of framed PDUs
- Insertion of segment headers
- Reconstruction and storing of CIG reference point in ULL
- Calculation and insertion of of Time-Offset
- Exit error spooling in ISO-AL on detecting start
- ISO-AL TX unframed fragmentation
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Signed-off-by: Morten Priess <mtpr@oticon.com>
Add implementation to generate node rx for missing ISO PDUs
and set the status as invalid. This is required for ISOAL to
correctly track the sequence numbers for every SDU interval.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add Kconfig to limit the Primary Advertising Interval and
Periodic Advertising Interval maximum supported values in
the Controller implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The bt_audio_stream_qos function checked if stream->ep was
NULL before checking if the stream were even valid for this
QoS procedure.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When create the CIG for a unicast group, we did not
verify whether stream->iso was NULL before attempting
to use that to create the CIG.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Socket offloading has been in the tree for a while and improved a lot
over time (from a simple define-based API override to a complex
vtable-based solution, supporting mutliple offloaded interfaces). As the
feature is heavily used by certain vendors (Nordic and its nRF Connect
SDK), I propose to move it out of experimental phase.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
None of the common DF configs should depend on using BT_LL_SW_SPLIT.
Added dependencies to it where this was the case.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
These configurations are tighlty coupled to the implementation,
so these should be hidden when not using BT_LL_SW_SPLIT.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Some controllers may support only TXing or RXing CTE.
As all DF features are guarded by BT_CTLR_DF, we need to ensure
that it is possible to select those when only TX or RX is available.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This updates the documentation of bt_gatt_is_subscribed function that
can take a bitfield of BT_GATT_CCC_NOTIFY and BT_GATT_CCC_INDICATE.
This might be useful if one wants to test if peer is subscribed, but
does not matter which method was used.
The gatt.c implementation handles API usage already, because it performs
bitwise AND:
if (bt_conn_is_peer_addr_le(conn, cfg->id, &cfg->peer) &&
(ccc_value & ccc->cfg[i].value)) {
return true;
}
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Adds a log backend that maintains a ringbuffer in coordination
with cAVS HDA.
The DMA channel is expected to be given some time after the logger
starts so a seperate step to initialize the dma channel is required.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
LwM2M engine is blocking new notification send.
Notification or Send timeout trig Reconnect and registration state.
Send/Notification message is blocked if client is not connected.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
In case a connection is encrypted received PDU is decrypted by CCM.
CCM does not encrypt/decrypt S1 byte that stores CTEInfo.
In case of reception of a PDU by encrypted connection there is missing
CTEInfo in a memory where CCM stores decrypted PDU.
The CTEInfo data must be copied from scratch packet.
The commit adds code responsible for copying of the CTEInfo into
target PDU memory.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
When bootstrap is used, the server object shouldn't be autocreated.
Automatically creating object may cause problems after bootstrap
has been done and bootstrap server deletes and creates instances
for server object. In the next boot the auto-created server object
may have clashing server_id with the server object that the
bootstrap-server has created.
Also lifetime wasn't properly added to the registration message from
the server object.
Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
Added return code for for lwm2m_rd_client_start() & lwm2m_rd_client_stop().
lwm2m_rd_client_start() return -EINPROGRESS when start is in progress and
0 for success.
lwm2m_rd_client_stop() return -EPERM when context is unknown and
0 for success.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Previously, the att_mtu_updated callback was only called on initial
connection of the channel or during the MTU Exchange procedure. There
was no way for the application to know that the MTU increased in the
case where the peer initiated the reconfiguration.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Bluetooth Host calculated authentication value correctly only
for data smaller than 255 bytes. If data is larger then
authentication transformation used wrong flags.
Since the issue was symmetric two Zephyr
based devices were able to understand each other. Hence,
other devices like Android or IOS smartphones weren't able
to authenticate large frames and broke communication.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
This complements the Kconfig possibility, and allows setting an
interface as default on runtime. Changing the default interface also
works around limitations when trying to use an offloaded interface
together with a native one.
Signed-off-by: Ole Morten Haaland <omh@icsys.no>
Adding a reference implementation of the Non-Volatile Memory module
needed to join any LoRaWAN network.
This NVM is based on the SETTINGS subsys to store all the required
key to join and communicate on a LoRaWAN network.
Without proper NVM, one may experience errors when using OTAA
to join the network, as the device may violate anti-replay
protection (depending on the version of LoRaWAN).
Signed-off-by: Giuliano Franchetto <giuliano.franchetto@intellinium.com>
Add SDMMC driver to subsystem. SDMMC driver will handle initialization,
as well as SDMMC I/O. SD mode support is currently supported, SPI mode
support is not.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
All SD cards require SD CMD0 (reset) and CMD8 (send IF cond) at boot.
Add this portion of the initialization flow to SD subsystem, as well as
query command to check if card is SDIO.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Fixed the issue when sometimes "update" is not called for the
last RXRDY signal. First, need to reset the signal and only
after that need to call the "update" function.
Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>
Keys' order - bn, n - might differ from the default due to
Length-First Map Key Ordering rules.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
Regenerates the encoder and decoder. Treats integers and floating-point
values as separate entities instead of saying that those are numerical
values. Brings some memory savings.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
Makes possible to write an empty CBOR array if there are no SenML CBOR
records that needs to be written. This came up when trying to delete a
portfolio object instance.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
The peripheral is configured to update the connection
parameters for 5 seconds by default.
There is an abnormal situation with a very low probability.
The central actively disconnects or abnormally disconnects the
Bluetooth connection at the same time.
At this time, the connection disconnection event will be
handled by BT RX.
At this time, sysworkq has sent a parameter update request and
will receive a reply with status = 0x02, because the handle is
invalid at this time.
We can not just cancel work, because work->flag may be
in K_WORK_RUNNING, so work->flag is set to K_WORK_CANCELING
and subsequent conn_cleanup will unable call k_work_rescheduler
successfully.
According submit_to_queue_locked will return ret = -EBUSY.
if (flag_test(&work->flags, K_WORK_CANCELING_BIT)) {
/* Disallowed */
ret = -EBUSY;
As a result, the connection cannot be cleanup correctly.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Added macro SHELL_SUBCMD_SET_CREATE which creates a set of subcommands.
SHELL_SUBCMD_ADD and SHELL_SUBCMD_COND_ADD can be used from any file to
add command to the set. This approach allows to have subcommands added
from multiple files.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Client jump to full registration state if registration update fail.
Update keep already opened DTLS session.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Enabled DTLS session cache for support session resume.
Fixed LwM2M queue mode for close connection and reconnect automatically.
Re-connect will do Registration update before it send queued data.
Session resume is helping a case when NAT change address and cause less
network traffic.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
When sending 2 or more confirmable message before first one is
writed to socket all messages use same coap pending structure.
Now coap_pending_init() set data pointer which lock allocation
by each call.
Using data pointer for detecting free is more stable than timeout.
Timeout is initialized only before first socket send. Queued packet
may be triggered later than other and may cause that same block is
allocated multiple time.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
The audio stream should be detached from the endpoint
when the endpoint goes into the releasing state, instead
of the idle state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
ase_process had a check for the IDLE state, but the
check did not do anything, so was removed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The releasing state does not trigger any stream ops,
but will be a no-op case to avoid the error log
message.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Terminate connection with a MIC failure if an unexpected control PDU
is received during the Encryption Start procedure.
Add a greedy option to pdu_is_expected() to make sure the procedure
processes all unexpected control PDU in all cases.
Add unit test inspired by Bluetooth Qualification test
LL/SEC/CEN/BV-14-C,
Central Receiving unexpected PDU during encryption start
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Add support for both LL_REJECT_IND and LL_REJECT_EXT_IND when waiting
for the the response to the LL_ENC_REQ and LL_START_ENC_REQ.
Add unit test to test both LL_REJECT_IND and LL_REJECT_EXT_IND as
responses to LL_ENC_REQ.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Chose correct rejection PDU based on features supported on remote peer
when rejecting due to missing LTK.
Update unit test setup with faking that a feature exchange procedure
has run.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Terminate connection with a MIC failure if an unexpected control PDU
is received during the Encryption Start procedure.
Add unit test inspired by Bluetooth Qualification test
LL/SEC/PER/BI-05-C,
Peripheral Receiving unexpected PDU during encryption start
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
This adds suport for validation of received PDUs before they are
pass further to LLCP state machines. If PDU size is invalid it is
rejected with LL_UNKNOWN_RSP.
This was affecting following qualification test cases:
LL/PAC/PER/BI-01-C
LL/PAC/CEN/BI-01-C
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Introduce TLS socket options, which allow to configure session caching
on a socket.
The cache can be enabled on a socket with TLS_SESSION_CACHE option.
Once cache is enabled on a socket, the session will be stored for re-use
after a sucessfull handshake. If a socket is attempting to connect to a
host for which session is stored, the session will be resumed and mbed
TLS will attempt to use a simplified handshake procedure.
The server-side management of sessions is fully controlled by mbed TLS
after session caching is enabled on a socket.
The other TLS_SESSION_CACHE_PURGE option allows to clear all of the
cache entries, releasing the memory allocated for sessions.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In 92d8329d5b a new DT property was introduced to set the WQ priority
of the instance. The fallback value when the property was not present
was arbitrarily set to <0 PRIO_PREEMPT>.
The problem is that this value is actually changing the behaviour for
the code that is not explicitly setting the DT property, breaking in
some cases the existing code.
Move the default value to <0 PRIO_COOP> to give the old code a
consistent behaviour before and after the 92d8329d5b commit.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
When receiving Transaction Start PDU, assure that number of segments
needed to send a Provisioning PDU with TotalLength size is equal to SegN
value provided in the Transaction Start PDU.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
These two options significantly increase the amount of stack space used
by the logging thread as these generate both additional logging and
generate deep stacks themselves. This fixes running the
tests/subsys/logging/log_core_additional/logging.add.log1 test on
riscv32 with THREAD_LOCAL_STORAGE enabled.
Signed-off-by: Keith Packard <keithp@keithp.com>
The thread switching hooks are invoked in the middle of thread
switching, after the out-going thread registers are saved, but before
the in-coming thread registers are restored, and also before
z_thread_entry is called if the thread is just starting.
When the core is first starting, the TLS base register won't be set at
all, so accessing variables will fault. When switching threads, the
in-coming thread TLS base register will not have been restored, so the
z_tls_current value will end up getting the out-going thread instead.
To fix this, switch from k_current_get() to z_current_get().
Signed-off-by: Keith Packard <keithp@keithp.com>
Instead of waiting one connection interval, as a result of the state
change, perform the check for instant already on reception of
CONNECTION_UPDATE_IND
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Compile out misc. members not used when Connection Parameter Request
is not supported.
Implement missing tests re. unsupported features in CU/CPR procedure
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Instead of using a fixed fin timeout, compute it based on the number
of retries. Fixes issue found by PR 44545.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Bluetooth Mesh uses tinycrypt library for security related
algorithms. This PR encapsulates tinycrypt dependency within
one file to make the current implementation more portable.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The function setsockopt() option TLS_CIPHERSUITE_LIST
allows the user to set a specific list of ciphersuites
when using the Zephyr native + Mbed TLS stack. However, the
list provided was not actually being used later for
handshaking.
This adds the missing calls to mbedtls_ssl_conf_ciphersuites()
to use the list provided. If none was provided, fall back
to the default list as determined by Mbed TLS from Kconfig
values.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.
Fixes#44108
Signed-off-by: Yuval Peress <peress@google.com>
When a running procedure receives a REJECT or UNKNOWN_RSP PDU that is
not an expected part of the procedure flow this leads to termination
of the connection
This affects procedures:
CU/CPR, CTE, PHY, PING, DLE, FEX, VEX, CHMU
Unit tests are updated to cover the updated behaviour.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Add all information from the ISO established events
and provide the information in the get_info function.
The use cases of each field heavily depends on what
the ISO streams are used for.
Most, if not all, of the field can be used by the
higher layers to improve quality and/or reliability
of e.g. audio streams that use ISO.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is potential buffer overflow in pb adv.
If Transaction Continuation PDU comes before
Transaction Start PDU the last segment number is set to 0xff.
The current implementation has a strictly limited buffer size.
It is possible to receive malformed frame with wrong segment
number. All segments with number 2 and above will be stored
in the memory behind Rx buffer.
Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
Rewrite the entire Procedure Response Timeout mechanism.
Use two separate timers for local and remote initiated procedures.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
As per bluetooth spec Vol. 6 part B section 5.3 we need to terminate
the connection under given situation
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
BT Core spec 5.3 Vol 6, Part B section 2.4.23 LL_PHY_UPDATE_IND says:
"If both the PHY_C_TO_P and PHY_P_TO_C fields are zero then there is no
Instant and the Instant field is reserved for future use."
Fields that are reserved for future shall be filled with zeros.
New LLCPs implementation didn't handle this case and set the instant
as if there were a PHY change. That caused qualification tests to fail.
The commit fixes the issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Previously, if a callback was set for notifications, they would always be
sent over unenhanced ATT.
The nfy_mult_data was bigger than the buffer user_data and we were this
overflowing the buffer when setting the tx callback user_data. Now the
data is stored separately and only a pointer to it is added to the
buffer user_data.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
This will generate profile data that can be analyzed using gprof. When
you build the application (currently for native_posix only), after
running the application you will get a file "gmon.out" with the call
graph which can be processed with gprof:
gprof build/zephyr/zephyr.exe gmon.out > analysis.txt
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Validate `id` so that `bt_dev.irk[id]` cannot result in an out-of-bounds
access.
This fixes coverity report 239569.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The Tx interval is now calculated at the beginning
of the Tx test and the next transmission is
triggerd by the switch timer instead of event
timer. This fixes a corner case issue when
timer rollover.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
When Host calls HCI_LE_Connection_CTE_Request_Enable with cte type
set to AoD with 1us slots or AoD with 2 us slots, the Controller
verifies if peer device supports Antenna Switching During CTE
Transmission (AoD) feature.
That is wrong because the feature is marked as optional when send
to peer, so it shall be igonerd by remote device.
There are no means to check if peer device supports particular
CTE type, hence the check has to be removed.
The check causes enable CTE REQ procedure to fail after feature
exchange has happened.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The CTE request procedure can be run in periodic and non-periodic mode.
In periodic mode it stays enabled until Host call HCI_LE_Connection_CTE-
_Request_Enable(Enable=0x0).
In non-periodic mode the command is disabled after completion,
LL_CTE_RSP is successfully received.
There is missing disable of the procedure in the current code,
so Host is not able to run the command HCI_LE_Connection_CTE_Request_-
Enable(Enable=0x1) again without explicit call to HCI_LE_Connection_-
CTE_Request_Enable(Enable=0x0).
The commit adds missing code responsible for disable of the procedure.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
...content formats
In case that SenML CBOR or SenML JSON are both disabled there is need to
use plain CBOR as backup.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
There is errata clarification (Errata ID:18700)
about subscriptions on fixed group addresses.
It is possible to subscribe models on non primary elements
on any fixed group address except all nodes address.
Devices should be able to receive messages on fixed addresses
even if they do not support the feature
to which the fixed group address belongs.
Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
Increase the default TX stack size for BT_CTLR && BT_LL_SW_SPLIT,
as we have seen applications/samples nearing and even reaching
the stack size, causing stack overflows. This is especially
true if CONFIG_FPU=y which takes 96 bytes of the TX stack.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix assert on LL BIG terminate call before BIG sync is
established. Assert was caused due to duplicate calls to
release stream contexts, once in LL BIG terminate function
then when releasing the HCI BIG sync failed to be
established node rx was being released.
Use iso_broadcast and iso_receive samples, power cycle the
iso_broadcast device when iso_receive sample is waiting for
BIG sync to be established, iso_receive sample will perform
a BIG sync terminate that leads to the assert.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When threads are in more than one state at a time, k_thread_state_str()
returns a string that lists each of its states delimited by a '+'.
This in turn necessitates a change to the API that includes both a
pointer to the buffer to use for the string and the size of the buffer.
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This updates the default proxy filter size to 16. Previous value of 3
is too less for the most practical uses and demos. The default proxy
filter type is accept list type and in this mode proxy server rejects
incoming messages from source addresses not in the accept list. The
addresses are added to the accept list when proxy client sends
messages to unicast addresses or manually adds certain addresses to
the accept list. Once this list is full more addresses cannot be added.
This also updates the default network message cache size to 32. The
network message cache helps in preventing duplicate messages getting
repeatedly relayed and helps in reducing unnecessary network traffic.
Previous value of 10 is quite less for most usecases and makes the
node appear to generate much more traffic in mixed network. The
updated value should suffice for most use cases.
Additional explannation is added in Kconfig to help users understand
the significance of this setting.
These two changes result in 176 bytes of additional RAM usage in mesh
samples.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
The "Database Out Of Sync" error response shall only be sent once on
each channel after a client becomes change-unaware.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
This fixes the case where the client reads the DB hash without reading
another attribute first after becoming change-unaware.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Changes the media_proxy API to pass structs by reference instead of by
value.
Also pass structs by reference in internal functions in media player
and in media controller test.
Add pointer checks to the public API implementation where
user/application code provides structs by reference.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the search parser to not modify the supplied parameter.
This will allow the parameter to be made 'const'.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Commit dc812539b8 ("Bluetooth: MPL: Fix use of uninitialized
command.param value") fixed the use of a potentially un-initialized
variable, by
- splitting a log statement, so that the variable is only
logged (=used) if in use (and therefore hopefully also initialized)
- setting the variable to zero if not in use
The second part is not required, as all other code in the module
checks whether the variable is in use before using it. And this
second part also prevents the parent struct from being made 'const'.
This commits removes the zeroing of the variable, so that the struct
can be made 'const'.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Changes the media control client API to pass structs by reference
instead of by value.
Also change internals of test to pass struct by reference.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the definition of the set extended advertising data command to be
a variable array instead of hardcoded to the maximum length. This
conforms to the definition from the Bluetooth specification and allows
the corresponding code to be slightly cleaner.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
In some cases (for examples when offloaded socket implementation does
not implement TLS functionality) it could be desired to create a native
TLS socket with an underlying offloaded socket.
This cannot be achieved with SO_BINDTODEVICE option only, as TLS socket
type is not really associated with a particular interface - it either
has to be offloaded, or a fully native socket is created (native TLS on
a native interface).
In order to address the problem, introduce TLS_NATIVE socket option.
This option instructs the socket dispatcher layer to create a native TLS
socket. As with the socket dispatcher the underlying socket
implementation is not decided during TLS socket creation, therefore it's
possible to use SO_BINDTODEVICE to choose either native or offloaded
interface for the underlying socket.
Additionally remove NET_SOCKETS_OFFLOAD_TLS Kconfig option, as it's no
longer needed with an runtime option to select whether to offload TLS or
not.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add an intermediate socket implementation called socket dispatcher. This
layer can be used along with the socket offloading, to postpone the
actual socket creation until a first operation on a socket is executed.
This approach leaves an opening to bind a socket to a particular
offloaded network interface, and thus offloaded socket implementation,
using SO_BINDTODEVICE socket option. Thanks to this, it is now possible
to use multiple offloaded sockets implementations along with native
sockets, and easily select which socket should use with network
interface (even if it's an offloaded interface).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Adds a Kconfig option for setting the Config Client and Health Client
timeout. Updates updates the default for Config Client to allow
reception of full sized message from a similar peer device at zero hops.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Commit f7c4fe6778 ("shell: optimize history storage a bit") forgot
to distinguish between the newly allocated history item and the previous
one, causing havoc on ring buffer wraparounds with excess padding.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
if CONFIG_LOG_TAG_MAX_LEN is 0, then a warning would be generated
on the MIN macro always being false, but as
CONFIG_LOG_TAG_MAX_LEN is a constant, then it is better to just
compile out the function if it's 0.
Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
The commit adds change to image management list where "<???>"
will be returned as version string in case when version to string
conversion fails.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The ull_to_s, which is used to covert ints to string, has been
replaced with snprintf.
Above also fixes a bug where ull_to_s has been given INT_MAX as allowed
output string, while it should be given maiximum allowed buffer size.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Commit removes mgmt_streamer_reset_buf from mcumgr lib,
and supporting Zephyr function zephyr_smp_reset_buf.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Add API to add devices to a power domain in runtime. The number of
devices that can be added is defined in build time.
The script gen_handles.py will check the number defined in
`CONFIG_PM_DEVICE_POWER_DOMAIN_DYNAMIC` to resize the handles vector,
adding empty slots in the supported sector to be used later.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This adds initial support for presets that includes API functions
to register/unregister presets and Read Preset Request control point
handler.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Adds a lock around the output to prevent corruption, and sets the buffer
size of the output to size of the output buffer. This fixes the
corrupted log output as process() may be called from multiple contexts
from different CPUs. A background log processing thread may race against
the panic ISR log context also calling process() on an SMP system.
Additionally sets the buffer size to 80 such that the cavs trace_out.c
functionality and lock are useful for more than one character at a time
greatly reducing the chances of garbled output in a printk and log race
but does not entirely prevent it. CONFIG_LOG_PRINTK=y should be used
to avoid all races.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
This allows an application to inspect a mcumgr os reset command and
either allow it or deny it with a result code.
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
Update client tx timestamp right after message is added to list
of outgoing messages. Delay between when message is generated and
sent is negligible. This will prevents bugs that appear when using
queue mode, where internal engine logic depends on timestamp being
updated when message is generated.
Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
Cleanup in kconfig options in preparation for adding a
frontend that will use dictionary mode.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
HCI_LE_CTE_Request_Failed may be generated in case received LL_CTE_RSP
PDU didn't contain CTE or if peer rejected the request. HCI function
encode_data_ctrl responsible for dispatching received control PDUs
should not expect a PDU with PDU_DATA_LLCTRL_TYPE_CTE_REQ opcode.
It should never happen. The correct opcode here is PDU_DATA_LLCTRL_TYPE-
_CTE_RSP.
Result of this issue is an assert when LL_CTE_RSP PDU is received
but it does not include CTE.
The commit fixes the problem.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In the case that the peer responds with fewer dcid values than the
number of scid values in the connection request, we would assert or read
past the end of the buffer.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
It is possible that LE CoC channel is in disconnecting state (eg due
to peer sending too many packets) but application is not yet aware
of this (ie disconnected callback was not called) and thus may call
bt_l2cap_chan_recv_complete() to return credits. In this case it
leads to assert in l2cap_chan_send_credits.
It looks like PTS 8.2.1 is able to trigger this scenario when
executing L2CAP/ECFC/BI-02-C test.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
The zcbor_bulk_priv.h uses STRINGIFY for some of definitions
and, due to lack of inclusion of the toolchain.h, that was causing
compilation errors when NEWLIB would be selected.
Fixes#44811.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
define test run id and make it available to ztest. This will be used to
verify we are evaluating the same test we have just built and flashed
and that we are not looking at some old output.
Existing code in ztest will use this, and twister will define the run
id.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
PR44014 introduced new pause logic for procedures but PR44297
was merged without being update to use it.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This adds a hash/checksum mcumgr handler to the file management commands
which can be used to get a hask or checksum of a file, and includes
handler implementations for IEEE CRC32 and SHA256.
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
This adds a command handler to the file management mcumgr system to get
the status of a file without needing to return file data (currently
reporting the file size).
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
Now refactored Connection Parameter Request procedure supports
parameter checking, and implements reject_ext_ind on invalid parameters
Updates to TODO description for remaining work
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
First available subcommand is for doing a send operation. Send operation
is supported by the LwM2M version 1.1.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
The event counter value for connection and periodic advertising
events is updated to next value during event preparation (in one
of prepare_cb functions in LLL).
IQ report is prepared after event preparation, so value of event
counter is ahead of the current event value by one, hence it has
to be subtracted.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
HCI_LE_Connectionless_IQ_Report and HCI_LE_Connection_IQ_Report
events has fields that store event counter values: Periodic_Event_-
Counter and Event_Counter, respectively.
Values assigned to this HCI events are taken directly from
lower link layer objects. In case of too slow processing of
HCI events values provided by LLL contexts could be changed before
HCI sends events to Host. That can happen e.g. in case of short
periodic advertising interval and slow UART baudrate.
In such situation event counter values will be corrupted.
To prevent that situation, event counter values connected with
IQ sample reports, has to be stored in node_rx_iq_report when
a report instance is filled in LLL.
This commit introduces required changes.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In order for the code to be more understandable, invert the logic to
decide when to re-trigger the RX work queue and document the approach.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
There is no need to use a k_fifo object to queue the items that are
passed to bt_recv() now that we are using a work queue instead of a
thread, since there is no need for blocking on the actual queue, instead
relying on the fact that work is triggered to know that an item is ready
for processing.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The zephyr_grp log module name was incorrectly named
MGMT_SETTINGS and module registration has been using module name
mgmt_zephyr_basic, which is also incorrect.
Both have been changed to mcumgr_zephyr_grp.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds transport dedicated menu and gathers all transport
options under that menu; each transport gets its own menu, witch
gathers options specific for that transport
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Adds new command that allows to retrieve MCUMGR parameters.
Currently the command returns MCUMGR buffer size and count.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Change CONFIG_BT_RECV_IS_RX_THREAD into a
choice:CONFIG_BT_RECV_CONTEXT with the following options
(names can be discussed further of course):
CONFIG_BT_RECV_BLOCKING
CONFIG_BT_RECV_WORKQ_BT
CONFIG_BT_RECV_WORKQ_SYS
This way users would be able to choose what to run most of
the BLE stack on, they wouldn't be forced to a single model.
We would default to CONFIG_BT_RECV_BLOCKING so that we wouldn't
need to change the system workqueue stack size by default, instead
asking users to do so if they select the CONFIG_BT_RECV_WORKQ_SYS option
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Introduce set/get SO_SNDBUF option using the setsockopt
function. In addition, for TCP, check the sndbuf value
before queuing data.
Signed-off-by: Mohan Kumar Kumar <mohankm@fb.com>
Use shell_print_ctx macro when printing to shall from callbacks.
ctx_shell may not be initialized when callback is called.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
'optval' in setsockopt(..., SO_BINDTODEVICE, ...) was casted explicitly
from 'const void *' to 'struct ifreq *'. Rely on C implicit casting from
'const void *' to 'const struct ifreq *' and simply update variable
type. This prevents unwanted modification of ifreq value in the future.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
This option will be used as default socket priority by offloaded socket
drivers.
Describe how to prioritize native TLS over offloaded TLS (and vice
versa) using sockets priorities.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Make sure that the test rules' `before` function runs before the
suite's. This allows the suite to override any defaults set by the
rule.
Signed-off-by: Yuval Peress <peress@google.com>
Move include paths and add new target_include_directories to support
backwards compatibility:
* /include -> /include/zephyr
example: <irq.h> -> <zephyr/irq.h>
Issue #41543
Signed-off-by: Yuval Peress <peress@google.com>
The IMG_MGMT_UL_CHUNK_SIZE is no longer used to control size of
intermediate buffer used for application image chunk processing,
instead directly request trasport buffer is used.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The echo sentence is now directly copied from request transport
buffer to response buffer, without use of intermediate buffer.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Now the chunk of uploaded file is directly read from the transport
buffer, net_buf, and is no longer copied into intermediate buffer
so the real size of chunk is actually how much the sender could
fit into MCUMGR_BUF_SIZE, less the other fields.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds private, for internal mcumgr use only, utility
function for bulk processing of CBOR map entries.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit switches OS group commands to use zcbor instead
of TinyCBOR for processing SMP requests.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Removes no longer needed elements of struct mgmt_ctxt.
Removes mgmt_ctxt_init, mgmt_streamer_init_reader and init_reader
from struct mgmt_streamer_cfg as they are no longer needed.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit removes cbor_decoder_reader from cbo_nb_reader and
adds zcbor state variable to the structure.
All the code that has been supporting the cbor_decder_reader
has been removed and/or replaced with zcbor/net_buf specific.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Replaces TinyCBOR cbor_decoder_reader with cbor_nb_reader in
SMP processing code.
The SMP source code has been relying on internal elements of the
cbor_decoder_reader and had to be rewritten to use net_buf
structures, that are part of cbor_nb_reader, instead.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
With transition to zcbor, the cbor_encoder_writer structure of
TinyCBOR is no longer used.
This commit replaces the structure with cbor_nb_writer, which
gathers zcbor processing structure with netbuf into one object.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit modifies cbor_nb_writer to handle zcbor.
Proper initialization code has been added to cbor_nb_writer_init.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Name OpenThread version selection option to `OPENTHREAD_STACK_VERSION`
to be able to superseed it somewhere else.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Fix null pointer dereference in Controller when receiving an extended
advertisement and CONFIG_BT_LOG_LEVEL_DBG is enabled.
Signed-off-by: Pieterjan Camerlynck <pieterjan.camerlynck@gmail.com>
This change augments the application object name change notification to
occur prior to the actual name change done by the OTS layer.
Notifying prior to the actual name change makes it possible to inform the
application of the current name of the object as well as the new name.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
Add implementation in Controller to set radio high voltage
to enable support for +3dBm Tx Power in nRF53 Series SoCs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add radio_stop interface that will be called on radio event
done. This interface can be in turn used to perform H/w
dependent cleanup for every Radio event done.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Log an error when allocating a network packet for transmission fails.
This is a problem which can be solved by increasing
`CONFIG_NET_PKT_TX_COUNT`, but is currently hard to diagnose.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
CONFIG_NET_L2_PPP_MAX_TERMINATE_REQ_RETRANSMITS
was not having any impact and
CONFIG_NET_L2_PPP_MAX_CONFIGURE_REQ_RETRANSMITS
was used incorrectly instead for terminate().
Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
Core spec version 5.2 introduced EATT, and multiple ATT channels on one
connection is now possible. The requirements for when a client
becomes change-aware were updated to reflect this.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The CIG was improperly handled by the unicast
client. It attempted to remove the CIG when an ACL
was disconnected, and did not properly use the
cig_reconfigure function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The endpoint will likely be in the idle state when
we first read the ASE state. In that case we have
not yet attached a stream to the endpoint, and
thus should not request the stream to be released when it
is NULL.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds initial support for Hearing Access Service client. The client
performs GATT discovery to find and read HAS related characteristics and
subscribe for characteristic value notifications/indications.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The above mentioned fix attempts to detect the situation when
bt_att_req_alloc() is invoked on the same thread that runs
att_handle_rsp. It attempts to do so by noting the thread that
first ran bt_recv, assuming the same thread will house all calls
to bt_att_req_free. This turns out not to be correct. It is
evident from the call stack provided below that bt_att_req_free
can be called from other threads than the one that runs bt_recv.
Fixes: #43448
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Making sure struct bt_l2cap_chan has absolutely no members related
to dynamic channels.
That way we ensure that there is no overhead for a build where only
fixed channels are used.
It's not enough that the dynamic channel-related members are put behind
ifdefs - they should be completely moved out from the struct definition.
Furthermore, the public l2cap.h header file already has a struct
that's meant to be used for dynamic channels: struct bt_l2cap_le_chan!
However, currently dynamic channel support is a mess - it's a mix
between these two structs. The bt_l2cap_le_chan struct should really
be an extension of the bt_l2cap_chan struct, i.e. the former should
contain as a member the latter.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Remove the custom MQTT logging macros and just use the NET macros
directly. The custom macros provide no additional functionality and the
non-standard naming can cause confusion.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The HPACKED fonts are already declared in header.
Extend drawing routine to allow HPACKED fonts
along with VPACKED fonts.
Signed-off-by: Karol Duda <karol.duda@grinn-global.com>
Signed-off-by: Maciej Zagrabski <maciej.zagrabski@grinn-global.com>
When an int16_t I or Q value was input to IQ_CONVERT_12_TO_8_BIT
the compiler would not make the correct comparison with
IQ_SAMPLE_STATURATED_16_BIT causing saturated IQ samples never
being found.
Signed-off-by: Jakob Krantz <jakob.krantz@u-blox.com>
This is the opesite of the macros to build codec configurations.
As some information was not up-to-date with the adopted
specification this change also includes alignment of the assigned
numbers in the Generic Audio section.
The codec config macros currently in lc3.h have moved from LC3
codec config parameters in the older specification to generic
codec configuration parameters in the adbpted specification.
This is why these additions have been made in the audio.h API
file rather in lc3.h. It is the expectation that lc3.h will be
merged into audio .h at some point.
Signed-off-by: Casper Bonde <casper_bonde@bose.com>
Add a flag that is set when the timestamp is supplied
by the controller when receiving ISO packets.
Previously we used 0 to indicate this, but a timestamp
value of 0 is a valid value, and should not be used
to indicate that it is not present.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the receive flags in the struct bt_iso_recv_info
to a bitfield instead of a single value. This will allow
us to extend the flags with more options.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When option is set whole logs shall be set to minimum
of CONFIG_LOG_OVERRIDE_LEVEL. However, module was not
registered when module specific level was set to NONE.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add a name for the choice of authentication modes so that it
can be default to a certain type in project's Kconfig.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Fix Extended Scan disable and Periodic Synchronization
terminate to cover scenarios where chain PDU reception could
complete while thread context is waiting for the radio event
to be done.
Changes here ensure auxiliary context is not released twice
which is caught as an assertion in flush() when checking for
validity of aux->parent pointer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing return value check when Periodic Synchronization
Auxiliary PDU reception has already been stopped, this can
be due to PDU reception in LLL completing while stop has
been requested.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add additional assertion check in the control path leading
to auxiliary context release to catch regressions that may
lead to duplicate auxiliary context release.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing execution of Tx demux for LOW LAT ULL variant
which caused connection events not being maintained to
transmit the latest Tx Data enqueued while being inside a
connection event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The autoconf.h header is not required because the definitions present in
the file are exposed using the compiler `-imacros` flag.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
When lwm2m_rd_client_stop() was called and immediately
followed by lwm2m_rd_client_start() it leaked the file
handle for existing socket.
Problem can be fixed when rd_client_stop() does not
move state machine to IDLE, but instead DEREGISTER
and then allow state machine to move forward.
I added a blocking wait for rd_client_stop() because
it needs to wait for proper clean up.
I also move couple of lwm2m_engine_context_close() to
set_sm_state() event handler or similarly in lwm2m_engine.c
there was couple of places where context was not properly
cleaned.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Changes parsing of input string args to provide error checking.
This is to prevent unintentional command execution on garbage input
strings.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Fixed wrong initialized base name objed id.
Base name was added to every object instance.
Fix will save message size.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
There was an extra call to llcp_lr_init and llcp_rr_init, which is
removed in this commit
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
llcp_lr_pause()/llcp_rr_pause() only pauses currently pending procedures
in their respective request machines, any future initiations are not
paused, thus they are allowed to run, when the opposite was expected.
Change the procedure pause logic into a global pause on the request
machines them self, this is essence what the per-procedure pause
flag was trying to achieve.
Add new query function llcp_?r_ispaused() to not expose the logic behind
the pause functionality.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Change LLCP TX data pause into using mask to allow for pausing from
multiple different sources - but only once per source
(the underlying TX queue still just has an integer counter).
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
The PHY update procedure may trigger a DLE update in certain
situations
When a limited number of rx buffers is available there may not be
enough for doing the phy update and dle update notifications
at once.
Fixes#41788
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Rewrite ull_cp_rx to handle the following cases:
(1)
Local active procedure
Unexpected local procedure PDU
Remote active procedure
Unexpected remote procedure PDU
=> Invalid Behaviour
(2)
Local active procedure
Unexpected local procedure PDU
Remote active procedure
Expected remote procedure PDU
=> Process PDU in remote procedure
(3)
Local active procedure
Expected local procedure PDU
Remote active procedure
Unexpected remote procedure PDU
=> Process PDU in local procedure
(4)
Local active procedure
Expected local procedure PDU
Remote active procedure
Expected remote procedure PDU
=> This cannot happen
(5)
Local active procedure
Unexpected local procedure PDU
No remote active procedure
=> Process PDU as a new remote request
(6)
Local active procedure
Expected local procedure PDU
No remote active procedure
=> Process PDU in local procedure
(7)
No local active procedure
Remote active procedure
=> Process PDU in remote procedure
(8)
No local active procedure
No remote active procedure
=> Process PDU as a new remote request
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
If the Kconfig BT_EATT_AUTO_CONNECT is enabled (on by default), the
host will try to connect BT_EATT_MAX EATT channels when a connection
to a peer is established.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
bt_eatt_connect may now send multiple credit based connection requests.
Previously it would only send one and thus only allow 5 EATT channels to
be connected.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Fix connectable advertising to not use uninitialized
secondary PHY value to set the max_tx_time and max_rx_time
for a non-extended connectable advertising context.
The symptoms being Data Length Update event being generated
when peer central initiated Data Length Update Procedure
does not change from default 27 byte 328 us values.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Offset the Coded PHY scan window by 1M PHY scan window
duration so that when 1M PHY scan window is less than
scan interval then Coded PHY scan window can utilize the
radio thereafter for its scan window duration. For
example, with 20 ms interval and 10 ms window there can
be 10 ms 1M PHY followed by 10 ms of Coded PHY scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Introduce a timeout to get HCI event buffer when preparing
Extended and Periodic Advertising reports. This will prevent
silent hanging of Controller in case of insuffient Rx buffer
configurations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
LwM2M specification is only mentioning BASE64 encoding but SenML-JSON
specification is talking about BASE64URL encoding.
This change is silently accepting both formats and automatically pads the
data if padding is dropped.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
This fixes Radio Rx when switching back-to-back is
used and device support CTE. For the CTE reception we need to use
PHYEND->DISABLE short instead of END->DISABLE short.
Using NRF_RADIO_SHORTS_PDU_END_DISABLE short handles
both cases.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
Increase the supported maximum simultaneous connection to
250, tested under BabbleSim simulations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update Controller to use uint16_t instead of uint8_t to
allow buffer counts to exceed beyond 255. Also fix pointer
arithmetic from being restricted to uint16_t that prevented
calculating the memory index for large offsets. This will
now allow support for 250 simultaneous connections, limited
by ticker_id type being uint8_t.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add Kconfig dependency to disable use of Force MD feature
when using LOW LAT ULL variant of the Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
NULL structure fields before releasing memory back to pool.
Add assertion check to prevent NULL pointer dereferencing of
node rx.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Getting rid of TODOs that are fairly straight forward to resolve
* introduce role checks in ENC API
* Remove ASSERT on re-rx of LL_VERSION_IND, ignore instead
* in tests/.../ctrl_chmu: rename variable and initialize initial ch map
* in tests/.../mock_ctrl/util.c: Changing TODO into FYI
* in tests/.../helper_features.h update mask and remove TODO comment
* in ull_llcp_remote.c: re-order cases in proc_with_instant switch
* in ull_conn_upd.c: PARAM REQ only uses REJECT_EXT_IND
* in ull_llcp_common.c: in CENTRAL on rx of LL_MIN_USED_CHANNELS_IND
chose to do nothing re. channel map. Update unit test accordingly
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Instead of selecting appropriate HAS_HW_NRF_* options for particular
nRF SoCs (and simulated nRF52 target), set their values basing on
information from devicetree.
Correct also semantics of those options so that they are set only when
a corresponding DT node is enabled. This allows using them directly in
Kconfig dependencies of Zephyr drivers for nRF peripherals. Update
appropriately these dependencies.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
On dual-core architecture the platform time can be not aligned with
radio time. This happens e.g. for nRF53 devices. Unaligned times imply
mulfunction in CSL windows scheduling.
This PR fixes it by adding/subtracting the time offset in functions
which return the plaform time. The changes have no impact on platforms
where the times are the same.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
Add several new functions to the IPC service API:
- ipc_service_get_tx_buffer()
- ipc_service_drop_tx_buffer()
- ipc_service_send_nocopy()
- ipc_service_release_rx_buffer()
- ipc_service_hold_rx_buffer()
This set of function is used to support backends with nocopy capability.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Introduce set/get SO_RCVBUF option using the setsockopt
function. In addition, use the rcvbuf value to set the
tcp recv window.
Signed-off-by: Mohan Kumar Kumar <mohankm@fb.com>
MIPI Sys-T catalog messages are similar to dictionary logging
where an ID is emitted instead of the format string. This allows
the format strings to be removed from the final binary to save
a few bytes. This adds the necessary bits to determine to emit
catalog messages when appropriate.
Note that this implementation copies the argument list as-is
with string arguments stitched together since the format strings
are assumed to have been removed and they cannot be examined
to properly convert the argument lists into catalog message
payloads. Because of this, various build asserts are there to
avoid building for configurations where they are known not to
work.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds a new CONFIG_LOG2_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS
kconfig. If enabled, the log message packages will always have
the indexes of read-only string arguments appended to the package.
This will be selected only by those backends requiring it.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The MIPI Sys-T library can now take a format string with a variable
argument list so there is no need for the temporary buffer anymore.
This saves some stack space in v1 immediate mode.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Whenever we disable Bluetooth we need to clear the supported commands
array, because there are several functions that check whether a
controller is ready to receive a particular command by testing a bit on
that bitfield.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In order to get rid of the duplication of the code that we had until now
in the tree, consolidate the handling of multiple calls to
bt_hci_cmd_send_sync(BT_HCI_OP_LE_RAND, ...) in a single location,
namely in hci_core.
This allows all of the users of this HCI command to use a single
implementation of the iterated sending of the HCI command to fill a
buffer with random bytes.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The commit splits the main mcumgr Kconfigs into primary Kconfig
that collect general mcumgr options for Zephyr (Zephyr specific
commands, transports, and so on), into lib/Kconfig
that collects library options and command groups' Kconfigs.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
LWM2M Client Sample with DTLS enabled fails because TLS_HOSTNAME is set
but MBEDTLS_X509_CRT_PARSE_C is disabled which leads to error
'net_lwm2m_engine: Failed to set TLS_HOSTNAME option: 109'
Add new field hostname_verify to let the application decide if hostname
should be checked.
Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
When connect() is called on a TCP socket, tcp_in() is called with a NULL
packet to start establishing a connection. That in turn leads to a SYN
packet being produced which, depending on the Ethernet driver, may
result in a synchronous transmit of that packet. After that, the
connect() implementation, which at this point is executing
net_tcp_connect() starts waiting to take a semaphore until the
connection timeout is reached. However, if the transmit of the SYN
packet results in a RST packet being returned from the connection
destination (due to there being no listening socket) very quickly on a
local network, the device driver may deliver an interrupt which can
cause the receive path of the network stack to run, resulting in the
tcp_in() of the RST packet via the network RX thread. That can cause
tcp_conn_unref() to be called before the connecting thread has gotten
to the point of acquiring (or failing to) the semaphore, which results
in a deinitialized semaphore being accessed.
This commit fixes the possible race condition by ensuring that the
connection lock mutex is held until after the connection state moves
to "in connect."
Fixes#44186
Signed-off-by: Berend Ozceri <berend@recogni.com>
Until now the whole USB device stack code is located
in the top subsys/usb directory. Move it to own directory
in preparation for upcoming extension and rework of USB support.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit adds the USB_DFU_PERMANENT_DOWNLOAD and USB_DFU_REBOOT and
symbols.When the permanent download symbol is enabled, slot 1 will be
marked as confirmed. With the reboot symbol enabled, the devices
automatically reboots after the download is completed.
The functionality is split into two symbols to allow the automatic
reboot without confirming the image. This enables image confirmation via
another channel. For example via the shell’s Mcuboot commands.
This functionality allows downloading an image to the device without the
user having to interact with the device. It is useful in cases where
ease of use is more important then safety. For example when using USB
download for daily development. This is especially applicable for
devices with a closed case.
The changes were tested on an nrf52840dk. The following line can be used
to build the USB DFU example with the symbols enabled.
west build -b nrf52840dk_nrf52840 zephyr/samples/subsys/usb/dfu \
-d build-dfu -- -DCONFIG_BOOTLOADER_MCUBOOT=y \
-DOVERLAY_CONFIG=overlay-reboot-permanent.conf \
-DCONFIG_MCUBOOT_SIGNATURE_KEY_FILE\
=\"bootloader/mcuboot/root-rsa-2048.pem\"
Fixes#41921
Signed-off-by: Martijn Stommels <martijn@martijnpc.nl>
If NET_IPV4 and NET_SOCKETS_PACKET is enabled, NET_SOCKADDR_MAX_SIZE will
be bigger than the ipv4 address length.
This is a problem when DTLS is used as the address comparison will fail
because of the different length of the received and the stored address.
This is also a problem if NET_IPV6 and NET_IPV4 is enabled and the remote
address is a ipv4 address
Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
Use defines instead of hardcoded strings to avoid future errors if the
values would change.
Signed-off-by: Andreas Pettersson <andreaspettersson95@gmail.com>
Previously, the hash of the firmware is checked while we are
downloading the firmware. This isn't ideal as the validity of
the firmware written into the flash is not verified and can be
corrupted. Furthermore, checking while downloading will have an
negative impact to the download speed as the CPU need to do
more work during the data transfer.
This PR removes the previous verify-hash-while-download
implementation and use the flash_img_check API instead.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
After the firmware is downloaded in hawkbit_probe, a series of
operations are done by using the fact that the conditions of
an if-else statement will be ran until a match.
This patches separate these condition into individual
if-condition for better readability
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Adapt logging to always use static packaging. Runtime packaging
is used only when configuration requires that. Static packaging
significantly speeds up logging when there are string arguments.
Update log_stack test to new stack usage.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The idle thread got an index suffix in #23536 to make it easier to
identify different idle threads on different cores. This looks out of
place on single-core devices when the idle thread is listed next to
other kernel threads, such as main.
Remove the idle thread index on single-core platforms, and replace all
references to this format in tests and documentation.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The `bt_conn_index` simply returns the index
of a `bt_conn` struct. There is no reason why
such a function should not use `const`.
Not using `const` will make other lookup/index
functions that perhaps relies on the bt_conn index
unable to use `const` as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When PHY is set to 1M, due to missed "break" statement of switch/case
the sample_offset will be set to the corresponding values of 2M
which causes improper function of sampling CTE signals.
By adding "break" statement the problem has solved.
Fixes: #44296
Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
When TCP stack enters retransmission mode, the variable tracking the
amount of unacknowledged data is cleared. This prevents the stack from
detecting when TX window is full, which could lead to queueing unlimited
amount of data, effectively consuming all of the avaiable network
buffers.
Prevent this, by returning early from net_tcp_queue_data() in case TCP
stack is in retransmission mode. The socket layer will take care of
retrying just as in case the window is full.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case a loopback or own address is used in TCP connection, the TCP
stack delegates the acatual data send to a workqueue. This is fine,
however it could lead to some aritificial delays in case a lot of data
is being sent before the workqueue has a chance to execute queued work
items. In such case, we only sent a single packet, when many could've
already been queued.
Fix this, by resubmitting the queue in case a local address is used, and
there's still more packets pending for send.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When peer reports a zero length receive window, the TCP stack block any
outgoing data from being queued. In case no further ACK comes from the
peer, the whole communication could stall. Fix this by sending a simple
Zero Window Probe, when we detect a Zero Length Window.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Timestamps can be 32 or 64 bit long based on the platform and
build configurations. The proper way to handle these timestamps
is to use the ad-hoc log_timestamp_t variable.
This patch fixes some timestamp's reference which were still
using uint32_t changing them to log_timestamp_t.
Moreover also a new config is added in order to print the
timestamp as the Linux's kernel format. This might be useful
in AMP platforms in which Linux's and Zephyr's logs must be
interleaved in order to get a more comprehensive log solution.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
The purpose of this change is to allow to enable more than one
backend at once by removing choice from ipc-service backend Kconfig
and depending backend Kconfig option on existing of correct compatible.
Overwriting IPC_SERVICE_BACKEND option in some places is removes
as no longer needed.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
The unicast client takes a reference to the ACL, but did
not return the reference when the ACL disconnected, but
rather just reset everything.
Modified to detach the stream, ensuring
a bt_conn_unref on ACL disconnect.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
f4df23c9 added dependency on ASSERT to some options prefixed
with ASSERT_ assuming that they are no used elsewhere. Turned
out that there are subsystem specific assert macros (e.g. BT_ASSERT)
which relies on those options. Removing the dependency.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Considering that in most scenarios, bt_rand will not be called
frequently, but the current implementation of tinycrypt will
occupy more than 300 bytes of RAM space. Its existence is to
optimize the frequent call of bt_rand.
Therefore, it is considered to put it into a config
(`BT_HOST_CRYPTO_RANDOM`), when this config has been selected,
will use tinycrypt library for random. Otherwise will call bt random
hci command.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The commit add checks whether frame received from BT transport
will really fit into allocated net_buf form mcumgr.
Fixes: #44271
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
NSEC_PER_SEC is an unsigned integer macro. Thus, -NSEC_PER_SEC will be
treated as unsigned integer as well which lead to calculation error on
64bits integer variables. Added the correct type casting into the formula
to fix the calculation error.
Signed-off-by: Kweh Hock Leong <hock.leong.kweh@intel.com>
Truncate strings being notified to fit the ATT_MTU, to prevent
notifications from not being delivered due to being too long.
For now uses the minimum ATT_MTU, as the MCS does not yet track
connections.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Added a code for initializing shared memory to zero. This operation
normalizes the memory state so that the IPC service is no longer
prone to reading status bits from the previous reset session.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Instead of having one single WQ per backend, move to one WQ per
instance instead and add a new "zephyr,priority" property in the DT to
set the WQ priority of the instance. Fix the sample as well.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Allocating a buffer to hold the entire directory listing consumes a very
large sum of memory when a large number of OTS objects are supported.
This implementation minimizes the memory footprint of the directory
listing by only allocating the minimum necessary buffer size to allow
for efficient over the air transfer. The contents of the transferred
buffer are built incrementally and upon request.
The directory listing manipulation upon object creation and deletion can
be removed since the directory listing content is never constructed
until it is requested.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
Add the telephone bearer service server implementation.
This support multiple service instances as well as the
generic telephone bearer service, but is still a work in
progress and should be treated as such.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
To identify the flash partition id, the macro DT_FIXED_PARTITION_ID()
was used previously.
Now the macro FLASH_AREA_ID() is used. This also supports the usecase
when a different flash map implementation is used that redefines the
macros in include/storage/flash_map.h, e.g. the nordic partition
manager.
Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
Remove the duplicated pairing_complete, pairing_failed
and bond_deleted informational callbacks from bt_auth.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new callback structure for Bluetooth authentication
This struct is meant to replace the information-only
callbacks in bt_conn_auth_cb. The reason for this is that
due to the nature of bt_conn_auth_cb, it can only be registered
once. To allow mulitple users gain information about pairing
and bond deletions, this new struct is needed.
Samples, tests, etc. are updated to use the new struct.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The lll_filter is used for rl_filter and fal_filter. Size of bdaddr
must be big enough for the worst case.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Add `ing` to the `BT_ISO_CONNECT` and `BT_ISO_DISCONNECT`
states, so that the name better matches the actual state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add `ing` to the `BT_CONN_CONNECT` and `BT_CONN_DISCONNECT`
states, so that the name better matches the actual state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a state field in struct bt_conn_info that is a simplified
version of the internal state value (bt_conn_state_t).
This should provide an application to better determine the state
of the connection whne calling bt_conn_get_info, in case the
application does not keep track of the state itself.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Conditional compile ISOAL implementation to support ISO
Broadcast only and ISO Receive only application builds.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix compile error, compiling the connectionless direction
finding samples, due to missing include file.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising Synchronization time reservation
updated when enabling/disabling direction finding IQ
sampling.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixes errornous arg index for new identity in cmd_node_id.
Fixes errornous arg index for uuid in mod_pub_set.
Fixes errornous arg index for net_idx in hb_pub_set.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Fixes errornous arg index for new identity in cmd_node_id.
Fixes errornous arg index for uuid in mod_pub_set.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Move variables to innermost scope - do not define the variable (and
read the value) until it is clear that the receiving callback exists.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Change return value from calls to player(s) to EINVAL.
These functions are guarded, so that if neither local nor remote
players are supported, the functions will not be accessible.
So no need to return EOPNOTSUPP. If the functions reach these
returns, it will be because the pointer provided does not match any
registered player.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The calls to the players were guarded by "_LOCAL_PLAYER_CONTROL".
This was incorrect for two reasons:
- the second part of each function uses the remote player, not the
local one
- the first part of each function is for local control (only) of the
local player
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This enables automatic MTU exchange for services that require MTU size
bigger than default ATT MTU to operate.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds support for automatic ATT MTU Exchange that will be done right
after the connection has been established.
Fixes: #43946
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This implements Core 5.3 recommendation to skip MTU Exchange procedure
if already performed by peer.
Core 5.3 | Vol 3, Part F 3.4.2.2:
If MTU is exchanged in one direction, that is sufficient for both
directions.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The MTU can be exchange once during the connection by the client.
This ensures the ATT MTU Exchange request will not be sent again.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Move the media control client callbacks into the media proxy instance
struct, as requested in earlier PR review.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
In case the CTE request was executed as a single shot and Controller
successfully received LL_CTE_RSP PDU there was an assertion.
The assertion was caused by not completely prepared notification PDU.
The notification PDU was send towards Host by CTE request handling code
due to an error in lp_comm_complete function. If the CTE request was
single shot it went into wrong if-else statement, despite that the
LL_CTE_RSP was correctly received.
A check if-clause if the procedure is periodic should not affect the
procedure completion. It should affect whether req_expire counter has
to be restored.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Added the stop_bits_client parameter to the modbus_serial_param struct.
Being able to configure the number of stop bits for the client
independently from the parity setting, allows to support connecting to
modbus server that do not follow the MODBUS over Serial Line Specification
and Implementation Guide.
Signed-off-by: Constantin Krischke <constantin.krischke@lemonbeat.com>
Signed-off-by: Jan Geldmacher <jan.geldmacher@lemonbeat.com>
Change NVS and FCB backends to look for chosen `zephyr,settings-partition`
in the first place, or fall back to partition "storage" if the chosen
is not set.
Signed-off-by: Alexander Mihajlovic <a@abxy.se>
ARRAY_SIZE was recently changed to a size_t instead of
a long. Update the log statement to use correct
string format.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The antenna number returned by controller if antenna switching is not
enabled was zero. That is not compliant with BT 5.3. Core Spec Vol 4.
Part E section 7.8.87. In this situation returned value should be 1.
There is always single antenna available that is responsible for PDU
reception and transmission.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The broadcast sink would continously register the PA sync callbacks,
effectively creating an infinite loop. Fixed by correctly
setting the boolean to prevent this.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When the broadcast sink receives a BASE it will now
properly check if the BIS indexes are valid.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Once a broadcast source is stopped, the endpoints
should go into the same state before it was
started (BT_AUDIO_EP_STATE_QOS_CONFIGURED), instead
of idle.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There was a missing break statement for the
BT_AUDIO_EP_STATE_QOS_CONFIGURED state, so the
broadcast source could never go into the streaming state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a (initally hidden) Kconfig option for broadcast source
used to determine the size of the advertisable BASE.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The broadcast sink will now not attempt to decode BASEs with
more subgroups than what the broadcast sink can
actually decode.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the unicast guard for bt_audio_codec_qos_to_iso_qos
and bt_audio_stream_attach as they are also used for
broadcast sink and broadcast source.
Also allow broadcast source to use bt_audio_stream_send.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the Kconfig options for BT_CODEC out of the
BT_AUDIO_UNICAST guard, as these are used for broadcast sink
and broadcast source as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Since the default syswork thread priority = `-1`.
`adv_send` will call when controller report advertising
sending completed, due to this process by BT RX task, will
maybe process this before `buf_send`, since, sysworkq will be
used by other place and defer by any place.
Note: secure beacon will be 40ms, and friend and lpn will be 20ms.
This problem is very easy to reproduce, especially in native posix.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When pb-gatt advertising enabled, after extablish connect,
will call `cb->connected` and `cb->adv_send`.
In previous connected also clear `ADV_FLAG_PROXY` flag, but
in `adv_send` will attempt unref null point buffers.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
bt_audio_valid_stream_qos() is used to validate the QoS parameters
set by a client. It did a check of a preferred setting which is
ok to exceed (mandatory in some cases).
This change removes the statement that causes the check to fail,
but keeps the check for debug purposes.
Fixes#43359
Signed-off-by: Casper Bonde <casper_bonde@bose.com>
Fix implementation to be able to establish synchronization
when scan filter accept list is in use and periodic
synchronization needs to be established using specified peer
address or using periodic advertiser list.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The CTE request has two parts: transmission of a CTE request and
reception of a CTE request. The outcome of reception of a CTE request
is transmission of CTE response.
In the new_proc_lut table for allowed remotely requested control procedures
the CTE request was quarded by CONFIG_BT_CTLR_DF_CONN_CTE_REQ.
In case of a build where CTE request is not enabled but CTE response is
the receiver part of CTE request should be enabled also.
The entry in the new_proc_lut should be quarded by CONFIG_BT_CTLR_DF_CONN_-
CTE_RSP.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The ARRAY_SIZE macro uses sizeof and thus the return
type should be an unsigned value. size_t is typically
the type used for sizeof and fits well for the
ARRAY_SIZE macro as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The commit moves shell command buffer to stack and changes
initialization to just just put null at the beginning, before calling
a function that will fill in the buffer, and at the end, after the call.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Moves Zephyr specific code to common source file and removes
no longer needed interface headers.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Bug introduced that prevented the logic from initializing the
context structure. Without this initialization, the application
will crash on repeated request for ctr_drbg random data.
Fixes: #44092
Signed-off-by: David Leach <david.leach@nxp.com>
Adds a simple boolean check of whether the Bluetooth subsystem has been
enabled. This allows users outside of `subsys/bluetooth` to check
whether they can send HCI commands.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
With f44b3dc4df statically initializing
the entropy_dev variable, `ctr_drbg_initialize` was not being run on
the first call to `z_impl_sys_csrand_get`. Use a dedicated static bool
to track whether the init needs to be run.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
When requesting seed entropy data fails, reseed the PRNG state with
runtime data. This is a minimal effort to ensure that random data
requested before a backing entropy device is ready does not result in
repeatable data on each boot.
The random XOR integers are selected from the CRC32 algorithm.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Defer the state initialization of the xoshiro algorithm until the first
time a random number is requested. This allows the PRNG algorithm to be
used with entropy sources which may not be available at boot, i.e
Bluetooth HCI.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The Kconfig function "dt_node_has_prop" was using label as its
parameter, where other functions use either chosen or path.
The documentation says that the parameter is path, so this patch
makes the function as documentation says and as other functions
in the file.
The additional nodelabel functions were added as counterparts that
are using nodes labels instead of paths.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
Fix scan aux context release when (ULL) ticker scheduling
fails due to overlapping events (example a new scan window)
and aux context being released before scan aux done event is
processed, caused assertion when processing the done event
with corrupt ULL reference count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase the event done max count when supporting Extended
Scanning with Coded PHY support, wherein prepare queue will
hold an extra resume prepare when both 1M and Coded PHY
are enabled in continuous scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We expect the address type to be set to PUBLIC or RANDOM always, even
if the controller reports that it was able to sync to a resolved
addresss.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/44110
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Use ticker yield interface to allow chain PDU reception that
overlaps with currently reserved time for received PDU.
Without the yield ULL scheduling to receive auxiliary PDU
fails to be scheduled using ticker.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing use of EVENT_TICKER_RES_MARGIN_US and receive
chain delay in the calculation of overhead value that
determines if ULL or LLL scheduling to be used to receive
auxiliary PDUs.
Also, fix missing use of EVENT_TICKER_RES_MARGIN_US when
ULL scheduling for reception of auxiliary PDU.
See also commit 544acb9804 ("Bluetooth: controller: Fix
missing EVENT_TICKER_RES_MARGIN_US").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Guard media proxy instance members.
As a consequence, change guarding for functions using remote player
member.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Change the default URL length value to something that can contain the
default URL string.
Increaste the default track title length.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the media proxy to use the new Kconfigs to include/exclude the
various parts of the implementation. This replaces existing guarding
using other Kconfig values.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Add Kconfig file for the media proxy, for high-level media control
configuration.
The media proxy did not have a Kconfig file, it was relying on the
Kconfigs for GATT media control client and server.
The purpose is to unify the media control configurations, to make the
different media control functionalities available separately, and to
separate the high-level media control from the bluetooth media control
server and client.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The media controller internal header file does not need to depend upon
the media proxy header.
Requires one piece of spec info here, but the media player already
needs to adhere to the media control service spec, so situation no
worse than before.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Do not initialize the media control service if it is not configured.
This is a temporary fix, there is an issue to fix this properly:
https://github.com/zephyrproject-rtos/zephyr/issues/42965
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Separate out the Kconfig for the media player.
Also removes some unused MCS configs.
The media player has been using MCS configs, while it should be the
other way around.
Also, this will make it easier to move the media player elsewhere, as
has been discussed.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The commit makes stats collection conditional so in case when
CBOR container encoding fails the stats collecting function
will not be called.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fixes a twister test issue whereby handler_found and valid_hdr variables
are checked prior to being set.
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
Use the back-to-back receive of PDU with a
configurable inter frame spacing. This fixes an issue
when nRF53 was able to receive only one Rx PDU and
was not able to switch to next Rx.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
Add Radio interface to perform back-to-back receive of PDU
with a configurable inter frame spacing.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit adds ipc backend, that relies on simple
inter core messaging buffer also added by this commit.
This backend is configurable with DT overlay. Each
ipc instance could be defined with ipc-icmsg commpatible.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This command is used to obtain 'Implementation eXtra Information for Test'
(IXIT) values that are required to proceed with BT qualification tests.
Signed-off-by: Tim Sørensen <tims@demant.com>
With BT_SETTINGS disabled, or when using an indefinite
RPL_STORE_TIMEOUT and not storing the RPL, the device will not be able
to follow the replay protection required by the spec. This adds a
warning about this.
Signed-off-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Fix uninitialized param field when generating incomplete
no more data to come periodic advertising report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix generating periodic advertising reports post sync
terminate under race condition when disabling reporting or
terminating the sync or while performing HCI reset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added BUILD_ASSERT definition to check for safe access to
memory pool allocated memory structure member after the
memory has been released back to mem pool.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Sometimes message is being reset from multiple locations in code.
If message has already been reset, pointer to context is invalid.
Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
This fixes issue where, the ASE went directly to QoS Configured state
when in Releasing state and the ISO link has been disconnected.
To not change the current behavior, the transition from Streaming state
has been unchanged, but rather fixed depending on the ASE direction.
Fixes: #44004
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This reverts commit 6bb75a53d1.
This fixes GATT that was uninitalized when application received
bt_conn_cb->connected callback. As the result, the bt_gatt_is_subscribed
was not working as expected when called from bt_conn_cb->connected.
The _bt_gatt_ccc->cfg_changed callback does not carry information about
the device that subscribed for notifications but rather is says the
app when it should start/stop broadcasting notifications.
This leads to the conclusion that the bt_gatt_ccc->cfg_changed can be
called before bt_conn_cb->connected callback.
Fixes: #42829
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Read operation must return empty payload when read /object_id
if there is no created object instances.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Use menuconfig in order to give a better grouping of HAS related
settings with separate subpage.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The priority of workqueue responsible for rpmsg processing was too
low. Any cooperative task could cause rpmsg processing to be
slightly delayed.
Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
The IMG_MGMT_VERBOSE_ERR Kconfig option has not been really working
since the SMP response that it would setup was reset in case of
error, so in any instance that it would actually be used.
Fixes#32545
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds support for passing "rsn" explanation strings,
for "rc" code, in error SMP responses.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The zephyr_fs_mgmt_truncate has been replaced with fs_unlink
since there is no point to specially check for file existence
before just removing it.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The fs_mgmt_file_upload_rsp has been renamed fs_mgmt_file_rsp
and is used everywhere where "rc" code and "off" is placed into
response, instead of duplicating code that does the task.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The function has been reimplemented within stat_mgmt_list directly,
reducing execution time and code size.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit merges Zephyr specific code from zephyr_stat_mgmt.c
to stat_mgmt.c, removes *_impl_* prototypes of functions that are
used for system specific implementations.
zephyr_ prefixes have been removed from identifiers as they are
no longer needed.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit reorganizes smp_handle_single_payload function to only
open map container, in response, after request have been validated
to be processable.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit removes arg parameter from mgmt_init_writer_fn
function typedef and implementation in zephyr_smp_init_writer.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit removes arg parameter from mgmt_init_reader_fn
function typedef and implementation in zephyr_smp_init_reader.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The smp_make_rsp_hdr prepares new response header from request
header, sets proper frame length to it and converts it to
network format.
Because a respose buffer has now pre-allocated space for header
it is no longer required to call the smp_make_rsp_hdr,
formerly smp_init_rsp_hdr, to reserve such space before adding
data that should follow it.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit changes cbor_nb_writer_init function to reserve
SMP header size on init. The change makes call to
mgmt_streamer_reset_buf within smp_write_hdr no longer needed.
The mgmt_streamer_write_at function, that has been exclusively
used to write headers, have been replaced with mgmt_streamer_write_hdr
and zephyr_smp_write_hdr, formerly zephyr_smp_write_at, has been
reduced as it no longer needs to check and update net_buf metadata
to write header as the cbor_nb_writer_init does it now.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
- Implemented ISO-AL TX interface functions for fragmentation of
unframed PDUs
- Implemented ISO-AL source construct and its creation for an input
data path
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Boolean options must not start with "Enable...". Adjusted the prompt to
comply with the guidelines.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
New CONFIG_MCUMGR_SMP_BT_PKASM has been added that enabled
SMP packet re-assembly, at transport level, to the BT.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds packet re-asembly to SMP that can be used to
collect packet from fragments at SMP transport level.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Use the received coding scheme when receiving Periodic
Advertising PDUs for correctly calculating the receive
chain delay and on-air PDU time.
Relates to commit 6911e7e1d8 ("Bluetooth: Controller: Use
the received coding scheme when scanning").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the received coding scheme when receiving Extended
Advertising PDUs for correctly calculating the receive
chain delay and on-air PDU time.
Relates to commit 6911e7e1d8 ("Bluetooth: Controller: Use
the received coding scheme when scanning").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix compile error when debug pins are enabled for nRF53
Series SoCs.
Regression introduced in commit 743b0583fc ("Bluetooth:
controller: Enable debug pins with TF-M enabled").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing assignment of SID in the Periodic Advertiser
Accept List. This cause advertisers with SID 0 only to be
accepted when using list.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Tx Power field in Extended and Periodic Advertising
for chain PDU reception. Tx Power shall be from the
current PDU containing the AD Data, Scan Response Data and
from first PDU of Periodic Advertising Data be used to
prepare the HCI report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The header file radio_df_vendor_hal.h was conditionally copiled in.
There were a dependency on a CONFIG_BT_CTRL_DR. The dependency is
removed because radio_df_vendor_hal.h and radio_df.h hasn't got any
DF related type dependencies. What more it allows to use IS_ENABLED
for code that uses types and functions defined in radio_df.h.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The EVENTS_CTEPRESENT is available when radio peripheral has
direction finding support. The event is set if received
PDU has CTEInfo and there were collected IQ samples during
CTE reception.
The event should be cleared always when other events are cleared.
That guarantees that the event is not set when use of radio for
following activities.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The radio_df_cte_ready function returns state of EVENTS_CTEPRESENT.
The function may not be used in create_iq_report function, because
it is called after lll_isr_rx_status_reset. The lll_isr_rx_status-
_reset clears EVENTS_CTEPRESENT value.
The result of this calls chain is lack of IQ sample report no matter
if the PDU has CTEInfo and radio has collected IQ samples.
To fix the problem, state of EVENTS_CTEPRESENT has to be get when
e.g. rssi_ready is get.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
As Extended Advertising primary PDUs do not use ticker
remainder value for fine scheduling of radio events, do not
use the remainder value for auxiliary PDUs. This fixes the
jitter in the aux_offset value that caused the auxiliary PDU
being observed to be late compared to the aux_offset value
filled in the primary PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Core Specification 5.3 clarified security requirements for GATT client
when handling incoming notifications and indications.
Vol 3: Part C: 10.3.2.2:
"...Since the configuration is persistent across a disconnection and
reconnection, the client shall check the security requirements against
the configuration upon a reconnection before processing any indications
or notifications from the server. Any notifications received before
the security requirements are met shall be ignored. Any indications
received before the security requirements are met shall be confirmed
and then discarded. ..."
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
The commit fixes erase storage command so that it would return with
error code instead of bus faulting when no device is attached
to flash storage.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
It is possible for flash partition to have no device attached
which may cause image commands to bus fault device.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This adds bare minimum implementation of Hearing Access Service.
The GATT HAS service contains one Hearing Aid Features mandatory
characteristic.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Include a pointer to the CAN controller device for the CAN
transmit, receive, and state change callback functions.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Starting with LoRaWAN 1.0.4 the DevNonce sent with the OTAA join must be
monotonically increasing for each new join with the same EUI. The DevNonce
should be stored in non-volatile memory by the application.
This commit uses a simple extension of the lorawan_join_otaa struct to
allow specifying the DevNonce.
Signed-off-by: Martin Jäger <martin@libre.solar>
This adds support for the following Direct Test mode
commands:
- HCI LE Receiver Test [v3]
- HCI LE Transmitter Test [v3]
- HCI LE Transmitter Test [v4]
Those commands set add a possibility to test an CTE
reception and transmission. The HCI LE Transmitter
Test [v4] commands allows also setting a transmit power.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
If peer sends invalid data length in response IUT should fix those
when calculating effective data length.
This was affecting following qualification test cases:
LL/CON/PER/BI-10-C
LL/CON/PER/BI-11-C
LL/CON/PER/BI-12-C
LL/CON/CEN/BI-07-C
LL/CON/CEN/BI-08-C
LL/CON/CEN/BI-09-C
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
http_client_req() was supposed to return the number of bytes sent as a
HTTP request. The return value was not riht however due to some bugs in
helper functions:
* http_send_data() returned the current buffer position istead of the
number of bytes actually sent. This could result in counting the same
data into the total request size several times. A helper variable was
added to track how many bytes were actually sent to the network.
* http_flush_data() forwarded the return value of sendall() helper
function. That function however did not return number of bytes sent,
but 0 or a negative error code.
Additionally, change the return type of sendall() function - according
to standard the ssize_t type is only capable of holding -1 negative
value, but the function could return the full range of negative errno
values. Use int instead.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Using a const-qualified object in a static initializer is implementation
specific in C, and it does not work in GCC 7.
Before this change, `write_appearance` was a pointer object if
CONFIG_BT_DEVICE_APPEARANCE_GATT_WRITABLE was disabled. This change
removes that object in favor of a macro `GAP_APPEARANCE_WRITE_HANDLER`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Avoid pre-empting scan window when extended active scanning.
If a scan request has been transmitted, then avoid being
pre-empted at the end of window when in continuous scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix power amp for transmitting of chain scan response
wherein capture of PDU end timestamp was missing causing
power amplifier from not being enabled for first chain PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The EATT support is optional for BAP. The specification mandates the
minimum MTU supported to be 64 bytes.
As per BAP_v1.0
"The Unicast Server shall support a minimum ATT_MTU of 64 octets for
one Unenhanced ATT bearer, or for at least one Enhanced ATT bearer
if the Unicast Server supports Enhanced ATT bearers."
The same applies for other BAP roles.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fix auxiliary context from being flushed when scanner or
periodic synchronization is stopped, to avoid using the
disable_cb by both. Fixes an assertion when this race
condition happens.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not enqueue NODE_RX_TYPE_RELEASE into Auxiliary context
when stopping scanner, as this type is not to be passed to
HCI processing, which would lead to assertion.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix auxiliary context leak on stop, under race condition
where ULL High execution context does not release the
auxiliary context as stop has been requested, and done
has decremented the auxiliary context's reference count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the order of Periodic Synchronize reset during HCI
Reset Command. Perform scan reset last after Periodic
Synchronize reset to avoid resetting the auxiliary
context which may be in use by Periodic Synchronize.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Users will usually not want to browse through these. Therefore it is
better to hide them a bit.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This prevents GATT service selection being selectable when compiling
controller only builds.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Closing a listening socket will set the accept callback to NULL.
This could lead to a crash, in case an already received packet,
finalizing the connection handshake, was processed after the socket was
closed. Thereby, it's needed to verify if the callback is actually set
before processing it.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The verification function for accept() did not take into account that
addr and addrlen pointers provided could be NULL.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add a new API that allows to register a callback that is called when the
maximum latency value changes. This can be used by SoC code to perform
actions based on certain latency values.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Add a new API that allows to configure maximum latency requirements.
When the policy manager computes the next state, it will check if the
state brings too much latency based on requirements. This can be useful,
for example, if a certain driver or the application want a system to
respond fast, since any low power state that brings too much latency
will not be used.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The state lock get/put calls should always be balanced: first call get
and then put. Add an assertion in case lock counter is about to go
negative, indicating a programming error.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The pm_constraint_* APIs were effectively used by the policy manager
only. This patch renames the API to the policy namespace and makes its
naming more explicit:
- pm_constraint_set -> pm_policy_state_lock_get()
- pm_constraint_release -> pm_policy_state_lock_put()
- pm_constraint_get -> pm_policy_state_lock_is_active()
The reason for these changes is that constraints can be of many types:
allow/disallow states, impose latency requirements, etc. The new naming
also makes explicit that the API calls will influence the PM policy
behavior.
All drivers and documentation have been updated accordingly.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Most include files were not used, and `toolchain.h` was missing (needed
by `__weak`).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
1. state < PM_STATE_COUNT: the function argument is an enumeration that
already indicates the valid values. It is a programming error to pass
random integer values, the API should not be defensive "just in case
the application has messed things up".
2. v < UINT_MAX: first, this assumes type used by `atomic_t` (opaque).
Second, if the integer overflows it will just wrap around, so the
check does nothing in practice.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The policy file does not perform any logging, so just drop logging
include and declaration.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Move policy code one level up for simplicity, since there is a single
source file. Source file has been renamed to "policy.c" to make things
clear.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The residency policy, is in reality, influences by other parameters for
example constraints. It has been renamed to "DEFAULT" policy to make it
more general. The "APP" policy has been renamed to "CUSTOM" to better
represent its purpose.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
TCP processed IPv4/IPv6 packets w/o verifying first if IPv4/IPv6 is
enabled in the system. This could lead to problems especially for IPv6,
where in case it's disabled the sockaddr structure is not large enough
to accomodate IPv6 address, leading to possible out-of-bound access on
the sockaddr structure.
Fix this by adding appropriate checks where applicable.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Create wrapper for printk to avoid including printk.h in __assert.h.
__assert.h is used everywhere thus should not have dependency to
printk.h.
Cleanup assert Kconfig options.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added support for Composite observation for LwM2M v1.1.
Updated current Observation node to support linked path list.
Rename typos lwm_ to lwm2m_.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Removed to store pmin and pmax at oberservation node structure and
use attribute list store for calculate time for next Notification.
Observation class use timestamp for triggering notification based on
resource update which use pmin and default pmax behaviour.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
There are no more context defines specific to metadata, the ones
coming from Assigned Numbers shall be used.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Delay start of threads and timer to ensure that setup
is completed. Especially, vital on multiple CPUs.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
TCP module can report EAGAIN in case TX window is full. This should not
be forwarded to the application, as blocking socket is not supposed to
return EAGAIN.
Fix this for sendmsg by implementing the same mechanism for handling TX
errors as for regular send/sendto operations.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Instead of including from nrfx_glue.h a specific Zephyr Bluetooth
controller header file that defines PPI and GPIOTE resources to be
reserved for exclusive use by the controller, include a file with
only a fixed name and expect the chosen Bluetooth controller to
provide the location of this file in include paths. This way, when
a different Bluetooth controller implementation is used downstream,
a different file can be easily pointed to.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
The enum did not contain an entry for unconfirmed messages. Instead, it
was only mentioned in the comment that 0 is the default for
unconfirmed messages.
This commit adds LORAWAN_MSG_UNCONFIRMED to the enum and changes the
parameter in the lorawan_send function to enum lorawan_message_type.
Signed-off-by: Martin Jäger <martin@libre.solar>
When queue mode is enabled, state machine will enter state
ENGINE_REGISTRATION_DONE_RX_OFF. This state needs to be
taken into account during registration update to send
correct event.
Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
Following #42026, the body_start pointer now points to the
start of the body fragment in the recv_buffer as long as there
is body in it, either entirely or partially.
Rename the body_start to body_frag_start to better reflect
what it represents.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This fixes data path configuration that was done for both directions
even if CIS was unidirectional. To ensure the data path shall be
configured, the QoS SDU is checked.
Fixes: #43190
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Removing backend config from board Kconfig.defconfig and moving
it to xtensa_sim backend configuration in logging. Without this
change define persisted even when logging was not using backends
and that impacted what is compiled in.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Removing backend config from board Kconfig.defconfig and moving
it to native_posix backend configuration in logging. Without this
change define persisted even when logging was not using backends
and that impacted what is compiled in.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Extended logging v2 to support frontend api. Contrary to v1,
it is possible to have frontend and backends in the system.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Rename
BT_CTLR_LLCP_PROC_CTX_BUF_NUM
to
BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM
to match naming scheme of
BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Add a separate procedure context pool for remote initiated procedures.
Make it configurable in size by BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM.
Fix all unit tests referring to the amount of free context buffers.
Fixes#41823
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Move the mem_pool structure to the internal header for wider access.
Introduce a mem_pool owner in the proc_ctx, sch that multiple mem_pool
could be used for memory management of proc_ctx, also static 'foreign'
allocated proc_ctx would be supported by this.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
When padding is added to "fill" the gap in order to wrap to the
beginning of the ring buffer, such padding is attributed to the
current item being added. Let's attribute it to the previous entry
instead so it'll be freed along with that entry and make the space
available one entry sooner, increasing the chances for keeping the
current entry around longer.
If ring buffer is empty then always reset it up front to get best
alignment right away i.e. beginning of buffer.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The `handle_signal()` function in the new ztest API (`ztest_new.c`) uses
an array of strings to lookup a friendly name for each test phase, but
the array only has three elements despite there being six test phases.
This can lead to an out-of-bounds issue. Replace the array with a helper
function and switch statement.
Signed-off-by: Tristan Honscheid <honscheid@google.com>
Start of the antenna switching and sampling CTE is configured by use
of DFECTRL2 register in Nodric Radio peripheral. As of now the
configuration was set to defaults, so antenna switching has started
immediately after CTE procedure was started (end of CRC).
Sampling was started at the very beginning of a sampling slot.
It should be delayed for at least 125 ns from beginning of sampling
slot and not more than 125 ns to the end of sampling slot. This is a
requirement from BT 5.3 Core specification Vol 6, Part B section 2.5.4
IQ sampling.
Although it seems to me that when samples are taken depends on
implementation and used hardware. Taking that into account
there is provided a set of KConfig options to configure samples
offset for PHY 1M, PHY 2M and sapling slots 1 us and 2us separetely.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
If there is enabled support for ADI in periodic advertising and
periodic advertising uses chained PDUs there is an assert when
periodic advertising is re-enabled.
There is missing a code that will set a chain for PDU with
updated ADI field.
The commit fixes the issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
SenML Json support dynamical basename for composite operation.
Changes simplify base name generation and compres message better.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Added new flags to packaging API:
- CBPRINTF_PACKAGE_ADD_RO_STR_IDXS - when set, read-only string
locations are appended to the package
- CBPRINTF_PACKAGE_ADD_RW_STR_IDXS - when set, read-write string
locations are appended to the package (instead of appending actual
strings)
- CBPRINTF_PACKAGE_FIRST_RO_STR_CNT(n) - indicate that n first strings
are known to be read only. Ignored in runtime packaging.
Add function for copying packages with optional appending strings.
Changed CBPRINTF_MUST_RUNTIME_PACKAGE to use same flags as packaging.
Aligned logging and test to those changes.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The entropy device reference can be obtained at compile time. Adjust
error code to -ENODEV.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
THe entropy device can be ontained at compile time. Simplify some
logs/code as a result. Also adjusted "entropy_driver" name to
"entropy_dev", since it holds a "device", not a "driver".
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The entropy device can be obtained at compile time. Adjusted the
assertion message slightly, as it no longer uses the entropy macro
label. Also adjusted the entropy_driver variable to entropy_dev, since
it does not hold a "driver" but a "device".
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The device can be obtained at compile time. Note that now the readiness
is checked on every call, but it's a fast operation anyway.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Refactor the PAC location read and write. Instead
of storing the location in the service, the
location is now stored in the application, and
is retrieved by the service via callbacks.
Similarly, if a client writes the location, this
request is being sent to the application.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a sent callback that is used to notify applications
using the audio API when a SDU has been sent over HCI.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
ot_setting_delete_subtree returns the information if the subtree
had been found in the persistent storage or not before removing.
This has matter for otPlatSettingsGet. In other uses cases
the return value shoud be ignored.
The right place for the check if deletion succeded is in
settings_load_subtree_direct and its callback.
Currently "ot factoryreset" causes an assert if there is no
OpenThread dataset stored in the persistent memory.
This PR fixes it.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
Changes ERR to WARN message when relay buffers
run out, as this is not really an error but a
consequence of high traffic.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Whenever a stream is attached to an endpoint, the
stream's operation callbacks will be called for the
unicast server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The os_mgmt_echo is supposed to return MGMT type error not
Cbor; there was missing translation.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The cbor_value_advance at the end of attribute parsing loop could
overwrite err with 0; this could cause loop to fail to break
on error and make cbor_internal_read_object return success, even
if parsing of input buffer failed.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
As the receive window is now decreased at the TCP module level, other
direct net_context users are also responsible for acknowledging the
received data with net_context_update_recv_wnd() - otherwise, the
communication will stall.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This patch fixes ISO data path setup that shall be done for enabled
directions only and removes usage of Path ID = 0xFF which is RFU value.
As per Core 5.3 Vol 4, Part E, 7.8.109
"If the Host attempts to set an output data path using a connection handle
that is for an Isochronous Broadcaster, for an input data path on a
Synchronized Receiver, or for a data path for the direction on a
unidirectional CIS where BN is set to 0, the Controller shall return the
error code Command Disallowed (0x0C)."
Fixes: #43190
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The capabilities callback did not provide information about
the type of the endpoint being configured, making it
impossible for the application to determine if it is a
sink or source endpoint.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The unicast client would set the QoS reversed, as the
client should configure it TX parameters for SINK
and RX parameters for source, where it did it the other
way around.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove functions and and macro uses that otherwise
determined the direction of an audio stream, and instead
use the direction (dir) field of the endpoint instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Audio streams as defined by the BAP spec does not
support bidirectional audio streams. This commit
updates the API and implementation to match that.
The use a bidirectional CIS with 2 audio stream will
be added in a future commit.
This removes the _IN_ and _OUT_ and _INOUT_ QOS
values, as well as the direction of the codec QOS
struct.
To keep direction for internal use, the direction
has been added to the endpoint struct.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the BASS client implementation
This is a standalone implementation that
needs to be (heavily) modified for the
broadcast assistant role in the future.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the BASS as a standalone service. The service is
used for the scan delegator role, which has not been
fully implemented yet.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make it consistent for audio.h and capabilities.h that the
array size parameter appear after the array parameter.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Check if the CTE was discovered by Radio peripheral should be
done with use of CTEPRESENT event. Samples count should not
be used for that purpose. If samples count is a value different
than zero for PDUs that don't have CTE, unwanted IQ samples
report will be generated. CTEPRESENT event is set only in case the
CTEInfo filed was correctly parsed by Radio peripheral during
PDU reception.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Don't replace destination of segmented message when acknowledgement is
received from a friend node, otherwise, when segments are retransmitted,
the destination will be used and the friend node will treat it as a new
segmented message.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
BT_ATT_OP_READ_MULT_VL_REQ, BT_ATT_OP_READ_MULT_VL_RSP, and
BT_ATT_OP_NOTIFY_MULT were missing.
Because of this, multiple variable length reads did not time out.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Heartbeat publication sent callback can be used
as a watch mechanism to determine whether
the mesh stack is still capable of sending messages or not.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Fixes#42306
Attach bt_att_chan objects to bt_att when creating them so that the
check in att_chan_new() works. Use the flag ATT_CONNECTED to signal that
a channel is connected instead of attaching it.
The flag ATT_DISCONNECTED was not set anywhere and is replaced by
ATT_CONNECTED.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
We emulate the interrupt by sending the IPI to core itself by
the local APIC for x86 platfrom.
But in X2APIC mode, this no longer works. So we emulate the
interrupt the by writing the IA32_X2APIC_SELF_IPI MSR to send
IPI to the core itself via LOAPIC also. According to SDM vol.3
chapter 10.12.11.
Fixes#42108
Signed-off-by: Enjia Mai <enjia.mai@intel.com>
Add `remaining_size` in struct ad_stream.
By calculating the actual space required instead of
using the maximum space.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
According to Kconfig guidelines, boolean prompts must not start with
"Enable...". The following command has been used to automate the changes
in this patch:
sed -i "s/bool \"[Ee]nables\? \(\w\)/bool \"\U\1/g" **/Kconfig*
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Fix Extended Advertising implementation to setup Power
Amplifier (PA) GPIO toggle for transmission instead of
incorrect Low Noise Amplifier (LNA) setup which is for
reception.
Relates to commit 4e5290948e ("Bluetooth: Controller: Fix
Periodic Advertising to setup Power Amp").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not implicitly allocate Rx buffers for maximum chain PDU
reception. Instead let applications increase as required the
Kconfig CONFIG_BT_CTLR_RX_BUFFERS.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The LE Audio clients will now do more and proper cleanup
during disconnects. Furthermore, the will also
take a proper bt_conn_ref when the conn pointer
is assigned locally.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix missing configure of Device Address Matching when
receiving auxiliary PDUs.
This fixes some privacy related conformance test cases.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing RPA timer start in Broadcaster only controller
builds.
Without the fix private resolvable addresses where not
updated at RPA timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing implementation to update private resolvable
address in auxiliary PDUs on RPA timeout.
Without the implementation the controller asserted on RPA
timeout when AdvA is not present in the primary channel PDU
of Extended Advertising set.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing reset of sync create association with scan
context when associated with both 1M and Coded PHY contexts,
and sync create cancel is called.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix address resolution when trying to match the maximum
entries in the resolving list.
Wait for address resolution AAR peripheral to complete with
checking with all the entries in the IRK list.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This change introduced some weird failures on x86 that will take some
time to untangle, and wasn't a particularly important feature to
merge. Revert for now.
This reverts commit adc901aa6a.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Some hardware has "interesting" configuration like asymmetric default
interrupt masking (the intel_adsp devices in particular, but x86's
IO-APIC driver has tripped over this in the past too) that needs
special treatment if you want to run something on "core 1"
specifically, and 1cpu test cases pretty much by definition are going
to have been written without SMP details in mind. Switch the logic
around a tiny bit such that these test cases always run on CPU ID zero
explicitly.
Actually in practice this was ALMOST guaranteed to be true already,
because test setup and happens serially, having been started on the
main thread, which starts on CPU 0 by definition. Then the test
teardown aborts all the spawned threads that might have been running
on CPUs 1+, so those reach idle, and the next test case starts
syncronously on the same thread (and thus CPU) where it started. But
nonetheless that wasn't actually enforced, and we've found at least
one simulation environment where timing conspires to break things.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit adds implementation of otPlatRadioSetChannelMaxTransmitPower
This function is responsible for setting maximum allowed power on
IEEE 802.15.4 channels.
Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
Prompt was removed by 154ca8526 to ensure that it is not
disable when it is required. That removed possibility of
manually enabling that option my the user. Bringing prompt
back and adding check to code to fail compilation if
LOG2_ALWAYS_RUNTIME is not set but is required.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The extended advertiser would fail to build due to a missing kconfig
option dependency when relay was disabled.
Fixes#43172.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When local node poweroff and power on again, will
receive iv update but within 96hours.
When 96h after, due to cache, we can't process this
beacon any more.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
According Mesh Profile 3.10.6 IV Index Recovery procedure
Upon receiving and successfully authenticating a Secure Network
beacon for a primary subnet whose IV Index is 1 or more higher
than the current known IV Index, the node shall set its current
IV Index and its current IV Update procedure state from the
values in this Secure Network beacon.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When pac_notify is called it will notify the
actual PAC records for the specific type (sink/source).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds function get_pac_records that will retrieve the PAC
records from the application. The pac_read callback
will then call this to get the value, before returning
it to GATT.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Some SOCs cannot be flashed reliably in low power modes. If
CONFIG_ZTEST_NO_YIELD is selected, do not yield to the idle thread after
testsuite completes, so that the SOC will not enter low power mode.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Adds an official behavior in response to null response from HTTP
endpoint.
Fixes#42988
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Add ztest_test_skip() support to non-kernel tests by implementing
long jump buffer and TC_SKIP result collection.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Fix#42800
Both pss->rate_ratio and port_ds->neighbor_rate_ratio are double type
but sync_receipt_time is uint64_t. If pss->rate_ratio is less than 1
or sync_receipt_time * port_ds->neighbor_rate_ratio is less than 1,
sync_receipt_time becomes 0 due to double to uint64_t cast.
Assign port_ds->neighbor_prop_delay to sync_receipt_time first to fix
this issue.
Signed-off-by: Lu Ding <lucasdinglu@gmail.com>
Fix k_sem_give() from being called from Zero Latency IRQs
when the Controller is configured with BT_CTLR_ZLI=y.
Kernel features shall not be used from Zero Latency IRQs as
these IRQs cannot be locked by the kernel to maintain
context safety of the kernel objects.
Relates to commit 92e017fd70 ("Bluetooth: controller:
split: Support Zero Latency IRQs") and
commit c842eef3ae ("Bluetooth: controller: Add semaphore
to indicate free AD data buffers").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
sw_switch implementation uses two parallel groups of
PPIs connecting radio and timer tasks and events.
The groups are used interchaneably, one is set for
following radio TX/RX event while the other is in use
(enabled).
The group should be disabled by timer compare event that
starts Radio to TX/RX a PDU. The timer is responsible for
maintenance of TIFS/TMAFS. The disabled group collects
all PPIs required to maintain the TIFS/TMASF. After
the time is reached Radio is started and the group is
disabled. It will be enabled again by software radio
swich during next call.
If the group is not disabled then it will work in parallel
to other one. That causes issues in correct maintenance of
instant when radio shoudl be started for next TX/RX event
e.g. radio may be enabled to early.
In case the PHY CODED was enabled and periodic advertising
included chained PDUs, that are transmitted back-to-back,
there was missing group delay disable. The missing case was
sw_switch function called with dir_curr and dir_next set
to SW_SWITCH_TX.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The commit:
- removes usage of strnlen to make taskstat code C99 compliant;
- corrects thread name len, following update description of
CONFIG_OS_MGMT_TASKSTAT_THREAD_NAME_LEN;
- reduces duplicated code.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit removes usage of strnlen from echo command to make
code C99 compliant, and allow it to compile with newlib.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The help for the OS_MGMT_TASKSTAT_THREAD_NAME_LEN stated that
the config includes terminating zero, but this is not true:
when thread name is encoded with CBOR it is encoded with actual
string length and is not zero terminated.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
It depends from a content formatter is there need to put constructs
with a path level deeper than object instance. In other words with
resource- or resource-instance-level.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
No need to start the wq every time the mbox is initialized, it must be
done once for all the instances (it is shared by all the instances).
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Since `CONFIG_BT_MESH_PB_GATT` represent to pb-gatt-srv.
We use `CONFIG_BT_MESH_PB_GATT_COMMON` to represent common.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Rename the data and metadata callbacks to _read(), for consistency
with the corresponding function calls.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Move the instance as the first parameter of the client function calls
and callbacks, for consistency with the server implementation.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Merge the metadata types for client and server.
This is part of merging the ots_client and ots header files.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Move the metadata request bitfields to the common header files.
This is part of merging the ots_client and ots header files.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Merge Kconfig file for OTS server and client.
Rename the client config from _OTC to _OTS_CLIENT
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the Object Transfer Client to use OTS defines and types instead
of the ones left over from the previous "le-audio local" object
transfer service:
DIR_LIST, object ID size, OACP and OLCP
Remove the no longer used defines and types from the OTC header file.
Exception: The OLCP sort order defines have not been removed, but
moved to the olcp internal header file, for expected later use.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Move the directory listing size defines to the OTS directory listing
internal header file.
This removes an implicit dependency upon users of
ots_dir_list_internal.h to also include ots_internal.h.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The media control client shell must include the OTC header file.
(It is currently indirectly included via otc_internal.h.)
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the OTC to use the existing ots_l2cap code rather than its own
implementation.
- Add an ots_l2cap struct and register it
- Add ots_l2cap callbacks, reuse most of old l2cap_recv callback in
the ots_l2cap rx_done callback
- Remove old l2cap code
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update configuration so that the OTS l2cap file can also be used for
the OTC.
(The plan is to merge the OTS and OTC config files later.)
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Add an l2cap connect() function to OTS. This is a function for
clients, added to prepare for the upcoming OTC client (re)using the
ots_l2cap module.
As part of this, factor out an internal function to find a free l2cap
context.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Remove L2CAP server registration. The object transfer client does not
need to register an L2CAP server.
OTS spec: "It is always the responsibility of the Client to open the
Object Transfer Channel, regardless of the direction of transfer, and
is never the responsibility of the Server."
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Preparations for making OTC "official"
Move remaining content of old ots header fil into the otc header file,
and remove the old ots header file.
(Another ots header file already exists in the ots folder.)
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit is the first in a series of commits to make the OTC
(Object Transfer Client) implementation that exists in the audio
folder "official". That is, the client implementation will be updated
and refactored to be aligned with the OTS (Object Transfer Service)
implementation that exists in subsys/bluetooth/services/ots, and moved
to that folder.
Preparations for making OTC "official":
Move remaining content of old ots_internal header fil into the
otc_internal header file, and remove the ots_internal header file.
(Another ots_internal header file already exists in the ots folder.)
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This change adds the kconfig option
BT_DEVICE_APPEARANCE_GATT_WRITABLE_AUTHENTICATED. When enabled, GAP
apperance is writable by authenticated peers.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Extend the command "bt appearance" to take an optional argument, which
is used to set the appearance.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Introduces new kconfig option CONFIG_BT_DEVICE_APPEARANCE_DYNAMIC.
New API `bt_set_apperance` allows dynamic setting of apperance. The
dynamic setting is saved in the settings subsys. `bt_set_apperance` is
analogous to `bt_set_name`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The new command "bt appearance" prints out the current Bluetooth
Appearance Value.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The this change is a step towards make the GAP appearance runtime
settable and ATT writable.
The new function bt_get_appearance() wraps CONFIG_BT_DEVICE_APPEARANCE
and should replace all its uses in code.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
This commit moves openthread CMakeLists.txt from openthread submodule
to zephyr/modules/openthread.
Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
So far close() was called on underlying socket when timeout has expired.
This is wrong in several ways. First of all POSIX specification of
close() does not specify what should happen on blocking recv() call and
different systems have different behaviors (e.g. Linux does not wake up
recv() caller if there was no new incoming data, while other systems
might wakeup recv() caller immediately). Another (and much more severe)
problem is that HTTP client user does not know whether underlying socket
was already closed or not after HTTP request has finished. As a result
it was not clear whether close() should be called by HTTP client user.
Use shutdown(..., SHUT_RD) in internal HTTP client implementation, so
that recv() is woken up immediately with 0 as result (which means EOF).
This will allow to gracefully handle timeouts and make it clear that it
is application responsibility to always call close() after HTTP
request (successful or not).
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Add basic shutdown() implementation of TLS sockets, which basically
calls shutdown() on underlying wrapped sockets.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Add basic shutdown() implementation for net_context sockets, which
handles only SHUT_RD as 'how' parameter and returns -ENOTSUP for SHUT_WR
and SHUT_RDWR. The main use case to cover is to allow race-free wakeup
of threads calling recv() on the same socket.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
So far shutdown() implementation was a noop and just resulted in warning
logs. Add shutdown() method into socket vtable. Call it if provided and
fallback into returning -ENOTSUP if not.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
When Proxy advertising or PB-GATT Advertising Enabled and use a same
advertising sets.
As `adv_start` will call multi HCI Command will cause syswork_q yield.
At same time, if another thread(BT RX) all `schedule_send` will cause
unable send mesh message, because `ADV_FLAG_ACTIVE` was be set, but
`ADV_FLAG_PROXY` not set currentlly.
Add `ADV_FLAG_SCHEDULE_PENDING` indicate mesh buf has been pendings
but not scheduled, so when proxy advertising enable, let's take again,
as we can't break or terminated `adv_start`, so we must waiting proxy
advertising enabled.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
correction field in sync follow up message must be converted from host
endianness to network endianness.
Signed-off-by: Lu Ding <lucasdinglu@gmail.com>
Fixes: #40559
Moving CMakeLists.txt gluecode into Zephyr repo minimizes the patching
needed in LittleFS repo.
It provides a dedicate Zephyr LFS config header which will define the
equivalent LittleFS settings based upon Kconfig settings.
This further reduces the patching needed in LittleFS.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fix missing call to ISOAL sink instance destroy interface,
without this there is leak in ISOAL sink instances when
removing ISO data path.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
[*] Fixed setting of SDU production status when exiting the
ISOAL_ERR_SPOOL state for framed PDU consumption when receiving the
start of the next SDU
[*] Changed condition identifying a padding PDU to include padding PDUs
with errors received after the end fragment is seen and expanded
unit tests to cover new condition
[*] Changed definition of ISOAL_PDU_STATUS_xxx errors to match value of
similar errors defined for the SDU status
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Kconfig options now belong to the Kconfig domain, therefore, the
:kconfig:option: role needs to be used.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This file defines the crypto driver API, cipher is supposed to be just
one type of capability (other can be hash) of these drivers, just
change the file name to be consistent with it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Improvement to generate Tx ack early when the event close
compared to being done at the start of the next event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising conditional compiles in header files.
Do not conditional compile declarations, definitions of
functions in source files only be compiled out.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix to include ll_adv_cmds_set when broadcast role is not
enabled in the Controller but advertising extensions is
enabled (Extended Scanning is used).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
A previous commit fixed OpenThread logging when `LOG=n`, but
introduced regression when `LOG_MODE_MINIMAL=y`. This commit
fixes the latest.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
This commit utilizes psa_crypto_get function to fetch cryptographically
secure pseudorandom numbers.
Signed-off-by: Lukasz Duda <lukasz.duda@nordicsemi.no>
Add a new API call to replace nvs_init: nvs_mount. The new API does the
same as nvs_init except that it assumes to be provided with a valid
flash device via `struct nvs_fs` `flash_device` field. Previously, it
was not possible to avoid the runtime overhead of device_get_binding()
even if the flash device was known at compile time.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
sys_le16_to_cpu is a macro, and not big endian the value
is referenced twice, which would incorrectly increment the
value.
Modifed to extract the value to a variable before calling
sys_le16_to_cpu.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of relying on a single globally increasing (but never
resetting) packet_sequence_number, it is now correctly
reset and incremented for each ISO channel.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adding the same BT callback struct twice can cause
an infinite loop when iterating the callback_list,
so register the gatt callback just once early.
Signed-off-by: Peter Johanson <peter@peterjohanson.com>
Rename the use of mstr word in advanced scheduling
implementation to cen as a representation for Central
role.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use connection interval units of 1250 us for periodic
scheduling of Extended Advertising auxiliary PDU events so
that auxiliary events can be periodically grouped alongwith
the Periodic Advertising Events. This will permit
mitigating overlaps amongst them.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to find free slot after Periodic
Advertising event, to place the BIG event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Make the Periodic Advertising time reservation calculation
function internal public so that advanced scheduling can
use it to scheduling the BIG event after the Periodic
Advertising radio events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the implementation to get free slot after a
state/role so that it is easy for reused for scheduling
Broadcast ISO events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix scheduling of Periodic Advertising events to be after
the group of Auxiliary set events. Do not reduce the slot
offsets as time reservations in ticker for non low latency
variant of controller does not include the slot offsets in
the reservation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the implementation to get free slot after a
state/role so that the code depth is reduced.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Extended the connection parameters negotiation procedure used in the
SMP BT module. From now on, it is possible to configure a preferable
set of all connection parameters to be used during the image transfer.
The default values are optimized for transfer throughput.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Guards the `recv` callback for just unicast and broadcast sink
builds, and removes the usage of it in broadcast_source.c
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The callbacks were implemented to notify the application
about the state of the ISO. However, since then, callbacks
such as `started` and `stopped` have been implemented,
and as such the `connected` and `disconnected` callbacks
no longer server any purpose.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add `ing` to the `BT_L2CAP_CONNECT` and `BT_L2CAP_DISCONNECT`
states, so that the name better matches the actual state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds a utility function to check if an address is within
read only section. This is extracted from logging subsys so
use the new func in logging. The one is cbprintf_packaged is
also replaced.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
XCC is based on GCC 4.2.0 which doesn't support auto type.
So force CONFIG_LOG2_ALWAYS_RUNTIME to be enabled if XCC is
being used.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Make it possible to "finish" with fewer bytes than what was "claimed".
This was possible before on the get side, but the put side was
cummulative wrt finish. The revamp made it cummulative on both sides.
Turns out that existing users rely on the opposite behavior which is
more logical and useful. So make both sides that way.
Adjust documentation, test case and users accordingly.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
No SoCs are re-implementing the constraints API. This _feature_ was
mostly put in place to cover TI platform needs, but it is no longer
needed. Refer to previous commit for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Makes possible to read a single resource instance at a time with
plaint text, JSON and TLV content formats.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
The L2CAP channels were removed from the bt_conn channels list. They
were thus not found in the ecred connection response handler.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
We keep the behavior for legacy advertising data as the controller will
ignore such scenarios when using legacy advertising commands.
Extended non-scannable advertising sets don't support scan response
data. Extended scannable advertising sets don't support advertising
data.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
No ring_buf_get_finish() should be performed on ring_buf memory that
wasn't claimed beforehand. Using ring_buf_get() with a NULL destination
does both the claim and the finish part without retrieving anything.
This is especially important with the ring_buffer revanp where the above
is enforced for proper operation.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The command.param may not always be set in send_command
depending on whether command.use_param is set.
If command.use_param is not set, the command.param is
not logged, and is set to 0.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If settings wipe fails we are not informed about this what can lead to
bugs which are hard to investigate.
This commit adds log and/or assert which is triggered by this failure.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
If the item has name but no help, there's no need to fill
shell with tabulators and colon at the end of the line.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
Adding mechanism to all the backends to switch the logging formats
at runtime while leveraging the function pointer table based upon
the Kconfigs which also cleans up the logging backend design.
Also demonstrate the working API with the changes
to syst sample. Clean up Kconfig for backends and add a standard
template to generate the Kconfigs for logging formats to be used
by all backends.
Signed-off-by: Aastha Grover <aastha.grover@intel.com>
Add support for new API's log_backend_format_set and
log_format_set_all_active_backends to switch the logging format
for one backend and for all the active backends respectively.
Using format_set function pointer in log_backend_api struct as a hook
to set the log format at runtime in the backends. Add function pointer
table with helper functions to be used as a way to select log format.
Add supported log format types as macros to use with the API.
Signed-off-by: Aastha Grover <aastha.grover@intel.com>
LwM2M version 1.1 will select SenML Json for default content format.
Version 1.0 will use TLV format.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
LwM2M engine Send operation support /dp.
Send operation based on Composite Read functionality
which is not enabled at engine side like composite write.
Added Kconfig configurable for composite read path list size.
Created generic Read object instance which is shared between
general read and Composite Read operation.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
LwM2M SenML JSON contain format support for Read / Write operation.
Added Kconfig configurable for enable SenML JSON format.
LwM2m read validate read operation and report out of memory.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Change the CPU_CORTEX_R kconfig option to CPU_AARCH32_CORTEX_R to
distinguish the armv7 version from the armv8 version of Cortex-R.
Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
Remove deprecated functions in the previous release. Note that PM API is
not marked as stable.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Aligning with the rest of PM API, replace pm_power_state_exit_post_ops
with pm_state_exit_post_ops.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Fix Periodic Advertising PDU ACAD set and clear interface to
support updating ACAD when previous and new PDU buffer are
same (i.e. when previous new PDU not consumed yet by LLL).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update implementation to have assertion when not finding the
Channel Map Update Indication field in ACAD.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In case an individual resource is being discovered, the LwM2M client
should not only fill the attributes assinged at the resource level, but
also the ones inherited from the object and object instance levels.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
LwM2M 1.1 allows to write attributes for resource instances as well.
Resource instance level attributes need also to be taken into
consideration when adding/updating observers.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
LwM2M adds Resource Instance reporting in Discovery response, along with
attributes assinged at the Resource Instance level.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Peer may send a zero-length keepalive message, probing the recv window
size - TCP stack should still reply for such packets, otherwise
connection will stall.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add implementation of net_tcp_update_recv_wnd() function.
Move the window deacreasing code to the tcp module - receive window
has to be decreased before sending ACK, which was not possible when
window was decreased in the receive callback function.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Move the unittest.cmake to the new Zephyr CMake modules dir.
This allows us to have a single Zephyr CMake package and load unittest
module as: 'find_package(Zephyr COMPONENTS unittest)'
This unifies the way Zephyr package is sourced and removes the need for
a dedicated ZephyrUnittest package.
Deprecate the use of: 'find_package(ZephyrUnittest)'
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
If OPENTHREAD_IP6_FRAGM is enabled the IPv6 fragments are handled in
OpenThread stack but also forwarder unconditionally to the Zephyr
uplayers. It causes additional packets processing and leads to errors
like unrecognized next header type or duplicate ping reply. What more
these errors generate additional traffic which jam channel and decrease
latency for packets required fragmentation.
This commit add filtering IPv6 fragments when data fragmentation and
reassembling is enabled in OpenThread.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
Uninitialized memory would report wrong value for
`mAckedWithSecEnhAck` flag in the received frame, making the
OpenThread stack to update the frame counter for the neighbor
wrongly.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
When immediate logging is used and optimization is off then bigger
stack is needed for thread analyzer. Adjusting the value.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Logging v2 is utilizing complex preprocessing operations to
prepare message at compile time. Multiple operations are peformed
on log message arguments. However, it is expected that argument
will be evaluated only once (e.g. it can be a call to a function
with side effects). Adding additional layer which creates copies
of user arguments on stack and passes them to further processing.
Updated test for log_msg2 which is using internal macro which
got renamed.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Always use runtime packaging in immediate mode. Removing attempt to
package on stack if possible. It would be done only to speed up
logging but that is not a requirement in immediate mode where
packaging time is fractional compared to backend processing. Using
runtime packaging also reduces stack usage in the context which calls
log message.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The commit adds FS_FATFS_MAX_ROOT_ENTRIES Kconfig option that allows
to select number of root node entries that will be allocated while
creating FAT file system on a device.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit removes redundant memcpy operations and switches from
using TinyCBOR provided byte order converters to sys_be, native
to Zephyr.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
When system clock is set globally for the test which is executed
on various qemu platforms it may happen that clock is set too
high compared to CPU clock frequency. In that case test may stuck.
Added check and test skipping in that case.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Updated log_core to use spin lock instead of irq_lock.
Refactored z_log_msg_post_finalize function.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This is a bare minimal changes to tell the server that we are using
LwM2M 1.1 version. Queue-mode parameter has changed between 1.0 and
1.1 so it must be changed in the same time.
Other 1.1 features may follow on separate commits. This is still
an experimental feature that allows developing and testing of
1.1 features.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
LE Audio builds on top of the BT Host stack, and will
thus require a higher amount of stack size. Even simple
applications using BAP will likely reach the 1024 default
size with the default BAP configurations, and when
we start adding CAP and even TMAP/HAP on top of it, it
will likely increase even further.
The default value of 2048 is unlikely to be reached,
and applications that want to optimize can likely
reduce it, depending on the configuration.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This far time values have been synonymous to integer values. Content
formats like CBOR do use different representation.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
As use for simple message with no-segment send or receive.
This will be useful for ram-resource-constrained device.
such as bbc-microbit-v1.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Remove the BT_AUDIO_DEBUG Kconfig option.
Given that all the audio modules are guarded by the BT_AUDIO config,
it seems excessive to also have a separate guard for audio module
debug. It is sufficient that this is turned on/off module by module.
Note that the BT_AUDIO_DEBUG was also located in the wrong file - the
babs Kconfig file, not the main Kconfig file.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Remove the check for BT_AUDIO from the Kconfig files that had it, for
consistency (some files did not have it).
This check is not required - all Kconfig.* files are sourced from the
main Kconfig file _only_ if BT_AUDIO has been configured. As long as
this is the case, it is not required to check in the files themselves.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Added support for Portfolio object support because LwM2M v1.1 conformance
test requirement that. This object is only for conformance test purposing.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Before this change, enabling CONFIG_BT_SETTINGS and calling
settings_load(), but delaying / not calling bt_enable would trigger an
assertion error due to a timeout. The fault is that the settings load
handler for the Bluetooth host assumes bt_enable has already been called
and sends HCI commands to the controller. This times out if HCI is not
running.
The fix is to skip loading Bluetooth settings before bt_enable. The doc
is updated to guide the user on how to enable Bluetooth after settings
have been loaded before.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
- Prevent double callback with ADV re-scheduling
For configurations using CONFIG_BT_CTLR_JIT_SCHEDULING, when last
ADV before initiating connection is re-scheduled with a small delay,
the disabled_cb would be called a second time. This would unexpectedly
invoke a second conn setup with illegal parameters.
To avoid this JIT scheduler phenomenon, clear the ADV disabled_cb
when invoked.
- Add priority to LLL header. This allows the conn priority to be
associated with the object. Used in vendor LLL implementation.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Do not retransmit a message that just has been send successfully.
This case can in particular happen quite frequently if the modem
connection/throughput is quite bad and so there is a high latency.
A message that has to be acknowledged is scheduled for retransmission.
Before retransmission a ack for this message is received that will
cause a reset of the original message. In this case you see a
"LwM2M message is invalid" error message.
Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
After PR: https://github.com/zephyrproject-rtos/zephyr/pull/38296
If we receive the second recovery after 192 hours after the first
recovery, we may still not be able to perform any recovery, even
if the IV Index differs by 42, because the `ivi_was_recovered` flag
will only be cleared during the iv update.
But still May lose iv update, as we did the first iv recovery.
This patch by checking the iv duration, if 192h later, auto clear
`ivi_was_recovered` flag.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Read operation must return empty payload when read /object_id
if there is no created object instances.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Use dedicated function for calculating stack usage of the
interrupt stack(s).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add option to include analysis of interrupt stack(s) when
threads are analyzed.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
There is no releavnce between CAN sockets and offloading that would
prevent one from working with another, therefore it's not right to
allow CAN sockets to be build only if offloading is disabled. Fix the
wrong dependency in socket CMakeLists.txt file.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Added a missing assert statement for validation of the preferred
supervision timeout parameter which can be configured by the user
via Kconfig.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Minor improvement: Use already existing variable, rather than finding
the same value again. It is clearer, and simpler, to use the variable
everywhere this value is needed.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Avoids copying the address and assigning the SID if the
PA list is used, as the values are ignored by the
controller, and thus there is no reason to copy
or assign the values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The smp_process_request_packet has been checking return code from
mgmt_streamer_init_writer where Zephyr implementation of the
callback always returns 0.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fix bug in radio implementation that reported any transmit error
as `OT_ERROR_NO_ACK` to OpenThread.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
This is to support Sypnosys Designware SDMMC controller read and write
operation where the buffer address is needed to be 16bytes and 512bytes
aligned. Adding macro FS_FATFS_WINDOW_ALIGNMENT to align the "win"
variable address in FATFS struct.
Signed-off-by: Boon Khai Ng <boon.khai.ng@intel.com>
This solves the following issues:
- Auto-initiation of commands is aborted if one of the issued commands
fails
- The controller return value for a PHY update or DL update is not
made available to the application.
As a result, the host no longer prevents the application from calling
bt_conn_le_data_len_update() and bt_conn_le_phy_update() before the
auto-initiated procedure completes. Now the controller may or may not
accept the additional command issued by the application.
It also simplifies the code:
- We no longer need to keep track of if the auto-phy update
or auto-dl update has completed. If the controller receives
another LE Set PHY while the procedure is pending in the LL, it can
decide if wants to accept another procedure initiation or not.
- We no longer need to auto-initiate auto-initiation of commands in
multiple places
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Logging v2 did not support getting memory usage data. Adding this
support by creating common api for getting current and maximum
usage. Tracking of maximum usage is optional and can be enabled
using CONFIG_LOG_MEM_UTILIZATION.
Updated shell command to use common API.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
There were some references to slave and master left in the unittests
for the refactored LLCP.
These are changed in respectively peripheral and central
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Tests that when a collision happens, the connection attempt is retried
and that it succeeds.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The iso_rx_pool did not use the correct buffer size due to
a missing BT_ISO_SDU_BUF_SIZE, causing it to be too small.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Ensure that ISO-TP Consecutive Frames (CF) are sent in
FIFO/chronological order.
In order to ensure this, we can only have one CF queued in the CAN
controller TX mailboxes at a time, since transmit order for mailboxes
with the same CAN-ID (priority) is hardware specific.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Firmware uploading to the host may not always be desired,
disable it by default.
Enable it for existing USB DFU sample to keep
the usual behavior, add note about new option to README.rst.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Rename confusing UPLOAD_FLASH_AREA_ID to DOWNLOAD_FLASH_AREA_ID
as it is area where firmware image is downloaded.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
It is possible that the actual data stage length of
the control transfer is zero, in that case we do not
need an additional ZLP packet.
This fixes a problem with USB DFU, where after an upload
the device is no longer responsive if upload size is
multiple of control endpoint MPS.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Fix an issue where a test's suite name was misspelled and thus the
test never ran because it wasn't associated with a suite. Example:
ZTEST_SUITE(my_suite, NULL, NULL, NULL, NULL, NULL);
ZTEST(myy_suite, test)
{
}
The above will no longer pass since `myy_suite` with a double `y` will
fail the verification.
Signed-off-by: Yuval Peress <peress@google.com>
This fix a typo where incorrect member of bt_keys was used for
checking if LTK is present. This was resulting in bogus results
depending on connection role and current identity used.
This was affecting L2CAP/LE/CFC/BV-25-C qualification test case.
Fixes: #42862
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Periodic advertising sync may be created with CTE type filtering
enabled. When received AUX_SYNC_IND, there are HCI_LE_Periodic_-
Advertising_Sync_Established and HCI_LE_Periodic_Advertising_Report
events generated. In case received AUX_SYNC_IND has wrong CTE type,
HCI_LE_Periodic_Advertising_Sync_Established event is generated.
There may not be HCI_LE_Periodic_Advertising_Report event generated.
In this case node_rx, prepared by LLL, was not released in ULL.
It was lost in ull_sync_established_report.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CONFIG_BT_CTLR_DF_CTE_RX is enabled by default if CONFIG_BT_CLTR_DF
is enabled and there is support for DF in given SOC.
If CONFIG_BT_CTLR_DF_SCAN_CTE_RX is disabled then the CONFIG_BT_CTLR-
_PER_SCAN_CTE_NUM_MAX is not available.
It causes build errors if that particular configuration is used by
an application. It was a case for example in split builds of direction
finding connectionless TX sample application were periodic advertising
was enabled but perddioc advertising sync was disabled.
The commit fixes the problem.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Previously the data was set incorrectly when the data was set in
multiple operations. It did not take the previous state into account.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/42648
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
There were used an uninitialized variable to set antenna identifiers
length. The value should be set with use of params argument, not
by cp pointer that is not yet initialized.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix to use non-discardable Rx buffer for handling Extended
and Periodic Advertising Report.
Regression introduced in
commit 18171bc774 ("Bluetooth: Host: Non-discardable event
buffer size is 255 for ext adv"). The default discardable Rx
buffer size was reduced causing increased fragmentation and
deadlock trying to get more free discardable Rx buffers to
generate HCI Extended and Periodic Advertising reports.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This reverts commit e7489d8de7.
And fixes the deadlock by allowing only 1 thread to actualy clean up
the connection when the ref_count is 0.
Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
Fixes issue #39989.
Save CCC data on pairing complete by replacing private addresses
for the just bonded device with its public address in CCC attributes'
CFG arrays. This is then followed by calls to bt_gatt_store_ccc
and bt_gatt_store_cf for the just bonded device.
Signed-off-by: Jim Benjamin Luther <jilu@oticon.com>
On some platforms, if there are multiple MODBUS interfaces,
receiving of RTU frames may fail. Replacing while loop with
just "if" fixes this problem.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Fix race condition in setting up ISR callback and parameter
caused between ULL_HIGH and LLL context. As LLL IRQ is not
disabled the parameter and ISR callback would get out of
sync causing incorrect parameter supplied to callback and
hence leading to development assert in ull_scan_done().
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing use of auxiliary context to generate done event
which caused leak in release of auxiliary context being not
release when reference count that should decrease to zero.
Regression in 'commit 665a8d2c6e ("Bluetooth: Controller:
Fix repeated per sync drift compensations").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix reset of is_aux_sched flag when closing the primary and
auxiliary PDU reception. Without this fix when scan window
is closed there would be duplicate auxiliary release message
generated causing memory corruption.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add development assert to check the validity of auxiliary
context allocation. This is to ensure that primary PDU
reception does not have an auxiliary context allocated until
ULL has processed the node rx.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add development assert to check the validity of auxiliary
context's parent. This is to ensure a released auxiliary
context is not reused without allocation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This patch is to fix an issue where the transceiver chip is
disabled before it has transmitted all data. This causes the
message to be corrupted because the last few bytes are missing.
The fix adds a check to make sure the transmission is completed
before disabling the transceiver.
Signed-off-by: Marius Scholtz <mariuss@ricelectronics.com>
Takes the modem state machine by calling lcp_close instead of lcp_down
Using this method the LCP layer sends a TERMINATE_REQ to the modem and the
network interface is only taken down when the LCP layer has properly
finished.
Moved the ppp_mgmt_raise_carrier_off_event and net_if_carrier_down
to lcp.c to avoid breaking the interface.
Tested on a real modem.
Fixes: zephyrproject-rtos#41627
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Fixes bug where Host sends L2CAP Flow Control Credit after receiving a
L2CAP Disconnect Response.
The when the callback in l2cap_chan_le_recv_sdu is handed a Disconnect
Reponse, the connnection becomes disconnected, as illustrated by the
asserts. The function should now trigger sending credits if the
connection is disconnected after the callback returns.
Fixes#42112
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Fix Periodic Advertising Synchronization lost implementation
to avoid processing done event twice in cases of overlapping
events or race between sync terminate being requested.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add code comment related to sync context field used to
indicate the sync established event being generated towards
HCI Layer.
Co-authored-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update implementation to generate Periodic Sync Failed to be
Established when Sync Established message could not be
generate due to lack of free node rx buffers and when there
is sync lost before sync established message could be
generated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In case of error in hci_df_prepare_connectionless_iq_report function
e.g. due to wrong periodic advertising sync handle, uninitilized
per_adv_sync and IQ report object were passed by cte_report_cb callback
to an application.
Correct behavior in such situation is to not to cal cte_report_cb callback.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix any stray Extended Auxiliary PDU from being scanned
when disabling Extended Scanning.
Updated Extended Scan disable implementation to find any
active auxiliary scan context and stop them.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix advertising pdu latest get to defer release of stale
PDU chain buffers. Returning NULL after some buffers where
released causes LLL to assert when chained PDUs are
switched.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
many functions in the lwm2m librarys api take a pathstr argument
that is never written to, so make it const
Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
Nordic Semiconductor Radio peripheral provides IQ samples as
12 bits signed integer with sign extended to 16 bits.
Where out of range IQ samples (saturated) have value -32768.
Due to conversion of IQ samples to 8 bit signed integer, required by
BT 5.3 Core Vol 4, Part E sections 7.7.65.21 and 7.7.65.22 the
saturation information was lost.
The PR fixes that issue by use of value -128 to mark saturated
IQ samples. Note that BT 5.3 Core does not give any particular
value of IQ sample a special meaning.
This is a vendor specific solution and does not affect other
implementations of lower link layer.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The path was erroneously pointing to update state
resource instead of update result causing a wrong
resource value to be updated.
Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
After https://github.com/zephyrproject-rtos/zephyr/pull/41337, extended
advertising reports are no longer discardable. Ensure the
non-discardable events are large enough.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
The conn pointer is still valid / not reused at this time and can be
used further up the stack as an identifer. This simplifies the API of
ATT, and fixes callbacks in GATT that pass on this value directly since
their API does not allow conn to be NULL.
Fixes#41794
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Unlock tcp_lock when calling the recv_cb. In case when
a connection is being closed from both the tcp stack
and the application, a race condition can happen resulting
in locking each other out on tcp_lock and socket lock.
Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
Possibility to initialize USB device support is useful when
only CDC ACM class is enabled and CDC ACM UART is used as
backend for console, shell, or logging.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
HCI/GEV/BV-01-C tries to send 255 bytes over HCI, as part of sending
an unknown/unsupported command, but the default buffer size
is 65, which results in a buffer overflow and undefined behaviour.
Instead of crashing hard we now check the buffer length.
In order for EDTT tests to pass we set the buffer size to 255
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
This patch fixes an issue where mcux usb devices may stop
functioning after a reset event, because they do not
provide a USB_DC_DISCONNECTED event and USB_DC_RESET
events were not handled by the forward status callback.
Signed-off-by: Jacob Caughfield <mlsvrts@protonmail.com>
In previous commits the crc16_ansi() function has been made compliant
with the CRC-16-ANSI aka CRC-16-MODBUS standard. Use that standard
function instead of a custom one.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since this CRC uses the 0x1021 poly with no reflection, a faster
implementation is available in the crc16_itu_t() function, which is
O(n).
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix Periodic Sync Terminate implementation for race
conditions with ULL scheduling by using a flag to stop any
new ULL scheduling to receive chain PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There was missing a PDU initialization. CP bit in data channel
PDU heder was not cleared. Also cte_info byte was not crelader.
That lead to malformed control procedures PDUs and issues
with connection maintenance.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In direction finding connected mode there is a CP bit that is set
data PDU header. The bit was initialized only if CTE transmission
was enabled. In case of reception of a CTE the bit was available
in PDUs but not initialized.
That caused issues in connection maintenance if PDU memory buffers
were reused. PDU were malformed and connections were lost.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Guard call to k_thread_abort() to ensure it's not called with an
uninitialized thread and fix improper use of inet_pton() with
INADDR_ANY passed in place of a dotted-decimal string. Both of these
would otherwise lead to NULL pointer dereferences.
Signed-off-by: Berend Ozceri <berend@recogni.com>
Fix missing offset adjust field assignment in the Periodic
Advertising's sync_info struct that is present in the
Extended Advertising PDU.
When the sync offset is equal or over 2.4576 seconds from
the Extended Advertising PDU, then the sync offset has to
be reduced by 2.4576 seconds and the offs_adjust flag be
set in the sync_info field.
This fixes a bug where Periodic Synchronization could not
be established for Periodic Advertisings with intervals
greater than 2.4576 seconds as the sync offset was
incorrect due to rollover in the 13-bit offset field.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Firmware Update Protocol Support resource initialization
has been left out in #41402.
Initialise the resource in object creation function.
Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
The Exchange MTU sub-procedure shall only be supported on the
LE Fixed Channel Unenhanced ATT bearer.
This was checked when receiving, but sending was allowed.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The directory listing's record length should not reflect the size of the
directory listing object. This field is only the size of the directory
listing entry in the directory object and is intended to help a client
find the next record entry in the list.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
The packaged string coming from logging subsys requires some
additional processing if there are string arguments.
These strings are actually embedded inside the package so
the string pointers inside the argument list must be
replaced with pointers to strings inside the package.
Without this extra step of processing, MIPI Sys-T's printf
function would process these arguments directly which may be
NULL pointers or invalid one pointing to somewhere.
This utilizes the new cbpprintf_external() for the processing
before feeding data to the MIPI library.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The commit fixes smp_process_request_packet failing to decrement
message_size, of read stream, by number of bytes it trims from
an input buffer.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Increments send retry every time
after the tcp_send_data when resending.
That way unhandled return values can time
out after set amount of tcp_retries.
Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
The new macro USBD_STRING_DESCR_USER_DEFINE works like
USBD_STRING_DESCR_DEFINE with the exception of being
ordered strictly after it. The new macro is needed to
ensures that user defined string descriptors can be added
without disturbing the order of string descriptors
defined by the usb subsystem.
Signed-off-by: Alexander Mihajlovic <a@abxy.se>
Constant Tone Extension may not be transmittied with PHY CODED.
There were check to avoid situation that controller tries to
transmit or receive CTE when PHY is set to CODED.
These check were not conditionally compilated, hence when
PHY Update feature is disabled code did build.
The commit fixes the issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In case the direction finding RX is enabled but without Angle
of Arrival functionality enabled, there HCI command buffer
had wrong command length assigned. It didn't take into account
two dummy antenna IDs provided to fulfil requirement from
BT 5.3 Core Vol 4, Part E sections: 7.7.82, 7.7.85.
HCI driver when received such command buffer, didn't handle it
due to wrong command length.
The commit fixes the problem.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
BT_BUF_EVT_RX_SIZE size by default was set to 68 bytes.
In case of build with direction finding connected mode receiver
enabled the size of event buffer was not enough to store all
IQ samples. In such situation IQ samples reports were not delivered
to Host.
The commit changes default size of event RX buffer to 255 in
case the BT_DF_CONNECTION_CTE_RX is enabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction finding samples had dependency on KConfig option defined
in Controller. That caused a problem for split builds where
an application and host are not part of the same binary as
controller. The code dependend on the Kconfig option
was always disabled.
To fix that issue new Kconfig options were introduced to
Host. The dependency is removed. Unwanted features may stil be
disabled and samples binaier will be smaller.
The commit aligns all direction finding samples code.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
A common pattern here was to take the work item as the subfield of a
containing object. But the contained field is not a k_work, it's a
k_work_delayable.
Things were working only because the work field was first, so the
pointers had the same value. Do things right and fix things to
produce correct code if/when that field ever moves within delayable.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
OpenOCD is still using these alias, until we fix OpenOCD
upstream we should keep them.
This partially reverts commit
1a7bc06086.
Signed-off-by: Julien Massot <julien.massot@iot.bzh>
Fix duplicate incomplete data status generated for Periodic
Advertising Report when LLL scheduling is used but auxiliary
context failed to be allocated in ULL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix duplicate release of auxiliary context when scanning
uses LLL scheduling for reception of auxiliary PDU but the
reception fails.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Calling lwm2m_rd_client_stop causes the client context to be closed.
Doing this from arbitrary thread other than internal lwm2m engine thread
causes racing condition on lwm2m engine context pointers.
Fixes#42358
Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
Move the same peer periodic sync check to after check for
existing periodic sync create on both 1M and Coded PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing progression of the rx_last pointer when
appending rx buffers before flushing them towards Host.
Under continuous scanning, as the disabled_cb would only
be called when reference count reaches zero, the rx_last
pointer needs to progress when appending the rx buffers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing Periodic Advertising Report with incomplete
data status when ULL scheduled chain reception is aborted.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing Periodic Advertising Report with incomplete
data status when LLL scheduled chain reception is aborted.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Controller implementation to release auxiliary context
when there is no node rx buffer available to receive
Periodic Advertising Sync AUX_CHAIN_IND PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising Report data status when ULL
scheduling to receive auxiliary PDU fails. Defer the
dispatch of Periodic Advertising Report until ULL
scheduling status is comfirmed and assign the correct
value to aux_sched flag.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Server Object SSID should only have Read access.
LightweightM2M-1.1-int-256 confirmance test validate
that write operation to SSID should return error.
Overwrite SSID affect dead block for lwm2m engine and
only reset will heal.
Fix by adding bootstrap overwrite access for Security and
Server object when bootstrap is active.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Use explicit casting to long long within `snprintk()` and logger
functions to prevent compiler warnings with different
platforms/toolchins (as 64-bit integer can be either represented
as ld or lld depending on platform).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
At some point OMA TLV integer encoding was optimised to use the smallest
size possible. This broke the objlnk encoding, which internally used
`put_s32()`, but should always be 4 bytes long. In case the result
32-bit integer would fit into 16 or 8 bytes, it'd get optimized.
Fix this, by creating and writing TLV manually for objlnk instead of
relying on int32 encoder.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case a string with an integer was provided to the function (no
decimal point), the function did not update the output pointer value.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Verify the restult of the content writer functions and return an error
if content writer fails to read/write field in the message.
This solves an issue when for example malformed packet was sent to the
server if the payload did not fit in the message.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
It's now possible to return an error code instead of 0 where
appropriate.
Make `buf_read()` return -ENODATA instead of -ENOMEM if there's not
enough data in the packet to serve the request, which is more meaningful
for this scenario.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Rework the content encoder/decoder API to allow to return negative
values as well. This allows a proper error reporting and error handling,
as it's now possible to differentiate when there is no content to write
(retuned 0) or and error occured, and further processing should be
aborted.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When a file is download, `ctc->current` is increaed by the block
size, which is correct for all the blocks except the last one.
Once the download is compelted, ctx->current must match
`ctx->total_size`.
Signed-off-by: Efrain Calderon <efrain.calderon@aquarobur.com>
There were no wait for free notification buffer (pdu object
used to send notifications to Host).
That may cause assertion in lp_comm_ntf function.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Accodring to BT 5.3 Core Vol 4, Part E section 7.8.85 the CTE request
procedure has to be disabled as if Host issued the HCI_LE_Connection-
CTE_Request_Enable with enable property set to 0. It means a Controller
should automaticall disable the procedure.
There were no handling of this part of specification.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were missing pause of CTE request in case remote PHY change
was handled. That may end in violation of BT 5.3 Core Vol 6, Part B
section 5.1.10.1 Packet transmission restrictions.
Without the change there was a possibility to transmitt CTE when
PHY is about to change to PHY CODED.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add handling of complete event in idle state of localy innitiated
control procedures.
The transition will be used by CTE request disable if PHY changes
to CODED while the procedure is waiting in the waiting queue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CTE request may not be enabled when actual PHY does not support
transmission of constant tone extension. In case a connection is
asymetric, receive PHY is required to support transmission of CTE.
Receive PHY will be used by a device to get PDU with CTE.
In ll_df_set_conn_cte_req_enable was checking TX PHY type.
It should check RX PHY type.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add a function that is responsible for set CTE request disabled.
It is a refactoring, to have a single place where CTE request
is_enabled and req_interval are zeroed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were missing set of is_enabled member of CTE request.
That allowed host to run HCI_LE_Connection_CTE_Request_Enable
command with enable parameter set to true sequently.
That violates BT 5.3 Core specification Vol 4 Part B section
7.8.8.85.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The commit fixes smp_process_request_packet not checking header
stated message length against actual message length.
This could lead to an erratic behavior of an application when it tries
to parse CBOR data beyond actual size of message or potential
Zephyr crash.
When application has asserts enabled the error leads to inevitable
Zephyr crash, caused by net_buf checks.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fix net_pkt leak by increasing net_context the reference count earlier
in the zsock_accepted_cb() with instalment of the
zsock_received_cb() callback.
And consequently flushing recv_q and decrement net_context
reference count if zsock_accept_ctx() fails.
Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
In case system workqueue processing is delayed for any reason, and
resolver callback is executed after getaddrinfo() call already timed
out, the system would crash as the callback makes use of the user data
allocated on the stack within getaddrinfo() function.
Prevent that, by cancelling the DNS request explicitly from the
getaddrinfo() context, therefore preventing the resolver callback
from being executed after the getaddrinfo() call ends.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Now that the forced flag is cleared with the kernel locked in the
suspend path, we need to clear it out when the suspend process fails.
This is being done before jump to the end label because in the
successful path the flag is already cleared.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The "state forced" flag has to be cleared with the scheduler locked,
otherwise the idle thread can be scheduled out without clear it and
the next call to force a state will fail.
Fixes#41911
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Use UTIL_CAT which resolves input arguments instead of direct
preprocessor concatenation.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Enable debug pins when TF-M has been enabled for the image.
This would otherwise produce an error message as the DEBUG_SETUP would
not have been defined for the non-secure image.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix missing ISO Data packet received by Synchronized
Receiver due to incorrect check on sink handle that did
not permit handle value of 0.
Fixed function to get ISO stream context to check for
valid ISO sync context, i.e. not being terminated.
Regression introduced in commit 7c89f1fe9f ("Bluetooth:
controller: Support for separate ISO RX data path").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The changes smp_process_request_packet to return MGMT_ERR_ECORRUPT
in case when failed to read header.
This helps to recognize that there will not be any response sent
from mcumgr to the buffer given to smp_process_request_packet as
it has not been recognized as valid request.
It also removes redundant check on mgmt_streamer_init_reader which
always returns 0 (no failure) in Zephyr.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The previous approach to detect if the underlying transport was closed
(by checking the return value of `mbedtls_ssl_read()` was not right,
since the function call does not request any data - therefore 0 as a
return value is perfectly fine.
Instead, rely on the underlying transport ZSOCK_POLLHUP event - if it
reports that the connection ended, forward the event to the application.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Report ZSOCK_POLLHUP event if peer closed the connection, and thus the
socket is in EOF state.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The mcumgr image upload uses buffed flash writes with use of stream
flash, which makes flash alignment check unneded.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fix implementation to check for empty ADV_EXT_IND and
ADV_SYNC_IND PDUs, and not parse them incorrectly.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to limit Periodic Advertising data to a
configurable maximum length when generating HCI reports.
Bluetooth Test Specification defines Scan_Max_Data value
in IXIT. When HCI LE Periodic Advertising Report events are
generated by assembling the chain PDUs, the test cases
expect that if the data length is no more than
Scan_Max_Data, then at least once the IUT shall not
truncate the data in the advertising report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove redundant parameter pass of lll_aux to isr_done as
the auxiliary context use is always for scan context as the
parent.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor refactor of auxiliary scanning implementation to use
consistent variable naming and assignment close to its
locality of reference.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename per_scan field in scan context to periodic field to
avoid confusing with abbreviation for peripheral.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When the periodic advertiser list is used,
the address and SID may not be identical to those passed in by
the application.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
The CPU power states were declared with a typecast array literal,
which is a GNU extension.
Unfortunately some compilers (xt-xcc even in very recent versions,
when used with -fdata-sections) will die with a compiler error when
those rvalues are used in an expression that also takes their address,
e.g.:
/* this all by itself crashes xcc -fdata-sections */
int *foo = (int[]){0};
Declare the array elments in two steps, making the code standard C.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
`gatt_req_alloc` will wait until a `req` is free (or until timeout).
`req`s are freed on the BT RX thread in calls into bt_att_recv.
When `gatt_req_alloc` called on the BT RX thread itself when there are
no free `req`s, it will block the BT RX thread and deadlock. The
deadlock lasts until timeout.
This change detects this condition and returns the failure early.
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/39624 where
if `bt_gatt_write` is called from BT RX thread (as can happen if it is
called from a bluetooth callback), the BT RX thread can be blocked and
prevented from processing the request responses and unblocking itself.
This was the cause of a soft 30s deadlock until gatt_req_alloc timeouts.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
`gatt_write_ccc` may fail if it is unable to allocate a `bt_att_req`.
This change adds handling of this case to `bt_gatt_unsubscribe`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
tc_util.h is also included by unit tests and in that case it
cannot have dependencies to subsystems. Including log_ctrl.h
only for ARCH_POSIX where it is needed to flush logs before
exit.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix Periodic Advertising implementation to setup Power
Amplifier (PA) GPIO toggle for transmission instead of
incorrect Low Noise Amplifier (LNA) setup which is for
reception.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Define EVENT_SYNC_B2B_MAFS_US to use the Kconfig option
used to configure the MAFS between Periodic Advertising
chain PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising ADI Support feature bits so that
it is return back in the Read Local Supported Features.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising Sync LLL scheduling flag to not be
set when chain PDUs use LLL scheduling, only set when
primary AUX_SYNC_IND PDU received use LLL scheduling.
Without the fix, spurious EVENT_DONE_EXTRA_TYPE_SYNC would
be generated when chain PDUs are failed to be received. This
can cause Sync Lost message to be generated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The lll_scan_aux.c file does not compile when the new LLCP is
selected due to missing conditional compiles.
Conditional compile and proper tx_times are selected with this
commit
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
If any specific stream callback is attempted
to be called but is missing, a BT_WARN log statement
is added.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for the BAP broadcast sink role. This role
allows a device to sync to a broadcast ISO stream.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the BAP unicast client implementation. This role
can discover BAP unicast server services and initiate
BAP audio streams.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the Basic Audio Profile (BAP) unicast server
functionality. This allows a device to act as the
unicast server role, which can accept unicast streams
initiated by a unicast client.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Pointer to int was passed to a function which expected pointer to
uint8_t. There was an unexpected content for big endian as the
highest byte was read instead of the lowest which contained valid char.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fixed a dependency from printk.h to logging headers which in
certain configurations could lead to circular dependencies.
Cleaned up printk.c to call z_log_vprintk from vprintk.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Flushing logs here is especially vital if LOG_PRINTK is enabled.
In that case printk goes to log and without flushing after all
tests are run you will not get the final report out.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add implementation to limit Extended Scanned data to a
configurable maximum length when generating HCI reports.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When hashing attributes for the UUID cases:
BT_UUID_GATT_PRIMARY_VAL
BT_UUID_GATT_SECONDARY_VAL
BT_UUID_GATT_INCLUDE_VAL
BT_UUID_GATT_CHRC_VAL
BT_UUID_GATT_CEP_VAL
where (handle || UUID || value) is to be hashed, the worst case size of
attribute value can be deduced from the associated union that describes
all the attribute values in the given cases.
Update the data array to accommodate for the worst case size.
Fixes#39131
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
If HCI packet length is greater than endpoint MPS or currently
received data block (over USB), next block could be larger
than allocated net_buf buffer.
Check buffer tailroom before copying data using net_buf_add_mem().
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Function bt_buf_get_tx(), which is used to allocate buffer from
fixed-size pool, does not check size argument before copying
the data with the length size into fixed-size buffer, wich may
not be large enough.
Check immediately before copying if the tailroom of the buffer
is large enough.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
In a similar way as its done for IPv6. This allows to rejoin the group
once the interface is up again.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
CONFIG_OPENOCD_SUPPORT was deprecated in favor of
CONFIG_DEBUG_THREAD_INFO in Zephyr v2.6.0 and can now be removed.
Signed-off-by: Maureen Helm <maureen.helm@intel.com>
Conceptually the net_mgmt_lock should be a mutex instead of a
semaphore. It is easier to identify the owner of a mutex and
debug when deadlock happens, so convert it.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
For tracing_user, the sys_trace_isr_enter() & sys_trace_isr_exit()
block any nest interrupts & most SMP interrupts for the user. It is
hard to analyze the IRQ preemption(e.g., each IRQ counter and execution
time). This commit adds ISR nest level for each CPU to the user instead
of blocking user call back when nest interrupts.
Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
The commit fixes bug in compile time calculation of file download
chunk, FS_MGMT_DL_CHUNK_SIZE, that is permitted within selected
mcumgr buffer size, where the mcumgr header length has not been
taken into account.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit removes internal names given to Kconfig options,
in img_mgmt_config.h, and modifies code to use the Kconfig options
directly.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit removes internal names given to Kconfig options,
in fs_mgmt_config.h, and modifies code to use the Kconfig options
directly.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Set `body_start` pointer regardless of the body position in the recv
buffer. In result, the pointer shall indicate correctly position of the
body for each fragment, it's also explicit now that if the pointer is
not set for a fragment, there's no body in that particular fragment.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Validate the respective attribute parameters only if both are provided
at given level. This prevents from comparing for instance unset pmax
value (equal to 0) with some new pmin value sent by the server.
Additionally, fix the sanity check for the `pmax` value set on observer,
after fetching the attribute value at all levels (including the default
value at from the server object). Instead of using wrong max(pmin, pmax)
formula, set the pmax value only if it's a valid one (>= pmin),
otherwise ignore the value and set it to 0. This makes the notification
engine ignore the pmax value set for observation.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The CP bit is read in DF connected mode while interpreting
LL_CTE_RSP PDU, hence it must be available in struct pdu_data
type.
There were missing two Kconfig options in new LLCP tests.
They were reponsbile for disable of CP bit instruct pdu_data.
That caused tests to fail during compilation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add missing implementation for disabling CTE request and resposne
control procedures.
If any of these commands is active in LLL then ULL context has
to wait before return. The wait mechanism is based on semaphore.
The semaphore is initialized in ULL context and given by code
responsible for command completion.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
When there is pending local control procedure that has instant
it should be possible to run remote control procedure without
instant because there is no collision.
There were missing code to run this case in rr_st_idle() of
refactored LLCPs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There are packet restrictions imposed by PHY update procedure
for PDU that includes CTE (BT Core 5.3 :
- central/peripheral can't send PDU with CTE after receive or send
LLPHY_UPDATE_IND until instant if the PHY after instant is CODED
- peripheral can't send PDU including CTE after it sends LL_PHY_REQ
PDU until receive LL_PHY_UPDATE_IND, LL_UNKNOWN_RSP, LL_REJECTED_EXT_-
IND_PDU if there is a CODE PHY in TX_PHYS
- peripheral can't send PDU including CTE after it sends LL_PHY_RSP
PDU until receive LL_PHY_UPDATE_IND if there is a CODED PHY in TX_PHYS
of LL_PHY_RSP PDU or RX_PHYS of LL_PHY_REQ PDU.
The BT 5.3 Core spec defines only one PDU that may include CTE, that is
LL_CTE_RSP PDU. To avoid a situation that there is such PDU enqueued
for transmission in LLL when packet transmission restrictions should
be applied, both procedures in almost all cases will not be executed
in parallel.
Current implementation always handles remote procedurerequest first.
There are possible three scenarios:
1. Remotely requested PHY update. Locally initiated CTE REQ.
In this case there is no problem with LL_CTE_RSP waiting in a TX
queue in LLL. Both procedures may be executed one after another.
2. Remotely requested CTE REQ. Locally initiated PHY update.
In this case the CTE REQ is handled first and it will pause the
PHY update procedure until LL_CTE_RSP PDU is acknowledged by
remote. Then the CTE REQ procedure will be completed and PHY update
continued.
3. Locally initiated PHY update is pending. Arrives remote CTE REQ.
In this case the CTE REQ will be paused until localy initiated PHY
update is completed. Then the CTE REQ will be continued.
Thanks to that there should be no PDU including CTE in LLL TX quueue.
That releases us from a situation there is a LL_CTE_RSP PDU in the
LLL TX qeueue that must be changed into LL_REJECT_EXT_IND PDU due to
change of PHY to CODED PHY after PHY update procedure completes.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In peripheral role when:
- data length update is enabled
- the CONFIG_BT_MAX_CONN is set to 1
the PHY update control procedure after reaching instant sends two
notifications to host. It notifies host about PHY update and data
length change. Both notifications are send one after another, so two
free node rx are required. The number of available node rx in
provided conditions is one. The PHY update FSM is stalled in waiting
state for enough empty node rx. At the same time remote device is
allowed to send new remote control procedures. Received request are
handled by PHY update FSM that asserts due to unknown procedure opcode.
The commit changes number of allocated nodes to be two times a number
of LLCP connections.
This is a workaround for the issue. The best solution seems to be
sharing nodsx between connections. Though this solution requires
buffering remote control procedures until host notification is done.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Macros responsible for preparation of packet configuration flags in
regard of PHY and CTE were wrong. PHY flags are not used as regular
integer values but bits in a bitfield, hence size of the field in
packet configuration flags is three instead of two.
In such case CTE presen filed should be moved to bit 4th.
The problem was spot when testing implementation with CODED PHY
enabled. When device was sending PDUs that had attached CTE the
radio was configured to use CODED PHY due to wrong bit set in
packet configuration flags variable (overlapping of CTE bit
with CODED PHY bit).
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were no handling of HCI_LE_CTE_Request_Failed event.
The commit adds missing implementation. An application will
be notified about failed request by cte_report_cb. It is the
same callback that is used for reporting collected CTE IQ
samples. The same callback was used to avoid creation new callback.
To give an application possibility to distinguish between regular
IQ samples report and request failed additional member err was added
to bf_df_conn_iq_samples_report structure.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CTE request control procedure may failed due to rejection by
peer device or due to receive of LL_CTE_RSP PDU without CTE.
These events has to be reported to host by HCI_LE_CTE_Request_Failed.
The commit adds missing functionalit.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Integrate existing CTE request control procedure code in ULL with
implementation of refactor LLCPs.
The commit includes code responsible for:
- enabling CTE request and scheduling its execution by refactored
LLCPs framework,
- running CTE request periodically
- disabling CTE reqest in case it is running periodic
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There are data received from peer device with CTE request.
These data are not part of local CTE request procedure and
they don't belong to CTE response configuration, hence separate
storage was provided.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
ant_sw_len and ant_ids members of the structure llcp_df_rsp_cfg
were not used. These data are stored in lll_df_conn_tx_cfg
that is member of lll_conn. Unused members are removed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Part of the CTE request procdure that is related with handling of
remote request should be compiled when CTE RSP is enabled.
Withouth it CTE response will not work. Local CTE request does not
need code reponsible for handling of remote reques.
The commit changes conditional compilation guards.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were missing initialization for CTX request and response conotrol
procedure related variables. The variables were zeored on system
startup but not initialized when a connection is established.
In case of re-use of connection instance for new connection it was not
possible to setup procedures again.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Request interval is a number of connection events that
is used to periodically run CTE request control procedure.
BT 5.3 Core Specification defines it as 2 octets long.
It had wrong type uint8_t. Changed to correct one uint16_t.
The commit also changes type of cte_rsp_en field of lll_df_conn_tx_cfg
to state that it is a boolean flag.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CTE type and length parameters in connected mode are dependent
on remote CTE request procedure. These parameters are required
to setup radio to correctly transmit CTE. The same parameters
are also included in CTEInfo byte of data channel PDU header.
The parameters were provided to LLL with PDU to be transmitted
and by lll_conn::df_tx_cfg, hence it was redundant.
The PDUs CTEInfo has to be set before transmission anyway.
The contents of the PDU are set in ULL by CTE RSP control
procedure. To remove redundancy CTE length and type from lll_df_-
conn_tx_cfg were removed from ll_df_conn_tx_cfg. It was better
option becuse it saves instructions in LLL.
Radio in connected mode was configured by lll_df_conn_cte_tx_enable.
The function just unpacked the lll_df_conn_tx_cfg mebmers and
called static function df_cte_tx_configure.
Instead of extending parameters list of lll_df_conn_cte_tx_enable,
the function was removed and df_cte_tx_configure was changed to
be global function - lll_df_cte_tx_configure.
Now LLL directly passes all parameters from pdu_data::cte_info
and ll_df_conn_tx_cfg to lll_df_cte_tx_configure.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The llcp_pdu_encode_cte_rsp functio didn't set pdu_data fields related
with CTE transmission. The commit fixes that.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were wrong conditions in rp_comm_tx function for CTE request
that vefiry if:
- PHY is allowed one,
- CTE length is within allowed value.
The commit fixes it.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The CTE reception and sampling in connected mode was enabled
with CONFIG_BT_CTLR_DF_CONN_CTE_REQ. This is a separate fearure
tha can be enabled when CTE reqest procedure is disabled.
What more the CONFIG_BT_CTLR_DF_CONN_CTE_REQ is dependent
on CONFIG_BT_CTLR_DF_CONN_CTE_RX, not other way around.
The commit adds separate Kconfig to provide such possibility.
Also changes compilation guards for code related with the
CTE reception and sampling.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The implementation of the ll_df_set_conn_cte_req_enable function was
based on former implementation of LLCPs. The CTE request and response
control procedures are not implemented in former LLCPs framework.
The code has been updated to use data structues from refactored
implementation of LLCPs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were missing code responsible for execution of HCI_LE_Connection_-
CTE_Response_Enable HCI command.
The commit adds missing implementation into hci and upper link layer.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Updated hci_init function to call HCI vendor-specific Setup function
(bt_dev.drv->setup()) on beginning of HCI initialization.
This feature need when the BT Controller requires execution of the
vendor-specific commands sequence to initialize the BT Controller before
the BT Host executes a Reset sequence. To enable this feature the
CONFIG_BT_HCI_SETUP should be enable.
Fixes#41140
Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
A lot of tests need to be able to get their current tid and do some
action with it. It makes sense for the `before` function/rule to be
able to run in the same thread as the test. Note that the `after`
function does not run in the same thread because we need to guarantee
that it will run.
Signed-off-by: Yuval Peress <peress@google.com>
Algorithm was failing in case when overflow mode was enabled
but allocation of new message failed. It could happen if message
size exceeded buffer size. Losing track of buffered messages
can lead to logging processing freeze.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Implement an empty `otPlatLog` function when `CONFIG_LOG` is not
enabled. This also fixes the issue with `log_count_args` not being
available when logging is disabled.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
MIPS (Microprocessor without Interlocked Pipelined Stages) is a
instruction set architecture (ISA) developed by MIPS Computer
Systems, now MIPS Technologies.
This commit provides MIPS architecture support to Zephyr. It is
compatible with the MIPS32 Release 1 specification.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Skip re-initialization of statically initialized PDU struct
fields that are not modified at runtime.
When supporting connection oriented CTE, the cp bit and
resv field used for CTE info are modified, hence
re-initialized these and accordingly reset the values
when just-in-time HCI Tx Data fragmentation is performed
in the Lower Link Layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When a device returns -ENOTSUP for actions TURN_ON or TURN_OFF
the device state still has to be updated since the domain will
cut or restore the energy.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Add a function to tell runtime power management that the device is
starting in the off state instead of active or suspended.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Adds a helper for devices to check if they are on a power-domain or not.
Drivers can use this information to determine if they will be turned on
at some point in the future, or if they are already turned on.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Adds a helper function for running PM actions on child devices. A custom
implementation of `device_supported_foreach` is used as we don't
necessarily want the early exit behaviour of that function in the power
domain context.
The early exit behaviour can be obained through a return value in the
failure callback if that is desired.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Adds `PM_DEVICE_ACTION_TURN_ON` to transition from `PM_DEVICE_STATE_OFF`
to `PM_DEVICE_STATE_SUSPENDED`.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add a Kconfig symbol to enable/disable power domain on Zephyr.
Disabling power domain save some memory / space.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Add support for power domains on Zephyr. Power domains are implemented
as simple devices so they can use the existent Zephyr API, for resume
and suspend sync and async and also reference count.
The pm subsystem will ensure that domains are resumed before and
suspended after devices using them. For device runtime power
management, every time the device is got or released the same actions
is done to the domain it belongs.
As domains are implemented as simple devices, it is totally acceptable
a domain belongs to another domain.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Replace all get_dev_data()/get_dev_config() accessor utilities with
dev->data and dev->config.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Stop using redundant DEV_DATA/DEV_CFG macros and use dev->data and
dev->config instead.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Stop using redundant DEV_DATA/DEV_CFG macros and use dev->data and
dev->config instead.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
For x86, make the testing purpose trigger_irq() function to send
interrupt processor interrupt to CPU by APIC, instead of executing
INT instruction. Doing this because:
1. It can be controlled by irq lock, more close to trigger irq.
2. We don't need to hardcode the interrupt vector.
Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
The application may want to want the type of an
ISO channel, and take action based on what the type is.
It has been implemented as a get_info to be
consistent with other get_info functions in the
Bluetooth subsystem.
The bt_iso_info struct can be expanded with more information
later as required.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for the gateway object [EXPERIMENTAL] used by the
MG100, BT510, and BT610 LwM2M demo.
Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
If a central disconnects an ISO, then the `chan` pointer
will become NULL before attempting to call the
disconnect callback.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Using macro which will resolve complex SUITE_NAME. Without
it wrong name was assigned when SUITE_NAME was consists of
concatenated defines.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add maximum timeout used for conversion to Kconfig. Option is used
to determine which conversion algorithm to use: faster but overflowing
earlier or slower without early overflow.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit adds OPENTHREAD_PLATFORM_CSL_UNCERToption to Kconfig.
This option will allow user to configure openthreads CSL clock
uncertianity during build time.
Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
Adds clause so that the LPN must have a established friend
connection for the connection terminate callback to trigger
upon clearing a friendship.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Merges bt_csis_client_discover and
bt_csis_client_discover_sets, as they should be done
together for the discovery procedure from the CSIP
spec.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename struct bt_csis_client_set to
struct bt_csis_client_csis_inst, as that is more descriptive
of the actual content of the struct.
This also avoids the confusion about what a "set" is,
which is clearly not a single instance of CSIS
on a single remote server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Several APIs worked on the bt_csis_client_set struct,
which not only included information about a set, but
also a reference to a specific CSIS instance.
A specialized struct only for the set information
is more useful in those scenarios.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify bt_csis_client_get_lock_state to be the Ordered Access
procedure, which means that instead of reading a single lock value
on a single device, it will read the lock value for all
set members supplied in the function, and return true if any
of them is locked, or false otherwise.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The verify_members_and_get_inst can be used for more than just
locking the set, so checking the specific handle in that
does not make sense.
The handle is furthermore already checked in
csis_client_write_set_lock.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename bt_csis_client_lock_get to
bt_csis_client_get_lock_state. `get` could be
misunderstood as acquire, i.e. that `get` would
mean that the lock was taken by this device.
The new name should make it more obviously that it
is just a read procedure.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the addr struct from bt_csis_client_set_member as that
was only used by the upper layers and not the CSIS client
itself, and as such should only reside in the
upper layers.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change how the SIRK is exposed to the upper layers.
The SIRK will always be the unencrypted 16 octet
SIRK now, instead of a struct.
This not only allows us to avoid having a
__packed struct in the API, but also gives a better
API as we don't expose encrypted data to the upper layers.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the error code BT_CSIS_ERROR_SIRK_ACCESS_REJECTED
as it no longer exists in the specification.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Refactor the bt_csis_client_lock_get function to use a
pointer to a member and a set instead of a bt_conn
pointer and an index.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Refactor the bt_csis_client_lock_read_cb callback to use
a bt_csis_client_set pointer instead of conn and index.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Refactor bt_csis_client_discover_sets to use the
bt_csis_client_set_member struct instead of a bt_conn.
The bt_csis_client_set_member represents a remote server
(set member), and make it possible to avoid sending indexes
of instances around instead of bt_csis.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the lock and release sets functions, as well
as the discover member function as they have been removed
from the implementation a while ago.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the bt_csis_client_set_member struct to store the individual
bt_csis client struct. This way they are exposed to the
client application.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the bt_csis struct instead of the
bt_csis_client_svc_inst struct for the CSIS client.
This makes it more similar to not only the CSIS
implementation, but also the other LE Audio
client implementations.
Furthermore, this change will make it easier to use
bt_csis in the API in the future.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename the array to a more descriptive name and change the type
to bt_csis, as well as renaming the individual variables
when accessing the array.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the struct definition to the internal header file,
and add it to the bt_csis struct.
This also renames the csis_instance to
bt_csis_client_svc_inst to use the bt_csis prefix.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds state check to the friend_req_sent CB to ensure
that the CB does not alter the LPN state if it is in a
disabled state. This resolves behavioural issue for lpn_set(false).
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Reduced logging mode selection to deferred, immediate, minimal and
frontend. Decoupled logging version from mode and created CONFIG_LOG1
which can be used to explicitly select deprecated version.
From now on, chosing CONFIG_LOG_MODE_{IMMEDIATE,DEFERRED} will result
in version2.
Deprecated CONFIG_LOG2_MODE_{IMMEDIATE,DEFERRED} with cmake warning.
Codebase adapted to those changes.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Up till now the littlefs only has been supporting the flash medium in
Zephyr.
This change provides code to also use littlefs stored on the block
devices - like SD card (accessed via SPI).
When FS_LITTLEFS_BLK_DEV Kconfig option is defined, the support for
using littlefs on block devices is enabled.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
The struct flash_area *area pointer has been renamed to void *backend
pointer.
This change is enabling further rework of the littlefs subsystem to work
with other backend devices (like block ones - i.e. SD card).
Signed-off-by: Lukasz Majewski <lukma@denx.de>
bt_mesh_subnet_find calls a callback for every subnet, and returns the
subnet that got a non-zero return code from the callback. As pointed out
in #41693, the callback should return a boolean, not an int.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Adds fix so that a node running with extended adveriser is able to
enable GATT proxy correctly. This fixes a corner case issue where a
device with no other ongoing message sending is unable to advertise
the GATT proxy through
bt_mesh_gatt_proxy_set(BT_MESH_FEATURE_ENABLED) .
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Hexdump via logging is supposed to be human-readable for
debug information. Therefore, it should actually print
in human-readable form (well... after some magical decoder
has processed the raw MIPI Sys-T output).
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If the advertiser is not running, the host can now set
periodic advertising data in multiple operations.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Provide possibility to have instance specific callbacks
for writing the FW image and executing the update
Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
Previously the object 5 was only single instance object. Provide
backwards compatibility, so it can be continued to use with single
instance.
Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
This is a proof-of-concept implementation.
A device might have multiple firmware images which needs to be updated
separately. For example a single device might have
* A bootloader image
* An application image
* External firmware image
Instead of pushing all these updates through the object instance 0 -
/5/0 - here a split to multiple has been made possible.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
Provides interface, data structures and demuxing capability for ISO RX
PDU allocation and transport from LLL to HCI.
Uses the RXFIFO composite for simplicity and reduced overhead.
Signed-off-by: Morten Priess <mtpr@oticon.com>
The overall code coverage report of mps2_an385 was blocked by the
tests/net/lib/coap, the error message shows "No Mem available to
continue dump". So we enlarge the gcov heap size to prevent this
situation, try to make the report can be generated at least.
Signed-off-by: Enjia Mai <enjia.mai@intel.com>
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Validate the OACP and OLCP procedure sizes as the procedure is parsed.
This is in contrast with the current implementation which first parses
the procedure and then validates its size and is prone to accessing
invalid memory when the procedure is malformed.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
Add a way to filter scan results by name and/or
address. The idea is that this can be further expanded
by also scanning the content for specific UUIDs, PHY,
RSSI, etc.
This is particularly useful for cases where there are many
devices advertising at once.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix initial thread priority and move starting of the
test timer after threads initialization to ensure that
it does not expire before threads are initiated.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Currently, ztress is not supporting SMP, mainly because of
cpu load calculation algorithm. It may be re-enabled in the
future.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Move coredump_backend_api struct to public header so that custom backends
for coredump can be defined out of tree. Create simple backend in test
directory for verification.
Signed-off-by: Mark Holden <mholden@fb.com>
`tracing_user.h` lost several definitions, which made
CONFIG_TRACING_USER build fail. This fixes the TRACING_USER
config & adds it to the test case.
Moreover, the idle task stack is overflow on qemu_x86, qemu_cortex_m0 &
qemu_riscv64. This makes the test fail. So this commit sets the idle
stack size to 2048 for this sample to avoid it.
Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
The intention behind this patch is to know the current state/result
of a firmware update process in the application code. It makes it
possible to use pre/post_write_callbacks to get the proper value
of state (5/0/3) and result (5/0/5) resource.
Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
If there were local LLCP pending and connection lost happened there
were no release of allocated control procedure context.
It caused to exhaustion of available procedures.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Default value for CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM was set to
CONFIG_BT_CTLR_LLCP_CONN, so the value was 1. That caused a problem
if a device had started a local control procedure and remote procedure
request was received. Ther there were no free context for remote
procedure.
The commit changes the range of allowed value to start from 2.
Also the default value is set to two if CONFIG_BT_CTLR_LLCP_CONN
is 1. In other case default value is set to number of CONFIG_BT_-
LLCP_CONN.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The tasktat code filling reposes with use of CBOR has been modified,
utilizing lazy evaluation of C '||' operator, to terminate CBOR
encoding as soon as first error appears.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds OS_MGMT_TASKSTAT_STACK_INFO Kconfig option
that allows to skip, when disabled, "stksz" and "stkuse" reports,
in "taskstat" command responses.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds Kconfig options and supporting code that allows
to select characteristic that will be used for thread name
in taskstat from:
- thread name, when THREAD_NAME is enabled;
- thread ID/index;
- thread priority.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
By default the mcumgr taskstat responses send task priorities
as unsigned integers, while Zephyr uses int8_t as priority type.
This commit adds OS_MGMT_TASKSTAT_SIGNED_PRIORITY Kconfig option
that allows to switch to use signed priorities in responses.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The change adds OS_MGMT_THREAD_NAME_LEN that allows to set length of
thread name that is returned in taskstat response.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit changes taskstat code to directly process thread information
from Zephyr structures, instead of translating them to system agnostic
layer, before formatting response.
It also moves the takstat code to os_mgmt.c.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit removes os_mgmt_config.h that has been translating Kconfig
options to mgmt internal definitions for constants, and replaces
usage of these constants with direct use of Kconfig options.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
1. Test suites in prior ztest serve no purpose other than logical
ordering of tests into a named-group. Move the construct of setup and
teardown into the test suite and away from individual tests.
Additionally, add the constructs of before/after to the test suites.
This model more closely resembels other testing frameworks such as gTest
and Junit.
2. Test can be added to a suite by using ZTEST() or ZTEST_F() where _F
stands for fixture. In the case where _F is used, the argument `this`
will be provided with the type `struct suite_name##_fixture*`. Again,
this models other modern testing frameworks and allows the test to
directly access the already set up data related to the test suite.
3. Add the concept of test rules (from Junit). Rules are similar to the
before/after functions of the test suites but are global and run on all
suites. An example of a test rule can be to check that nothing was
logged to ERROR. The rule can cause the test to fail if anything was
logged to ERROR during an integration test. Another example would be a
rule that verifies that tests ran within some defined timeout.
Signed-off-by: Yuval Peress <peress@google.com>
The PM state code is in practice useless when no cpus are defined in DT,
so require this node to be defined.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Return a constant reference to the next state instead of a copy of
struct pm_state_info. When the next state should be active, just return
NULL. Struct copying should be in general avoided, specially in code
paths executed frequently as is this one.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Use the pm_state_cpu_get_all API to obtain the list of available CPU
states. This changes reduces the need for non-interesting code within
the policy codebase.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Adds two routines to flush pipe objects:
k_pipe_flush()
- This routine flushes the entire pipe. That includes both
the pipe's buffer and all pended writers. It is equivalent
to reading everything into a giant temporary buffer which
is then discarded.
k_pipe_buffer_flush()
- This routine flushes only the pipe's buffer (if it exists).
It is equivalent to reading a maximum of "buffer size" bytes
into a temporary buffer which is then discarded.
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Serial line interface does not use transaction and protocol
IDs. Continue to use memcpy() for the whole frame as it is safer
and more efficient but temporarily store transaction and protocol
IDs, and write it back if the transfer was successful.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Updates the kernel service to display the extended thread
runtime stats when the following shell command is issued.
kernel threads
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
The usage count and device power state has to be restored when the
device action callback fails in the async operation. Otherwise it will
lead to an inconsistent state.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Implementing the final parts of procedure pause mechanism
This is needed to bar procedures from generating pdus during encryption
procedure handling
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
wip
Rename a few CAN API functions for clarity and consistency with other
Zephyr RTOS APIs.
CAN_DEFINE_MSGQ() becomes CAN_MSGQ_DEFINE() to match K_MSGQ_DEFINE().
can_attach_isr() becomes can_add_rx_filter() since a filter callback
function is not an interrupt service routine (although it is called in
isr context). The word "attach" is replaced with "add" since filters are
added, not attached. This matches the terminology used is other Zephyr
APIs better.
can_detach() becomes can_remove_rx_filter() to pair with
can_add_rx_filter().
can_attach_msgq() becomes can_add_rx_filter_msgq() and documentation is
updated to mention its relationship with can_add_rx_filter().
can_register_state_change_isr() becomes can_set_state_change_callback()
since a state change callback function is not an interrupt service
routine (although it is called in isr context). The word "register" is
replaced with "set" since only one state change callback can be in
place.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
`bt_gatt_cancel` takes a `bt_gatt_.._params` pointer. The `params`
pointer is mistakenly passed on to `bt_att_req_cancel`, which expects a
`bt_att_req`.
This change makes bt_gatt_cancel locate the `req` and pass that to
`bt_att_req_cancel`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Co-authored-by: Emil Gydesen <Thalley@users.noreply.github.com>
The strtol() function use errno to return error code.
However, it is not being initialized in the parser_arg()
function before calling the strtol(). Thus, hitting error
when performing net ping command with -c / -i parameters.
Signed-off-by: Kweh Hock Leong <hock.leong.kweh@intel.com>
This structure can be reused to set periodic advertising data.
The structure tries fills the buffer as much as possible.
Later this can be reused for setting advertising data in other cases
as well.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
bt_le_stop() previously did the same restting as bt_scan_reset(). After
the recent changes they were out of sync.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
How the conversion worked was unclear. Moving the conversion out to a
separate function and documenting how it works makes the code easier to
understand.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The host reassembles fragmented advertising reports from the controller.
Non-complete advertising reports from different advertisers may not be
interleaved. If non-complete advertising reports from an advertiser
is received while advertising reports from another advertiser is
reassembled, an error message is logged and the advertising report is
discarded. Future scan results may be incomplete.
Advertising reports from legacy PDUs or complete extended advertising
reports may be interleaved as these do not require reassembly.
If the controller sends more advertising data than fits in the
reassembly buffer, the data is truncated. Further advertising reports
from the advertiser are discarded until the final complete advertising
report is received and discarded.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Getopt has been rework in this way that calling it does not require
extra state parameter and its execution is thread safe.
Global parameters describing the state of the getopt function have been
made available to ensure full API compatibility in using this library.
However, referencing these global variables directly is not thread
safe. In order to get the state of the getopt function for the thread
that is currently using it, call: getopt_state_get();
Extended the library with getopt_long and getopt_long_only functions.
Moved getopt libary from utils to posix.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
When logging is using immediate mode then logging messages
can be processed from any context, including interrupt context.
z_shell_fprintf was asserting in that case since it allowed to
be called from interrupt context only when logging was in panic
mode. However, shell works in the same way when logging is in
immediate mode as in panic mode.
Renamed internal shell flag from panic_mode to sync_mode. Flag
is also set when shell log backend is started in synchronous
mode (immediate logging) which prevents assertion.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
When message is dropped then log_process is called with
bypass flag set and additionally z_log_dropped() is called.
In both functions counter of buffered messages was decremented.
That resulted in counter being decremented twice. It resulted
in logging misbehavior after messages being dropped (delayed
processing). Fixing it by decrementing the counter in log_process
only when bypass flag is not set.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Use value returned by atomic_inc to decide on action.
Previously direct value was used and that could lead to
delays in logging processing because thread waking up
could be mishandled.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Only consider negative statuses returned from a L2CAP server as error.
This makes the status check done here consistent with the check done in
l2cap_chan_le_recv_sdu.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
Adding functions log_output_msg2_syst_process and hexdump2_print
to support v2 logging subsystem.
Updates west.yml to pick up a new version of the MIPI sys-t library that
supports vprintf.
Signed-off-by: Aastha Grover <aastha.grover@intel.com>
Signed-off-by: Maureen Helm <maureen.helm@intel.com>
The signature of bt_mesh_app_key_resolve expresses pointer to a 16 byte
array as a const uint8_t *app_key[16], which is actually an array of 16
byte pointers. The intended type is equivalent to a double pointer to
const uint8_t, but trips up GCC 11, which actually checks this.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The crypto.h declaration of the bt_mesh_beacon_auth function declares
the net_id parameter to be a 16 byte array, but the function definition
says 8 bytes. This breaks compilation in GCC 11, which feeds an 8 byte
array into this API, triggering a warning. Change the header declaration
to 8 bytes, which is the right size.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Tag can be changed at runtime. Feature is enabled by setting
maximum tag length to positive value. Additionally, default
tag can be configured in Kconfig.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Reset duplicate filtering of Periodic Advertising Reports
when Periodic Advertising Sync is created again after a
terminate or sync lost.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing implementation to use correct data status when
detecting duplicate Periodic Advertising Report data.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing data status reset when DID change, based on
whether the data status is complete or not, the entry needs
to maintain the correct data_cmplt flag value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The CTE type is used in two ways by HCI layer:
1) single value representing particular CTE type: AoA, AoD 1 us,
AoD 2 us
2) bit-filed where bits 0-2 represent particular CTE types AoA
AoD 1 us, AoD 2 us
The bit-field is used to inform Controller about allowed types
of CTE, hence single value carries more than one value.
To avoid confusion between these use cases in code that refers
to case 1) all named cte_type (singular form). For case 2)
cte_types (plural form) is used.
There is an enumeration that is used for both cases:
bt_df_cte_type. For cte_type only single value from the
enumeration may be assigned to variable except
BT_DF_CTE_TYPE_NONE and BT_DF_CTE_TYPE_ALL.
For cte_types all enum members may be used. Ocasionally
BT_DF_CTE_TYPE_NONE may be excluded. If that is true,
it is described in code documentation.
Thanks to that applications are released from requirement
to include hci.h header file.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were no implementation for HCI_LE_Connection_CTE_Request_Enable
command from BT 5.3 Core specification.
The PR adds implementation and API to be used by applications.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Code that is part of radio_df_cte_inline_set_enabled may be not
compilable for targets that do not have Direction Finding Extension
in Radio peripheral. Added condition with IS_ENABLED to execute
the code only for those SOCs that have the extension.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were changes done to controller code that cause
tests to do not build and fail during execution.
Changes are related with:
- modified code related with extended advertising ADI
field handling
- added generic double buffer data structure that is
used in controller
- moved code that was building only when DF is enabled
- added EVENTS_PHYEND that is not available in nrfbsim
board
The PR addresses those issues.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Connectionless mode of direction finding was based on assumption
that PDU ends when EVENTS_END is generated.
Advertiser added CTE length to IFS duration to correctly maintain
IFS between consecutive PDUs.
Scanner was using separate API to configure radio to configure
software TX/RX mode switch to use PHYEND event instead of END.
Currently every SOC that has Direction Finding Extension in
Radio peripheral uses PHYEND event to mark end of PDU.
There is no need for separate API to configure software switch.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Radio peripheral that includes Direction Finding Extension is
able to generate EVENTS_PHYEND at very end of received PDU.
In case there is a Constant Tone Extensions in received packet
the EVENTS_PHYEND event is generated after end of CTE reception.
If the CTE is present in received packet, the EVENTS_PHYEND
event is generate in the same instant as EVENTS_END.
If CTEINLINE is enabled then Radio will do a runtime packet parsing
to check if CTEInfo is present in received packet. In case there
is no CTEInfo the EVENTS_PHYEND event will be generated with
16 us delay after EVENTS_END.
To maintain the IFS, additional EVENT_COMPARE is used that
will timeout earlier than regular EVENT_COMPARE for EVENTS_PHYEND
generated withtou delay. That additional EVENT_COMPARE will start
software switching of radio mode to TX. In case there is a CTEInfo
present in the packet, additional PPI wiring will cancell
EVENTS_COMPARE set for delayed EVENTS_PHYEND.
The commit provides changes to support delayed PHYEND for nRF53 SOCs.
Besides that there are small formatting corrections due to extended
max line length.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In connected mode when Receiving Constant Tone Extensions feature
is enabled, controller shall be able to receive CTE in any
data channel packet.
The commit adds required changes to allow receive of CTE for
all data channel packets in peripheral role.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CTEInfo may be stored in S1 byte for BLE1M or BLE2M data channel
packet or in payload of advertising channel packet. To allow
selection of where to expect the CTEInfo to be Radio and
DF lower link layer API has to be changed. New parameter
cte_info_in_s1 was introduced.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There are multiple places where double buffer is used in controlers
code. This commit adds generic implementation of the double buffer.
It can be used in future in all places where the data structure is
in use.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Radio peripheral that includes Direction Finding Extension is
able to generate EVENTS_PHYEND at very end of received packet.
In case there is a Constant Tone Extensions in received packet
the EVENTS_PHYEND event is generated after end of CTE reception.
If the CTE is not present in received PDU, the EVENTS_PHYEND
event is generate in the same instant as EVENTS_END.
If CTEINLINE is enabled then Radio will do a runtime packet parsing
to check if CTEInfo is present in received packet. In case there
is no CTEInfo the EVENTS_PHYEND event will be generated with
16 us delay after EVENTS_END.
To maintain IFS, additional EVENT_COMPARE is used that
will timeout earlier than regular EVENT_COMPARE for EVENTS_PHYEND
generated withtout delay. That additional EVENT_COMPARE will start
software switching of radio mode to TX. In case there is a CTEInfo
present in the packet, additional PPI wiring will cancell
EVENTS_COMPARE set for delayed EVENTS_PHYEND.
The commit add support for delayed PHYEND event for nRF52 SOCs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To make possible to correclty receive PDUs that optionally include
Constant Tone Extension after CRC the PHYEND event must be used
instead of END event. PHYEND event is generated by Radio peripheral
for actual end of a PDU. In case there is a CTE the PHYEND event
is generated at end of the CTE. If PDU does not have CTE, then
PHYEND event is generated at end of CRC. In this case it is the
same instant as END event.
Use of PHYEND event is required only when BLE 5.1 Receiving Constant
Tone Extensions feature is supported. Because it is the same event as
END for SOCs that supports Direction Finding Extension, it is always
used for that SOCs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Changed resource IDs 11 and 12 of the security object to use
signed integer as they are defined in the OMA specification.
Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
Update the connectivity monitor object to version 1.2.
OMA core specification for the object adds 2 optional
resources.
Signed-off-by: Jarno Lamsa <jarno.lamsa@nordicsemi.no>
According to MbedTLS API documentation, its session must be reset if
mbedtls_ssl_handshake returns something other than:
- 0
- MBEDTLS_ERR_SSL_WANT_READ
- MBEDTLS_ERR_SSL_WANT_WRITE
- MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS
- MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS
In MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS and
MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS cases the function must be called
again when operation is ready. These cases now return -EAGIN or
continue to retry if it's a blocking call.
Signed-off-by: Ramiro Merello <rmerello@itba.edu.ar>
Add the BT_GATT_WRITE_FLAG_EXECUTE flag that indicates
whether a write callback is from an ATT execute write.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The current implemenation of GATT long write
(ATT prepare + exec write) worked by sending
each segment individually to the application.
This was a simple and effective method, but
the application had no indication of when the
last segment had been written.
This commit reassembles all the prepare writes
for a specific handle, and then sends the combined
write data to the application.
The prepare+exec write may include multiple handles,
so the implementation has taken that into account,
and will loop over the prep_queue multiple times.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the type of the prep_queue to a linked list
instead of a fifo. The main reason for this, is
that we can then iterate over the content in it,
without popping it.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add host API to allow execution of HCI_LE_Set_Connection_CTE_Transmit_-
Parameters HCI command.
The commit also provides a refactored version of hci_df_set_conn_cte_tx-
_param function. The function was aligned to other hci_df_XXX functions
structure with separated parameters validation and preparation of
command object before it is send to controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Co-authored-by: Emil Gydesen <Thalley@users.noreply.github.com>
OS_MGMT_TASKSTAT depends on THREAD_MONITOR, so when it defaults to y
and THREAD_MONITOR is disabled we get a build error.
Add a depends on to enforce a correct configuration.
Remove default y, as features should be default n.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
zephyr_os_mgmt_task_at and friends are ifdef'ing on a feature they
depend on instead of their own Kconfig option.
Which is not correct.
ifdef on CONFIG_OS_MGMT_TASKSTAT instead.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Change the can_tx_callback_t function signature to use an "int" (not an
uint32_t) for representing transmission errors.
The "error" callback function parameter is functionally equivalent to
the return value from can_send() and thus needs to use the same data
type and needs to be able to hold negative errno values.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Added framework for concurrency testing. Framework setup multiple
priority contexts and executes user handlers in that context. Test
terminates after certain number of repetitions or preemptions or
when timeout occurs. It can also be aborted by the user.
Framework can be used for testing resiliency to preemptions.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Update Controller implementation of Advertising Extensions
to inherit the set dynamic Tx power values of the primary
channel PDU transmissions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In MCUboot:
commit 4aa286d2db2d02a8f0ff29cdc3304f3185dbe261
Author: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
Date: Wed Nov 24 14:54:56 2021 -0300
flash_map: Increase minimum supported write align via
flash_area_align
MCUboot changed the type of the alignment value in flash from a uint8_t
to a uint32_t. Indeed, Zephyr contains flash devices that have a larger
alignment than will fit in an 8-bit value. This generally means that
`flash_area_align` will just return 0 on these platforms.
Change call in Zephyr as well.
This shouldn't cause any observable behavior changes in Zephyr, other
than making some cases that don't work currently begin to work. If a
client is storing these results in a u8, it will be truncated, the same
as things were previously. If, however, the caller is prepared to
handle a larger type, this will result in having correct information,
instead of the truncated value.
Signed-off-by: David Brown <david.brown@linaro.org>
Rename the variable drop to accept to avoid multiple use of
negations in the implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use DUP_FILTER_DISABLED define instead of magic value to
represent duplicate filtering being disabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update support for Periodic Advertising Synchronization
Receive Enable command, so that PDUs are received so that
contents of Extended Common Payload Format is parsed and
process for information like Channel Map Update and BIGInfo.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Period measurement should be started right after a message is updated.
That is because `struct bt_mesh_send_cb.start` callback is called from
the advertiser thread which is not necessary to be scheduled immeditely
and a user may see some delays between update handler calls.
The publication timer still needs to be scheduled after a message being
actually sent out to the air so that access layer doesn't overflow the
advertiser's buffer. To achieve some specific use cases, where a
published message needs to be retransmitted with 50ms interval, a user
has to switch off network retransmissions to make the legacy advertiser
sleep for the shortest possible time.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Wrong variable was passed when isr_done was registered. It lead to
memory faults and exceptions. It should be a pointer to lll_adv_sync
instance instead of lll_adv.
The commit fixes the issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix Periodic Advertising Synchronization Auxiliary context
leak when failing to receive chain PDUs.
Auxiliary context has not being associated with sync context
when ULL scheduling was used.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Periodic Advertising Synchronization Reports do not use a
list for the received chain PDUs, remove the stale code that
free extra list.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising Synchronization to private address
when public and static identity address is supplied as peer
device address to synchronize to.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising Report's AD data and Scan Response
total data length type to use uint16_t.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix HCI fragment of Extended Advertising Report when chain
PDUs are received. Implementation was missing HCI event
generation for last frag of each PDU when there was a next
chain PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As EVENT_OVERHEAD_START_US offset is used in ticks unit in
LLL, ULL scheduling using ticker should also use ticks unit
for EVENT_OVERHEAD_START_US when reducing the first Periodic
Advertising event preparation.
Relates to commit 858dc7fab4 ("Bluetooth: controller: Fix
EVENT_OVERHEAD_START_US jitter").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix undefined reference to radio start time in FEM support
in ISO Synchronized Receiver implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In the ISO Data the payload number shall be the value of
bisPayloadCounter for the PDU containing that payload.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add configuration of transmission of CTE in connected mode.
The transmission is enabled only for PDUs that have CTE present (CP)
bit set to 1.
Radio peripheral is configued by df_cte_tx_configure to transmit CTE.
The same parameters are set for connected and connectionless mode.
The function was changed to re-use the same code for configuration
of CTE in both modes.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To transmit CTE with data channel packet the CTE configuration must
be stored in S1 field, that is placed just after length field.
The commit changes radio_pkt_configure function to allow configuration
of S1 field. When S1 field is used to store information about CTE
then its length is 8 bits. The content of the field is filled with
CTEInfo data. The same as the one used in periodic advertising.
The signature of the radio_pkt_configure function was not changed.
There were not used bits in flags parameter of the function.
From now on, bit 3 of the flags parameter will be used to store
information whether CTE will be added to the packet.
Besides that changed, the commit provides set of macros that
help in preparation and validation of the flags parameter content.
Macros provide information about bits that are currently used.
Ther are also macros that help to retrieve particular information
stored in the flags parameter.
Every place of code where the radio_pkt_configure function occurs
was changed to use provided macros.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
HCI_LE_Set_Connection_CTE_Transmit_Parameters host command was
not completely implemented in controller. There were missign
storage of TX parameters in ll_conn instance.
The commit adds missing part of the command handling.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
If the CTE is attached to data channel packet, the packet must
include information about CTE. The information is stored in
CTEInfo structure that is available in S1 byte of a packet.
Radio checks if the S1 byte is present by verification of
CTE present (CP) bit in byte S0.
The commit add these data to pdu_data structure declaration.
That allows to prepare packet before it is parsed and send
by Radio peripheral.
Besides that there added a new function ull_pdu_data_init that
initlializes fields in pdu_data object that are read only by
lower link layer. CP bit in S0 byte and content of S1 bytes
are examples of such fields.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
When PDU has CTE added to the end, the PHYEND event must be used
to correclty switch between TX and RX. END event is triggered just
before start of CTE.
The commit adds new function that configures radio to disable after
PHYEND is generated and then swtich to RX.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Log_strdup was used in NET_ASSERT macro which is not logging.
As a result linking fails when logging is disabled but asserts
are enabled.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
this entry is already defined in subsys/bluetooth/Kconfig. let's keep
that one since it's used by the controller as well.
Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
For instance, DHCP (UDP protocol) can send broadcasted packet and if we
no not serve the requested destination port, let's not send an error
back.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Invert src/dst strings, the icmpv4 error is sent from the dst (us) to
src (sender of the ipv4 packet that generated the error).
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
When support for custom MRU/MTU was added with
CONFIG_NET_L2_PPP_OPTION_MRU=y, code flow with
CONFIG_NET_L2_PPP_OPTION_MRU=n has been broken due to lack of valid
'ctx->lcp.my_options.mru' initialization and its use (with value 0) in
the implementation.
Initialize 'ctx->lcp.my_options.mru' unconditionally in lcp_init(), so
that PPP works fine with CONFIG_NET_L2_PPP_OPTION_MRU=n.
Fixes: 8a51a79d89 ("net: l2: ppp: possibility to have a custom
MRU/MTU")
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This provides the infrastructure to create network packet filter rules
and to apply them to the RX and TX packet paths. Rules are made of
simple condition tests that can be linked together, creating a facility
similarly to the Linux iptables functionality.
A couple of generic and Ethernet-specific condition tests are also
provided.
Additional tests can be easily created on top of this.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Adds support for LWM2M object 9 Software management.
This is implemented according to this release:
http://openmobilealliance.org/release/LWM2M_SWMGMT/V1_0_1-20200616-A/
Note that the XML is lacking some resources and for that reason those
resources are not included. This is a known problem by OMA and will be
fixed in a later releases.
This uses the lwm2m_pull_context to pull binaries in case
FIRMWARE_PULL_SUPPORT is enabled
Signed-off-by: Michal Ciesielski <michal.m.ciesielski@voiapp.io>
Add a semaphore to control that no collisions occur when multiple
sources want to use the pull_context
Add struct firmware_pull_context *ctx as an argument to the result_cb of
the context. This allows the receiver to do some kind of differentiation
on the source.
Signed-off-by: Michal Ciesielski <michal.m.ciesielski@voiapp.io>
Make it possible to reuse the pull logic from firmware_pull.c by
separating it to a separate file.
The firmware_pull_context is still owned and statically allocated in
firmware_pull.c and is being passed into lwm2m_pull_context.c as a
pointer.
In other words, pull_context, does not keep any state except for a
pointer to the context currently in use.
Signed-off-by: Michal Ciesielski <michal.m.ciesielski@voiapp.io>
This change adds a posibility to enable low latency connection
parameters for BT when SMP commands are handled.
Support for this functionality is disabled by the default and
can be enabled by CONFIG_MCUMGR_SMP_BT_LATENCY_CONTROL=y option.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Add EtherCAT protocol support, now applications can
transmit/receive EtherCAT packets via RAW socket.
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Since most of the functions will access non thread-safe resources like
SLIST, and can be invoked from different threads (like the expiry timer
delayed work), add mutex protection to the function calls.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Implement a concept of Route Preference, as specified in RFC 4191. The
Zephyr host will prefer routes with higher preference, if they lead to
the same prefix through different neighbours.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add support for route lifetime, as defined in RFC 4191. The existing
route adding logic remains the same, if not specified, lifetime is set
to infinite. For routes added with Route Info option from ICMPv6 RA
message, set the expiration timer, according to the route lifetime value
received.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commits adds handling of the Route Information option from
the Router Advertisement message. This option allows to add/delete
routes in the host based on the information sent by the router.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When new route is allocated, a corresponding NBR entry (containing
`struct net_route_nexthop` data) is allocated from
`net_route_nexthop_pool`. When the route was deleted however, the entry
was not freed - only the "core" neighbor entry from the neighbor
management module (nbr.c) was dereferenced. This lead to a resource
leak, effecitevly leaking one `net_route_nexthop_pool` entry for each
deleted route.
Fix this, by defreferencing the NBR entry corresponding to the `struct
net_route_nexthop` data of the deleted route when route is removed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Verify the `ref` value of the neighbor entry in `net_route_foreach()`,
so that it only executes the callback on routes in use. Otherwise, the
function could call the callback for the route that has already been
deleted.
This could be encountered when executing `net route` shell command,
which printed the already deleted routes along the existing ones.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Adds a buffer to the host to reassemble potentially fragmented
periodic advertising reports.
The buffer size is configurable through BT_PER_ADV_SYNC_BUF_SIZE.
Reports that cannot be reassembled because there is no buffer or because
the buffer is full will be dropped.
Signed-off-by: Bernhard Wimmer <bernhard.wimmer@nordicsemi.no>
Period measurement should be started right after a message is updated.
That is because `struct bt_mesh_send_cb.start` callback is called from
the advertiser thread which is not necessary to be scheduled immeditely
and a user may see some delays between update handler calls.
The publication timer still needs to be scheduled after a message being
actually sent out to the air so that access layer doesn't overflow the
advertiser's buffer. To achieve some specific use cases, where a
published message needs to be retransmitted with 50ms interval, a user
has to switch off network retransmissions to make the legacy advertiser
sleep for the shortest possible time.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Added Kconfig configurable choise option for enable Server
object version 1.0 or 1.1.
Server Object v1.1 enable by default server initiated bootstrap
trigger when CONFIG_LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP is enabled.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Two CMake policies has been removed:
CMP0000 was introduced in CMake 2.6 and set to OLD, but with all Zephyr
CMake files using cmake_minimum_required() then there is no
reason for having this policy to OLD.
CMP0002 was introduced in CMake 2.6 and was set to NEW.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The pm_device_runtime_enable did not suspend devices, so it assumed that
the device was in a physically suspended state. This change makes sure
that device is left in a suspended state if the device is initially
active.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
In case runtime PM is not enabled (or not built-in), the get/put
functions always return 0 (instead of -ENOTSUP/-ENOSYS). When runtime PM
is disabled, a device is left into active state. Similarly, when device
runtime PM is not built-in, it is safe to assume that a device will
be active when it is called. If a user implements a custom solution, it
is its responsability to make sure that a device is active when using
it. For all these reasons, the -ENOTSUP/-ENOSYS are error codes that
should always be ignored by devices using get/put, since in practice it
means that: device is active, function is a no-op. The example below
illustrates how error handling is simplified:
```c
/* before: safe to ignore -ENOSYS/-ENOTSUP since device is active (we
* can continue)
*/
ret = pm_device_runtime_get(dev);
if ((ret < 0) && (ret != -ENOSYS) && (ret != -ENOTSUP)) {
return ret;
}
/* now */
ret = pm_device_runtime_get(dev);
if (ret < 0) {
return ret;
}
```
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The previous PR was not fully baked, so this PR fixes issues by:
- Adding checks when dereferncing pointers stored in params.
- Clearing ack context if a return argument is NULL to not block and
wait for response.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Incorrect address was being taken for cpus_states variable, causing
transition to low power modes to fail with an assertion (since the data
in the pm_state_info struct is no longer valid). Fix the address.
Fixes#41244
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Similar what is done in pm_device_state_set, checking if the power
state for a given device in pm_device_action_run is locked.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Set the number of L2CAP TX buffers suffiently high if MCS (media
control) is enabled.
Add BUILD_ASSERT if number is too low.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Kconfig choice allows to set a default, so there is no need for an extra
hidden Kconfig option.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Check that minimum residency time is greater than exit latency time for
all CPUs power states at compile time.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The values contained by the array are const, and number of states is
usually far below 255, so uint8_t can be used.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Change the function pm_device_runtime_enable() to return 0 on
success or an error code in case of error.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Add a new API to lock a device pm state.
When the device has its state locked, the kernel will no longer
suspend / resume devices when the system goes to sleep and device
runtime power management operations will fail.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Rework suspended to be a shared atomic variable between
bluetooth_status_cb() and hci_tx_thread().
If the bus is suspended, initiate remote-wakeup and
wait until the bus is operational.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
When CONFIG_TRACING_OBJECT_TRACKING is enabled, the kernel will keep
lists of some objects (detailed below), so that debuggers or other tools
can keep track of them.
The lists of objects are:
struct k_timer *_track_list_k_timer;
struct k_mem_slab *_track_list_k_mem_slab;
struct k_sem *_track_list_k_sem;
struct k_mutex *_track_list_k_mutex;
struct k_stack *_track_list_k_stack;
struct k_msgq *_track_list_k_msgq;
struct k_mbox *_track_list_k_mbox;
struct k_pipe *_track_list_k_pipe;
struct k_queue *_track_list_k_queue;
Note that while CONFIG_TRACING is needed, one can always use
CONFIG_TRACE_NONE=y. Also, tracking will only be done for objects that
are also being traced (so, to prevent tracking of some type of object,
such as k_timer, just make CONFIG_TRACING_TIMER=n).
Some simple "sanity checking" tests are also added in this patch.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Adds Xtensa as supported architecture for coredump. Fixes
a few typos in documentation, Kconfig and a C file. Dumps
minimal set of registers shown by 'info registers' in GDB
for the sample_controller and ESP32 SOCs. Updates tests.
Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
Since enabling runtime pm on a device sets the device state to
suspended. The usage count has to be zeroed otherwise we may
have an inconsistency.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
It is not possible to rely on pm->dev to do lazy initialization of
some components. For example, in the follow sequence of commands:
1 - pm_device_runtime_enable()
pm->state == PM_DEVICE_STATE_SUSPENDED;
2 - pm_device_runtime_disable()
pm->state == PM_DEVICE_STATE_ACTIVE;
3 - pm_device_runtime_enable()
pm->state == PM_DEVICE_STATE_ACTIVE
After the first time pm_device_runtime_enable(), the device state will
be suspended, but after the second time this function executes the state
will be active. That is not consistent.
It is just easier to remove the branch check and always set those
fields for the sake of consistent.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Storing CCC right after it's written reduces risk of inconsistency
of CCC values between bonded peers. The option should be enabled by
default. The developer could explicitly disable it to reduce memory
usage. After disabling the option explicitly, the developer is
aware of related potential issues.
Fixes: #40758
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
CONFIG_BT_LOG_SNIFFER_INFO allows print of LTK for debugging.
If CONFIG_BT_SMP_SC_PAIR_ONLY is set a non-existing struct
entry was printes, which caused a compile-time error.
Signed-off-by: Casper Bonde <casper_bonde@bose.com>
Replace deprecated macro USBD_CFG_DATA_DEFINE by
USBD_DEFINE_CFG_DATA which places usb_cfg_data structures
in specific iterable section.
Replace __usb_data_start, __usb_data_end usage patterns
size_t size = (__usb_data_end - __usb_data_start);
for (size_t i = 0; i < size; i++) {...}
by
STRUCT_SECTION_FOREACH(usb_cfg_data, ...) {...}
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Fix all instances in the controller of -Waddress-of-packed-member by
casting through an intermediate variable and verifying the alignment
with an assertion.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rework samples to use DEVICE_DT_GET and DT_CHOSEN
to get default display controller device.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
MCUMgr sample was failing to build due to including a deprecated header.
Replace it with the new header file to fix the build.
Fixes#41050
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
When CONFIG_NET_HOSTNAME_ENABLE=y, local_addrX may be used uninitialized
causing unexpected behaviour.
Signed-off-by: Robert Melchers <robert.melchers@taitradio.com>
Add reception of IQ sample report from controller.
Add applications notification about received reports.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add enable of CTE reception and sampling in connected mode.
The implementation allows an application to decide what type
of CTE is expected to be reported. Bluetooth Core specification
does not provide such functionality, so it is provided as part
of host implementation. Host will filter out all reports for not
enabled CTE types.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The BT_BUF_RX_SIZE did not take the CONFIG_BT_ISO_RX_MTU
into account. Add BT_BUF_ISO_RX_SIZE which
depend on CONFIG_BT_ISO and use that for the
BT_BUF_RX_SIZE macro.
Furthermore, move the BT_BUF_RX_COUNT macro definitions
into buf.h and update that to account for ISO RX as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Deprecate the use of CAN-specific error return values and replace them
with standard errno values.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit adds an option to store OpenThread settings in RAM for the
case where the flash driver is not available. This can be useful
for testing openthread on new platforms which are still under
development.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
Bluetooth callbacks are now registered dynamically again. When Bluetooth
callbacks were registered statically, they could be invoked before the
Bluetooth shell (ctx_shell) is initialized. The callbacks try to
shell_print(ctx_shell, ...), which results in a fatal error if ctx_shell
is undefined.
Fixes#40881.
Signed-off-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>
Add new Kconfig BT_CONN_TX which is true if the ACL and
ISO configuration allows for sending data. This is mainly
used to avoid initialization of the tx_complete_work
for ISO sync receiver only builds.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If CONFIG_BT_ISO_BROADCASTER=y and CONFIG_BT_CONN=n, i.e
an ISO broadcaster only build, then the handling of the
TX callback was not properly initialized, causes a fatal
issue when sending.
This commit moves the tx_complete_work out from the ACL group
and into the common area, so that it will be enabled
for connected ISO as well as broadcaster ISO.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Although we are declaring `pm->enable`as bitfield, it ends up using
more memory due memory alignment.
Since we already have an atomic variable for device flags, this commit
adds a new flag to indicates whether or not device runtime is enabled.
Doing it we are saving some extra bits and avoiding need to lock the
mutex in several situations since we can atomically check if pm
runtime is enabled on a given device.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Refactor implementation to use a single common ISO PDU
node rx type for ISO Synchronized Receiver.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Adds reassembly of framed PDUs to ISO adaptation layer.
Reference times are also computed based on anchor points,
transmission latency components and a PDU specific time offset.
Some partial preparations for ISO broadcast can be found for
convenience. This needs to be properly merged, and currently will not
work with both CONFIG_BT_CTLR_CONN_ISO and CONFIG_BT_CTLR_SYNC_ISO
enabled.
Includes fixes and improvements for unframed mode.
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
Signed-off-by: Morten Priess <mtpr@oticon.com>
The GATT Server should wait with clearing Service Changed
indication configuration data until the response callback is
called. Otherwise the indication may not be properly delivered
to a given GATT Client.
Fixes: #40761
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Atempting to mount LittleFS with the flag will cause the fs_mount
to return -ENOSUP and log error message.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Mounting FAT FS will set FS_MOUNT_FLAG_USE_DISK_ACCESS to the flags
of an object serving the mount point.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
- Do not ignore unsolicited status messages to allow for the API to be
- used asynchronously
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
- Add optional callback to receive status messages even when using async
API
- Split acked and unacked API
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Rename PM_STATE_DT_ITEMS_LEN to DT_NUM_CPU_POWER_STATES to make its
purpose more clear. This macro could be made part of a Devicetree API
for PM in the future.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Rename the PM_STATE_INFO_DT_ITEMS_LIST macro to
PM_STATE_INFO_LIST_FROM_DT_CPU to make its purpose more clear. Similar
naming scheme is found e.g. in the GPIO API.
Associated internal macros and docstrings have been adjusted, too.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
As per the GATT documenation, the conn pointer may actually
be NULL in the notify callback, indicating that the connection
is being unpaired.
Add a check for conn == NULL to avoid calling bt_conn_index
on a NULL pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The CCC update should be done after the connection is encrypted.
Before the connection is encrypted, the GATT Server does not know
if the reconnecting peer was actually bonded.
Fixes: #40759
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
In bt_iso_chan_disconnected we did not check for role before
we started to get the CIG and setting the CIG state.
Mmove the CIG code to the central part of the if statement.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
By use of the new macro RXFIFO_DEFINE, a complete set of data
structures for supporting a MEMQ'able FIFO with data pool backing is
created. This is intended for RX nodes such as done-events, RX PDU-
and ISO PDU events. The purpose is to simplify the data management
and code complexity, and provide re-usability.
This commit implements the existing done structures (MFIFO, mem pool,
mem link pool) as an RXFIFO. ISO is the next customer, and later the
pdu_rx_free MFIFO- and related pools may be refactored.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When LOG2 is enabled, timestamp func which was just set
according to various conditions, is overwritten using sysclock.
Since sysclock is very fast, it will cause uint32_t to wrap very
fast and cause the time to start over from 0 often.
This commit combines the two statements doing the same thing,
to one statement.
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
Move all defines that specifies (D)PPI resources which are used
to dedicated files which have no include dependencies. This allow
to use them in nrfx_glue.h to specify fixed (D)PPI channels used
by the bluetooth.
Additionally, added mask with GPIOTE channels used by the bluetooth
controller. It was previously not defined which could lead to
conflicts since same channels could be allocated by the nrfx_gpiote
user
Updated nrfx_glue.h to use new approach.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This PR add multi advertising sets for bluetooth mesh adv bearer.
At the present, the local mesh network occupy single advertising.
And GATT Services Advertising use a single advertising, if support.
One or more advertising sets maybe used by relay node.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The type qualifier of the return type is causing warnings if
-Wignored-qualifiers, and it's irrelevant anyways since
the function returns a value and not a pointer
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
The comment before this change was misleading, as those functions
(and other ones used from the level of user space application) require
DSA interface (like lan{012}), not the master one (like eth0).
Signed-off-by: Lukasz Majewski <lukma@denx.de>
The address of DSA API functions' structure available for usage from
the level of user's application (like for example in
samples/net/dsa/src) is stored in dsa context, not per DSA interface
device.
The struct dsa_context is defined once for all DSA (i.e. not master)
interfaces.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Transports should close the socket in case of `setsockopt()` failure,
otherwise we end up with a leaked socket, as it won't be closed
elsewhere.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Asynchronous API may utilize DMA and significantly reduce
CPU load during outputing to UART.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Taking random numbers from hardware may be time consuming thus
it was deferred to a work queue. On the other hand, taking them
from software algorithm is fast. Use xoshiro128++ when enabled,
instead of real random numbers from hardware RNG generator. They
are use for random intervals in the test so no security concerns
here.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This adds basic support for GDB stub on Xtensa. Note that
this only provides the common bits on the architecture side.
SoC support is also required to fully enable GDB stub on
each Xtensa SoC.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds the architecture interface so that the GDB stub can
deal with breakpoints and watchpoints. By default, weak
functions are implemented to indicate breakpoints and
watchpoints are not supported.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Some architectures may require memory accessed to be aligned to
certain size and cannot be accessed byte-by-byte during memory
read/write in GDB stub. This adds the ability to specify
the alignment via kconfig. The existing byte-by-byte access is
retained as it is simplier code.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds bits for architectures, SoCs or boards to restrict
memory access in GDB stub. This is mainly to make sure
GDB stub only read/write to memory that can be legally accessed
without resulting in memory faults.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Storing the state where this is the first GDB break can be done
in the main GDB stub code. There is no need to store the state
in architecture layer.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Adds a new function gdb_bin2hex() to convert binary into
hexadecimal string representation. This is similar to
bin2hex() but does not force a null character at the end
of the output buffer. This avoids an issue where the last
character of the hexadecimal string is replaced with
null character before sending to GDB.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
There is no need to bail out of the debugging session if there
are recoverable errors, for example, erroneous GDB packet
received, cannot write to certain registers, etc. So simply
send an error message to GDB and continue the GDB stub main
loop for more debugging.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds architecture-specific functions to read/write registers.
This allows architecture to have a sparse representation of
the register file as not all registers are saved during context
switches. This saves some runtime space, and provides some
flexibility on what architectures can do.
Remove from header the need to define ARCH_GDB_NUM_REGISTERS as
it is no longer used in the common gdbstub code.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If an incoming GDB packet is bigger than what the buffer can hold,
stop putting the extra characters into the buffer. This will still
read till the end to acknowledge the packet but will return error
instead. This allows the GDB session to continue instead of hanging
or timed out due to packets not being acknowledged.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds a kconfig to specify the buffer size for GDB packet
I/O. Some architectures may need a bigger buffer for the general
register packet, and we don't want it to overflow our buffer.
This also changes the packet read/write buffer to be allocated
outside of stack. Since the buffer can be large enough that it
won't fit inside the stack.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The commit adds CONFIG_OS_MGMT_TASKSTAT_ONLY_SUPPORTED_STATS
Kconfig option that disables code filling in task statistics, for
mcumgr command `taskstat`, that are not collected or supported by
Zephyr.
Setting this option to y will skip following statistics in response:
"runtime", "cswcnt", "last_checkin" and "next_checkin".
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
When populating bt_df_per_adv_sync_iq_samples_report the
rssi was not wrapped in sys_le16_to_cpu.
Signed-off-by: Jakob Krantz <jakob.krantz@u-blox.com>
ll_adv_set stores poitner to direction finding TX configuration.
When ll_reset is executed the pointer was not NULL assigned.
That lead to erroneous behavior e.g. df_cfg->is_enabled was set
to TRUE even the functionality was not enabled.
DF configuration is stored in memory pool. The memory pool uses
free elements to store its internal data. On reset whole pool is
expected to be free, so ll_adv_set->df_cfg may not point to any
element allocated from memory pool.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Correct an issue that prevents CONFIG_TRACING and CONFIG_PM_DEVICE to be
enabled at the same time.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
A variable is tracking number of buffered messages. This is used
to trigger processing thread in certain cases. Counter was not
handled correctly when message was dropped. In certain cases that
can lead to hanging of log processing.
Added counter decrementation in the callback called whenever
message is dropped.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add guard to not pend until all logs are flushed when default
logging thread is disabled. In that case, logging has no control
where logs are processed and sleeping may not lead to flushing
log data. That may result in test hanging.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Simplify common `getsockname()` implementation by using VTABLE_CALL()
macro, in the same way as other socket calls do. This additionally
allows to cover the case, when `getsockname()` is not implemnented by
particular socket implementation, preventing the crash.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
ull_tx_queue.h needs to be included before ll_sw/ull_conn_types.h
zephyr/zephyr/subsys/bluetooth/controller/hci/hci.c
In file included from zephyr/zephyr/subsys/bluetooth/controller/
hci/hci.c:52:
../../subsys/bluetooth/controller/./ll_sw/ull_conn_types.h:453:18:
error: field 'tx_q' has incomplete type
453 | struct ull_tx_q tx_q;
| ^~~~
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
The device PM subsystem _depends_ on device, not vice-versa. Devices
only hold a reference to struct pm_device now, and initialize this
reference with the value provided in Z_DEVICE_DEFINE. This requirement
can be solved with a forward struct declaration, meaning there is no
need to include device PM headers.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The supported protocol must be delivered to the firmware update object
as optional, then configured in the application.
This information is device/server dependent so does not can be fixed
in library.
Signed-off-by: Jair Jack <jack@icatorze.com.br>
Fix implementation to use ADI flag in Periodic Advertising
enable command to add ADI field in Periodic Advertising
PDUs.
Related to commit 6433a6aac1 ("Bluetooth: Controller:
Add Periodic Advertising ADI support").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use nrfx_gpiote and nrfx_ppi allocators to allocate channels
at runtime instead of fixed, device-tree based allocation which
is harder to maintain.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
`struct ieee802154_mpdu` access generates warnings related to unaligned
access to packed structure member. The structure itself however does not
need to be packed, since it is not mapped directly into the frame
buffer, but rather contains pointers to the structures representing
corresponding header regions in the frame. Those structures are
correctly defined as packed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Replace unpacked in6_addr structures with raw buffers in packed icmpv6
structs, to prevent compiler warnings about unaligned access.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Replace unpacked in6_addr structures with raw buffers in net_ipv6_hdr
struct, to prevent compiler warnings about unaligned access.
Remove __packed parameter from `struct net_6lo_context` since the
structure isn't really serialized.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Replace unpacked in_addr structures with raw buffers in net_ipv4_hdr
struct, to prevent compiler warnings about unaligned access.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Replace unpacked in_addr/in6_addr structures with raw buffers in
net_arp_hdr struct, to prevent compiler warnings about unaligned
access.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Make sure that in_addr/in6_addr structure size match the respective
binary IP address size with BUILD_ASSERT.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The define for PDU_AC_LL_SIZE_EXTRA was removed in main, but not in
the topic-branch. The merge of topic/branch erroneously reintroduced
this define, so it needs to be removed
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
During work on the new LLCP the assignment to
phy_aux_flags_rx was by accident deleted.
This reverts that deletion
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Added an observe callback so that the application can register to
receive events like observer added/deleted, and notification acked/
timed out. The notifications can be traced back to the exact data
contained within them by use of the user_data pointer.
Fixes#38531.
Signed-off-by: Maik Vermeulen <maik.vermeulen@innotractor.com>
When multiple notify feature is enabled, notifications are pushed
twice. Host sends multiple notify with BT_ATT_OP_NOTIFY_MULT and
then continues to send regular notification with BT_ATT_OP_NOTIFY.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/40546
Signed-off-by: Ilhan Ates <ilhan.ates@nordicsemi.no>
Add an option in MQTT client context to take advantage of the
"TLS_CERT_NOCOPY" option when using TLS socket transport.
Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
Add TLS socket option "TLS_CERT_NOCOPY" to prevent the copy of
certificates to mbedTLS heap if possible.
Add support to provide a chain of DER certificates by registering
them with multiple tags.
Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
Initial attempt at integrating the ISOAL datapath with ISO
Synchronized Receiver implementation to generate HCI ISO
data packets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement ISO Synchronized Receiver connection handle
representing the streams in the BIG Sync. Add implementation
to return these handles on Sync Established event, and to
release these on Sync Lost.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement ISO Broadcaster connection handle representing the
streams in the created BIG. Add implementation to return
these handles on BIG complete event, and to release these on
BIG terminate.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As EVENT_OVERHEAD_START_US offset is used in ticks unit in
LLL, ULL scheduling using ticker should also use ticks unit
for EVENT_OVERHEAD_START_US when reducing the first ISO
Broadcast and Synchronized Receiver event preparation.
Relates to commit 858dc7fab4 ("Bluetooth: controller: Fix
EVENT_OVERHEAD_START_US jitter").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Since drivers implement a callback based on action and not the state,
we should be using the API based on the action instead of the one based
on the state.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Devices PM callback receive an action and not a state. Add a new API
that receives an action instead of a state.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Increases the size-limit of ACL packets, to accomodate for using Zephyr
as a host for controllers which support ACL packets larger than 251
bytes.
Signed-off-by: Frode van der Meeren <frode.vandermeeren@nordicsemi.no>
The priority of workqueue responsible for rpmsg processing was too
low. Any cooperative task could cause rpmsg processing to be
slightly delayed.
Signed-off-by: Andrzej Kuroś <andrzej.kuros@nordicsemi.no>
Update the macro prototype to explicitly require the length of the
desired user data. Update all in-tree usage of this macro.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Update the macro prototype to explicitly require the length of the
desired user data. Update all in-tree usage of this macro.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Transition the `user_data` field in `struct net_buf` to be a flexible
array member instead of a hardcoded array. Compile-time asserts are
introduced at the location of the intermediate struct usage to ensure
that the assumptions utilised in runtime code hold true.
The primary assumptions are that the two `user_data` fields exist at the
same memory offset, and that the instantiated struct size can be
determined from the generic struct size and the length of the user data.
`net_buf_id` and `pool_get_uninit` must now use manual address
calculations as the `__bufs` type is no longer the actual size of the
instantiated variable.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Store the `user_data` array size on both the pool and net_buf structs.
This will enable length validation once `user_data` fields are not
globally the same size. The new variables fit inside existing padding,
and therefore do not increase the size of either structure.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Replace the statically defined net_buf with the standard mechanism of
allocating the buffer from a pool. This introduces a minor memory
overhead, but has the benefit of ensuring that standard net_buf calls
will work correctly.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Zephyr device that is not a GATT Client, should ignore indication.
An Android device may send an indication even if Zephyr
device does not support GATT Client role. In that case, the sent
error response was improperly matched to subsequent GATT request
of the Android device which caused issues.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
In the current USB device support, the sizes of bulk endpoint
are mostly configure through Kconfig and do not care if a device
is high-speed capable. The information if a USB device controller
supports high-speed comes from devicetree. Add a Kconfig option to
map this information and configure bulk endpoint sizes
accordingly.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Define a custom IEEE802154 based L2. The user can then use those symbols
to implement their own 802.15.4 based L2, based on those symbols, w/o a
need to modify the Zephyr tree.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Introduce a common config for all 802.15.4 based L2 implementations.
This way, any custom 15.4 L2 implementation will be able to
automatically enable use 15.4 driver, w/o a need to modify the actual
Kconfig.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case the payload and header size exceeded the network MTU size,
`websocket_send_msg()` would only send a part of the payload,
effectively leading to erronous results if called again to send the
rest. Fix the issue, by calling `sendmsg()` in a loop internally in case
it did not manage to send the entire websocket message in a single call.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fix the dummy ISO Broadcast PDU for correct LLID when
testing with burst number, immediate repetition count and
pre-transmission offset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing link buffer allocation for ISO Broadcaster role.
Without this allocation, create BIG will fail.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
- Rename time start/stop variables
- Use uint8_t vs. int as loop index variable type
- Flag unused variables
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Stats are an optional feature, moving it into a separate source file
improves code readability.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Replace PM_STATE_LEN with PM_STATE_COUNT, so that number of states is
automatically computed.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Since 581c20e242 ("drivers: uart: Cleanup not supported API handling")
uart_fifo_read() returns -ve on errors. Correct the check on its return
value to work with this new API.
CID: 240662
Fixes: #39840
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
`net_eth_vlan_enable()` allowed to use illegal vlan tag values, fix this
by disallowing any tag value higher or equal to 0xfff (which is a limit
for the tag and a reserved value).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fix ISO Broadcast only supported related conditional compile
so that data path setup does not return command disallowed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix PTC iteration value calculation for pre-transmission
subevents to consider multiple BIS events in the BIG event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use memcpy to access the reference to AD data passed in the
list of length encoded parameters used to construct the
Common Extended Payload Format in AUX_SYNC_IND PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to send ISO Sync payload number and
timestamp from LLL to HCI/ISOAL layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the iso_interval field from ULL to LLL context to
facilitate calculation of timestamp when there is PTO in
the BIG events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing initialization of ISO sync control procedure
variables.
Without this initialization, after synchronization the sync
is lost.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ISO Sync implementation to use the CRC ok status of
anchor point PDU, and not the last PDU receive, when
generating the event done message.
Without this fix, ISO sync is lost if there is continous
CRC error in the last PDU before the event is done.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Per prf spec 7.2.2.2.1, "A node that does not support
the Proxy feature or has the Proxy feature disabled
shall not advertise with Network ID".
The PR aligns implementation with the specification.
Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
Introduce a new RPMsg with static VRINGs backend. This new backend makes
easy to generate and use IPC instances backed by OpenAMP using the DT.
Each instance is defined in the DT as (for example):
ipc: ipc {
compatible = "zephyr,ipc-openamp-static-vrings";
shm = <&sram_ipc0>;
mboxes = <&mbox 0>, <&mbox 1>;
mbox-names = "tx", "rx";
role = "primary";
status = "okay";
};
It is then possible to register an send data through endpoints using the
IPC service APIs.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Extend the RPMsg structs to accommodate for the introduction of new
backends and contextually fix the ipc_rpmsg_static_vrings_mi backend
(the only user).
Rework also some comments and ipc_service glue code.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
As know, an instance is the representation of a physical communication
channel between two domains / CPUs.
This communication channel must be usually known and initialized (that
is "opened") by both parties in the communication before a proper
communication can be instaurated using endpoints.
Depending on the backend and on the library / protocol used by the
backend, this "opening" can go through some handshaking or
synchronization procedure run by the parties that sometimes can be
blocking or time-consuming.
For example in the simplest case of a backend using OpenAMP, the remote
side of the communication is waiting for the local part to be up and
running by loop-waiting on some flag set in the shared memory by the
local party.
This is a blocking process so a particular attention must be paid to
where this is going to be placed in the backend code.
Currently it is only possible to have this synchronization procedure in
two points: (1) the init function of the instance, (2) during
ipc_service_register_endpoint().
It should be highly discouraged to put any blocking routine in the init
code, so (1) must be excluded. It is also frowned upon using the
endpoint registration function (2) because the synchronization is
something concerning the instance, not the single endpoints.
This patch is adding a new optional ipc_service_open_instance() function
that can be used to host the handshaking or synchronization code between
the two parties of the instance.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Adds configuration BT_CTLR_SCHED_ADVANCED_CENTRAL_CONN_SPACING to enable
per-application preferred central connection spacing. This is an
extension of feature BT_CTLR_SCHED_ADVANCED, which when enabled, adds
user defined spacing between existing, and new central initiated
connections.
This is crucial for ensuring that centrals acting as ACL connection
based multi-channel streaming sources do not get overlapping
connections, and that spacing allows full frame transfer without
scheduling collision.
Due to the simple, compile-time configuration, use is limited to
specific applications in which the specified spacing is required.
Signed-off-by: Morten Priess <mtpr@oticon.com>
The task_wdt was getting stuck after approx. 36 hours on e.g. nRF52840,
which has a SysTick with 32768 Hz. This corresponds to an overflow of
the uint32_t current_ticks in schedule_next_timeout.
This commit fixes the accidentally introduced narrowing conversion.
Fixes#40152
Signed-off-by: Martin Jäger <martin@libre.solar>
This changes both k_mem_domain_add_partition() and
k_mem_domain_remove_partition() to return errors instead of
asserting when errors are encountered. This gives the application
chance to recover.
The arch_mem_domain_parition_add()/_remove() will be modified
later together with all the other arch_mem_domain_*() changes
since the architecture code for partition addition and removal
functions usually cannot be separately changed.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If Kconfig SETTINGS_SHELL option is enabled, add the
following shell commands:
* settings list [subtree] - list all settings belonging to
the given subtree,
* settings read name - read a setting with the given name
and output hex dump of the value.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
LOG_MODULE_DECLARE was referring to power name which was renamed
to pm by faa06ac. This results in compilation failure.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
A user may want to control message parameters (for example, delay
parameter) on every retransmission of a published message (for example,
see section 1.4.1 of the mesh model specification). This is essential
for lighting messages as time gap between messages retransmitted via
the publish-retransmit mechanism introduces unwanted jitter/pop-corn
when such retransmissions are received by a large 'group' of lights.
This commit adds an option to `struct bt_mesh_model_pub` to make the
access layer call `bt_mesh_model_pub.update` callback on every
retransmission. This also addes few macros and functions that can be
used for further calculations.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This change is supposed to fix the issue of incomplete acl mtu
initialization in the absence of BREDR. Find further information here:
https://github.com/zephyrproject-rtos/zephyr/issues/39549
Signed-off-by: Tobias Scharnowski <tobias.scharnowski@rub.de>
When deferred mode is used, logging is using lowest priority
thread to process the logs. When test cases are performed one
by one processor never reaches lowest priority thread until
whole suite is completed. Added flushing after each test case.
Feature is optional (by default enabled).
CONFIG_TEST_LOGGING_FLUSH_AFTER_TEST=n to disable.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Remove LOG_MINIMAL kconfig option which was confusing
since LOG_MODE_MINIMAL existed. LOG_MINIMAL was used to
force minimal mode but because of invalid dependencies
it was leading to issues.
Refactored code to use LOG_MODE_MINIMAL everywhere and
renamed LOG_MINIMAL to LOG_DEFAULT_MINIMAL which has impact
on defualt logging mode (which still can be later changed
in conf file or in menuconfig).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Limit the maximum ACL Tx buffer size to 251 octets due to
implementation restricted use of uint8_t for PDU len field,
also used as the Tx buffer size data type.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix compile warning filling 24-bit value in 3 octets using
sys_put_le32, used sys_put_le24 instead.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove misplaced declaration of ll_tx_ack_put in
ull_internal.h file while it is already present in
ull_conn_internal.h.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
It is well known that PM subsystem has never been optimized in terms of
resource usage. The situation is particularly bad in case the PM runtime
API is enabled. What this patch does is to move the responsability of PM
resource definition to the device like this:
- Device is responsible to define PM resources, using a new set of
macros: PM_DEVICE_*DEFINE().
- DEVICE_*DEFINE macro accepts a reference to the device PM state, which
can be obtained using PM_DEVICE_*REF() set of macros. This
allows device to initialize the dev->pm reference.
This method decouples a bit more PM from devices since devices just keep
a reference to the device PM state. It also means that future PM changes
will have less chances to impact all devices, but only devices that
support PM.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Use defines for AD data format field sizes and offsets when
populating AD data format in advertising PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As ISO interval is to be returned in the HCI LE BIG Sync
Established event, store it in ULL context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is initial commit towards integration of ISOAL Rx for
Broadcast/Synchronized Receiver ISO support.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
ULL reference count is checked in ULL_LOW context to decide
if LLL events are pending, but the reference count can be
decremented by the ULL HIGH execution context which can
prevent the set `disabled_cb` function not being called due
to no pending event to produce the done events.
Fixed by checking the reference count in the ULL HIGH
execution context using a mayfly to schedule the check.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix side effect in assertion when checking a volatile
variable inside assert check.
Fixes#32904, #32923.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation of BIG Sync to use any succussful
received subevent to calculate the anchor sync. Also, use
window widening on subevents if previous subevent did not
sync.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation of ISO Synchronized Receiver data subevents
and control subevent. Implementation of terminate procedure
in the receiver side.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update ISO Broadcaster subevent implementation for incorrect
calculation and use of PTO.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update the ISO Synchronized Receiver Terminate and context
release handling to check for prepares in pipeline and
accordingly call lll_disable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update the ISO Broadcaster Terminate and context release
handling to check for prepares in pipeline and accordingly
call lll_disable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When BIG events are close such that their prepares overlap
and are placed in the pipeline, then more than one done
complete event is generated, ignore them.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation of ISO Broadcast data subevents and control
subevent. Implementation of terminate procedure in the
broadcaster side.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Broadcast ISO BigInfo structure to be filled with
correct payload counter value considering accumulated
latency and ticker lazy value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing use of EVENT_TICKER_RES_MARGIN_US in Periodic
Synchronization and Synchronized Receiver implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the order in which the ISO context is associated with
the Periodic Advertising and Extended Advertising context.
This is done so that the Periodic Advertising does not try
to calculate offset to BIG event before the BIG event is
scheduled by ticker.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the LE BIG complete event generation to not use the
Sync Established structure to access the status value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the BIG Sync Lost event generation to not use the Sync
Established structure to access the reason value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation of BIG Create Sync in LLL. Generation of
LE BIG Sync Established event and LE BIG Sync Lost event
notifications from the controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to generate the Create BIG Complete
event after the first empty BIS PDU has been transmitted.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to populate the aux, sync and ISO offset
in the latest PDU. If both the current and latest of the
double buffer has been filled and LLL did not pick the
latest PDU, then the offset should be filled into the latest
PDU (and not into the first/current PDU).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing traversal of ADI field in advertised Common
Extended Payload Format. This will cause invalid offset used
for other fields and BigInfo field following the ADI when
Periodic Advertising ADI feature is supported.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing traversal of CTEInfo field in advertised Common
Extended Payload Format. This will cause invalid offset used
for other fields and BigInfo field following the CTE Info
when Extended Directed Advertising is used.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to fill the BIG Offset, calculate the
BIS Access Address and CRC init, scheduling and transmission
of BIS empty PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Construction of BIGInfo with mandatory parameters and
placing it in the ACAD of Periodic Advertising PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to release Broadcast ISO Sync, Sync Lost
event and ISO instance allocations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Handling of HCI_LE_Periodic_Advertising_Sync_Established didn't
have implemented handling of possible failures of periodic
advertising synchronization.
There are two situations definded by BT 5.3 Core spec:
- There is no AUX_SYNC_IND pdu within 6 periodic advertising events.
If that happens, status of the command is set to (0x3E) Connection
Failed To Be Established / Synchronization Timeout.
- Periodic advertising has wrong CTE type while periodic advertising
list is not used to determine the advertiser to listen.
In this case status of the command is set to (0x1A) Unsupported
Remote Feature.
The commit provides missing functionality.
In case of error, the periodic advertising will be deleted and
application will be notified by call to terminated callback.
The callback data were extended by err member. It provides
information why periodic advertising was terminated.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Since there are no more users and dependencies of
Kconfig option USB_UART_CONSOLE in the tree,
remove the remains and the option USB_UART_CONSOLE.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Use same init level and priority as serial drivers.
Align priority to the changes in
commit ad1450510a ("drivers: serial: Refactor drivers
to use shared init priority Kconfig")
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Do not have the "forced" bit cleared up scattered across the function.
Do it only in one place at the exit of the function.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Change pm_power_state_force to receive which cpu the state should be
forced. Also, it changed the API behavior to force the given state only
when the idle thread for that core is executed.
In a multicore environment force arbitrarily a core to suspend is not
safe because the kernel cannot infer what that cpu is running and how it
impacts the overall system, for example, if it is holding a lock that is
required by a thread that is running in another cpu.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Avoid runtime warning in bt_enable when CONFIG_BT_SETTINGS
and CONFIG_BT_DEVICE_NAME_DYNAMIC is not set.
This warning was intoroduced in
commit d76bba4b5e
("Bluetooth: host: Device name handling of invalid length")
Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
Previously, a `uint32_t` was aliased as an `atomic_t`. However,
with #39531, `atomic_t` is now a `long` under the hood, which
is 64-bit on 64-bit platforms.
Fixes#40369
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
Reading a set MTU from the used net_if when starting LCP.
This enables also other custom MTU/MRU to be set for the link than
the default CONFIG_NET_PPP_MTU_MRU (set by a ppp driver during
initialization).
Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
Pushes all work done in the topic-ble-llcp branch into main branch
This is a refactoring of the LL control procedures; the refactored
control procedures are hidden behind a KConfig option and
per default disabled
Goal of the refactoring:
close issue Link Layer Control Procedure overhaul #15256
make it easier to add/update control procedures
Refactoring consists in principal of writing explicit state machines
for the control procedures.
To reduce the risk of regression errors unit-tests have been added
Following control procedures are implemented:
Connection update procedure
Channel map update procedure
Encryption procedure
Feature exchange procedure
Version exchange procedure
ACL termination procedure
Connection parameters request procedure
LE Ping procedure
Data Length Update procedure
PHY update procedure
Min. nr. Of channels used procedure
Constant Tone extension request procedure
This is a joined work by the people listed in the signed-off-by
list (in alphabetical order)
Signed-off-by: Andries Kruithof Andries.Kruithof@nordicsemi.no
Signed-off-by: Erik Brockhoff erbr@oticon.com
Signed-off-by: Piotr Pryga piotr.pryga@nordicsemi.no
Signed-off-by: Szymon Janc szymon.janc@codecoup.pl
Signed-off-by: Thomas Ebert Hansen thoh@oticon.com
Signed-off-by: Tommie Skriver tosk@demant.com
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
The commit fixes the issue where duplicated code in
img_mgmt_impl_upload_inspect caused redirecting all image uploads,
in multi-image configuration, to the first image.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Added heap reference parameter to k_free tracing
hook to allow tracing of the pointer which was
passed as a parameter to a k_free call.
As part of this update the defines
(for this hook) in the various tracing formats
was also updated.
Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
Fix Periodic Advertising Synchronize implementation to
generate Synchronization Failed to be Established event
when 6 AUX_SYNC_IND PDUs are not received when establishing
synchronization.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The commit adds Kconfig options that enables "frugal status list";
when enabled, the status list will be sent with zero, empty and false
values omitted, slightly reducing number of bytes sent as response
from device.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
References to Mynewt have been removed and README for Zephyr has been
merged directly to the README.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit removes MYNEWT sepcific code and code that has been
conditionally compiled with "ifndef _ZEPHYR_".
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit copies code of mcumgr, as a lib, under subsys/mgmt/mcumgr.
Only source files relevant for Zephyr have been copied, and changes
to source files have been limited only to path changes, where
required.
Samples have been left out as the only relevant sample, smp_svr,
is already within Zephyr source tree.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Add a state to the bt_iso_cig struct. This makes
checks for the CIG state easier, and follows the
state machine in the core spec.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the validation of specific CIG parameters to its
own function. This is mainly to be able to reuse it for
validationg CIG refconfiguration parameters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Renames the struct from bt_iso_cig_create_param to
bt_iso_cig_param as the same struct can, without
modification, be used to update the CIG as well
(function to support that will come in a later commit).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the verification of the individual cis/bis checks to
an earlier point, because we actually start allocating
resources for the groups.
This removes a double check for NULL, while also
allows us to terminate earlier if there were any
issues.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A CIG may be updated later to include more CIS, and thus a slist
makes more sense.
The BIG doesn't need the change, but it makes more sense to
have similar handling for both.
This change also removes the requirement that the arrays
used to create the CIG/BIG need to static.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
With the change of `atomic_t` from `int` to `long` there
were a few places where there was some type aliasing
occuring.
Update CMSIS to use `atomic_t` rather than `int` for all
atomic operations.
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
The print specifier for `atomic_t` should be updated
to `%ld`, `%lu`, or `%lx` to account for the type
change of `atomic_t` to `long`.
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
If source_id is -1, which is a valid value, it will be
converted to unsigned since it's compared with an unsigned
which means it will be huge and asserts will trigger. To avoid
this, we typecast the unsigned part to signed.
Resolves#40115
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
Add a macro to retrieve the iso data load length (the
length stored in the iso header) with a bit mask that
ensures that we only take the first 14 bits.
This is to remove any RFU bits that may have been set.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There were a few cases where bt_hci_iso_data_hdr was used
instead of the proper struct bt_hci_iso_hdr.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The IPC libraries will be used by several backends. Move the libraries
out in a new 'lib' directory.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
The mcumgr_serial_parse_op has been called to extract marker and
check if it is valid, just for the caller mcumgr_serial_process_frag
to process the marker again.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Add implementation to check Periodic Advertiser
Synchronization to already synchronized peer and same SID.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When telnet client queries about remote echo support, we reply that we
won't do it (which reduces the traffic), however the echo was not
actually disabled on the shell. In result characters were double-echoed
in the character mode (by both local echo from the client and remote
echo from the server).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case multiple commands were sent in a single packet, only the first
one was processed. Fix this by processing them in a loop.
As the subnegotiation command have variable length, and we currently
don't have any support for subnegotiation, stop processing packet when
such a command occurs.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There was a problem with source address selection for ARP
retransmissions, when an ARP entry was already pending. In such case,
the `entry` value passed to `arp_prepare()` is NULL, which in result
caused the `current_ip` variable being used as the source value. The
problem with this approach is, that the `current_ip` is only set in
IPv4 autoconf, the Ethernet L2 does not set this variable. In result,
every retransmission of an ARP packet was sent with unspecified source
address, preventing the response from being handled.
Fix this by partially restoring the behaviour of the ARP source address
assignment from before IPv4 autoconf was introduced. If the ARP is sent
by the IPv4 autoconf, use the `current_ip` value provided. If entry is
not set, use the source IPv4 address set in the actual data packet.
Otherwise, search for a source address on the interface corresponding to
the `entry`.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Remove now-unused Kconfig options used for specifying radio front end
module configuration.
These are now handled in devicetree.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
A FEM in this case is an external Front-End Module. This is basically
a range booster with some extra amplification in the TX and RX paths.
This feature is supported for the Nordic open source controller. See
the changes to the ubx_bmd345eval_nrf52840 board for a quick summary
of what you have to do to take advantage of this.
(This patch doesn't actually remove the feature in the openisa HAL,
though, because that never implemented the required GPIO handling
routines.)
We are using the 'fem' property previously added to the
nordic,nrf-radio's devicetree binding, which points to the FEM that is
in use. If you have this property and the node it points to is
enabled, the controller subsystem respects it. Otherwise, FEM support
is disabled.
This obsoletes the following Kconfig options, which are now unused:
- CONFIG_BT_CTLR_GPIO_PA
- CONFIG_BT_CTLR_GPIO_PA_PIN
- CONFIG_BT_CTLR_GPIO_PA_POL_INV
- CONFIG_BT_CTLR_GPIO_PA_OFFSET
- CONFIG_BT_CTLR_GPIO_LNA
- CONFIG_BT_CTLR_GPIO_LNA_PIN
- CONFIG_BT_CTLR_GPIO_LNA_POL_INV
- CONFIG_BT_CTLR_GPIO_LNA_OFFSET
- CONFIG_BT_CTLR_FEM_NRF21540
- CONFIG_BT_CTLR_GPIO_PDN_PIN
- CONFIG_BT_CTLR_GPIO_PDN_POL_INV
- CONFIG_BT_CTLR_GPIO_CSN_PIN
- CONFIG_BT_CTLR_GPIO_CSN_POL_INV
- CONFIG_BT_CTLR_GPIO_PDN_CSN_OFFSET
The PA and LNA pins are now specified via fem-specific devicetree
properties in the FEM node:
- The "generic" PA/LNA case is handled with the ctx-gpios and
crx-gpios properties of the generic-fem-two-ctrl-pins compatible,
respectively.
- If the fem is an nRF21540, use the tx-en-gpios and rx-en-gpios
properties instead (and also respectively). This allows us to specify
FEM properties in a way that makes sense for the hardware datasheet,
while still handling them in a uniform way within the controller.
We support this in the nRF5 HAL with a new radio_nrf5_fem.h
sub-header, which pulls in radio_nrf5_fem_generic.h or
radio_nrf5_fem_nrf21540.h depending on the fem node's compatible, if
one is defined. These in turn let us replace the implementation
routines in radio.c with DT equivalents.
Keep in-tree users and devicetree binding documentation up to date.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Introduce an intermediate macro for use detecting that we have a FEM
node, and it's an nRF21540. This is also prep work for converting the
FEM configuration mechanism to devicetree.
No functional changes expected.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Add indirection macros for the ifdefs that test for the existence of
PA and LNA pins.
This will be convenient when the pins are configured in devicetree,
and the Kconfig symbols will no longer be around.
No functional changes expected.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Hide the CONFIG_BT_CTLR_GPIO_..._OFFSET Kconfig macros behind
equivalent ones in the HAL_RADIO_ namespace. This removes any direct
usage of the Kconfig macros from the controller HALs.
That will be convenient when we are getting these values from
devicetree properties instead.
Notice that the "PDN/CSN offset" is dropping the "CSN" portion of the
name: CONFIG_BT_CTLR_GPIO_PDN_CSN_OFFSET is now
HAL_RADIO_GPIO_PDN_OFFSET. This is because the DT binding for nRF21540
has a pre-existing 'pdn-settle-time-us' property we're going to use to
replace the Kconfig option.
Other than that, the name changes are self-explanatory.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Hide the CONFIG_BT_CTLR_GPIO_..._POL_INV Kconfig macros behind
equivalent ones in the HAL_RADIO_ namespace. This removes any direct
usage of the Kconfig macros from the controller HAL ifdeffery, except
for the usage in radio.c where the actual work is done.
Add "NRF21540" in the macros that are specific to that FEM.
That will be convenient when we are getting the GPIO polarity from
devicetree GPIO flags instead.
No functional changes expected.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The GPIOTE channels used to manage radio front end module GPIOs are
configured with invisible Kconfig symbols. They are therefore not user
visible. Remove them by redefining them in terms of equivalent macros
defined in radio_nrf5.h. This lets us get rid of a couple of ifdefs
that are no longer needed as well.
This is because these invisible symbols depend on the
CONFIG_BT_CTLR_GPIO_* pin configuration symbols. We would like to move
all of that pin configuration to devicetree, because it's hardware
description. It is therefore inconvenient to have the GPIOTE channel
configuration set via Kconfig in a way that depends on something we
would like to remove.
No functional changes or user impact expected: invisible symbols
cannot be set in .conf files.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Recently there was added ADI support to periodic advertising.
There was missing implementation of ADI for periodic advertising
chained PDUs and direction finding. Also unit tests for periodic
advertising chains required update to handle ADI field.
The commit provides missing implementation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add missing parameter to shell_print call
(The bug exists in the topic-le-audio branch also, but was not
discovered there. In the upmerge branch, it causes build failure.)
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit adds shell commands for the media control client, the
media player and the media proxy. This is a part of the upmerge of
the le-audio media control files.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with these exception:
- some include paths have been modified to correspond to new locations
of files.
- some instances of the shell variable has been renamed to not be the
same as the name of the shell struct tag.
- spaces have been replaced with TABs a couple of places
- remove cplusplus guards
- changed a debug dependency for MCC from MCS to MCC
- changed log name for the media controller shell
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
mcc.c shell - replace name of shell variable
tmp
f
shell
This commit adds the Media Control Service, and a dummy media player,
from the topic-le-audio branch. This is a part of the upmerge of the
le-audio media control files.
This service has been developed and maintained over a couple of years
now, and is mature. During the development it has passed both
IOP-testing and PTS qualification testing.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with the following exceptions:
- files are in bluetooth/audio instead of bluetooth/host/audio, with
some include paths updated as a consequence
- as a consequence, CMake files and Kconfig files updates are done in
other locations
- copyrights have been updated
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit adds the media proxy from the topic-le-audio branch.
This is a part of the upmerge of the le-audio media control files.
The media proxy adds a common API to register and access local media
players, and to discover and access remote media players over
bluetooth using the media control client and a remote media control
service.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with the following exceptions:
- files are in bluetooth/audio instead of bluetooth/host/audio, with
some include paths updated as a consequence
- as a consequence, CMake files and Kconfig files updates are done in
other locations
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit adds the Media Control Client from the topic-le-audio
branch. This is a part of the upmerge of the le-audio media control
files.
This client has been developed and maintained over a couple of years
now, and is mature. During the development it has passed both
IOP-testing and PTS qualification testing.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with the following exceptions:
- files are in bluetooth/audio instead of bluetooth/host/audio, with
some include paths updated as a consequence
- as a consequence, CMake files and Kconfig files updates are done in
other locations
- a macro for debug output of Object ID values has been (temporarily)
added to mcc.h, to avoid a dependency
- a blank line added after a declaration and an overlong line split,
to pass check_compliance
- copyrights have been updated
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit adds the Object Transfer client from the topic-le-audio
branch. This is a part of the upmerge of the le-audio media control
files. Media control depends upon Object Transfer for feature
completeness.
This client works, and has been used for IOP- and PTS-testing of the
media control server and client. It does, however, need an overhaul
before being made "Zephyr official", so for now it will be kept as an
internal file to the le-audio code.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with the following exceptions:
- files are in bluetooth/audio instead of bluetooth/host/audio, with
an include path updated as a consequence
- a sa consequence, CMake files and Kconfig files updates are done in
other locations
- In otc.c a superfluous semi-colon has been removed to please
check_compliance
- Kconfig.ots has been renamed to Kconfig.otc, as there is only
otc-content left in that file
- copyrights have been updated
- add TODO that these files are to be cleaned up and moved
The Object Transfer Client in this commit was originally written by
Leif Aschehoug <Leif-Alexandre.Aschehoug@nordicsemi.no>.
It has later been updated and maintained by
Emil Gydesen <emil.gydesen@nordicsemi.no> and
Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
ots
TCP2 is no longer needed as it is the unique implementation since the
legacy one has been removed.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Move the structure definition into the relevant header. Rename the
access relevantly as well. It's easier to read without mss_option being
used in various places (struct and access).
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Too long lines and indentations mostly. Let's just keep it concistent
over the file.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The RSSI measurement was not enabled while receiving periodic
advertising. The function responsible for enable the feature
in radio was called, but it was done too early.
It was overwritten by radio_switch_XXX function that assigns
a value to RADIO->SHORTS register.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
OpenThread has changed it's behaviour in terms of prompt printing in the
CLI module. Previously it was only printed on the UART CLI backend, now
it's printed on every CLI backend. This results in a double prompt being
printed when combined with Zephyr shell (one from OT and other form
Zephyr).
This commit adds a temporary fix to prevent OT prompt from being printed
in Zehpyr shell. As a long term solution we should add an option to
OpenThread to allow to disable prompt on the output.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
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 is affecting L2CAP/LE/CFC/BV-25-C and L2CAP/ECFC/BV-32-C
qualification test cases.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This was affecting L2CAP/LE/CFC/BV-26-C, L2CAP/LE/CFC/BV-27-C,
L2CAP/ECFC/BV-33-C and L2CAP/ECFC/BV-34-C qualification test cases.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
The commit changes messages of VFS API LOG_ERR calls to distinguish
between file and directory operations.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This comment was previously associated with a stand-along net_buf_ref
call. Now it's not clear what exactly it's referring to, and the
additional reference to net_buf_put() is fairly self explanatory.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
isotp_recv and the called pull_frags functions were violating the
net_buf API by interacting directly with net_buf fragments pulled from
a k_fifo.
This commit reworks the isotp_recv function. The currently processed
net_buf is stored in an additional context variable so that reading from
it can be continued in the next call to isotp_recv if not all fragments
could be fit into the provided uint8_t *data buffer.
Fixes#40070
Signed-off-by: Martin Jäger <martin@libre.solar>
The fs_open copies open flags into fs_file_t structure for use with
other VFS API calls; the commit moves the operation into success path.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The fs_statvfs is supposed to return, as all VFS functions, -ENOTSUP
error when underlying file-system driver does not implement the
API call.
The fs_statvfs was returning 0 for success and when API call is not
implemented, which means it is indistinguishable whether stat
structure has been filled by diver with any data or not touched at all.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
During stack reset in RCP, the mac keys are resseting my calling
otPlatRadioSetMacKey with aKeyId == 0. aKeyId == 0 was not handling
properly since it is not valid for mac keys. This commit fixes it.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
The commit fixes problem with UART TX frame processing, which was
caused by incorrect output buffer size evaulation, where input buffer
of certain len would cause entire output frame to be filled with no
place left for CRC causing a transmission to hang.
The commit, additionally, moves input buffer reminder processing out of
the input buffer processing loop.
Fixes#37893
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Removed some of variables used within the function, and some of
the redundant arithmetic operations.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Move the header file csis.h from the internal location to
the public include directory. This file is supposed to provide
the public API for CSIS and the CSIS client, but is not fully
complete yet.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds the coordinated set identification service (CSIS) client.
This is still a work in progress and thus there are no public
API for it yet, and some code changes will still be needed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds the coordinated set identification service (CSIS) server.
This is still a work in progress and thus there are no public
API for it yet, and some code changes will still be needed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adding a KConfig to allow for disabling of the passing of invalid SDUs
through the ISOAL HCI data path.
Defaults to keeping current behavior.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
This change adds `k_cycle_get_64()` on platforms that
support a 64-bit cycle counter.
The interface functions `arch_k_cycle_get_64()` and
`sys_clock_cycle_get_64()` are also introduced.
Fixes#39934
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
The commit adds missing static to the zephyr_smp_alloc_rsp
function definition; it also reorders some of definitions
and removes no longer needed block of forward declarations
of functions.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This change organizes the file structure for the shell.
Files implementing backends are moved to a separate folder.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
The mesh shell module owns the composition data for the shell
application, which makes it impossible to use it outside of the
application itself. To support the shell as a generic debugging
component that can be added to any application, we have moved the
composition data out of shell.c, and into the application.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Kconfig USB_DEVICE_REMOTE_WAKEUP option depends only on
USB device controller capability, but is not controlled
by the USB device controller drivers configuration.
Move USB_DEVICE_REMOTE_WAKEUP option to drivers and
make it promptless.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
USB_SCD_ATTRIBUTES is a configuration dependent macro
that does not map any part of the spec and does not
belong to usb_ch9 header.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
bt_ccm_encrypt only works when encrypting in place. To fix this
ccm_auth() inside bt_ccm_encrypt() must take plaintext instead of
enc_data, to not rely on assumption that plain and cypher data are the
same memory.
Signed-off-by: Ilya Makarov <ilya.makarov.592@gmail.com>
Fixes: #40069
Change the wording of the warning printed when there is no entropy to
hopefully remove any doubt that there might be security in TLS without
an entropy source. TLS connections with insufficient entropy are
trivially decodable, and should not be relied on for any type of
security.
Signed-off-by: David Brown <david.brown@linaro.org>
Fix missing auxiliary context release when reception of
Periodic Advertising Chain PDU fails due to header complete
timeout, i.e. no reception of on-air PDU. Also, fix missing
generation of auxiliary reception failure notification when
no auxiliary context was allocated for chain PDU reception.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When an CIS is connected, the peripheral did not have
any information about the QoS settings. This commit
adds information about the PHY and SDU. For some reason
the peripheral won't ever have information about the RTN.
The remaining values in the event (interval, delay and
latency) are still not exposed, nor is framing or
packing, the latter of which are not part of the event.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
As the already existing macro K_MEM_SLAB_DEFINE results in
two variable definitions, the preceding static modifier leads to
a seemingly working solution, though linkage conflicts will occur
when the same memory slab name is used across multiple modules.
The new K_MEM_SLAB_DEFINE_STATIC macro duplicates the functionality of
K_MEM_SLAB_DEFINE with the difference that the static keywords are
internally prepended before both variable definitions.
The implementation has been tested on my Zephyr project (the build
issue faded out). The documentation has been updated altogether
with all incorrect occurences of static K_MEM_SLAB_DEFINE.
Signed-off-by: Pavel Hübner <pavel.hubner@hardwario.com>
Fixed compilatione error when shell sample has been build with flag
CONFIG_SHELL_VT100_COMMANDS set to n.
Fixes: #40124
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
net: lwm2m: When mbedtls CONFIG_MBEDTLS_SERVER_NAME_INDICATION is
enabled, a destination hostname must be passed to socket to properly
connect do lwm2m server.
Passing lwm2m context to lwm2m_parse_peerinfo
Signed-off-by: Jair Jack <jack@icatorze.com.br>
_handle_device_abort is only called in one place and it basically does
two instructions. Just remove it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
On smp environment, we cannot do device power management based only on
the state the current core. For example, do not suspend devices if
there are other cores active, or resume devices if there are other
cores already active.
This change ensure that devices are only suspend when the last active
core become idle and that these devices are resumed only when the first
core becomes active.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Instead of returning PM_STATE_ACTIVE for when the cpu didn't enter a
low power state and a different state when it entered, but has
already left the state and is active again, it changes
pm_system_suspend to return true when the cpu has entered a low power
state and false otherwise.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Each CPU can have its own set of states. Update the policy to get them
from DT and account it when return the best state to the kernel.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Currently power management subsystem uses a global variable to hold
power state. On multicore environment this is a problem and we have to
have this information per core.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
When Device use pb-gatt bearer provisioning, and first
provisioning failed due to some reasons(invalid oob etc..).
Which cause `proxy:gatt_disconnectd` incorrected write `conn_count`
Cause this var euqals `-1`.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
As part of the work to support multiple IPC instances / backends using
IPC service, the static vrings mi code must be reworked to resemble a
classic device driver.
Fix also the sample using it.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
The IPC service code is currently assuming that only one IPC instance
does exist and the user can use the IPC service API to interface with
that singleton instance.
This is a huge limitation and this patch is trying to fix this
assumption introducing three major changes to the IPC service API:
- All the IPC instances are now supposed to be instantiated as a struct
device. A new test is introduced to be used as skeleton for all the
other backends.
- ipc_service_register_backend() is now removed (because multiple
backends are now supported at the same time).
- All the other ipc_service_*() functions are now taking a struct device
pointer as parameter to specify on which instance the user is going to
act and operate.
In this patch the documentation is also extended to better clarify the
terminology used.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Reason why the prority was at its lowest is unknown, but now that it may
be used to send local packets (which used to be sent right away),
it seems to affect TCP scheduling in loopback mode. Raising the prority
so it matches how it was previously (i.e. sent right away) should fix
things. (Note however that this issue was not broadly present, only
sockets.tls test seemed to be affected.)
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Closing a connection, thus calling net_context_put() will not close a
TCP connection properly, and will leak tcp connection memory.
This is because: net_context_put calls net_context_unref which calls
net_tcp_unref which leads to unref tcp connection and thus sets
ctx->tcp to NULL. Back to net_context_put, that one finally calls
net_tcp_put: but that bails out directly since ctx->tcp is NULL.
Fixing it by inverting net_tcp_put() and net_context_unref() calls
within net_context_put().
Fixes#38598
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
On any target, running a TCP server and a net shell can show the issue:
net tcp connect local_ip port
will fail. Usally it ends up by consumming all tcp connection memory.
This is because in tcp_in(), state changes will most of the time lead to
sending SYN/ACK/etc... packets under the same thread, which will run all
through net_send_data(), back to tcp_in(). Thus a forever loop on SYN ->
SYN|ACK -> SYN -> SYN|ACK until tcp connection cannot be allocated
anymore.
Fixing it by scheduling any local packet to be sent on the queue.
Fixes#38576
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Fix Advertising LLL header initialization to be done early
so that other functions like Periodic Advertising Parameter
set functions can use LLL context to reference ULL conttext.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move Periodic Advertiser List option check in LE Periodic
Advertising Create Sync command to HCI.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Scan Duplicate Filtering to consider different
advertising mode and multiple advertising set id from same
advertiser Bluetooth device address.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The device service creates a notification of the current time resource
every 10s. This commit adds the possibility to change this timer to a
different value thus giving more control over the way the device object
is notified.
Signed-off-by: Sebastian Salveter <sebastian.salveter@grandcentrix.net>
System PM tracing was broken for SEGGER SystemView, and was missing
proper documentation.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Move all PM device runtime API calls from pm_device* to the
pm_device_runtime* namespace.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This patch refactors the runtime API to make it more clear and simple.
Relevant changes:
- API uses the action callback in a direct manner, avoiding unnecessary
overhead.
- API documentation has been improved to include detailed return error
codes.
- pm_runtime_disable() is now synchronous (to simplify possible error
paths) and returns error in case it fails. It is also safe to disable
in pre-kernel now.
- pm_runtime_put(_async)() will return -EALREADY if called with usage
count at zero (result of an unbalanced get/put call sequence)
- A transitional state has been added back. This makes code more
readable, and avoids using atomics (not required).
TODO:
- Solve in a better manner the asynchronous suspend error path (now
"solved" using asserts).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
After the removal of pm_device_get_async, the pm_device_wait API has
become redundant. Its usage after pm_device_put_async should not be
considered a valid usecase, since after that call what will happen is a
pm_device_get (which is blocking).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
As of today there is no clear usage of asynchronous gets, since in
general, a resume operation should be synchronous (we are about to use
the device immediately after resuming it). Removing this API simplifies
the runtime implementation in a significant way (refer to future
commits).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Use function to get the set/clear AD data parameter to
populate the common extended payload format field.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated the implementation to allow population of auxiliary
pointer field as necessary to append PDU chains.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Allow SMP messages to be sent from user space.
For example, a user defined command can be sent when a value changes
so the client doesn't have to poll.
Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
Fix missing traversal of TargetA field in advertised Common
Extended Payload Format. This will cause invalid offset used
for fields following the TargetA when Extended Directed
Advertising is used.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ASSERTION FAIL [!hdr->disabled_cb] @ ull_conn.c:882
When initiating a connection using continuous scan window
if there is preemption by the next window then the ISR
callback was overwritten to switch to next scan window
instead of the initiator event being closed.
Fixed by not aborting the initiating state when requested
by the next continuous scan window.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use define for maximum number of primary advertising radio
channels used while scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In HCI event, PHY indices start at 1 compare to 0 indexed in
aux_ptr field in the Common Extended Payload Format in the PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor changes to remove redundant whitespaces and to use
uint8_t instead of uint32_t to return true or false.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing reset of LLL scheduling flag when auxiliary PDU
scan scheduled in LLL is aborted due to preemption.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix continuous skipping of Extended Scanning of Auxiliary
PDUs. Due to duplicate prepare events of continuous scanning
present before the auxiliary scanning prepare, preemption
schedules only the primary scan prepare and auxiliary scan
infinitely is postponed.
This is a revert of commit 190532bcc4 ("Bluetooth:
Controller: Only remove duplicate resume events").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation to fragment the list of received Extended
Advertising PDUs into HCI LE Extended Advertising report
events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing implementation to setup the PDU radio end
timestamp capture for Scan Response PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use variable names lll and lll_aux for struct lll_scan and
struct lll_scan_aux respectively.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to check auxiliary PDU device address
match by comparing the address in the AUX_ADV_IND PDU with
the addresses in the filter accept list.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the filter check function so that it can be reused
for the Extended Auxiliary PDU filtering.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor move of lll_scan_aux_isr_aux_setup function alongwith
other global functions in the file.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement setting the correct directed advertisers address
type in the Extended Advertising Report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to filter using access list the received
extended auxiliary PDUs. Use resolving list addresses when
resolving list is enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended scanning filter implementation to permit
ADV_EXT_IND PDUs without AdvA so that AUX_ADV_IND PDU can
be received and to filter that PDU based on whether AdvA
is present.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising Report data status to have
"Incomplete, data truncated, no more to come" when data
length is more than "Scan_Max_data".
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Cleanup the scan event LLL done handling for abort on late
schedule, preemption pipeline abort, preemption current
event yield, duration expire, and connection establishment.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use 32-bit value variables when calculating Extended
Advertising and Periodic Advertising radio event time
reservations to consistently use 32-bit variables for
microsecond time units when calculating radio event where
there is possibility to reserve for scheduling of back to
back chained PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Firmware Update object did not initialise resources PkgName,
PkgVersion and Firmware Update Protocol Support. Initialise
Firmware Update Protocol Support on creation and report CoAP
as default transfer protocol.
Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
`engine_remove_observer_by_path()` was not updated during some recent
LwM2M observer changes, still using the `engine_observer_list` which got
moved into the `lwm2m_context` structure. Update the function to align
with these changes.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add get_config function to I2C emulator.
Also update tests using I2C emulator to use i2c_get_config.
Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
`ztls_socket_data_check()` function ignored a fact when
`mbedtls_ssl_read()` indicated that the underlying TCP connection was
closed. Fix this by returning `-ENOTCONN` in such case, allowing
`poll()` to detect such event.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Previously, if the AD field length was greater than the maximum
fragment size - 2 bytes, an out of bounds access would occur.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/39852
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Updates to the CCID module for upmerge to Zephyr main
- add bt_ prefix to the ccid_get() function, add explaining comment,
use defined value for limit
- update copyright statement
- update Kconfig to current practice
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit adds the content control ID (CCID) module from the
topic-le-audio branch. This is required to the le-audio media control
files and call control files, which depend upon CCID.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with the following exceptions:
- files are in bluetooth/audio instead of bluetooth/host/audio, with
some include paths updated as a consequence
- as a consequence, CMake files and Kconfig files updates are done in
other locations
The CCID module is written by
Emil Gydesen <emil.gydesen@nordicsemi.no>
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Loop by LOOP_DIVIDER counts instead of the number of seconds
specified in the timeout.
Fixes#39672
Signed-off-by: Paul Gautreaux <paulgautreaux@fb.com>
- Add a `log_strdup` to the role text output for logging V1
compatibility
- Fix style issues
- Change where the documentation refers to an OpenThread device as
"himself" to "itself"
Signed-off-by: Chris Pearson <ctpearson@gmail.com>
If CONFIG_NET_LOG=y is set, OpenThread will output the current OT
role whenever the state changes.
To simplify understanding of the log output, this change replaces
the numerical role ID with the text name of the role. This also
required a change to a documentation file to replace an instance
of a numerical ID.
NOTE: This is potentially a breaking change should anyone be using
test scripts that monitor the OpenThread state changes and look
for the numerical ID. This does not seem to be the case for the
Zephyr tests, however.
Signed-off-by: Chris Pearson <ctpearson@gmail.com>
make sure channel request reference is cleared if send fails. without
this change this could happen when att_handle_rsp was called:
1. reqs before call:
head: 0x2000f8e8, tail: 0x2000f8c0, elements:
- addr 0x2000f8e8, function pointer NULL
- addr 0x2000f8c0, function pointer 0x35c1d
2. att_handle_rsp called, calling bt_att_req_free with address
0x2000f8e8
3. reqs after call:
head: 0x2000f8e8, tail: 0x2000f8c0, elements:
- addr 0x2000f8e8, function pointer NULL
- addr 0x2000f8d4, function pointer NULL
- addr 0x2000f8ac, function pointer NULL
- addr 0x2000f898, function pointer NULL
- addr 0x2000f884, function pointer NULL
- addr 0x2000f870, function pointer 0xd92b7e7c
- addr 0x2000f85c, function pointer 0x462a03a9
- addr 0x2000f848, function pointer 0xf77b2f4b
- addr 0x2000f834, function pointer 0x33714775
- addr 0x2000f820, function pointer 0x31ba37f8
- addr 0x2000f80c, function pointer 0x5fda8494
- addr 0x2000f7f8, function pointer 0xbcff174e
- addr 0x2000f7e4, function pointer 0x341393f
- addr 0x2000f7d0, function pointer 0xbcfee8b8
- addr 0x2000f7bc, function pointer 0x1e73d9e5
which obviously is broken.
closes#39506.
Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
Dequeue and scheduling IQ samples report towards host
was working by accident. IQ samples were casted to
pointer to struct pdu_adv. Then type of PDU was checked.
Fortunately the IQ samples hadn't got PDU_ADV_TYPE_EXT_IND
in memory pointed by struct pdu_adv->type.
NODE_RX_TYPE_IQ_SAMPLE_REPORT must have separate execution
path in rx_demux_rx.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were no assignment to iq_report->hdr.handle in the code
hence all IQ samples reports had the same handle value which
was zero.
Since the handle is related with ll_sync_set pointer the handle
value may not be set in LLL.
The best place to set handle value is thread context where
bt_hci_evt_le_connectionless_iq_report is prepared.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There is no need to veirfy the result value of the strtol() operation,
as we copy the result to a 64 bit buffer anyway.
CID: 240696
Fixes#39810
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Move functions around so it is not necessary to keep a header
that with functions declaration that is just used in one single
place.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The size of overhead for each heap allocation can change after
heap implementation change and such change impacts automatic
calculation of heap size for littleFS.
This patch allows per-alloaction overhead to be configurable and then
automatic heap size calculation can be adjusted without code change.
This is a temporary fix until per-alloaction overhead value will be
available from kernel internals.
Fixes#36962
Signed-off-by: Artur Lipowski <Artur.Lipowski@hidglobal.com>
Introduce a weak implementation of test_main() which calls:
* ztest_run_registered_test_suites(NULL);
* ztest_verify_all_registered_test_suites_ran();
This will attempt to run all registered test suites and verify that
they each ran.
Signed-off-by: Yuval Peress <peress@chromium.org>
Add new functionality to ztest to improve test modularity. The two
primary new entry points are:
* ztest_register_test_suite
* ztest_run_registered_test_suites
When registering a new test suite, users provide the name as well as
an optional predicate used to filter the tests for each run. Using NULL
as the predicate ensures that the test is run exactly once (after which
it is automatically filtered from future runs).
Calls to ztest_run_registered_test_suites take a state pointer as an
argument. This allows the the pragma functions to decide whether the
test should be run.
The biggest benefit of this system (other than the ability to filter
tests and maintain a larger test state) is the ability to better
modularize the test source code. Instead of all the various tests
having to coordinate and the main function having to know which tests
to run, each source file manages registering its own test
suite and handling the conditions for running the suite.
Signed-off-by: Yuval Peress <peress@chromium.org>
When user only use pb-gatt provisioning, which unable to
send out connectable advertising, due to adv thread not started.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Enable the existing aarch32 Cortex-R implementation of
timestamp_serialize() for aarch32 Cortex-A CPUs as well.
Signed-off-by: Immo Birnbaum <Immo.Birnbaum@Weidmueller.com>
List of improvements:
- The PM logging module was only available if CONFIG_PM=y, however, it
was also used by Device PM (which can be selected without PM). A new
logging module has been created for Device PM.
- Log level is passed to LOG_MODULE_(DECLARE|REGISTER)
- Logger name has been adjusted to `pm` (was `power`)
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
POLL is not a dependency of runtime device PM since it now uses
conditional variables to notify waiting threads.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
SYS_POWER_MANAGEMENT and DEVICE_POWER_MANAGEMENT were deprecated in
2.5.0, remove them now.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Fix compilation error for devices where ssize_t can not
be formatted with %d, due to ssize_t not being equal int.
Fixes#39629
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Previously the host would handle disconnecting associated CISes and
invoking callbacks when a host ACL conn was disconnected.
This responsibility has now been moved to the controller, which needs to
send a NODE_RX_TYPE_TERMINATE with the CIS handle for proper
disconnection in the host. This is in accordance with the spec.
As disconnect reason, the CIS uses the ACL reason, which is passed to
the host along with the handle.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Add a function to update the coap block context from a
packet, according to the block option enum provided.
The existing coap_next_block does not handle block1 transfers
properly because we need to inspect the block1 option
returned by the server. This function is reworked to make use
of the newly introduced one.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
According to RFC-7959:
When uploading with coap block1 requests the server may respond
with a size1 option (together with the response code 4.13).
This to indicate the maximum size the server is able and willing
to handle.
This commit changes the total_size in the current block context
being handled to the optional size1 option value from the server.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Just always prove interface association descriptor for RNDIS
function instead of forcing it via Kconfig USB_COMPOSITE_DEVICE
option.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Set reasonable range for the request buffer in case RNDIS
function is used. Align net_buf size from rndis_cmd_pool to
request buffer size since request is copied there before
it is queued.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Fix BT_CTLR_LOW_LAT_ULL_DONE synchronization counting so
that done events are processed before pipeline enqueue
decisions are taken in LLL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect Periodic Advertising interval when Coded PHY
support is built, chain PDUs is used and Extended
Advertising is disable while the Periodic Advertising
continues to be active.
Related to commit a379196b48 ("Bluetooth: controller:
nRF5: Back-to-Back Radio Tx interface").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There is not need to handle all power states in switch state after
remove lower power and off states for devices.
Also, it incorporates the fix done in pull/38873.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
As discussed in issues/38619, this commit aims to simplify device
power management. It was removed PM_DEVICE_SATE_LOW_POWER.
The power subsystem now doesn't need to figure out which device state to
use of a given system power state. It just suspend and resume devices.
Devices now just need to respond to ACTIVE and SUSPEND and OFF actions
and they are free to use any particular substate they have when the
subsystem asks to suspend. They also don't need to worry about states
transitions (unless they have multiple substates) because the system
will just request them to suspend if they are active and vice-versa.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
rebase
Add a function that can be used by device drivers to know
what will be next power state used by the SoC.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The OpenThread stack uses uint32_t to calculate expiry time for
alarms, while comparing to zephyr's uint64_t uptime.
This commit fixes broken milliseconds alarms after ~49.7 days of
uptime.
Fixes#39704
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Core Specification 5.3 Vol 3. Part G. 4.2:
The Signed Write Without Response sub-procedure shall only be supported
on the LE Fixed Channel Unenhanced ATT bearer.
This was affecting GATT/SR/GAW/BI-38-C qualification test.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Some shell prints didn't use the correct format for some
values, causing warnings/build errors.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix extended advertising set remove and clear, to reset the
PDU double buffer to keep one initialized PDU. This is done
to prevent common extended payload format contents from
being overwritten and corrupted due to same primary PDU
buffer being used to remove AdvA if auxiliary PDU is
allocated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reset allocated advertising and scan response PDUs to one
initial PDU in the double buffers when advertsing set is
removed or cleared.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Based on on RFC 8132 -
PATCH and FETCH Methods for the Constrained Application Protocol (CoAP)
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
Based on on RFC 8132 -
PATCH and FETCH Methods for the Constrained Application Protocol (CoAP)
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
ipv6_prefix_find() wrongly tests if the unicast address is in use
instead of the prefix. This has two implications:
- The function can return an expired prefix to net_if_ipv6_prefix_add(),
which will do nothing more to enable it (since it assumes that it is
already enabled). As a result, the prefix will not be used by the
rest of the stack due to prefix->is_used being false.
- ipv6_prefix_find() loops using a bound of NET_IF_MAX_IPV6_PREFIX, but
the size of the unicast[] array is defined by NET_IF_MAX_IPV6_ADDR.
This could lead to an out-of-bound access if NET_IF_MAX_IPV6_ADDR is
smaller than NET_IF_MAX_IPV6_PREFIX.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
With the introduction of `EXPERIMENTAL` and `WARN_EXPERIMENTAL` in
Zephyr all subsys/shell settings having `[EXPERIMENTAL]` in their
prompt has has been updated to include `select EXPERIMENTAL` so that
developers can enable warnings when experimental features are enabled.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
With the introduction of `EXPERIMENTAL` and `WARN_EXPERIMENTAL` in
Zephyr all subsys/lorawan settings having `[EXPERIMENTAL]` in their
prompt has has been updated to include `select EXPERIMENTAL` so that
developers can enable warnings when experimental features are enabled.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
With the introduction of `EXPERIMENTAL` and `WARN_EXPERIMENTAL` in
Zephyr all subsys/debug settings having `[EXPERIMENTAL]` in their
prompt has has been updated to include `select EXPERIMENTAL` so that
developers can enable warnings when experimental features are enabled.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
With the introduction of `EXPERIMENTAL` and `WARN_EXPERIMENTAL` in
Zephyr all subsys/net and drivers/ethernet/Kconfig.e1000 settings
having `[EXPERIMENTAL]` in their prompt has has been updated to include
`select EXPERIMENTAL` so that developers can enable warnings when
experimental features are enabled.
The following settings has EXPERIMENTAL removed as they are considered
mature:
- NET_OFFLOAD
- NET_PROMISCUOUS_MODE
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
When generating syscall wrappers, call a tracing macro with the id,
name, and all parameters of the syscall as params when entering and
leaving the syscall. This can be disabled in certain call sites
by defining DISABLE_SYSCALL_TRACING which is useful for certain
tracing implementations which require syscalls themselves to work.
Notably some syscalls *cannot* be automatically traced this way and
headers where exclusions are set are in the gen_syscall.py as notracing.
Includes a systemview and test format implementation.
Tested with systemview, usb, and uart backends with the string
formatter using the tracing sample app.
Debugging the trace wrapper can be aided by setting the TRACE_DIAGNOSTIC
env var and rebuilding from scratch, a warning is issued for every
instance a syscall is traced.
Automatically generating a name mapping for SYSVIEW_Zephyr.txt is a
future item as is documenting how to capture and use the tracing data
generated.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Originally, it was added to allow to slightly vary API (e.g. function
signatures) without burdening the subsys with compatibility stabs.
There were not many changes recently, and with EXPERIMENTAL master
switch which is planned to be added soon, it's better to remove
this marker so the subsys remained accessible as it was before.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Issue #38643
Introduce a more powerful and well established mocking framework
into Zephyr. It also allows running the actual FFF tests using the
zephyr SDK and ztest framework to ensure compatibility.
As per TSC meeting, the fff.h header was directly added to
subsys/testsuite/include/. As per the guidelines, the file is exactly
the same as it is in FFF's library, but re-styled with clang-format.
The west.yml entry was added using the "ci" group and filtered by
default. (note that the tests will break until the CI actually
specifies that the group is needed).
Signed-off-by: Yuval Peress <peress@google.com>
With the introduction of `EXPERIMENTAL` and `WARN_EXPERIMENTAL` in
Zephyr all subsys/canbus, subsys/net/l2/canbus, and drivers/can settings
having `[EXPERIMENTAL]` in their prompt has has been updated to include
`select EXPERIMENTAL` so that developers can enable warnings when
experimental features are enabled.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
With the introduction of `EXPERIMENTAL` and `WARN_EXPERIMENTAL` in
Zephyr all subsys/bluetooth and drivers/bluetooth/hci settings having
`[EXPERIMENTAL]` in their prompt has has been updated to include
`select EXPERIMENTAL` so that developers can enable warnings when
experimental features are enabled.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
The commit separates conditionally compiled API calls to separate
C files and moves conditional compilation to CMakeLists.txt.
Inline helpers have been moved to flash_map_priv.h.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fix compilation and logic issues to allow testing OTS functionality with
assert enabled.
The compilation fixes are simple and do not require an explanation.
The assertion in bt_ots_dir_list_init was logically reversed. Its
purpose is to ensure the directory list is not already initialized
and as such should assert that the dir_list is not set (i.e. is NULL).
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
The condition checks whether the connection was established or not. The
return value should reflect that.
Signed-off-by: Caspar Friedrich <c.s.w.friedrich@gmail.com>
If a fallback hardware watchdog is used, it is fed together with the
task watchdog in task_wdt_feed. However, the hardware watchdog was
not yet set up before the first call to task_wdt_feed.
This commit fixes the order of wdt_setup and task_wdt_feed calls.
Fixes#39523
Signed-off-by: Martin Jäger <martin@libre.solar>
Fixes#39538
RTT_UNLOCK() uses a variable defined in RTT_LOCK() making mandatory
to use both function in the same block
Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
Better group code specific for e.g. ISO broadcaster and
ISO sync receiver.
No code has been changed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Splitt he ISO broadcast config into broadcaster and
sync receiver. This will allow a device that only
wants to one of the roles to have a much more optimized
configuration.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
OpenThread has lately got an option to provide a custom
crypto backend that replaces the default, based on mbedTLS
API. Implement a backend based on ARM PSA crypto API that
is better suited for applications willing to take advantage
of the ARM trust zone technology.
Add Kconfig option: OPENTHREAD_CRYPTO_PSA_ENABLE which
enables that backend.
Also, another Kconfig option:
OPENTHREAD_PLATFORM_KEY_REFERENCES_ENABLE, implied by the
former, which enables usage of key references instead of
literal keys in OpenThread. It will eventually allow
OpenThread applications to keep sensitive data such as
encryption keys in the secure storage, accessible from the
secure world only.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Uses the stats subsys to provide simple but useful debugging stats for
power management state changes and timing.
Removes the no longer needed PM_DEBUG config option
Replaces the use of PM_DEBUG for a test clock output pin for mec1501 and
adds in its place an SoC Kconfig option to enable it.
Adds a STATS_SET macro for assigning a value to a stat group field
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
This include is not used at all by fs.c. Zephyr includes a minimal
sys/stat.h, but only for the minimal libc.
Signed-off-by: Chris Reed <chris.reed@arm.com>
Threads may wait on an event object such that any events posted to
that event object may wake a waiting thread if the posting satisfies
the waiting threads' event conditions.
The configuration option CONFIG_EVENTS is used to control the inclusion
of events in a system as their use increases the size of
'struct k_thread'.
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Fixes the format specifier type in a call to shell_printf().
Instead of printing with %x (which expects an unsigned int) for
an address, it is now using %p.
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
If a firmware update is fetched from a server, and no port number is set
in the URI (e.g. coap://example.com/fw_update), the client will try
to connect on the port specified by CONFIG_LWM2M_PEER_PORT.
If a port different from the peer port is to be used for firmware
update, this has to be set explicitly in the URI:
coap://example.com:5683/fw_update.
This fix adds CONFIG_LWM2M_FIRMWARE_PORT, which will be used when
fetching a firmware update without specifying the port number in the
URI.
Signed-off-by: Tjerand Bjornsen <tjerand.bjornsen@nordicsemi.no>
Add __printf_like modifier to validate strings used by shell.
Fixing warnings triggered by this change.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
- Rename to "action" to make its purpose more clear
- Use the _cb suffix to align with naming used for callbacks in other
areas.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Accessing members from pm_device improves code readability, since it
removes dev-> from most accesses.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Some includes were already performed by the device(_runtime).h header/s,
others like were not necessary.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Replace the custom float32_value_t LwM2M type with native double, to
facilitate LwM2M API and improve floating point precission.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If a driver doesn't support PM, as indicated by setting the
pm_control_fn parameter to NULL, no need to manage busy or wakeup state.
This also prepares the PM support for issue #39286, which will allocate
PM structures only for the devices that request it.
Signed-off-by: Keith Short <keithshort@google.com>
The struct basically only had a pointer to
bt_iso_chan_path as well as duplicating the pid and
the direction.
The commit removes the struct as it was more confusing than helpful,
and instead use the PID for the bt_iso_chan_path and
supply the direction as a argument instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A recent change broke the fallback to using a simple
HCI data path configuration in case that the application
does not provide a data path.
This commit fixes that issue, while retaining the
intended update from the change that broke the fallback,
as well as making the code a bit easier to read
and more documented.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There was an error in handling of max number of IQ reports
generated by controller. Accordin to BT Core Spec 5.1 the host
may request a number of CTEs to be sampled and reported by
controller while enable IQ sampling. The max_cte_count value
set to zero means sample all CTEs in a periodic advertising chain.
The commit fixes wrong handling of the max_cte_count provided
value to generate expected number of IQ reports.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The irq_lock() usage here is incompatible with SMP systems, and one's
first reaction might be to convert it to a spinlock.
But are those irq_lock() instances really necessary?
Commit 6161ea2542 ("net: socket: socketpair: mitigate possible race
condition") doesn't say much:
> There was a possible race condition between sock_is_nonblock()
> and k_sem_take() in spair_read() and spair_write() that was
> mitigated.
A possible race without the irq_lock would be:
thread A thread B
| |
+ spair_write(): |
+ is_nonblock = sock_is_nonblock(spair); [false]
* [preemption here] |
| + spair_ioctl():
| + res = k_sem_take(&spair->sem, K_FOREVER);
| + [...]
| + spair->flags |= SPAIR_FLAG_NONBLOCK;
| * [preemption here]
+ res = k_sem_take(&spair->sem, K_NO_WAIT); [-1]
+ if (res < 0) { |
+ if (is_nonblock) { [skipped] }
* res = k_sem_take(&spair->sem, K_FOREVER); [blocks here]
| + [...]
But the version with irq_lock() isn't much better:
thread A thread B
| |
| + spair_ioctl():
| + res = k_sem_take(&spair->sem, K_FOREVER);
| + [...]
| * [preemption here]
+ spair_write(): |
+ irq_lock(); |
+ is_nonblock = sock_is_nonblock(spair); [false]
+ res = k_sem_take(&spair->sem, K_NO_WAIT); [-1]
+ irq_unlock(); |
* [preemption here] |
| + spair->flags |= SPAIR_FLAG_NONBLOCK;
| + [...]
| + k_sem_give(&spair->sem);
| + spair_read():
| + res = k_sem_take(&spair->sem, K_NO_WAIT);
| * [preemption here]
+ if (res < 0) { |
+ if (is_nonblock) { [skipped] }
* res = k_sem_take(&spair->sem, K_FOREVER); [blocks here]
In both cases the last k_sem_take(K_FOREVER) will block despite
SPAIR_FLAG_NONBLOCK being set at that moment. Other race scenarios
exist too, and on SMP they are even more likely.
The only guarantee provided by the irq_lock() is to make sure that
whenever the semaphore is acquired then the is_nonblock value is always
current. A better way to achieve that and be SMP compatible is to simply
move the initial sock_is_nonblock() *after* the k_sem_take() and remove
those irq_locks().
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Only one single IPC service backend is currently present: multi_instance
backend. This backend is heavily relying on the RPMsg multi_instance
code to instanciate and manage instances and endpoints. Samples exist
for both in the samples/subsys/ipc/ directory.
With this patch we are "unpacking" the RPMsg multi_service code to make
it more modular and reusable by different backends.
In particular we are re-organizing the code into two helper libraries:
an RPMsg library and a VRING / virtqueues static allocation library. At
the same time we rewrite the multi_instance backend to make fully use of
those new libraries and remove the old multi_instance sample.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
While adding support for service type enumeration, a regression was
introduced which prevented mDNS ptr query responses.
1. There was an off-by-one error with label size checking
2. Valid queries were failing to match in `dns_rec_match()` due to
not checking for either NULL or 0 "wildcard" port
Fixes#39284
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
If CONFIG_STREAM_FLASH_ERASE is set, a page erase is done before
writing the coredump header to the flash. If the flash page erase size
is larger than the flash write size this results in erasing part of
the coredump data.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The stream api initialization for the coredump flash backend used an
incorrect size.
This commit subtracts the header size.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The filtering of periodic advertisements by scanner may be not needed
in certain situations e.g. while use of periodic advertising by BT ISO.
To make the code smaller and avoid execution of not needed code the
functionality will be conditionally compilable. It may be enabled
or disabled by use of CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING
Kconfig option.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
First implementation of periodic advertising sync filtering
requires existence of Direction Finding Extension in Radio
peripheral.
To add the filtering support for other Nodric SOCs software
based PDU traversing for CTEInfo should be implemented.
In case there is no DFE in Radio peripheral, actual filtering
is done in ULL.
The commit provides necessary changes to previous solution.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Follow up on changes in lower link layer to add filtering
of periodic advertisements synchronization by CTE type.
The NODE_RX_TYPE_SYNC is used to transport information that:
- Sync is established. In such situation the node_rx
includes data related with received PDU
- Sync scanning is terminated.
In first case ULL will generate NODE_RX_TYPE_SYNC_REPORT
after sending NODE_RX_TYPE_SYNC.
Also EVENT_DONE_EXTRA_TYPE_SYNC handling has additional
execution path that terminates sync scanning if requested
by lower link layer. In other case it adjusts sync scan
window and maintains timeout as usual.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Periodic advertisement synchronization may be filtered by CTE type.
If particular CTE type is not allowed then depening on filtering policy:
- if filtering policy is off synchronization if terminated
- if filtering policy is on synchronization is continued to
synchonize with another device from allowed adverisements list.
If synchronization is established and peer device changes CTE type
to one that is not allowed, synchronization should be maintained.
There are two new execution paths. First one is executed when
synchronization is created. In this case CTEILINE is enabled
to parse PDU for CTEInfo field. In this execution path CTE
type is verified. Second execution path does not include
parsing PDU for CTEInfo and verification of CTE type.
Information about sync allowed is added to node_rx instance
that transports received PDU data. In case the sync has to be
terminated the node_rx will not hold PDU data.
Also done event is extended with information about sync
termination if CTE type is not allowed and filtering
policy is off.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To enable runtime parsing of PDU to find CTEInfo field CTEINLINE mode
has to be enabled. Thanks to that it is possible to verify if the PDU
has allowed CTE type e.g. for periodic advertising synchornization.
To run CTEInfo parsing other parametrers of CTEINLINE are not relevant.
If Radio is set to disable after PDU END event the CTE sampling
will not be processed.
The commit moves the radio_df_cte_inline_set_enable function to make
it accessible even the direction finding features are disabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add missing code responsible for handling of allowed CTE types
in HCI_LE_Periodic_Advertising_Create_Sync command.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
From the OMA LwM2M Object and Resource Registry: "When the single Device
Object Instance is initiated, there is only one error code Resource
Instance whose value is equal to 0 that means no error."
This fix creates that initial error code resource instance, and makes
sure that it doesn't get deleted by the Reset Error Code resource.
Signed-off-by: Tjerand Bjornsen <tjerand.bjornsen@nordicsemi.no>
Use __WFE and __SEV for CPU sleep in simulation too to
avoid stalling and to let ISRs execute during CPU sleep.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added weak function for data path dependent ISO-AL sink creation. This
is required for vendor specific ISO-AL data sink operation. Invoke sink
creation for vendor specific data path.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Implemented host function for configuring vendor specific data path for
use with ISO, and fixed passing of path ID in setup.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Devices need to be resumed in the reverse order they are suspended.
e.g: devA +---> devB ---> devD
|
+---> devC
They are initialized in the following order, devA -> devB -> devC ->
devD, and suspended starting from the end of the list, devD -> devC ->
devB -> devA. When they are suspended they are temporary put in a list
that is used later to resume them.
This list has to be iterated from the end to the beginning, otherwise a
device may be resumed before its parent.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Mbed TLS 3.0 removes the definition for MBED_ERR_SSL_PEER_VERIFY_FAILED,
since non of its code ever returns that value. Since there isn't really
a perfect response, instead return a somewhat generic response
indicating this was unexpected.
Signed-off-by: David Brown <david.brown@linaro.org>
z_impl_sys_csrand_get is implement if the system is build with either
CONFIG_CTR_DRBG_CSPRNG_GENERATOR or CONFIG_HARDWARE_DEVICE_CS_GENERATOR.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Several fields of structures in mbedTLS 3.0 are now private. To access
them directly is necessary to define MBEDTLS_ALLOW_PRIVATE_ACCESS.
That is a temporary fix, the proper solution is not access directly
but using proper API.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Fixes#38994, ARP messages were being sent to IPvXmcast MAC addresses
rather than the expected source MAC address or the broadcast address.
Signed-off-by: Robert Melchers <rmelch@hotmail.com>
Implements mechanism similar to the one available in net/lib/sockets.c
(since the merge of #27054) in sockets_can to enable parallel rx/tx.
Fixes#38698
Signed-off-by: Mateusz Karlic <mkarlic@internships.antmicro.com>
Previously stats were kept in a single static but would be updated by an
idle thread per cpu core. Stats/debug info is now kept per cpu core.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Add an option to force close the LwM2M connection
instead of always trying to deregister.
If on a cellular connection and the connection is dropped,
deregistering will never complete and take a long time
before retries fail. This option allows the app to close the
socket and quickly re-establish the connection when the
network connection is available again.
Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
If blockwise transfer is not in use it must be possible to send bigger
CoAP messages than what is the block size used with blockwise transfers.
To compensate for the increased memory usage number of in-flight packets
allowed could be decreased.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
...range for LWM2M_COAP_BLOCK_SIZE.
The range has been set to start from 64 bytes and now the help text has
been brought up to date.
Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
Emulators are difficult to work with, they generally require maintaining
some state in a mutable data struct. Since the emulator struct doesn't
support a data field like devices do, the pattern seems to be to add it
to the configuration. This makes following the logic of where things are
difficult.
1. Add a `struct emul *parent` structure to the espi/i2c/spi emulator
structs to make it easier when casting up.
2. Add a `void *data` field to `struct emul` to hold the data for
emulators.
Signed-off-by: Yuval Peress <peress@chromium.org>
The commit adds IMG_MGMT_UPDATABLE_IMAGE_NUMBER Kconfig option, int,
that allows to select how many images are supported by mcumgr.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Introduce Kconfig for Read ISO Link Quality command. Support for the
command is optional according to the specification.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Reorder variable declarations in HCI command handlers of ISO-related
commands to conform to reverse Christmas tree style.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Fix use of handle field in HCI command handling for some ISO-related
commands. The response buffer may reuse the command buffer. Therefore,
the handle field must not be copied directly from the command to the
response.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Set bits for ISO-related supported commands depending on selected
features and adjust compilation guards for the respective handler
functions.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
When reaching the last model in the circular extension linked list, the
walker would abandon the walk before checking the last model. This makes
us skip models when checking the subscription list, potentially causing
incoming messages to be wrongfully ignored.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
bt_mesh_proxy_role_setup() is called conditionally when peer is
connected and gatt_disconnected() is always called. This leads
to unbalance in role->conn reference count and crash.
Instead of hot-fixing this in gatt_disconnected(), this commit adds
proper bt_mesh_proxy_role_cleanup() API that is called by roles
implementations if cleanup is needed.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
When there are radio events with time reservations lower
than the preemption timeout of 1.5 ms, the pipeline has to
account for the maximum radio events that can be enqueued
during the preempt timeout duration. All these enqueued
events could be aborted in case of late scheduling needing
as many done event buffers.
During continuous scanning, there can be 1 active radio
event, 1 scan resume and 1 new scan prepare. If there are
peripheral prepares in addition, and due to late scheduling
all these will abort needing 4 done buffers.
If Extended Scanning is supported, then an additional
auxiliary scan event's prepare could be enqueued in the
pipeline during the preemption duration.
Fixes#36381.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
It seems that if the IV update is missed, a node cannot
recover it until the IV index has increased to a value
greater than Node's Last known IV + 1.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
This allows application to increase channel's MTU and (in some cases)
MPS. When channel gets reconfigured dedicated callback is called to
inform application.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Support DNS-SD Service Type Enumeration in the dns_sd library
and mdns_responder sample application.
For more information, please see Section 9, "Service Type
Enumeration" in RFC 6763.
https://datatracker.ietf.org/doc/html/rfc6763Fixes#38673
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
Refactor out the implementation of Periodic Sync Setup
address check including Periodic Advertiser List and SID.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement support for Periodic Advertiser List to be used
in LE Periodic Advertising Create Sync command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor `ull_filter_adva_get` and `ull_filter_adva_get` to
input resolving index compare to adv context reference.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactoring related to filter accept list, resolving list,
and removed the redundant anon variable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In panic mode, the function: z_shell_fprintf is expected to be
called from an interrupt context. Therefore, the dedicated assert
cannot be checked in this case.
Fixes#38612
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
There are two simmilar functions for unsubscribing from GATT handles.
- `gatt_sub_remove`, which is called on disconnect for every
subscription will free the `subscriptions` entry when the entry
represents no subscriptions.
- `bt_gatt_unsubscribe`, called by the application, which forgets to
free the `subscriptions` entry.
If all subscriptions grouped in a `subscriptions` entry are removed
using `bt_gatt_unsubscribe` before disconnect, there are no
subscriptions left to call `gatt_sub_remove` on. The `subscriptions`
entry is then never freed.
The above results in a resource leak of a `subscriptions` entry.
This fix makes explicit and enforces the invariant that there should not
be entries in `subscriptions` with an empty subscription list.
Fixes#38688
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Add unit tests that will ensure the CTE disable operation does not
cause breaking of LLL operations by too early release of chained PDUs.
The tests verify if numbers of PDUs in free PDUs fifo and free PDUs
memory pool are correct.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
When CTE is enabled for periodic advertising and number of CTE is
greater than number of PDUs in a chain, that are needed to transport
advertising data, there are additional empty PDUs used for transport
CTE.
CTE transmission may be disabled when periodic advertising event is
pending in LLL. rem_cte_info_from_per_adv_chain removed CTEInfo field
from extended advertising header in chained PDUs. When there were found
empty PDUs (created to transport CTE only), they were released from
the chain that was currently used by LLL. That caused an assert in
isr_tx handler due to broken advertising chain.
The rem_cte_info_from_per_adv_chain may not relese PDUs that are in
use by LLL. The PDUs may be released by LLL in prepare step when
advertising pdu double buffer is swapped by lll_adv_sync_data_latest-
_get.
This PR fixes that issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix asserted in ULL due to incorrect resumption of scan
window when auxiliary channel chain PDU is LLL scheduled by
a ULL scheduled auxiliary channel PDU reception.
The issue is solved by having `is_chain_sched` flag in the
auxiliary channel scan context and using the already present
`is_aux_sched` in the primary channel scan context to
differentiate if the auxiliary PDU Rx ISR is to return back
to primary channel scan window or to close the auxiliary
chain PDU reception radio event.
Relates to #38146.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix to ignore aux pointer struct in scanning advertising, to
avoid ULL scheduling from setting up ticker to receive chain
PDUs while LLL is receiving scan response PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The task_wdt_init() API can fail to install a timeout for the fallback
hardware WDT (hw_wdt) without returning an error code. This patch
enables task_wdt_init() to return the hw_wdt install timeout error code
if the hw_wdt install timeout fails.
Signed-off-by: Nick Ward <nick.ward@setec.com.au>
According to the state documentation, this state does not need to handle
devices:
> Runtime idle is a system sleep state in which all of the cores enter
deepest possible idle state and wait for interrupts, no requirements for
the devices, leaving them at the states where they are.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Local public key has been logged in little endian but
remote public key in big endian. That has been changed.
Both are logged in big endian to be able to compare in logs.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Debug configuration for prov and prov_device has been split
since prov general modul and it is used for provisioner as well.
It is not necessary to enable prov_device debugging
to debug provisioner.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Current impementation assumes that CONFIG_LOG_IMMEDIATE=y
guarantees complete transfer, and it is not true.
In my opinion core dump should always be printed in panic mode.
Signed-off-by: Robert Gałat <robert.galat@nordicsemi.no>
When the controller forwards incomplete reports to the host,
the application currently has no way of reassembling them.
Therefore the application may fail to parse the data.
Issue a warning until
https://github.com/zephyrproject-rtos/zephyr/issues/37368
is resolved.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Have separate Bluetooth Device address get and read
functions, remove use of function just to return Extended
Advertising Random address and replace with simple
assignment statement.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation defined channel index in the auxiliary
pointer of the common extended payload format in the primary
channel PDUs and the same be used in the transmission of
auxiliary PDUs.
Fixes#35668.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add FIXME comments for missing use of channel selection
algorithm for Periodic Advertising chained PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to set correct Advertiser's clock
accuracy value in the auxiliary pointer field in the common
extended payload format.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to populate the aux, and sync offset
in the latest PDU. If both the current and latest of the
double buffer has been filled and LLL did not pick the
latest PDU, then the offset should be filled into the latest
PDU (and not into the first/current PDU).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In some HCI packed structures we place non-packed structs inside (in
particular the address structs).
Alignment is not an issue for those because all their members are just
byte-aligned, but size is. If the compiler ever packs those it would
become a real problem, and so detect this at build time.
See the link below for more info:
https://stackoverflow.com/a/66389167
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Change the way the local IRKs are accessed to be consistent with the
all other uses.
Coverity thinks using the pointer to the array is suspicious in this
case.
Fixes: #38130
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Verify that the local identity loaded from the settings key is
valid for the current configuration.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use defines for scanning state types of passive, active,
initiator and synchronization state.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Allow resolving list update when passive scanning,
otherwise deny if advertising, active scanning, initiating
or periodic sync create is active.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix imprecise data bus error when receiving Periodic
Advertising Report caused due to uninitialized `extra` field
member in the node rx struct passed from ULL to LL thread
context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix repeated periodic sync drift compensation invoked when
receiving chain PDUs which caused memory corruptions and
bus faults.
Use `is_aux_sched` flag in Periodic Sync's LLL context to
differentiate between the first AUX_SYNC_IND PDU followed by
use of LLL scheduling to receive following AUX_CHAIN_IND PDU
versus ULL scheduling being used to receive AUX_CHAIN_IND
PDUs.
Drift compensation to be done only using the AUX_SYNC_IND
PDU and not on reception of AUX_CHAIN_IND PDU using ULL
scheduling.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There were some leftovers in logging after attempt to use
logging as tracing backend. Removing all references since it
lead to test compilation failures.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
According to `sendmsg()` man pages, the `struct msghdr` can contain
empty records (iov_len equal to 0). Ignore them in TLS `sendmsg()`
implementation to avoid unnecessary calls to mbed TLS.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case zsock_sendmsg did not send all of the data requested, update the
`struct msghdr` content and retry.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If data for `context_sendto()` was provided in a form of
`struct msghdr` (for instance via `sendmsg()`), it was not verified that
the provided data would actually fit into allocated net_pkt. In result,
and error could be returned in case the provided data was larger than
net_pkt allows.
Fix this, by verifying the remaining buffer length when iterating over
`struct msghdr`. Once the buffer is filled up, break the loop. In
result, functions like `sendmsg()` will return the actual length of data
sent instead of an error.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Added log_internal.h for internal APIs. Move functions out of
log_core.h. Log_core.h shall have only macros and functions related
to logging message creation. Log_core.h is included by log.h thus
number of dependencies in that headers must be limited to minimum
to allow including without risk of circular dependencies.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add a new struct that provides information to the upper
layer when accepting an connected isochronous stream.
The CIG ID and CIS ID makes it possible for the upper layer
to determine which ISO channels are "together" in a group.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Update the VCS client to use the auto CCC discovery
feature instead of expecting it to be a specific place
in the remote server's GATT database.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Issue #38271
Implement a getter for emulators similar to device_get_binding. This
function can be used to get the emulator instance during tests to call
emulator specific functions.
Example: The current BMI160 emulator pre-defines a finite set of data
samples that will be returned. If a test was to be written for logic
that uses that data, then the emulator would become completely useless
without the ability for the test to define what data should be returned.
This will also help in exercising error conditions in tests.
Signed-off-by: Yuval Peress <peress@chromium.org>
When creating a socket, all of the registered socket implementation are
processed in a sequence, allowing to find appropriate socket
implementation for specified family/type/protocol. So far however,
the order of processing was not clearly defined, leaving ambiguity if
multiple implmentations supported the same set of parameters.
Fix this, by registering socket priority along with implementation. This
makes the processing order of particular socket implementations
explicit, giving more flexibility to the user, for example when it's
neeed to prioritze one implementation over another if they support the
same set of parameters.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Info log messages don't have dedicated color which
makes them harder to separate from debug logs.
Introduce green color in log output for info level
so it stands out like error and warning messages do.
Signed-off-by: Marin Jurjević <marin.jurjevic@hotmail.com>
Add the BT_ISO_SDU_BUF_SIZE which can be used to declare
the TX buffers for ISO, similar to the BT_L2CAP_SDU_BUF_SIZE
macro for L2CAP.
This also updates the ISO samples to use this as well
updating the SDU check to use
CONFIG_BT_ISO_TX_MTU/CONFIG_BT_ISO_RX_MTU without
subtracting the BT_ISO_CHAN_SEND_RESERVE to make the
API more clear.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
As with IPv6, the mdns and llmnr responders should join their multicast
groups for IPv4 instead of just adding the multicast address to the
interface.
Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
Handle the case that setting up the iso data path for a
broadcast (sink or source) bis fails.
As part of this fix, implement the lookup_big_by_handle
function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Each backend can configure separately features like colors on/off, VT100
handling and so on. This can be very handy for planned MQTT backend.
Shell will not send VT100 commands when VT100 is not enabled globally or
for particular backend.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
VT100 commands are now stored as strings rather than character arrays.
This change will make it easier to create a unified macro for sending
all VT100 commands.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
As per #38352, we would like to start building out PTP (IEEE 1588)
support for superset of gPTP functionality in Zephyr. This is the first
step to abstract away some key interfaces from NET_GPTP umbrella to
NET_L2_PTP.
Signed-off-by: Alex Sergeev <asergeev@carbonrobotics.com>
Add seperate config to control whether device name include in
pb-gatt advertising scan response data.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
we will no longer need the additional `disconnect` parameter,
such as we only process gatt database from disconnect handler.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
In order to be able to make a "choice" from any other
Kconfig.defconfig (-ish) file, the choice needs to be named.
This commit names a few choices.
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
The current implementation has hidden dependencies that break
OOB authentication if provisioner does not have the configured
input or output fields used for device capabilities.
It didn't allow to pass several OOB authentication cases.
After refactoring provisioner behavior is independent to
provisionee settings.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Fix BT_CTLR_FAST_ENC Kconfig help text to reflect the
current Encryption Setup Procedure behavior.
With the split architecture, Encryption Setup Procedure
will take 4 connection events when BT_CTLR_FAST_ENC is
enabled, in comparison to 3 connection events in the
legacy Controller architecture. This is due to split
architecture processes control procedures in the lower
priority Upper Linker Layer execution context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
EAGAIN is used in some other places in the code, e.g. if node is not
provisioned when a model tries to send a message. This change helps to
differentiated if the acknowledged message timed out from other failers.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Fix deadlock in multiple peripheral connection in a device
due to redundant double reservation of node rx buffer during
crossover scenario in Data Length Update procedure.
Data Length Update resize state was reset back to response
wait state when peripheral received an acknowledgment to
local initiated Data Length Request PDU after having already
transitioned to resize state.
Implementation is designed to transition to resize state
under both Data Length Response reception and crossover
scenario of Data Length Request reception when procedure is
local initiated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add check that can be removed by the compiler since the rest is only
needed when multiple identities have been enabled.
Fixes: #38134
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Removed the bt_conn_unref from the deferred_work function.
For ISO, the conn unref for the peripheral will happen in
the bt_iso_disconnected function. For the central, the
unref shall only happen when the CIG is terminated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Log failure to register authentication handlers since returning errors
from the shell is not visible to the user.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Handle return value of GATT service register and unregister functions.
Log action to shell.
Fixes: #38013
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Check the return value of bt_rand when creating identities.
Failure to generate a random IRK would result in the privacy feature
being compromised.
Fixes: #38120
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix unexpected control flow in host keys module. A continue in a do
while false act the same as a break. This entire construct can be
replaced with a simple if else control flow.
Fixes: #38014
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Check len is not zero before accessing data pointer, the len variable
is not checked before this point so cannot be trusted to not be zero.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fixes an issue whereby the application is configured for extended
advertising mode but advertises in legacy mode with a large device name
which should be limited to 31 bytes
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
Ignore the return value of the bt_gatt_change_aware function when the
client is reading the database hash characteristic value. This is the
point where the client becomes change-aware, so nothing else should be
done if the client is change-unaware.
Fixes: #38012
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This is a regression introduced in b8770acc28 when
aligning with BT Core Spec 5.3 naming convention.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
When CONFIG_ARM_MPU is explicitly unset in application prj.conf there
were build warnings related with implicit declarations of following
symbols: NRF_DT_GPIOS_TO_PSEL, __WFE, __SEV.
Lack of NRF_DT_GPIOS_TO_PSEL lead to build error due to undeclared
dfegpio0_gpios symbol.
The cause for the warnings and error were missing soc.h includes in
few source files. The missing includes were added in this commit.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
RFC 2460 Sec. 5 requires that a ICMPv6 Time Exceeded message is sent
upon reassembly timeout, if we received the first fragment (i.e. the one
with a Fragment Offset of zero).
Implement this requirement.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
The purpose of shift_packets() is to make room to insert one fragment in
the list. This is not what it does currently, potentially leading to
-ENOMEM even if there is enough free room.
To see the current behaviour, let's assume that we receive 3 fragments
in reverse order:
- Frag3(offset = 0x40, M=0)
- Frag2(offset = 0x20, M=1)
- Frag1(offset = 0x00, M=1)
After receiving Frag3 and Frag2, pkt[] will look like:
.-------.-------.-------.
| Frag2 | Frag3 | NULL |
| 0x20 | 0x40 | |
'-------'-------'-------'
pkt[0] pkt[1] pkt[2]
When receiving Frag1, shift_packets(pos = 0) is called to make some room
at position 0. It will iterate up to i = 2 where there is a free
element. The current algorithm will try to shift pkt[0] to pkt[2], which
is indeed impossible but also unnecessary. It is only required to shift
pkt[0] and pkt[1] by one element in order to free pkt[0] to insert
Frag1.
Update the algorithm in order to shift the memory only by one element.
As a result, the ENOMEM test is only simpler: as long as we encounter
one free element, we are guaranteed that we can shift by one element.
Also assign a NULL value to the newly freed element since memmove() only
copy bytes.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Currently net_ipv6_handle_fragment_hdr() performs 2 distinct tests: it
checks the M-bit of the most recent fragment to decide if we can proceed
with the reassembly. Then it performs some sanity checks which can lead
to dropping the whole packet if not successful.
The test on the M-bit assumes that fragments arrive in order. But this
will fail if packets arrive out-of-order, since the last fragment can
arrive before some other fragments. In that case, we proceed with the
reassembly but it will fail because not all the fragments have been
received.
We need a more complete check before proceeding with the reassembly:
- We received the first fragment (offset = 0)
- All intermediate fragments are contiguous
- The More bit of the last fragment is 0
Since these conditions can also detect a malformed fragmented packet, we
can replace the existing sanity check that is performed before
reassembly. As a bonus, we can now detect and rejected overlapping
fragments, since this can have some security issues (see RFC 5722).
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Currently we only store the fragment offset. But in some cases it might
be necessary to also inspect the M-bit (More Fragment) of all received
fragments.
Modify the semantics of the field to store all the flags, rename the
setter to account for this change, and add a getter for the M-bit.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
The special handling of the 1st fragment in unnecessary, since it will
be correctly handled even without it. Moreover it causes some corner
cases, like a single packet with a fragment header (M=0), to be
incorrectly handled since the reassembly code is skipped.
Remove the special handling of the 1st fragment to fix these problems.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Currently the requirement of the length being a multiple of 8 is not
tested for the first fragment, since the first fragment takes a
different path due to the goto.
Move the test earlier in the process, so that it is performed on all
fragments, including the first one.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
If we have less fragments than what can be stored in the reassembly
array, some loops will blindly dereference NULL pointers.
Add checks for NULL pointers when necessary and exit the loop.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Currently the stack is limited to a maximum of 2 incoming fragments per
packet. While this can be enough in most cases, it might not be enough
in other cases.
Make this value configurable at build time.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Currently prev_hdr_offset always equals 6, which is the offset of
the nexthdr field in the IPv6 header. This value is used to overwrite it
when removing an IPv6 Fragment header, so it will work as long as there
is no other Extension header between the IPv6 header and the Fragment
header.
However this does not work in the other cases: the nexthdr field of the
IPv6 header will be overwritten instead of the nexthdr field of the last
Extension header before the Fragment, leading to unwanted results.
Update prev_hdr_offset so that it always point to the nexthdr field of
the previous header, either the IPv6 header or an Extension header.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
The current validation code waits to process the header before rejecting
it, while some checks can be already enforced when reading the nexthdr
field of the previous header.
The main problem is a wrong pointer field in the resulting ICMPv6 error
message: the pointer should have the offset of the invalid nexthdr
field, while currently it will the offset the invalid header.
To solve that problem, reorganize the loop in two parts: the first
switch validates nexthdr, while the second switch processes the current
header. This allows to reject invalid nexthdr earlier.
The check for duplicated headers is also generalized, so that we can
catch other kind of headers (like the Fragment header).
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
By definition, NET_IPV6_NEXTHDR_NONE is void. So we must stop processing
before trying to read any data, since we will start reading values that
are outside the Extension Header (likely the payload, if any).
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
When an unknown option is encountered, an ICMPv6 error message must be
sent in some cases. The message contains a pointer field, which must be
the offset to the unknown option. Currently the offset is computed from
the beginning of the option list, while it should be computed with
respect to the beginning of the IPv6 header.
Record the offset when reading the option type and pass it later to
ipv6_drop_on_unknown_option() to correctly set the pointer field. Also
rename the argument in ipv6_drop_on_unknown_option() to make the
purpose more clear.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Currently PADN data are not skipped, which results in the stack to think
that the next header starts in the middle of the padding. We have to
skip the bytes before going on.
Also clarify the PAD1 does not have any length field.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
The current names are confusing. Indeed "nexthdr" if the type of the
header currently processed, while "next_nexthdr" is the nexthdr field of
the current header.
Rename them to improve readability and make it less error-prone.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
ICMPv6 error messages are not sent (on native_posix) because the first
net_pkt_write() returns an error.
pkt has just been allocated using net_pkt_alloc_with_buffer(). Trying to
write an empty packet in overwrite mode will result in an error. There
is no need to be in overwrite mode, since we want to write the LL
src/dst addresses at the beginning.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Refactor IPv4 multicast address to MAC multicast address conversion
into its own function, so it can be reused by drivers as it is already
possible for IPv6 multicast addresses.
Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
This patch fixes the issue that can cause a deadlock in shell.
When two threads simultaneously poll the TXDONE signal, only one
of them will receive it, leaving second one stalled.
The problem was that shell's context contains k_poll_event objects that
were polled by multiple threads. Polling it overwrites the poller field
that was set by previous thread.
Instead, the k_poll_event object must be created on the stack by every
thread that wants to poll the TXDONE signal.
This makes sure that no thread will be left waiting for this signal
forever.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
When falling back to L2CAP for connection parameter updates, the
interval min and maxes should also be saved.
Fixes#38613.
Signed-off-by: Eric Johnson <eric@liveathos.com>
When calling ull_conn_iso_cis_stop with no pending LLL events,
cis_disabled_cb may be called recursively if more than one CIS is
associated with a disconnecting ACL connection.
To prevent ticker_stop being called more than once, it shall be
registered at entry of cis_disabled_cb whether this is the last CIS.
Only then shall ticker_stop be called.
Signed-off-by: Morten Priess <mtpr@oticon.com>
CIS LLL events pending was checked incorrectly using a
mayfly incorrect set to be called from ULL LOW context,
but the actual call was from ULL HIGH context.
Beside this, the code was refactored to have file static
functions after global scope functions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In case LwM2M server or bootstrap server rejected
Registration/Registration Update/Deregsitration attempt, there were no
reasonable notification to the application. Fix this by reporting
LWM2M_RD_CLIENT_EVENT_*_FAILURE in such case.
Addtitionaly, remove pointless ENGINE_DEREGISTER_FAILED event, which
have no use in the state machine.
Finally, simplify the response code logging to prevent code duplication.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Replace the old master and slave prefixes with the new central and
peripehral ones from the Bluetooth spec v5.3.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Replace the old whitelist-related terms with the new filter accept list
one from the Bluetooth spec v5.3.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In k_mem_paging_eviction_select(), the returned dirty bit value
may not be actually associated with the page selected, but
rather the last page examined. So fix this.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Align with the new inclusive naming terms in the v5.3 spec in the
Bluetooth Host implementation.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Align with the new inclusive naming terms in the v5.3 spec in the
Bluetooth shell implementation.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
To avoid hitting the following violation:
Violation to rule 5.7 (Tag name should be unique)
Replace the use of "shell" in the shell as an instance of a pointer to
const struct shell.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Align with the new inclusive naming terms in the v5.3 spec in the
controller's HCI implementation.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The Counter resource in the IPSO Push Button object was incremented
silently by the post write handler of the State resource. This prevented
the resource from being marked as updated, effectively preventing
the engine from sending notifications to observers.
Fix this, by setting the new counter value with `lwm2m_engine_set_u64()`
instead. This will update the resource value, and trigger the engine to
send notifications if needed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add an array similar to the bt_conn (ACL/L2CAP)
tx sent callback, and initialize it.
This increases the number of bt_conn_tx available
such that ISO does not take any of "L2CAP's" buffers,
but also ensures that the sent callback is called
for a broadcast iso only build.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The new inclusive naming terminology changes in v5.3 of the Bluetooth
specification affect the HCI layer, so apply all relevant changes to
align with it.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix the definiion of Common Extended Payload Format data
field in the PDU definitions to be zero-length array,
because PDU size are configurable and to avoid allocations
being made using these PDU structs.
Corrected the extended scan response length check code to
use the correct define instead.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising stop on duration by using the
ticks_drift which now includes the random delay and any
ticker rescheduling of advertising radio events due to
collision with other radio events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The ticker `ticks_drift` is propagated via the ticker
elapsed callback, in order to provide necessary information
to correctly calculate total elapsed durations by states and
roles that use ticker extensions to mitigate scheduling
collisions by drifting within a permitted window.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
HTTP_DATA_FINAL was incorrectly notified in case Content Length field
was present in the HTTP respone - in such case it was set for every
response fragment, not only the last one.
Fix this by relying on `message_complete` flag instead of
`http_should_keep_alive()` function to determine whether to notify
HTTP_DATA_FINAL or not. As the HTTP parser calls the
`on_message_complete()` callback in either case (response is chunked or
not), this seems to be a more reasonable apporach to determine whether
the fragment is final or not.
Additinally, instead of calling response callback for
`on_body`/`on_message_complete` separately, call it directly from
`http_wait_data()` function, after the parsing round. This fixes the
case when headers were not reported correctly when the provided buffer
was smaller than the total headers length, resulting in corrupted data
being reported to the user.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The helper function to conver 32-bit binary float value to
float32_value_t incorrectly identified the "hidden" bit, resulting in
invalid conversion when TLV encoding was used to write a resource
(the output value was divided by 2).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There were several issues preventing JSON format writes to work
correctly:
1. The formatter wrongly assumed that Base Name and Relative Name values
read from the message are NULL terminated, which in result could give
invalid results when combining them.
2. The formatter wrongly assumed that Relative Name is always present,
which is not always the case. In result, it failed to parse messages,
which contained full path in their Base Name Field
3. There were no boundaries check when reading JSON variable name/value,
which could lead to buffer overflow in case malformed data was
received.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Just like plain text, JSON parser ignored leading zeros after decimal
point, giving invalid results. Fix this in a similar way as for the
plain text.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Floating point parser for plain text format was parsing floats wrongly,
ignoring leading zeros after decimal points.
Fix this, by reusing atof32() function, already avaialbe in a different
part of the engine, which did the parsing correctly.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
According to the specificaion, resources are not predefined to use 32 or
64 bit floating point numbers, but should rather accept any of them (as
indicated by the size of the TLV in the message). This lead to issues
for instance with Eclipse Leshan LWM2M server, where Leshan sent 64-bit
value, while Zephyr expected 32-bit, making it impossible to write
the resource.
Therefore, unify the float usage to 32-bit float representation and fix
the TLV parsing functions, to accept values sent as either 32 or 64 bit
float.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The `poll()` function did not report POLLHUP if the peer ended the DTLS
session, making it impossible to detect such event on the application
side.
On the other hand, TLS erroneusely reported POLLHUP along with each
POLLIN event, as the 0 returned by the `recv()` socket call was
wrongly interpreted (it was expected to get 0 in return as 0 bytes were
requested).
Fix this by introducing a helper function to process the mbedtls context
and verify if new application data is pendingi or session has ended.
Use this new function in the poll handler, instead of a socket `recv()`
call, to remove any ambiguity in the usage, for both TLS and DTLS.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Notify the application when DTLS client session ends by returning
ENOTCONN on such event. Additionally, reset the mbed TLS session
structures, allowing to reinstante the session on the next send() call.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
ECONNABORTED was returned in case tls_mbedtls_reset() function for
resetting session failed, which can be caused by memory shortage. Return
ENOMEM instead.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fix Periodic Advertising Sync Establishment to accept
synchronization establishment to device listed in the
Periodic Advertisers List when filter policy was used.
Fixes#38520.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect calculation of received common extended header
length. Due to this a zero length advertising data is
reported in Extended Advertising and Periodic Advertising
report as one byte AD data.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add #defines for the maximum and minimum allowed values for object
IDs.
Moves the #define for the directory listing object ID to the public
header file
Having these limits available is useful for applications wanting to
ensure they pass in (or handle) valid object ID values.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The Bluetooth Core Specification, version 5.3, has introduced multiple
changes to several widely-used terms in order to make them inclusive.
Update the public API to reflect this, excluding hci.h, which will be
done in a subsequent commit.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Implements the Bluetooth appropriate language mapping for the Bluetooth
mesh subsystem.
Changes the following terms:
- Master security credentials -> Flooding security credentials
- Whitelist filter -> Accept filter
- Blacklist filter -> Reject filter
- Removes CDB's NODE_BLACKLISTED, which was not in use.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Add a warning if the image is unconfirmed. Add a delay before rebooting
so that the user knows what happened.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
The current HAWKBIT_PROBE & HAWKBIT_PROBE_DEPLOYMENT_BASE response
handlers aren't able to handle multipacket response from Hawkbit
server. This commit fixes it by using the implementation from
HAWKBIT_DOWNLOAD.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Signed-off-by: Joep Buruma <burumaj50@gmail.com>
net_packet_socket_input() was changed to hardcode the return of
NET_CONTINUE and that caused a segmentation fault/crash in
net_core/process_data(), in cases when pkt was unreferred and
NET_OK was returned from net_conn_input()
This happened with socket combo of: AF_PACKET+SOCK_RAW+IPPROTO_RAW.
Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
Extracted new Kconfig file for the Extended Advertising
and for the Bluetooth Isochronous Channel from the
Bluetooth subsystem Kconfig.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
The BAS serivce Kconfig uses now a log template instead of
defining logger configuration itself.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
The nbr_lock var actually depends on CONFIG_NET_IPV6_NBR_CACHE
(not CONFIG_NET_IPV6_ND), so move its initialization call.
Signed-off-by: Stancu Florin <niflostancu@gmail.com>
If one of AUX_CHAIN_IND is not received properly we need to send an
extra report over HCI to indicate that data are incomplete.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
BT_SECURITY_LOW and etc. were previously renamed and are no longer
valid.
The original rename is in the following commits:
1c48757d94 (New names, deprecate old)
5f2a9ba8e4 (Remove deprecated names)
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemiconductor.no>
Implement constraint API as weak symbols so applications or platform
can override them. Constraints are a high-level abstraction to inhibit
the power subsystem of using certain power states. Some platforms can
have their own way to set/release constraints in their drivers that
are not part of Zephyr's code base.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Since it's not possible to encode full range of 64-bit unsigned integer,
remove this type from the LwM2M implementation, and replace its uses
with 64-bit signed integer.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As the resource values represented by the unsigned integers were casted
to integers of a corresponding size in the read handler, they were not
ecoded properly if the unsigned value was larger than the maximum
integer value of the corresponding size (i.e. they were encoded as
negative values).
Fix this by casting the unsinged value to a wider integer type, to
prevent incorrect interpratetion of the data provided. The TLV encoding
functions take care of the optimization (i. e. encoding integers on the
minimum number of bytes needed), so it should prevent bandwith waste if
the unsigned value would actually fit into the integer of the
corresponding size.
Similar case is for the write hander, where unsigned integers encoded at
8 bytes were not processed correctly. Fix this by using wider decoder as
well.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Listing a neighbour table with "net nbr" command, when a neighbour w/o
assigned link address was present, resulted in an assert condition. Add
additional check to prevent this.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
TCP state machine gets stuck in TCP_FIN_WAIT_2 state
when server responds with [ FIN, PSH, ACK ]
Fixes#37842
Signed-off-by: Nicolas Marty <nicolas.marty@zuehlke.com>
Using zsock_ in http_client instead of the POSIX API versions of the
functions allows the usage of http_client in combination with
CONFIG_POSIX_API.
Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
Xtensa does not store the stack pointers in thread objects but
pushing the registers into the stack. There is no fixed location
to retrieve the stack pointer so mark it as unimplemented to
avoid the #warning.
Fixes#38405
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
When the application sets more than 251 bytes of advertising data,
the data is sent over multiple HCI commands.
This is only allowed if the advertiser is not running
as defined by the HCI specification.
The data is sent to the controller one AD-field at the time.
If an AD-field is larger than BT_HCI_LE_EXT_ADV_FRAG_MAX_LEN,
the data is split over two commands.
This introduces some additional complexity.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
add a bitarray into struct osThreadDef_t to indicate whether the
thread is used or not, then we can get the first available thread
by searching this array when creating a new thread, and update this
array to add a free thread when terminating a thread.
Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
To test fallback to remaining bearers PTS might request IUT to
disconnect one of the connected EATT channels, while the others remain
intact. Test function must be added, because we cannot create L2CAP
server on EATT PSM and manage this server as normal and have EATT
enabled at same time.
This is affecting GATT/SR/GAW/BV-14-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Add some tracing functions to fix that the samples/tracing code
cannot generate coverage by twister.
Fixed#38323
Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
Th Configuration Server should respond with and Invalid AppKey Index
status code when the AppKey identified by AppKeyIndex is not known to
the node or is not bound to the model identified by the ModelIdentifier.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
A check for valid_chan_io_qos in big_init_bis was missing
a negation when checking for invalid parameters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix assert at line 1085 in ull_adv_aux.c due to auxiliary
offset calculation scheduling on ticker timeout under must
expire which can happen for overlapping multiple advertising
sets without previous calculation not complete, a single
mayfly instance is used hence the assertion.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The commit adds CONFIG_IMG_MGMT_DIRECT_IMAGE_UPLOAD that allows
to turn on the direct image upload.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
cte_info_clear function is responsible for remove of CTE from
periodic advertising PDUs, including remove from optional chained
PDUs. The function uses subortinate function rem_cte_info_from_per_-
adv_chain to remove CTE from chained PDUs.
The rem_cte_info_from_per_adv_chain had pdu_prev and pdu as arguments.
After return from the function the pdu_prev should point to last
PDU from previously used periodic advertising data and pdu should
point to last new periodic advertising data.
The rem_cte_info_from_per_adv_chain function removes CTEInfo from
all but last one PDU. Last PDU must have removed AuxPtr field also.
Remove of CTEInfo and AuxPtr from last PDU is done explicitly in
the cte_info_clear function.
Unfortunately rem_cte_info_from_per_adv_chain had wrong type of
parameters for pdu_prev and pdu. These parameters were pointers
instead od double pointers.
That caused cte_info_clear function to remove CTEInfo and AuxPtr
from first PDU in a chain, which is AUX_SYNC_IND.
Changed parameters pdu_prev and pdu in the rem_cte_info_from_per_adv_-
chain to be double pointers.
Added small corrections in comments.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Co-authored-by: Emil Gydesen <Thalley@users.noreply.github.com>
According to the rule MISRAC-2012 21.4.a the standard header
file <setjmp.h> shall not be used. Suppress it, because it raises
violation in a testcode, not in a runtime code.
Tag suppresses reporting of violation for the current file,
starting from the line where the suppression is located.
It is a deliberate deviation.
Found as a coding guideline violation (MISRA R21.4.a) by static
coding scanning tool.
Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
Zephyr Bluetooth Mesh move adv send cb to buf destructor
callback, There are two net_buf_pool define, one to adv.c
and ore to friend.c, we are missing destructor in friend.c.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Two checks reported wrong value if the value was invalid.
CIS parameter check would always fail on correct values
due to missing negation of valid_chan_qos.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Problem:
In some cases, as described in: https://github.com/zephyrproject-rtos/zephyr/issues/36948
shell backend sends characters to output before serial device
is ready for it. It results in observing additional characters
inserted on the shell input after device boot.
Solution:
Added waiting on DTR signal before sending anything to the output.
Fixes: #36948
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
When Public Key field is set to RFU value then we should send
Provisioning Fail with Invalid Format error.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Fix MPU fault due to incorrect EV_COUNT, `conn_change`
signal was not accounted for in the array used by k_poll.
Relates to commit 7854088116 ("Bluetooth: ISO: Fixes
missing handling of broadcast ISO TX").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Instead of disconnecting ISO channels on ACL,
we put them in a non-connected state, and wait for
the ISO disconnect events.
This ensure that the controller has free'd the
ISO channels when the iso disconnect callbacks
are received. It will thus be possible to e.g.
terminate the CIG on the ISO disconnect callback.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When an ISO channel is disconnect on the central, it is
not deallocated, but merely disconnected. This is because,
as per the HCI spec, the CIS handle lives on in the CIG.
Instead of unref'ing the bt_conn to 0, we simply put the
channel and connection in the disconnected state.
This also fixes a few missing returns for
terminating a CIG.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Function parameters can be checked without MQTT instance lock being
held. Additionally if NULL parameter would be passed (which this check
tries to handle), then function would return without releasing lock.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Sending of > 2k buffers leads to split socket writes.
Current implementation is not checking for full buffer size.
ztls_sendmsg_ctx proceeds to next iov on sucessful write.
Solution: Add loop into ztls_sendmsg_ctx to process whole buffer
before proceeding to next iov.
Signed-off-by: Pavlo Hamov <pasha.gamov@gmail.com>
The #36758 fixes coap_packet_get_payload function by normalizing
offset value in the library. That change create a regression on
UpdateHub. However, the UpdateHub can now use coap_packet_get_payload
function instead manually compute payload start and payload size.
This refactors the current code in favor of coap_packet_get_payload
and fixes the regression.
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Create a new tracing option TRACING_USER that allows
the user to define certain user_sys_trace_... functions
to perform whatever work desired for tracing when
tasks are swiched in/out, during isr enter/exit, and when
cpu is idle.
This infrastructure can be useful for plugging into
locally defined tracing tools or any user-specific
debugging environment.
Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
Add a sent callback to bt_iso_chan_ops so that the application
can be notified when an SDU has been sent. This can help the
application decide whether to queue up multiple, or only
have a single ISO PDU enqueue for reduced latency.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
__cxa_atexit implementation provided by MWDT startup code calls
malloc which isn't supported right now. As we don't support
calling static destructors in Zephyr let's provide our own
__cxa_atexit stub and get rid of MWDT startup libs
entirely.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
When we build tests/kernel/common/kernel.common.misra on
bl654_usb we get the following error:
subsys/usb/usb_descriptor.c:313:2: error: ISO C90 forbids array
'hwid' whose size cannot be evaluated [-Werror=vla]
Fix by removing use of usblen variable in array.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
On native_posix_64 we get the following compile error in CI:
error: format %u expects argument of type unsigned int
Fix by using %zu instead of %u as type is of size_t.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
The HCI spec defines the BIS index range as starting from
index 0x01. We had previously implemented it such that it
starts from 0x00, and then simply adding 1 to the index
when sending over HCI. However, this may cause issue with
other HCI, or other SIG defined specification, commands
and events, and thus it is probably simpler if we just
use the HCI defined range.
This commit disallows BIT(0) (representing the BIS
index 0x00) to be set, and removes the addition
of 1 when sending over HCI.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove littlefs dependency as FS backend works with any file system as
long as it is (manually or automatically) mounted.
Fixes#36851
Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
Fix null pointer deferencing in Periodic Synchronization
when ULL execution context could not assign an auxiliary
context when in LLL scheduling to receive chain PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix null pointer dereferencing in Extended Scanning when
there are more peer devices than the allocated auxiliary
contexts.
When LLL scheduling does not get an auxiliary context
assigned in the ULL execution context, then further chain
reception is aborted, access to `lll->lll_aux` which is
NULL causes null pointer dereferencing in
`ull_scan_aux_release`.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When Extended Initiating a connection, release auxiliary
context memory referenced by the lll_aux pointer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update Periodic Advertising Synchronization's drift
compensation to save radio ready and address capture on
AUX_SYNC_IND reception, restore and apply at the end of
reception of all AUX_CHAIN_IND PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Instead of checking `if (iso == NULL)` it simply checked
`if (iso)` which is the opposite of what it should have done.
This completely blocks iso from connecting channels.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
cdc_acm_irq_tx_ready was not checking if its interrupt was enabled.
This causes spurious tx irq handler calls.
Signed-off-by: Eric Johnson <eric@liveathos.com>
We get build issues due to the removal of the Kconfig symbol
CONFIG_UART_SHELL_ON_DEV_NAME on platforms that didn't have a uart
set as we'd get a default value for those platforms. Update the
Kconfig logic to only enable SHELL_BACKEND_SERIAL if we have
zephyr,shell-uart specified in the devicetree to address the issue.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Timeout cancel should only be done for connections established in
peripheral role.
Enhanced connection complete event could still be delivered without
extended advertising support (i.e no advertising set terminated event)
so this handling should be moved to the common conn complete function.
Fixes#37467
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
PR #35774 introduced a uuid field in the bt_mesh_cfg_mod_pub structure.
The shell does not initialize this pointer before passing it to the
access layer. Add a line to initialize this pointer.
Fixes#38016.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
param can never be NULL here, so the check is redundant. Coverity is
complaining because param is accessed before the NULL check.
Fixes#37949.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
param can never be NULL, so this check is redundant. Coverity complains
about this, as the param variable is accessed before the check, which
would be wrong if param could be NULL.
Fixes#37948.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When Extended Scan Response data of length zero is set, the
Scan Response do not have the Common Extended Payload Format
and hence no ADI field. Fix uninitialized pointer to Scan
Response Data's ADI to avoid copy of ADI from primary
channel PDU.
Fixes#38015.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The rpmsg_mi_configure_shm() function is not returning anything and it
is not marked as static. Fix this changing the return type to 'static
void'.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
When possible use 'size_t' for sizes and 'uintptr_t' for generic
addresses instead of relying on uint*_t types.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
When call bt_gatt_indicate with param->attr set to null.
and attr->uuid set to given uuid, the internal notify will
search uuid, but not assigned to param->attr, which cauce
null point reference when:
notify --> gatt_indicate --> bt_gatt_check_perm
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When call `bt_gatt_notify_cb` with param->attr set to null.
and attr->uuid set to given uuid, the internal notify will
search uuid, but not assigned to param->attr, which cauce
null point reference when:
notify --> gatt_notify --> bt_gatt_check_perm
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Prefix ringbuffers with cdc_acm because it is not possible
to use static specifier with RING_BUF_*_DECLARE_* macros
to avoid conflicts.
Fixes: #36608
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
PR #36996 disabled running mem_protect/stack_random test on qemu_riscv32
platform because of this test consistently failing on said platform.
This test starts new threads in equal time intervals, and because of
that we get repeating values after performing the modulus operation when
calculating the stack pointer address.
This can be solved by changing the value of the _RAND32_INC constant
that is used to increase the value returned by the timer-based PRNG.
This commit decreases the value of the mentioned constant from
1000000013U to 1000000003U.
Fixes#37006.
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
Advertising might stop when:
- it was stopped by application
- device connected to a peer
- extended advertising reached stop condition
defined in BT_LE_EXT_ADV_START_PARAM - this is handled in ll
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Call bt_le_adv_stop() if adv == bt_dev.adv (Meaning it is the legacy
advertiser and was started with bt_le_adv_start()), otherwise use
bt_le_ext_adv_stop(), because it was started with bt_le_ext_adv_start().
Failing to stop advertising shouldn't result in assert.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Cleanup and preparation commit for linker script generator.
Zephyr linker scripts provides start and end symbols for each larger
areas in the linker script.
The symbols _image_rom_start and _image_rom_end corresponds to the group
ROMABLE_REGION defined in the ld linker scripts.
The symbols _image_rodata_start and _image_rodata_end is not placed as
independent group but covers common-rom.ld, thread-local-storage.ld,
kobject-rom.ld and snippets-rodata.ld.
This commit align those names and prepares for generation of groups in
linker scripts.
The symbols describing the ROMABLE_REGION will be renamed to:
_image_rom_start -> __rom_region_start
_image_rom_end -> __rom_region_end
The rodata will also use the group symbol notation as:
_image_rodata_start -> __rodata_region_start
_image_rodata_end -> __rodata_region_end
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
PM_DEVICE_STATE_RESUMING and PM_DEVICE_STATE_SUSPENDING
are transitional states and are only used in device runtime. Remove it
and use device flag to keep track of a transition.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
'err' is already defined in parent scope, we can use. Just need to set
it back to 0 before returning from function.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This was changes when sync chain handling was done in lll_scan_aux, we
can now revert to original code.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We need more RX nodes when scanning either extended/periodic advertising
trains and CTE samples so pudate those values based on observer and DF
features enabled.
The number of nodes for non-DF allows to scan complete chain for each
aux scan set (assuming max data length and optimal fragmentation by
advertiser), for DF it allows to scan max possible PDUs and CTE samples.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Periodic advertising train scanner implemented in lll_scan_aux adds lots
of branches that cannot be compiled out with periodic advertising sync
disabled.
This commit moves sync parts of the code from lll_scan_aux to lll_sync.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Periodic advertising PDUs are now dispatched immediately one by one
(i.e. without list of PDUs as when flushed from aux context) so we
do not need to iterate such a list.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
AdvA, TargetA, ADI and SyncInfo are RFU in periodic advertising PDUs so
we should ignore them when present in PDU.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Periodic advertising reports can be reated directly from single PDU
as they do not require any information from superior PDU, so we can
dispatch them immediately instead of buffering in aux context and
flushing at the end of chain.
This also resolves proper order of Periodic advertising and IQ reports.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We use 1st node enqueued in aux context to retrieve lll scan/sync
struct, but that only works if we buffer PDUs in aux context. It's
better to store parent lll struct as explicit member in aux context
as this also works if we skip buffering.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds complete support for scanning for periodic advertising trains.
AUX_SYNC_IND is always scheduled from ULL as usual, then code for aux
scanning is reused to allow for AUX_CHAIN_IND scanning scheduled from
both ULL and LLL, depending on AuxPtr.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
aux->rx_last cannot be NULL since it's always set after acquire to a
valid node so the flow in flush() can be simplified.
rx parameter is only used to update PDU chain, then it's overwritten,
so we can instead update PDU chain in caller since there's only one
place when this should happen.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We should decide on flush immediately vs. from disabled_cb based on
ull_hdr reference count instead of last rxd node - if ull_hdr has
non-zero ref, then done event is still pending and we should flush
from there.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Periodic advertising reports can have 255 bytes of payload so need to
use that value by default if periodic advertising is enabled.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Update the name of the bt_conn pointers to make it clear
whether the connection pointers are ACL or ISO connections.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make the name of the internal bt_conn pointers explicit as to
whether they point to an ACL or ISO bt_conn.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Ignore received Extended Advertising PDU with RFU field set
in the Common Extended Advertising Payload Format of the
PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use defines to access hdr_data fields used by interfaces to
populate the Common Extended Advertising Payload Format in
the PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use defines for event instant and event instant latency
maximum values of 65536 and 32767 respectively.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation in Periodic Advertising Synchronization
to support Channel Map Update Indications present in the
ACAD fields of the AUX_SYNC_IND PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Make the block of code that is used to release node rx with
type NODE_RX_TYPE_RELEASE to be conditionally available for
other Kconfig selectable features like Extended Scanning.
Previously it was only available for CONFIG_BT_CONN, but now
Extended Scanning with LLL scheduling releases node rx when
radio event is closed due to failure to receive an auxiliary
PDU.
Relates to commit 2feffaf719 ("Bluetooth: Controller:
Release LLL scheduling aux on incomplete data").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing reset of connection handle in the LLL context.
During a central connection, if LL reset is called, then
disabled connection context's handle has to be reset
otherwise new connection creation will fail by detecting
that there exists a connection to same peer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to initiator to check and reject
connection requests to already connected peer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
ULL reference count is checked in ULL_LOW context to decide
if LLL events are pending, but the reference count can be
decremented by the ULL HIGH execution context which can
prevent the set `disabled_cb` function not being called due
to no pending event to produce the done events.
Fixed by checking the reference count in the ULL HIGH
execution context using a mayfly to schedule the check.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This patch is the first step to make the rpmsg_multi_instance usable in
a multi-core scenario.
The current driver is using a local driver variable (instance) to track
the number of allocated instances. This counter is practically used to
allocate to the instance the correct portion of the shared memory.
This is fundamentally wrong because this is assuming that it does exist
only one single shared memory region to split amongs all the allocated
instances. When the platform has more than one core this is obviously
not the case since each couple of cores are communicating using a
different memory region.
To solve this issue we introduce a new struct rpmsg_mi_ctx_shm_cfg that
is doing two things: (1) it's carrying the information about the shared
memory and (2) it's carrying an internal variable used to track the
instances allocated in that region. The same struct should be used every
time a new instance is allocated in the same shared memory region.
We also fix a problem with the current code where there is a race
between threads when accessing the instance variable, so this patch is
adding a serializing mutex.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
For the instance configuration the rpmsg_multi_instance code is
currently using a set of configuration info coming from two different
sources: the rpsmg_mi_ctx_cfg struct and Kconfig.
This is not only confusing but it's preventing to configure the
instances using information not coming from Kconfig (for example if we
want to configure the instance using DT).
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This adds a flash-based backing store for qemu_x86_tiny board for
testing demand paging. This allows us to test code execution where
.text section is not in physical memory at boot.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This ensures that all mesh settings were removed from persistent storage
after node reset.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Fix maximum radio packet size configuration to use 255 bytes
for Extended Scanning and Periodic Synchronization.
Add a Kconfig option so that application can reduce RAM
usage if a specific user scenario can live with smaller PDU
receptions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In the calculation of auxiliary PDU offset for periodic advertising
AUX_CHAIN_IND PDUs there were used old macro that was removed.
The code didn't compile.
Also there were no support for S2 Coded PHY in the offset calculation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The channels list were originally meant to be used
for multiple bt_iso_chan per iso connect (bt_conn), but
that is not the case for the current API, and won't be
going forward, so the use of the list has been removed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for setting initial values in bt_vcs_register_param
when registering a VCS service
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Before commit 4f2682bd79
("usb: cdc_acm: avoid spurious interrupt on configured or resume
events") spurious rx-interrupt provided start to read shell tx ring
buffer by CDC ACM UART. Now shell log backend not transmit data,
until CDC ACM UART received data from host.
This PR added invoking interrupt callback if tx interrupt is enable,
when CDC ACM class go to configured state, and flag tx_ready go to true.
Signed-off-by: Grixa Yrev <GrixaYrev@yandex.ru>
In case that creating a BIG fails due to missing
ISO channel, cleanup_big would try to access a
NULL pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Do not include ULL header in LLL, instead values and fields
required in LLL shall be declared in LLL contexts.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The fs_statvfs function assumes FatFs is configured for a fixed sector
size and therefore may return wrong sector sizes when it is configured
for variable sector sizes instead. Fix that by returning the ssize
variable given in the file system object structure.
Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
The runtime API is referenced count and uses a uint32_t.
Avoid underflow when dealing with put requests.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Return 0 in cases where the request does not trigger a device state
change, only incremented or to decremented the reference count.
Fixes#37821
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Removed implementation that used memcpy of received PDUs and
instead using the free Rx buffers; use the scratch PDU for
transmitting scan requests and connection requests.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add the lll_prof_reserve and lll_prof_reserve_send profiling
functions to use when profiling active scanning and
initiator.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
llcp.conn_param.ack was reset on tx of conn param rsp, however this
should only be done once the expected conn update ind is received
and sets the cu.ack flag to indicate cu procedure 'takes over'.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing implementation to release Auxiliary PDU chains
and then resume back to scanning on primary channel.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add PDU time calculation macro for S2 and S8 Coded PHY.
Rename PKT_AC_US to PDU_AC_MAX_US.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add missing range delay value when calculating the header
complete timeout value for the reception of extended scan
response PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the received coding scheme when scanning for correctly
calculating the receive chain delay and on-air PDU time.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
After 31045c7 was merged, it was possible to use broadcast
iso without CONFIG_BT_CONN, but it did not properly handle
TX as there were missing support to read the buffer
size from the controller, as well as missing support
for handling the number of completed packets event.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change so that num_completed_packets event handling is also
enabled for broadcast ISO only builds. This is because sending
data on a broadcast ISO still generates this event.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the function out of the ACL group as it may be used
for broadcast ISO only builds.
er 31045c7 was merged, it was possible to use broadcast
iso without CONFIG_BT_CONN, but it did not properly handle
TX and RX as there were missing support to read the buffer
size from the controller, as well as missing support
for handling the number of completed packets event.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Follow up on commit bfd45e5b8c
("drivers: remove Kconfig option CONFIG_UART_CONSOLE_ON_DEV_NAME")
Remove Kconfig options
CONFIG_BT_UART_ON_DEV_NAME and CONFIG_BT_MONITOR_ON_DEV_NAME
since all UART drivers are converted to devicetree and we can just use
DEVICE_DT_GET(DT_CHOSEN(zephyr_bt_uart)) and
DEVICE_DT_GET(DT_CHOSEN(zephyr_bt_mon_uart)).
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The IPC drivers rpmsg_service and rpmsg_multi_instance are not
explicitly enabling the RX IPM channel when two different devices are
used for TX and RX. While this could be redundant for some IPM drivers,
in some cases the hardware needs to be enabled before using it.
Add the missing calls to ipm_set_enabled() for both the devices.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
There were missing commands in local supported commands list that
are related with connectionless direction finding.
The commands are implemented but they haven't been added
to HCI_Read_Local_Supported_Commands list.
The commit fixes that.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Suspend devices when the system goes to STATE_SOFT_OFF.
This state was not triggering any device power management. This should
at least suspend devices as it is done for SUSPEND_TO_RAM and
SUSPEND_TO_DISK.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Follow up on commit bfd45e5b8c
("drivers: remove Kconfig option CONFIG_UART_CONSOLE_ON_DEV_NAME")
Now we can also remove Kconfig option CONFIG_UART_CONSOLE_ON_DEV_NAME
since all UART drivers are converted to devicetree and we can just use
DEVICE_DT_GET(DT_CHOSEN(zephyr_shell_uart)).
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Move the implementation of scan trains after call to LLL
prepare, so that LLL prepare executes without any latency.
To increase radio utilization, LLL prepare should be
scheduled as early in the `ticker_cb` of the radio event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the return value use to indicate unassigned auxiliary
context when scanning is using LLL scheduling. This can
happen only under LLL scheduling where in LLL auxiliary
channel PDU reception has been spawn from LLL primary
channel scanning and on completion will join back to resume
primary channel PDU scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Keep the default AD Data length to Bluetooth Specification
defined minimum of 31 octets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update the connected ISO API to be more
similar to the broadcast ISO API as well
as the HCI spec.
This updated API allows for more flexibility
and will better support scenarios such as true
wireless setup, as ISO channels and connections
are more independent now.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix implementation to not to put back the primary channel
scanning to resume state when Extended Scan has used ULL
scheduling which pre-empts the scan window.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME)
and use DEVICE_DT_GET(DT_CHOSEN(zephyr_console)) to get
chosen "zephyr,console" node.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Rework NCP interface configuration and NCP sample. Remove
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME and
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM Kconfig
options in favor of chosen node zephyr,ot-uart usage.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add hidden Kconfig option to Kconfig.cdc and allow
to configure CDC ACM UART device from devicetree.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Simplify implementation that clears extended scan response
data by moving the length check after the new PDU buffer
has been correctly initialized.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add check to validate PHY value in the Auxiliary Pointer
structure in the common extended header format.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The bt_sdp_get_add_proto_param is used to get the protocol
parameter from Additional Protocol Descriptor List.
In order to implement it, one parameter
(proto_profile_index) is added to sdp_get_uuid_data_index
to get the indexed item.
Fix one bug in sdp_get_uuid_data because there may be more
than 2 consequent "seq len item".
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
Add a build assert if the device name has been misconfigured. The device
name has a max length of 248. When configured as dynamic make sure that
the initial device length can fit in the dynamic max length.
This prevents us from having to handle length overflow when setting
device name in advertising data which has an 8-bit length field.
Log a warning if failing to set the device name in bt_enable.
Remove unused defines in the shell.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix adv-data command when given arbitrary advertising data in
hexadecimal format. The data_len field should contain the length of the
data which does not include the data type. Instead the AD len field in
the data was given. This caused the AD len field to be increased by 1
in the advertising dat.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
In the case where keys are distributed on an unencrypted link,
we got the following call trace:
- bt_smp_recv()
- smp_error()
- smp_pairing_complete()
- bt_conn_security_changed()
- smp_pairing_complete()
- bt_auth->pairing_failed()
- smp_reset()
- bt_auth->pairing_failed()
- smp_reset()
To avoid the second call to bt_auth->pairing_failed()
we validate the that smp flags before calling the callback.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
(Re)setting the connection handle in hci_disconn_complete
should not be done as the handle are used for
logging/debugging purposes after this, and makes it
impossible to lookup the handle of disconnected
connections.
The connection handle is set to 0 during bt_conn_new
in any case.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
No initialisation will lead to undefined behaviour in check for
BT_L2CAP_RECONF_INVALID_MPS.
This is affecting L2CAP/ECFC/BV-23-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Fix missing synchronization when stopping primary and
auxiliary PDU scheduling.
Added implementation to ensure primary and auxiliary event
count match when terminating extended advertising on maximum
number of events or on duration.
Fixes#37571.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Max events and duration parameter are not used in high duty
cycle directed, hence correctly initialized them and not
depend on the caller of advertising start API to set them
to zeroes.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
unseg_app_sdu_decrypt decrypts messages in place using a single net_buf.
While this is safe in terms of data access, the buffer state is
manipulated with the assumption that they're two different buffers, and
the output buffer's length field is increased at the end. When
assertions are enabled and the pdu length is 11 or 12 bytes, this
triggers the net_buf length assert, as the decrypt function attempts to
add the pdu length to the out buffer, with the assumption that it was
reset before decryption was started.
Create a separate output buffer with len = 0 to avoid triggering the
assert. Improve readability of the unseg_app_sdu functions to highlight
the need for the additional buffer.
Fixes#37519.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Allow the application to configure the advertiser as scannable when it
does not provide scan data in the call to bt_le_adv_start. This makes it
possible for the application to later add scan response data in the
bt_le_adv_update_data call.
This aligns the legacy code path with the extended code path which
already had this behavior.
This also stops a directed connectable advertiser from being marked
internally in the host as scannable. This appears to not have been
causing any issues.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix non-connectable advertiser configured as ADV_SCAN_IND when
configured by application to have the device name appear in the
advertising data instead of the scan response data.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Disallow creating an extended scannable advertiser with the device name
configured to appear in the advertising data.
This would fail in either the call to bt_le_ext_adv_start or
bt_le_ext_adv_set_data when the host would try to set advertising data
in the controller.
Instead this now fails in the bt_le_ext_adv_create call.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
There is a problem with the previous method, that is,
we use the same label(bt_mesh_subnet_cb_subnet_evt) and
put it in the same section, which is not friendly for debugging.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Move to CMake 3.20.0.
At the Toolchain WG it was decided to move to CMake 3.20.0.
The main reason for increasing CMake version is better toolchain
support.
Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
When device is first provisioned with IV Update
flag is set to 0, it should wait for minimum of
96 hours before going into IV Update In Progress
state. Such limit does not apply, if device is
provisioned with IV Update flag is set to 1.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
This commit adds missing API that allows to discard the Subscription
List of a vendor model.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Name length can't be longer than 8 bytes. This needs to be clarified
in the bt_mesh_model_data_store() documentation.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Change the fail handling of setting the CIG parameters
(or when allocating the CIS) to unref the ISO conns
instead of calling cleanup on them directly.
This fixes an issue that if the CIG parameters failed,
then the iso conns would not be unref'ed and we could
not try again.
Unref'ing an iso conn will call cleanup once it hits 0
refs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A channel should only be allowed to unbind when in
the BT_ISO_BOUND state. If it is in a disconnected state,
then it the function would have meaning. If it is a connected
state, unbinding it would generate an error when removing
the CIG, which would fail silently.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
LE Set Connection CTE Receive Parameters HCI command size may not fit
into HCI TX command buffer size, which default value is 65 bytes.
For platforms other than Nordic there may be up to 75 antenna IDs
put into the command.
Added new default value for SOCs not compatible with Nordic to
extend default TX buf size to 83 bytes (75 bytes for antena IDs,
5 bytes for other command parameters, 3 bytes for command header).
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add functions that handle enable CTE request control procedure
request from host.
Implementation of ll_df_set_conn_cte_req_enable in ULL is partial.
It will be integrated with refactored implementation of control
procedures.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add struct ll_df_conn_rx_params sturcutre to struct lll_conn.
This is storage for parametrers required to configure radio
for CTE reception in connected mode by lower link layer.
Add required includes to make the controller code compilable
after change struct ll_conn.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
HCI_LE_Set_Connection_CTE_Receive_Parameters handling is required to
enable sampling of Constant Tone Extension in connected mode.
The commit adds handling for HCI_LE_Set_Connection_CTE_Receive_-
-Parameters command.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add struct ll_df_conn_rx_params sturcutre to struct ll_conn.
This is storage for parametrers required to configure radio
for CTE reception in connected mode.
Add required includes to make the controller code compilable
after change struct ll_conn.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add new strcture type for storage of CTE receive parameters.
The structure will be used in to store parameters for connected mode.
The parameters provided by HCI commands for receiving CTE
in connected mode and disconnected mode are a bit different.
There is common subset of parameters but extraction of those
into common structure would increase of size of other stuctures
that aggregate them.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Code related with connected mode was in middle between connectionless
RX and TX. Moved to the bottom of the file.
Added missing compilation guards for ll_df_set_conn_cte_tx_params.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add features: connection CTE request, connection CTE response
and receiving constant tone extensions; to HCI and features
supported by controller.
The features are not enabled yet.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Compute the SHA256 hash of the downloaded image and compare that with
the hash in the deploymentBase to guarantee that only the correctly
downloaded image will be flashed.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Use a semaphore to prevent the hawkbit_probe from running more than once
at the same time since it reset the hawkbit context on entry and will
affect other running instance.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Fix multiple typos and make the sample's log output consistent
with the subsys.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Co-Authored-By: Sylvio Alves <sylviojalves@gmail.com>
The commit applies changes that are required by update of ELM Chan's
FAT FS driver update to version 0.14b.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The way we currently handle direction finding extension (DFE) support
on Nordic nRF5 controllers relies on required devicetree properties
related to DFE in the "nordic,nrf-radio" node.
That doesn't make sense on radios without DFE support, though.
Any .dtsi for an SoC without DFE support which has such a node would
require extraneous DFE related properties like dfe-antenna-num.
Instead of making the properties required, mark them optional. We
indicate the presence of DFE support via a new 'dfe-supported' boolean
property which the SoC .dtsi files can set (or not) depending on
support.
This gives us the opportunity to do some cleanup in the Kconfig,
removing CONFIG_HAS_HW_NRF_RADIO_BLE_DF since we know from the
devicetree whether DFE support is available.
Handle that change appropriately in radio_df.c. This gives us an
opportunity to improve readability in the devicetree-related macro
magic in that file.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Fix scan_data_status value from being incorrected OR-ed with
the advertising data status.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Simplify the implementation deciding the use of LLL
scheduling for scanning PDUs with close auxiliary offsets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to release Auxiliary Context on failure
to receive auxiliary chain being in LLL scheduling.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We need to alloc node prior to calling lll_scan_aux_setup, otherwise
the same node will be peeked inside that function and it will overwrite
some data in our node (e.g. "extra" field).
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation to use LLL scheduling for close auxiliary
offsets when active scanning and initiating connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to resume primary PDU scanning window
after use of LLL scheduling to receive auxiliary PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When Auxiliary PDUs are scanning by the primary scan's LLL
scheduling, then flush the Auxiliary PDUs when processing
them in the ULL instead of using the disabled callback.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This can be used to check if pointer is a valid lll_scan_aux pointer,
e.g. if we need to decide what kind of struct is attached to RX node
for further processing.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We need to reset isr status before returning as otherwise irq will be
triggered over and over again.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to traverse the Extended Active Scanned
advertising PDUs, generate the Scannable Advertising and
Scan Response Advertising Report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When Extended Active Scanning hold back the received PDUs in
a linked list and send it to HCI together so that fields
present across these PDUs can be aggregated for generating
the LE Extended Advertising Report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Flush the scanned advertising PDUs to HCI while receiving
the scan response PDU when Extended Active scanning.
This reverts earlier implementation to remember the
advertising PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for Extended Active Scanning and generation of
Extended Advertising Report with Scan Response event type.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reverting Extended scanning with LLL scheduling as this is
causing unresolvable merge conflict with the commits that
is implementing the Extended Active Scanning support.
Subsequent commit add the revert implementation back again.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
After the modules are adapted for the revised
USB device stack configuration, and it seems that
it was only necessary for MCUboot, we can finally
remove Kconfig option CONFIG_USB.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Checks PAN ID for matching self address / broadcast, then the short /
extended address based on the used address mode.
Only when IEEE802154_HW_FILTER is not advertised by driver.
Signed-off-by: Stancu Florin <niflostancu@gmail.com>
Instead of putting object files inside libzephyr.a,
simply build a separate static library as most other
driver types are doing this already.
Note that the include to subsys has been moved from
under the drivers into subsys, as it is actually
the subsystem's job to make sure the include
directories are correct.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Instead of putting object files inside libzephyr.a,
simply build a separate static library as most other
driver types are doing this already.
Note that the include to subsys/bluetooth has been
moved from under drivers/bluetooth to subsys/bluetooth,
as it is actually the subsystem's job to make sure
the include directories are correct.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Make subsys/bluetooth/audio build as a static library.
This is in preparation to enable building the bluetooth
drivers as a static library. That would change the line
"zephyr_include_directories(subsys/bluetooth)" where
this include path is applied to all code compiled.
Its removal will result in subsys/bluetooth/audio not
able to find subsys/bluetooth/common/log.h. So change
subsys/bluetooth/audio to be built as a static library
so it can link to the subsys/bluetooth library where
it can find "log.h" there.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
_pm_devices, pm_suspend_devices, pm_low_power_devices and
pm_resume_devices are only used if CONFIG_PM_DEVICE is defined and not
CONFIG_PM.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Fix a race condition that caused the Controller to deadlock
waiting for a semaphore that be given when LLL events have
been disabled.
ULL reference count is checked in thread context to decide
if LLL events are pending, but the reference count can be
decremented by the ULL execution context which prevents the
set `disabled_cb` function not being called due to no
pending event to produce the done events.
Fixed by re-checking if reference count is zero and avoid
waiting to take the semaphore.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
While RADIO_DFECTRL1_TSAMPLESPACING and RADIO_DFECTRL1_TSAMPLESPACINGREF
has similar values, but they are logically different.
As expected by "radio_df_ctrl_set" function, TSAMPLESPACING should be
passed to this function not TSAMPLESPACINGREF.
Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
When events are placed back into pipeline as resume events,
only remove duplicate resume events and not new prepare
events that may have been enqueue between the start of the
pre-empt ticker and its timeout.
Due to new prepare events that was removed, extra done
events generated cause the number of enqueued done events
to overflow and assert.
Fixes#36381.
Fixes#37597.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the incorrect iterator index being reset when flushing
duplicate resume events in the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update the AD data race condition handling with explicit
revert of `pdu->last` value after detecting the race.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reduce the Rx window swithch overhead for continuous scan by
using radio interfae `radio_tmr_start_now` that accounts for
any minimum ticker offset requirement.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the radio software switch from Rx to Tx when in
passive scanning, as there is no transmission requirement
after reception of a PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit adds a devmem load command for shell that allows
users to easily load arbitrary data into the device memory.
Signed-off-by: Mateusz Sierszulski <msierszulski@internships.antmicro.com>
Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
The new JIT scheduler does not have slot reservation, which means that
the ticker extension feature for automatically re-scheduling a colliding
non-anchored event, e.g. ADV, cannot be used.
This implementaion reacts to ADV envent done with result ABORTED or
TOO_LATE, and in those cases attempts to re-schedule the ADV event again
within the 10 ms pertubation window.
As the original scheduling, the re-scheduling is randomized, so there
is no absolute predictability as to how many attempts will be made. The
advertiser will attempt with randomly delayed re-schdules until the
window is exhausted.
If re-scheduling is unsuccessful, the weight of the ADV event is
increased, improving it's chances of success in the next event.
Signed-off-by: Morten Priess <mtpr@oticon.com>
This migrates all the current iterable section usages to the external
API, dropping the "Z_" prefix:
Z_ITERABLE_SECTION_ROM
Z_ITERABLE_SECTION_ROM_GC_ALLOWED
Z_ITERABLE_SECTION_RAM
Z_ITERABLE_SECTION_RAM_GC_ALLOWED
Z_STRUCT_SECTION_ITERABLE
Z_STRUCT_SECTION_ITERABLE_ALTERNATE
Z_STRUCT_SECTION_FOREACH
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
we use flag 0 in osSignalWait function to wait for
any single signal flag, but with this 0 flag,
it won't clear thread signal results as expected,
we need to check whether signal flag is 0 firstly.
Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
Change cdc_acm_poll_out to do the best to mimic behavior
of a hardware UART controller without flow control.
With this patch, if the USB subsystem is not ready,
no data is transfered to the buffer, that is, new character
is dropped. If the USB subsystem is ready and the buffer is full,
the first character from the tx_ringbuf is removed to
make room for the new character.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Currently, with EATT enabled, when bt_gatt_read is called with multiple
handles first it'll try to use gatt_read_mult_vl, and if it fails
gatt_read_mult will be used to try again. Add option to skip
the gatt_read_mult_vl and use gatt_read_mult right away. This is needed
by tests that expect BT_ATT_OP_READ_MULT_REQ but support variable
lenght, thus don't return BT_ATT_ERR_NOT_SUPPORTED.
Removed fallback from read multiple vl to read multiple on
BT_ATT_ERR_NOT_SUPPORTED error.
This was affecting:
GATT/CL/GAR/BV-05-C, GATT/CL/GAR/BI-18-C, GATT/CL/GAR/BI-19-C,
GATT/CL/GAR/BI-20-C, GATT/CL/GAR/BI-21-C, GATT/CL/GAR/BI-22-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Add the number of strdup buffers currently in use to the
`log strdup_utilization` shell command.
Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
Fix the node rx memory pool corruption regression introduced
due to same peer connection being rejected.
Regression introduced in commit 30f260dfaa ("Bluetooth:
controller: Fix adv/scan context access post release").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When a new radio event is scheduled with a relatively short
preempt timeout while there is already a started preempt
ticker, then stop the ticker, abort the previous event that
requested the preemption, and request to start ticker with
the new relatively short preempt timeout.
Fixes#30245.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When there are multiple events in prepare pipeline then fix
the implementation so that only one preempt ticker start
or stop operation is enqueued towards ticker_job for
processing.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Introduce a new API to allow devices capable of wake up the system
register themselves was wake up sources. This permits applications to
select the most appropriate way to wake up the system when it is
suspended.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Just using a simple atomic for flags instead of using an array.
While is neat using ATOMIC_DEFINE for future proof. The reality is
that it brings some problem for the wakeup source implementation
that needs to statically initialize it during the device definition.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
When transmitting a frame, inform the radio driver whether
security processing and/or header updates are needed or not.
When a frame was transmitted, inform back to OpenThread whether
the security procedure and/or header updates were completed for
the frame or not.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
If HCI LE Set Extended Advertising Enable command is sent
again for an advertising set while that set is enabled, then
any change to the random address shall take effect.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Permit enabling already enabled advertising. Enabling
advertising when it is already enabled can cause the
random address to change, as specified in the Bluetooth
Specifications.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
By default ICMP desination unreachable error packets are generated when
input packets target ports that are not in a listening state. This not
only reveals the presence of the host on the network which may be
considered a security vulnerability depending on the application, it
also ends up triggering ARP lookups to respond to the sending host. With
a small ARP table and a network where there may be broadcast (or
multicast) service discovery traffic such as mDNS or uPnP, ARP table
thrashing can occur impacting network stack performance.
Signed-off-by: Berend Ozceri <berend@recogni.com>
The latest MESH.TS 1.0.1.2 4.15.10 Appkey List Procedures
MESH/NODE/CFG/AKL/BI-04-C
Verify that the IUT can respond to an Config AppKey Add
message with NetKeyIndex and AppKeyIndex already stored.
6. Repeat step 1 with the same AppKey, the same
AppKeyIndex, but NetKeyIndex field set to 0x001.
7. The Lower Tester expects the IUT to respond
with an Config AppKey Status message with the
Status field set to 0x04 (Invalid NetKey) and
the NetKeyIndex and AppKeyIndex values equal to
those sent in step 5.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The function to execute shell commands: shell_execute_cmd will now
behave similarly to invoking command line commands.
I.e. after the command is executed the command buffer is cleared,
while the cursor is set to the initial position.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Fix the missing resumption of connectable advertising and
release of received connection complete buffers from LLL
after detecting connection from same peer.
Relates to commit 010c5c2f20 ("Bluetooth: controller:
Ignore connections from same peer").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The constructors of static objects are stored in ".ctors"
section. In case of MWDT toolchain we have incompatible
".ctors" section format with GNU toolchain. So let's use
initialization code provided by MWDT instead of Zephyr one
in case of MWDT toolchain usage.
As it is done for GNU toolchain We call constructors of
static objects but we don't call destructors for them.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Add a check for the mandatory channel receive callback when the
application provides the L2CAP channel operations.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Adds defines for ECC public keys, private keys, DH keys and key
coordinates. Replaces raw numbers throughout.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Remove compilation warning about adv_sync_pdu_ad_data_set function
that is defined but not used.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction finding functionality allows to send a number of periodic
advertising PDUs in a chain that have CTE.
Disable sending CTE requiers additional steps while removing
cte_info from periodic advertising chains.
Removal of cte_info fields may be just delete of that filed
from extended advertising header. In case the PDUs are empty
PDUs created just to transport CTE. Those PDUs should be removed
from a periodic advertising chain.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add release of chained PDUs by lll_adv_pdu_and_extra_data_-
latest_get function. It is requier to release unused
PDUs from a chain to avoid PDUs leakage.
It maight happen when chained PDUs were used by Direction
Finding, then lll_adv_pdu_and_extra_data_lates_get is used
instead of lll_adv_pdu_lates_get.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To check if advertising PDU is empty we can compare its length to 1.
To avoid use of magic number, the commit provides a macro for that
purpose.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction finding functionality allows to send a number of periodic
advertising PDUs in a chain that have CTE.
ll_df_set_cl_cte_tx_enable function was changed to update periodic
advertising chain to include cte_info field. If the chain is too short,
there is less PDUs in the chain than requested number of CTEs,
the function will add new empty PDUs to the chain end.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Enabling or disabling transmission of Constant Tone Extension with
periodic advertising PDUs requires update of a PDU content.
CTE_INFO field of periodic advertising PDU must be filled with
appropriate data. That operation may be done for periodic
advertising PDU (or chain of PDUs) filled with other payload that
wasn't enqueued towards LLL. In that situation PDUs are updated
in place, to avoid increase of memory consumption.
The commit changes ull_adv_sync_pdu_set_clear function to
make possible update of the advertising PDU in place.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Some functions, provided to handle changing content of periodic
advertising PDUs, were defined as static.
Code responsible for handling direction finding updates periodic
advertising PDUs also. For that purposes, those functions were mede
globally accessible.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add configuration of CTE for periodic advertising chain transmission.
The commit provides configuration of radio in prepare stage and
in handle of Tx ISR. CTE is configured only for PDUs that
have cte_info field in extended advertising header.
During prepare of periodic advertising event there are updated
aux_ptr fields in extended advertising header in other PDUs from
a periodic advertising chain. aux_ptr offset value also depends
on CTE length. CTE configuration is always the same for every
PDU in periodic advertising chain.
CTE may be added to requested number of PDUs in periodic
advertising chain. Although it is possible that there are PDUs
that don't have CTE. PDUs that have CTE are alsways at the beginning
of a periodic advertising chain.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Configuration of CTE for transmission is stored in extra_date member
of a lll_adv_sync object. PDUs in periodic advertising chain share the
same CTE configuration, so there is single instance of the extra_data.
To configure CTE transmission for every PDU in periodic advertising
chain a new function was introduced to peek extra_data instance without
peeking new PDU.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Transmission of Constant Tone Extension is done after END event
triggered by radio. To correctly switch from TX to TX (back 2 back
TX) after transmission of CTE PHYEND event must be used instead of
END event.
The commit provides required function that allows LLL to correctly
setup radio to do back to back switch of TX when CTE transmission
is enabled.
The radio_switch_complete_and_phy_end_b2b_tx cannot be implemented
in radio.c source file. It will fail build of unit tests targeted
for NRFBSIM simulator board. There is no RADIO_SHORTS_PHYEND_DISABLE_Msk
macro defined in bsim_hw_models module.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Amount of memory allocated for advertising PDUs (including
periodic advertising) depends on two factors:
- maximum advertising data length
- maximum number of CTE in a periodic advertising chain.
Maximum advertising data length is divided by maximum size
of a single fragment (number of payload bytes that single
advertising PDU may hold) to get required number of fragments.
Actual number of PDUs allocated for advertising is maximum
of acutal number of advertising payload fragments and maximum
number of CTEs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add possiblity to configure maximum number of PDUs with Constant Tone
Extension in a single periodic advertising chain.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Socket CAN does not require interface link address to be
assigned, check is not applicable for socket CAN
interfaces. As this address is NULL for socket CAN interface
it results in assertion.
Signed-off-by: Ramesh Babu B <ramesh.babu.b@intel.com>
Use the internal function z_device_get_all_static helper function
instead of using __device_start and __device_end directly. Some other
minor adjustments have been done (e.g. reduce *dev scope to the for
loop). An issue on the range of the for loop in _pm_devices has also
been fixed.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The shared _pm_devices function used should_suspend check function to
see if a device had to be suspended or not. Some of the logic inside
that function was redundant since the pm_device_state_set function
already performs similar checks, e.g. if the device is already at the
given state or the state transition is not supported it will return
error codes appropriately.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
A device that is turned off should not be suspended. A device that has
been turned off can only be resumed. This action is currently forbidden
by the "should_suspend" function in the device PM code.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
k_timeout_t was converted to ticks using a nonsense function
causing poll timeout corruption for offloaded sockets; this
commit uses ticks directly from the struct instead.
Fixes#37472
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
According to MbedTLS API documentation, its session must be
reset if mbedtls_ssl_handshake returns timeout error. This
commit resets the session for said return value, and that
allows us to call send() multiple times even if handshake
times out for previous calls.
Fixes#35711
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
We had added a break in a switch statement that stopped
ISO channels from setting the BT_CONN_CLEANUP flag
which in turn stopped them from disconnecting (in the
eyes of the upper layers) properly.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of just writing "err" we make it clear that it is
the ISO server that failed to accept.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add missing otPlatTimeGet implementation which is needed for proper
calculation the time offset in host-RCP communication.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
With the last changes in USB device stack it was unfortunately
not considered that an interface can have no endpoints.
This caused the USB DFU class to stop working in DFU mode.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add implementation to resume primary PDU scanning window
after use of LLL scheduling to receive auxiliary PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When Auxiliary PDUs are scanning by the primary scan's LLL
scheduling, then flush the Auxiliary PDUs when processing
them in the ULL instead of using the disabled callback.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This can be used to check if pointer is a valid lll_scan_aux pointer,
e.g. if we need to decide what kind of struct is attached to RX node
for further processing.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We need to reset isr status before returning as otherwise irq will be
triggered over and over again.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix potential bug when returning error codes not handled by
OpenThread in `otPlatRadioTxDone`.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Fix bug in adv timeout for limited advertiser when extended advertising
features has been enabled. The advertiser was only stopped when
configured as an extended advertiser. It should be stopped when
configured as a legacy advertiser also.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Deprecate the xoroshiro128+ PRNG algorithm in favour of xoshiro128++.
xoshiro128++ is a drop-in replacement which is invisible from the user
perspective.
xoroshiro128+ is unsuitable because it is explicitly a floating-point
PRNG, not a general-purpose PRNG. This means that the lower 4 bits of
the output are actually linear, not random (from the designers,
https://prng.di.unimi.it/). This means 1/8th of the generated data is
not random.
Additionally, xoroshiro128+ is not a 32bit algorithm, it operates on
64bit numbers. For the vast majority of Zephyr devices, this makes the
PRNG slower than it needs to be. The replacement (xoshiro128++) is
32bit, with no loss in state space (still 128 bit).
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Adds an implementation of xoshiro128++ as a pseudo random number
generator from https://prng.di.unimi.it/ that operates on 32bit words.
The algorithm postfix signifies the main operation in the generation
function. Therefore xoshiro++ is chosen over xoshiro** as we would
prefer to do 2 additions isntead of 2 multiplications on embedded
hardware. The quality of the generators appears to be the same in all
other respects.
xoshiro+ is not chosen despite being faster as it generates random
floating-point values, not general purpose random values (The lower 4
bits are linear).
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
ZFD_IOCTL_POLL_OFFLOAD operation needed special handling, as it needed
to modify the fds table for the offloaded implementation, overwriting
websocket file descriptors with the underlying offloaded ones. This is
only needed for the offloaded sockets, as the native implmentation use
POLL_PREPARE/UPDATE operations instead.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The websocket implementation of ioctl wrongly passed websocket context
to the undrelying `ioctl` implementation instead of the context of the
underlying socket.
Additionally, currentl implementation used the vtable of the native
socket implementation unconditionally, making it unusable with an
offloaded underlying socket.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add support for FORCE_SUSPEND and LOW_POWER actions. Even though these
actions have no clear meaning, they are added for compatibility until
their associated states are discussed. Their usage in new code should be
discouraged until the associated states are clarified.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
If a device does not support, for example, the suspend action the
subsystem should just ignore the device.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Instead of passing target states, use actions for device PM control.
Actions represent better the meaning of the callback argument.
Furthermore, they are more future proof as they can be suitable for
other PM actions that have no direct mapping to a state. If we compare
with Linux, we could have a multi-stage suspend/resume. Such scenario
would not have a good mapping when using target states.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The verb tense for the suspended state was not consistent with other
states. The likely reason: state was being used as a command/action.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
If the device is already at the given state, do not call the device PM
control function. This makes sure that devices are only called to change
from one state to another.
Even though asynchronous device PM is completely broken, transitional
states are considered too.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Improve the docstrings of the pm_device_state_set function and change to
shorter argument variable names.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Since the state is no longer modified by the device PM callback, just
use the state value.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The device PM subsystem already holds the device state, so there is no
need to keep duplicates inside the device. The pm_device_state_get has
been refactored to just return the device state. Note that this is still
not safe, but the same applied to the previous implementation. This
problem will be addressed later.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Fix the received Extended Advertising PDU's address
resolution latency due to missing reset of pending IRQ in
the NVIC which caused the wait loop from not exit correctly.
Fixes#30243.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When generating LE Extended Advertising Report the device
address can be either in primary or auxiliary channel PDU,
do not overwrite resolving list index if present in primary
channel PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Cleanup standard device request handler.
Pass pointer to setup packet as argument where
it is reasonable.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Cleanup standard device request handler.
Pass pointer to setup packet as argument where
it is reasonable.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This class does not handle any vendor request,
therefore just return -ENOTSUP on any vendor request.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
HCI commands are always directed to controller and should be
host-to-device class control requests.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Return ENOTSUP if request is unsupported and pass on the error
from encapsulated command/response functions.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Control request handler from CDC ECM implementation does not
care at all about returning errors when a request is not supported.
Return EINVAL/ENOTSUP if request is incorrect/unsupported.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Set data stage length variable to zero as a precaution
so that no trouble happens if control request handler
does not check the request values sufficiently.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The USB configuration option is actually a global switch
to enable USB drivers in general, but currently only
the device controller drivers are meant.
USB device controller drivers also have USB_DEVICE_DRIVER option.
Thus the option USB is actually redundant and can be replaced
by the self-explanatory option USB_DEVICE_DRIVER.
The name USB itself is not unique and should not be used as an
configuration option.
With these changes the option USB_DEVICE_DRIVER generally
enables USB device controller drivers. The option USB_DEVICE_STACK
enables USB device support. It is sufficient to enable only option
USB_DEVICE_STACK because it selects USB_DEVICE_DRIVER.
CONFIG_USB Kconfig option is temporary added to subsys/usb/Kconfig.
This is necessary to pass CI and will be removed again
when the USB configuration has been adapted in modules.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
It is mainly for testing purposes where logging is multiple times
reinitialized.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix key distribution not calling pairing complete callback when
distributing encryption information when not bonding.
Encryption information is only distributed in legacy pairing so issue
was only seen during legacy pairing.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
A mutex is used to syncrhonize the start, stop and service() functions
of the RD client. Previously it could happen that while service() was
working on e.g. bootstrapping, a stop() call by another thread would
close the socket. Then the bootstrapping process would detect it as a
network error, and restart the process.
Fixes#37170.
Signed-off-by: Maik Vermeulen <maik.vermeulen@innotractor.com>
The existing extension tree does not support all the features that are
defined by the specification (e.g. multiple parents).
This patch approaches this problem by defining a circular single-linked
list of extension models. So for a given model, all models that are on
the same list as that model are in some extension relationship with that
model. All models on a list represent a single connected component of an
extension graph but without defining specific relationships between each
pair of models. This list is used to manage a shared subscription list
as per the Mesh Profile Specification:
```4.2.4 Subscription List
Within an element, each model has a separate instance of a Subscription
List, unless the model extends another model on that element. Instances
of models that extend other models (i.e., all models within an extension
relation tree) shall share a single instance of a Subscription List per
element.
```
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
The Bluetooth Core spec 5.2 requires to provide CTE type in
periodic advertising report.
The implementation of le_per_adv_sync_report assigned
value zero to be default CTE type. The assigned value
in Bluetooth Core spec 5.2 means "AoA Constant Tone
Extension". In case there is no CTE attached to periodic
advertising PDU, CTE type should contain value 0xFF.
This commit fixes the issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix compilation warning in hci_df_set_cl_cte_rx_enable function.
The struct bt_hci_cp_le_set_cl_cte_sampling_enable *cp variable
was used just to evaluate size in bt_hci_cmd_create call.
The variable is moved to prepare_cte_rx_enable_cmd_params
function and size of the buf is evaluated directly from type.
Code is simpler and prepare_cte_rx_enable_cmd_params does not
require passing additional argument.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
It is desirable to have the read and write like functions follow the
POSIX read and write parameter types.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
There were missing calls to periodic advertising functions:
lll_adv_sync_init() and lll_adv_sync_reset() corresponding
functions in lll_adv.c.
Lack of those calls didn't introduce any harm.
I've added them to have complete init and reset patch,
similar to extended advertising implementation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There is missing handling of periodic advertising reset for
HCI_Reset command. That makes impossible to execute e.g.
qualification tests without rebooting of the DUT
for periodic advertising and direction finding.
This commit adds missing implementation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The local function has been missing static specifier.
The commit also removes unused STORAGE_MGMT_ID_ERASE define.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
In the current code the naming of the
CONFIG_RPMSG_MULTI_INSTANCE_?_IPM_{TX,RX}_NAME symbol is 1-based. While
this is not currently an issue, it could easily become such if the
symbol is programmatically used as part of a preprocessor enumeration
(for example when using DT_INST_FOREACH_STATUS_OKAY(...) & co).
To avoid trouble, just make the index starting from 0 instead than 1.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Extract functions which are managing logging sources
and backends into separate file: log_mgmt.
So far those functions were in log_core mixed with functions
specific to log message creation and log processing.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
There was an issue with receiving CTE packets when the time
slot has changed from 2us to 1us. After receiving the packets
when it tries to enable receiving of CTE, the validator
returns EINVAL error.
Source of the problem is "validate_cte_rx_params" function,
it calls DF_AOA_RX_1US_SUPPORT(df_ant_info.switch_sample_rates)
which is expanded to:
((df_ant_info.switch_sample_rates) & BIT((BT_HCI_LE_1US_AOA_RX)))
And due to definition of BT_HCI_LE_1US_AOA_RX in hci.h it will be:
((df_ant_info.switch_sample_rates) & BIT(BIT(2)))
So the BIT operation has executed two times.
Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
Busy check APIs now return boolean type. Due to that change, the
function names have also been adjusted. The common name pattern for
boolean check type APIs is "PREFIX_is_CONDITION". For example,
"pm_device_is_busy". pm_device_busy_check has been renamed to
pm_device_is_busy and pm_device_any_busy_check to pm_device_is_any_busy.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
- Use an enum for the available flags
- Use ATOMIC_DEFINE macro to declare the flag bit field
- Improve naming
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The following device busy APIs:
- device_busy_set()
- device_busy_clear()
- device_busy_check()
- device_any_busy_check()
were used for device PM, so they have been moved to the pm subsystem.
This means they are now prefixed with `pm_` and are defined in
`pm/device.h`.
If device PM is not enabled dummy functions are now provided that do
nothing or return `-ENOSYS`, meaning that the functionality is not
available.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Increase LOG_PROCESS_THREAD_STACK_SIZE for ARCv3 64 bit to
fix failing test
tests/subsys/logging/log_core_additional/logging.add.async
due to stack overflow.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
Busy simulator is using counter device and entropy device to
generate random cpu load. Counter device cofiguration can be
used to set cpu load interrupt priority and optional pin that
can be set during the load.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
When in le_ecred_reconf_req multiple CIDs are received host should
return 0x0002 error (Reconfiguration failed - reduction in size of
MPS not allowed for more than one channel at a time).
This affects test L2CAP/ECFC/BI-04-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
In limited advertising advertising should end after certain timeout.
Previously, limited advertising was just general advertising with
BT_LE_AD_LIMITED flag set. Now, if this flag is set the work is
scheduled, that will disable advertising after timeout.
This affects tests GAP/DISC/LIMM/BV-03-C and GAP/DISC/LIMM/BV-04-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
When downloading large files from the hawkbit server
the only time rsp->body_start is checked is on the
first call. After this it is never checked again.
This caused the wrong data to be written to flash
and a failed update.
Signed-off-by: Joep Buruma <burumaj50@gmail.com>
Flush any pending Tx PDUs in the lower link layer before
enqueueing PHY_UPDATE_IND PDU with instant to ensure the
PDU is transmitted before the instant occurs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement the advanced scheduling for Extended Initiator to
group central connections established to Extended
Advertisements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Currently, in Zephyr the shell thread is the lowest priority i.e.
K_LOWEST_APPLICATION_THREAD_PRIO. Due to this all the other threads can
preempt the shell thread. Proposed solution is to add Kconfig which
gives the flexibility to change the priority of the shell thread.
This is now implemented using a new Kconfig variable
SHELL_THREAD_PRIORITY_OVERRIDE. By setting this option
SHELL_THREAD_PRIORITY can be set.
Signed-off-by: Uday Ammu <udaykiran@google.com>
Added support for conversion from a standard package which contains
pointers to read only strings to fully self-contained (fsc) package.
Fsc package contains all strings associated with the package thus
access to read only strings is not needed to format a string.
In order to allow conversion to fsc package, standard package must
contain locations of all string pointers within the package. Appending
that information is optional and is controlled by flags parameter
which was added to packaging API. If option flag is set then
package contains header, arguments, locations of read only strings and
transient strings (each prefixed with string argument location).
Package header has been extended with field which contains number of
read only string locations.
A function for conversion to fsc package has been added
(cbprintf_fsc_package()).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Change DSA API to use `net_if` directly to make API calls instead of
indirectly via `dsa_context` and `switch_id`.
Remove unused `switch_id`, `switch_enable_port`, and `dsa_get_context`.
Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
Check for the address family of the packet when setting the multicast
destination address used in the response. Current code checks either the
query type or the stack configuration, which can result in setting the
wrong type of address for the frame.
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
In order to avoid to generate warning log message from
file system, first check if directory exists before trying to
create it.
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
There are multiple reasons to want to find out if file or
directory exists, for example to create it. Stating and
finding out it doesn't exist should not cause an LOG_ERR call as
this gives information to the user in a normal call case.
Fixes#35718
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
To be consistent in how order header flags are handled when
updating the common header format fields, explicit check
for ADI flag in previous auxiliary PDU buffer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remember last used DID for each SID, so that DID value used,
when updating the advertising PDU fields, change between
consecutive changes to PDU fields.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Make the Extended Advertising DID value updated to be unique
for every new advertising set created.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix corrupt AD data used after directed advertising by
storing a backup of the AD data before switching to directed
advertising. Restore back the AD data with switching to non-
directed advertising.
The fix also addresses AD data backup when switching between
Legacy and Extended Advertising.
Fixes#18850.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to resolve AdvA in the received
AUX_CONNECT_RSP PDU before generating the connection
complete.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
SoC hooks are defined as weak functions for the case where they are
not implemented by a SoC. The problem that may happen is when an
application define it as weak as well. In this case, no compilation
error is issued but the version that will be used depends on the build
order. Just remove the weak placeholder implementation.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
When the Hardware Information Driver (HWINFO) provides a device ID
longer than the configured USB serial number, truncate the most
significant part instead of the least significant part. The lower part
is usually having more entropy, e.g. on STM32.
Fixes#34550
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
SMP implementation across bt/udp does not check
if allocation of the buffer was successful.
If the buffer is not granted an error shall be
returned.
This patch fixes BUS FAULT issue when NULL
pointer is referenced.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
If BT_ISO is enabled we now compile conn.c which contains a
lot of functionality used by BT_ISO, even for broadcast-iso
builds, i.e. builds that do not require BT_CONN.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the guard such that the iso_mtu and iso_pkts are
not guarded by BT_CONN as they should be available for
iso broadcast-only builds.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the bt_acl_recv function that works similar to
bt_iso_recv but for ACL data only, simplying the
generic bt_conn_recv function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the bt_conn_disconnect and conn_disconnect functions
to the ACL group.
Also adds a guard in the iso.c file for connected ISO.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the notify_le_phy_updated, notify_le_data_len_updated,
notify_le_param_updated, notify_remote_info,
notify_disconnected and notify_connected functions
to the ACL group.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the deferred_work callback function to the ACL group.
This also moves the static function conn_lookup_iso
which is only called form deferred_work.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the bt_conn_lookup_state_le, bt_conn_lookup_addr_le and
bt_conn_is_peer_addr_le functions to the ACL group.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the bt_conn_get_tx_power_level and
bt_conn_le_get_tx_power_level functions to the ACL group.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Start a group of functions guarded by CONFIG_BT_CONN
that are for connected-only functions. This is a
preparation step for allowing compilation and usage of
conn.c for ISO broadcast-only builds.
Moving all connected-only functionality into a single
group will also allow a possible move of all those
functions into an connected (ACL) only file.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add missing API:
- Delete all group addresses in a SIG model's subscription list
- Update a network key
- Update an application key
- Get/Set Node Identity parameters
- Set virtual addtess for a SIG model
- Get/Set Key Refresh Procedures
Signed-off-by: Agata Ponitka <agata.ponitka@codecoup.pl>
The functions to check advertising and target address in a
PDU are used only inside the same file, hence make them file
static functions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add target address check to extended scanning implementation
to detect invalid target address present in primary and
auxiliary channel PDU. Implementation is reuse of the check
used in the initiator after refactoring to pass parameter to
differentiate, its use for primary or auxiliary channel, and
for scanning or initiating.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added bt_mesh_msg_send() which can be used by the application to
directly send model layer messages without local instantiation of
related models. Also added bt_mesh_msg_cb_set() which allows the
application to recieve mesh model layer messages without local
instantiation of related models.
Added bt_mesh_has_addr() which returns a bool. For unicast addresses,
this returns whether or not bt_mesh_elem_find() was successfull. If the
above mentioned bt_mesh_msg_cb_set() has been used by the application to
set a message callback, this returns true so that the stack attempts to
push every model message up to the application via the callback. If no
callback has been set, group addresses are searched to see if the stack
should pass the message up the stack to an instantiated model.
These changes allow applications that do not or can not instantiate
models to interface with models in a mesh network. This is applicable to
applications which act as a Bluetooth mesh gateway, sniffer, debugger,
network monitoring, non-mesh relay/extender, etc.
In app_keys.c friend.c net.c bt_mesh_elem_find() is used only to
determine the existance of an address. The full return value of
bt_mesh_elem_find() is unecessary and so was replaced by the above
mentioned bt_mesh_has_addr() function in these instances.
Simplified bt_mesh_elem_find() by removing the search through group
address. Since the above mentioned bt_mesh_has_addr() function handles
instances where group addresses must be searched, it was no longer
necessary to preform this search in this function.
Signed-off-by: Bud Wandinger <bud@budkoembedded.ca>
For setting the APP_KEY, "mib_req.Param.AppKey" field should be used.
Fix it!
Fixes: #36540
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
This provides a command line interface to query and modify
bridge instances, similar to Linux's brctl utility.
It can be used to inspect an application's bridge usage,
or manage a bridge of its own in a generic way.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This adds the ability to create Ethernet bridges for connecting
separate Ethernet segments together to appear as a single
Ethernet network.
This mimics the Linux functionality of the same name.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
cc13x2_cc26x2 had its own power policy that was implementing the same
logic available in the default residency policy. Also, this policy was
unnecessarily setting up a timeout to wakeup the system. This is not
necessary, the power subsystem takes care of this.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Because we use the extended kconfig, we have already
supported relative paths, and it is clearer to use
relative paths in the bluetooth submodules.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
So far the maximum configurable file size was limited to 16KB (2^14).
This might be enough for small partitions on internal flash. For
external QSPI memories however, this is certainly too restrictive.
Change maximum configurable file size to be 1GB, which is 2^30. Such
value will prevent signed integers overflow on 32-bit platforms, while
giving user full flexibility on how big log files should be.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Zephyr Bluetooth Low Energy Controller for mesh stack
uses pre-emptible continuous scanning, allowing advertising
events to be transmitted without delay when advertising is
enabled. No need to compensate with scan window duration.
Zephyr Bluetooth Low Energy Controller built for nRF51x
SoCs use CONFIG_BT_CTLR_LOW_LAT=y, and continuous scanning
cannot be pre-empted, hence, scanning will block advertising
events from being transmitted. Increase the advertising
duration by the amount of scan window duration to compensate
for the blocked advertising events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Disable use of BT_CTLR_SCAN_UNRESERVED with BT_CTLR_LOW_LAT.
nRF51x SoC needs to block any CPU use inside radio events,
hence use of radio without time reservation is required for
proper functioning of Controller in nRF51x.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In case a non-readable resource gets updated (either by the server or
with an API), it makes no sense to send a notification in such case, as
no such resources are not included in notifications anyway.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Adds length defines for all provisioning PDUs and uses them to split
prov_link.conf_inputs into separate fields.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Opened directory descriptor is leaked when returning 1. Fix that by
utilizing goto in function return path.
Fixes: 6b18e6992d ("subsys/loggin/log_backend_fs: added recovery after
file lost")
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Add guards to the structs. This has two purposes:
1) Reduce size of only one of them are enabled
2) Fix a compile issue if only one of them were enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add guards to the structs. This has two purposes:
1) Reduce size of only one of them are enabled
2) Fix a compile issue if only one of them were enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If either AICS or VOCS clients were not enable, then the VCS
client could not be enabled as there was a compile error
in the function that registered callbacks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Even though it's highly unlikely that a component of time
would ever approach INT_MAX, use the unsigned specifier to mitigate
any unexpected behaviour.
Fixes#36814
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
Flag that indicates if a given packet is being retransmitted has become
obsolete since more detailed flags were added. This commit removes the
flag and references to it altogether.
Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
Fix HCI Reset Command from asserting when there is pending
connection creation requested on coded PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing initialization of legacy advertising PDU length
when advertising sets are reused between extended and legacy
advertising modes.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use CONFIG_BT_CTLR_BROADCAST_ISO when CONFIG_BT_CTLR_ADV_ISO
or CONFIG_BT_CTLR_SYNC_ISO Kconfig option is supported.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added Bluetooth Specification references to the
implementation of Channel Selection algorithm #2 in the
Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement the functions required to calculate the SubEvent 1
and SubEvent n mapped channel indices.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add the check for mixed use of Legacy vs Extended HCI
commands for Periodic Advertising related HCI commands.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix extended advertising report to set the directed bit in
the event type when receiving directed non-connectable
advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix extended advertising PDUs seen after the advertising
duration has elapsed, by considering the events skipped
due to overlap with other events which is provided by
the ticker lazy parameter.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add checks for invalid PHYs supplied to HCI LE Extended Scan
Parameters and LE Extended Create Connection commands.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Newline character is automatically appended in log backends such as
UART, so there is no need to add it explicitly.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
There is '%u' and '%d' in format message, while there is only one
argument (besides format string). Remove ununsed '%u' to stop printing
garbage.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
FS backend is no different when it comes to producing human readable
timestamp. Allow to select it when FS is the only enabled logging
backend.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
The len argument always has the same value as
usb_dev.setup.wLength, which is also the last received
USB device request.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
After extracting from ull_adv_sync_pdu_set_clear functions:
ull_adv_sync_pdu_alloc, ull_adv_sync_extra_data_set_clear
Use of ull_adv_ext_hrd_data structure became unnecessary.
The extra_data member of the structure was never used
due to separate function responsible for setting extra_data
content.
In all cases content for extended advertising header fields
may be passed to the ull_adv_sync_pdu_set_clear directly
as void * pointer, instead of pointer to ull_adv_ext_hdr_data.
This simplifies use of ull_adv_sync_pdu_set_clear as well
as removes unneccesary code to handle special structure type.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
extra_data is not used by ll_big_create and ll_big_terminate.
extra_data_prev and extra_data_new are optional arguments for
ull_adv_sync_pdu_alloc.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
ull_adv_sync_pdu_alloc function was extracted from ull_adv_sync_pdu_-
-set_clear function. The arguments list of ull_adv_sync_pdu_alloc
was derived from source function but the acutal functionality is
only part of what it was before.
The ull_adv_sync_pdu_alloc does not change extended advertising
PDU header fileds. The hdr_add_fields and hdr_rem_fields arguments
were used to allocate or not allocate memory for extra_data related
with new periodic advertising PDU. Also hrd_data pointer was
not used by the function.
The function arguments list was simplified.
New enum ull_adv_pdu_extra_data_flag was introduced to provide
named flags for extra_data memory management.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix `poll()` handling for DTLS clients when the underlying socket is an
offloaded socket. As in this case no `k_poll()` is used underneath, it's
not possible to monitor the handhshake status with `tls_established`
semaphore. Instead, do the following:
1. If no handhshake is in progress yet, just drop the incoming data -
it's the client who should initiate the handshake, any data incoming
before that should not be processed.
2. If handshake is currently in progress, lift the `POLLIN` flag and add
small delay to allow the other thread to proceed with the handshake.
3. Otherwise, just proceed as usual.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The TLS/DTLS handshake in most cases is a blocking process, therefore
the underlying socket should be in a blocking mode to prevent busy
looping in the handshake thread. Fix this by clearing the O_NONBLOCK
flag on the underlying socket before the handshake, and restoring it
afterards.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fixes#36667
If you had a single log file with index 0 created and you reboot
the log backend wasn't counting it and was overwiting it.
If you filled that file up before rebooting then it worked as
expected, creating a new file at the next index on each boot.
Signed-off-by: Elliot Revell-Nash <elliot.revell-nash@wdtl.com>
Implementation of the backend for IPC Service.
Multi-instance RPMsg was used as a backend.
Signed-off-by: Marcin Jeliński <marcin.jelinski@nordicsemi.no>
IPC Service allow plugging in different transport backends.
Specifies a generic API that is implemented by the backend.
Signed-off-by: Marcin Jeliński <marcin.jelinski@nordicsemi.no>
This patch implements a service that adds multiple instances
capabilities to RPMsg.
Each instance is allocated a separate piece of shared memory.
Multiple instances provide independent message processing.
Each instance has its own work_q.
Signed-off-by: Marcin Jeliński <marcin.jelinski@nordicsemi.no>
Refactor Periodic Advertising time update function to use
caller supplied Periodic Advertising PDU to calculate the
time reservations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Apply suggestions from code review, and change to using
BT_HCI_ERR_SUCCESS instead of returning 0.
Co-authored-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended and Periodic Coded PHY time reservation. The
define earlier used does not have calculations for Coded
PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation to update Periodic Advertising time
reservations when advertising data and/or CTE length is
updated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add check for already enabled and started Periodic
Advertising when HCI LE Set Periodic Advertising Parameters
command is called.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out Periodic Advertising time calculations so that
it can be reused when PDU length is updated as part of
advertising data updates.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation to update Extended Advertising time
reservations when advertising and scan response data are
updated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Export the function calculating the primary channel
advertising event time reservation, so that Extended
Advertising implementation can reuse it.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out Extended Advertising time calculations so that
it can be reused when PDU length is updated as part of
advertising data and scan response data updates.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation to update legacy advertising time
reservations when advertising and scan response data are
updated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out advertising time calculations so that it can be
reused when PDU length is updated as part of advertising
data and scan response data updates.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use a conservative turnaround time of 150us covering slower
nRF51 and faster nRF52 CPU that influence the turnaround
timing.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The openthread has enhanced features for periodic parent search,
this commit adds kconfig options to enable and configure these.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The Bluetooth 5.3 specification was recently released, and
has a new version identifier (12) assigned to it in the
Bluetooth Assigned Numbers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Introduce a helper function for being able to remove any arbitrary
length from tail of packet. This is handy in cases when removing
unneeded data, like CRC once it was verified.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
There was an issue with wrong length of CTE send in connectionless
mode, with periodic advertising PDUs. Radio peripheral was not
configured to send CTE with correct length while PDU had CTEInfo
field informing receiver that CTE is attached to the PDU.
Source of the problem was in ll_df_set_cl_cte_tx_enable function.
Order of parameters in ull_adv_sync_pdu_alloc was wrong.
ULL_ADV_PDU_HDR_FIELD_CTE_INFO was speficed as hdr_rem_fields.
Because of that extra_data, memory used to provide CTE configuration
to LLL, was not allocated. PDU content is prepared in ULL, so CTEInfo
field included correct information, while Radio was never configured
by LLL to send CTE.
ull_adv_sync_extra_data_set_clear received a pointer to hdr_data,
instead of a direct pointer to df_cfg structure. When extra_data
was allocated correclty, wrong CTE configuration was provided
copied there and LLL received invalid CTE length. It was different
than the length in PDUs CTEInfo field.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
According to spec we should ignore messages with incorrect msg size.
This patch adds a check to every opcode handler.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
```
3.7.3.4 Message error procedure
When receiving a message that is not understood by an element, it shall
ignore the message.
Note: A message can be falsely identified as a valid message, passing
the NetMIC and TransMIC authentication using a known network key and
application key even though that message was sent using different keys.
The decryption of that message using the wrong keys would result in a
message that is not understood by the element. The probability of such a
situation occurring is small but not insignificant.
A message that is not understood includes messages that have one or more
of the following conditions:
• The application opcode is unknown by the receiving element.
• The access message size for the application opcode is incorrect.
• The application parameters contain values that are currently
Prohibited.
Note: An element that sends an acknowledged message that is not
understood by a peer node will not receive any response message.
```
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
`OT_LOG_LEVEL_NONE` has some uses within OpenThread but it is not
hanled in the Zephyr's platform implementation. This commit makes
use of those logs as `LOG_LEVEL_ERR` level.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Align the capitalization of the term "Bluetooth Mesh" to Bluetooth mesh"
in the documentation. This is done to to match the new updated naming
convention done in Bluetooth SIG. In the upcoming spec versions, it its
used "Bluetooth mesh" with the lower case convention.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Some commands shell not be present when shell is not acting as
a log backend. Use of them lead to crash in that case.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The callback is not used anymore, so just delete it from the pm_control
callback signature.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The callback used by the device runtime PM can be easily replaced by a
simple state set after calling the state set/get calls. Broadcast logic
is simplified too, leading to the same previous behavior.
Since this is the only place where this callback was used, it can now be
removed from all devices and so pm_control callback signature
simplified.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The commit adds support for Zephyr basic mgmt group to mcumgr.
The first command added to the group is storage erase command.
Authored-by: Sigvart Hovland <sigvart.hovland@nordicsemi.no>
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
When zsock_close() is called, socket is freed before the mutex for the
socket is unlocked. If the freed socket is given to another thread
immediately, the mutex for the socket will be initialized by the new
socket owner, while the mutex is still locked by the thread calling
zosck_close().
Fixes#36568
Signed-off-by: Chih Hung Yu <chyu313@gmail.com>
When tcp_send_data() is called to resend data, but there is no data
to resend, zero length packet is allocated and NULL net_buf is passed
to net_buf_frag_insert() in which assertion fails.
Fixes#36578
Signed-off-by: Chih Hung Yu <chyu313@gmail.com>
Fix Periodic Synchronization setup when handling invalid
number of channel count in Periodic Advertising's Sync Info
structure.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use macros to access SCA and Channel Map fields in the Sync
Info structure in advertising PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Based on review comments, refactor out sync_info population
to be performed by the caller of the function that prepares
the extended advertising PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the set/clear function to modify the common extended
header format in the PDU to add/remove ACAD.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to add/remove ACAD field in the common
extended header format of the periodic advertising PDU on
create/terminate BIG.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add CMake warning message when building experimental
features like Advertising Extensions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
adv_sync_hdr_set_clear was just wrapped by ull_adv_sync_pdu_set_clear
so we can merge both into single function.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds simple helper to update CTEInfo. It assumes proper periodic
adv PDU as input to simplify code.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds some initial support to update AD in chain. We still only
support placing AD in 1st PDU, but this will properly copy any linked
PDUs that may be added due to e.g. CTEInfo present.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds adv_sync_pdu_init helper which initializes pdu_adv buffer
with contents of AUX_SYNC_IND/AUX_CHAIN_IND PDU. Extended header flags
can be specified to reserve required space for corresponding fields if
necessary.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This enables chaining ota for periodic advertising. AUX_CHAIN_IND PDUs
will be sent automatically if AuxPtr is detected in preceding PDU.
AuxPtr offset is always set to achieve minimal required frame spacing,
i.e. 300us (T_mafs). AuxPtr in all PDUs in advertising train are
updated on enqueue since PDU spacing is already known at that time so
we do not need to waste time in LLL.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds support to allow advertising PDUs to be linked which is
required to send advertising trains, i.e. AUX_CHAIN_IND.
PDUs are linked with a simple single-linked list, the pointer to next
PDU is stored at the very end of PDU buffer. This prevents it from
being overwritten if PDU is modified and allows for build time offset
calculation.
There are few helpers added to make handling easier, e.g.:
- get next linked PDU
- get last linked PDU
- link one PDU to another
- link PDU at the end
- release all linked PDUs (except for 1st)
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This function is the same as lll_adv_pdu_alloc except it also allocates
extra data at the end - it can just use lll_adv_pdu_alloc call to avoid
extensive c&p.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds helper to always allocate advertising PDU either from memory
pool or pdu_free queue and does not reuse existing PDU in adv_pdu.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Advertising channel packets do not have MIC, there's no need to have
extra parameter which always has to be set to 0 anyway.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We previously removed the iso data path when the iso channel
disconnected. Since the iso data path is unique for a given
iso channel (by handle), it does not make sense to remove
it for a disconnected channel, as the channel is, in
a sense, not existing anymore.
This update is to better comply with the bluetooth
core spec, and to avoid getting errors from the
controller on disconnect.
Rather than removing the implementation of being able
to remove the data path, the function was made non-static
and moved to the internal header file, in case we ever
want to use it. This should not affect compile size.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the function from scan.c to hci_core.c.
When in scan.c, the function is only available if
CONFIG_BT_OBSERVER was enabled. Since the function
can be used in other scenarioes where we need to parse
LTV data, it has been moved to a more generic place.
hci_core.c might not be the ideal place, but it is
where most other common bluetooth functions
are located.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When compiling existing libraries that are difficult to change, these
headers simplify the library's integration. This specifically was the
agreed upon fix for trying to compile Android's CHRE as a subsystem.
Making changes to the Android repo to use the C style includes would be
very difficult and would likely take a very long time.
Signed-off-by: Yuval Peress <peress@chromium.org>
The Bluetooth proxy feature includes proxy client and proxy server.
In addition to the proxy pdu message used above, pb-gatt also uses
the same proxy pdu message.
Currently zephyr bluetooth mesh couples them in one file.
A file at the separation is called gatt_services.c,
which is used to contain Mesh Provisioning Service and
Mesh Proxy Service.
Another file in the separation is called proxy_msg.c,
which is used to process Proxy pdu messages.
Also according to Trond's suggestion:
Rename CONFIG_BT_MESH_PROXY to CONFIG_BT_MESH_GATT.
Create an additional promptless entry CONFIG_BT_MESH_GATT_SERVER
that selects CONFIG_BT_MESH_GATT and is selected by
CONFIG_BT_MESH_GATT_PROXY or CONFIG_BT_MESH_PB_GATT.
Create additional CONFIG_BT_MESH_PROXY used to represent
proxy feature (also include proxy client).
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The Bluetooth proxy feature includes proxy client
and proxy server. In addition to the proxy pdu
message used above, pb-gatt also uses the same
proxy pdu message.
Currently zephyr bluetooth mesh couples them in one file.
A file at the separation is called gatt_services.c,
which is used to contain Mesh Provisioning Service and
Mesh Proxy Service.
Another file in the separation is called proxy_msg.c,
which is used to process Proxy pdu messages.
Also according to Trond's suggestion:
Rename CONFIG_BT_MESH_PROXY to CONFIG_BT_MESH_GATT.
Create an additional promptless entry CONFIG_BT_MESH_GATT_SERVER
that selects CONFIG_BT_MESH_GATT and is selected by
CONFIG_BT_MESH_GATT_PROXY or CONFIG_BT_MESH_PB_GATT.
Create additional CONFIG_BT_MESH_PROXY used to represent
proxy feature (also include proxy client).
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The Bluetooth proxy feature includes proxy client
and proxy server. In addition to the proxy pdu
message used above, pb-gatt also uses the same
proxy pdu message.
Currently zephyr bluetooth mesh couples them in one file.
A file at the separation is called gatt_services.c,
which is used to contain Mesh Provisioning Service
and Mesh Proxy Service.
Another file in the separation is called proxy_msg.c,
which is used to process Proxy pdu messages.
Also according to Trond's suggestion:
Rename `CONFIG_BT_MESH_PROXY` to `CONFIG_BT_MESH_GATT`.
Create an additional promptless entry
`CONFIG_BT_MESH_GATT_SERVER` that selects
`CONFIG_BT_MESH_GATT` and is selected by
`CONFIG_BT_MESH_GATT_PROXY` or `CONFIG_BT_MESH_PB_GATT`.
Create additional `CONFIG_BT_MESH_PROXY` used to represent
proxy feature (also include proxy client).
see #36343
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
6lowpan module can swap the original buffer with a newly allocated one
during decompression in case the decompressed header would not fit into
the original buffer. Therefore, storing the LL address offset and
restoring the pointer after decompression as it is done today is not
correct, as the new packet with decompressed IPv6 header will not
contain the LL header.
As the 6lowpan module doesn't deallocate the original buffer and
doesn't overwrite the LL header, its fine to use the original
pointers as they are.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
All variables for address, width and value are unsigned, so use strtoul
instead of strtol. This fixes an issue when 0xffffffff is about to be
assigned to specific address, which was truncated to 0x7fffffff so far.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.
All drivers and tests have been adjusted accordingly.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Regular OpenThread upmerge to bring in a fix for a possible
infinite loop and support for DNS service subtypes.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Do not use periodic executions of the timer handler, as in certain
circumstances (the fallback hardware watchdog used, one or more
task_wdt channel activated but none of them being ever fed) this
would lead to no callback/reset being executed for any channel.
Instead, schedule the next timeout from the timer handler function
when the function is executed for the dummy background channel or
for a channel that was deleted.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Instead of manually computing payload offset, let the CoAP library do
the work, and use the payload pointer returned by the
`coap_packet_get_payload()` function instead.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The function did not work correct for packets generated with Zephyr
APIs, as `max_len` holds the entire buffer size, not the actual packet
size.
Additionally, unify how Payload Marker is handled in the calculation -
currently the coap parsing function adds it to the `opt_len` field,
which is counter-intuitive.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
It is important that offset is set in the same manner, regardless of the
origin packet - it should indicate the final packet length in both
cases, when the packet is generated on the Zephyr side with CoAP APIs,
and when it's parsed from the UDP datagram. This allows for functions
like `coap_packet_get_payload()` to work correcty in both cases.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Use defines for offset unit and for calculation of Periodic
Advertising window widening using clock accuracy value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix clock accuracy value used in the calculation of window
widening applied when scanning for auxiliary PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a configuration of characteristic access permissions for
Bluetooth Heart Rate service.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Rename `write_signal` to `readable` and `read_signal` to `writeable`
which are more meaningful to the actual states they represent, and make
the code analysis easier.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case read or write were called before the actual poll() call, the
poll() function was not signalled correctly about such events, which in
order could lead to a deadlock if the poll() was called with infinite
timeout.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add the ability to perform a write on the object name GATT
Characteristic with a notification callback to the application
that the name has been written.
In order for this operation to work the memory backing the
object name must be modifiable. To prevent forcing the user
to always allocate 120 bytes for the name, the maximum name
length is changed from a define to a configuration parameter.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
In case of non-recoverable errors (e.g. the connection breaks while
transmitting), the l2cap_chan_tx_process deques the net_buf but does
not unreference it. As this is inside a work queue thread, the sending
thread gets no information on this error, relying on the tx_process to
ultimately free the buffer.
Signed-off-by: Patrick Rathje <git@patrickrathje.de>
Added api call that can set a callback that is called whenever
data is received on shell. When callback is set, shell processing
is bypassed and data is passed to that callback.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Promote the "edac mem" shell subcommand to a generic "devmem" root shell
command. This command is useful for poking around registers and memory
outside of the EDAC drivers.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Fix an auxiliary scan context leak when initiator
establishes a connection while there is another pending
auxliary PDU scheduled to be received. In this case, the
pending auxliary scan LLL context does an early abort
without generating a scan aux done event. Missing scan aux
done event caused the auxiliary scan context leak.
Fixes#36131.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit fixes an issue where bt_mesh_reset() call just erases all
mesh flags set at the initialization instead of restoring them and
thus disabling some features until the board reboot.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This will fix a bug caused by creating a multi instance resource with
only a single resource. Previously this was treated as a single instance
resource. This is now properly treated as a multi instance resource with
one instance
Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
Move the Zephyr-specific interface and support code for CANopenNode into
the modules directory. Consolidate the CMakeLists.txt files into one.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Minor update to calls to get Tx chain delay in extended
advertising and scanning to use S8 encoding delays.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We need to take RX chain delay and PHY used to receive
CONNECT_IND into account when calculating 1st connection
event offset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In the Tx to Rx switch, fix the delay which should be the
Rx ready delay plus the Tx chain delay and plus 4 us active
clock jitter compensation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor cleanup of the implementation of mutual exclusion
of LE Connection Parameter Request amongst active
connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Bluetooth Mesh Vendor model hava company id field.
Accordin MeshPRFV1.0.1 3.7.3.1 Operation codes.
The 3-octet opcodes are used for manufacturer-specific opcodes.
The company identifiers are 16-bit values defined by the
Bluetooth SIG and are coded into the second and third octets of
the 3-octet opcodes.
Therefore, we can speed up the search process by checking whether
CID fields match, rather than comparing opcodes one by one.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Reserve a minimum node rx of 2 that can happen when local
central initiated PHY Update reserves 2 node rx, one for PHY
Update complete and another for Data Length Update complete
notification. Otherwise, a peripheral only needs 1
additional node rx to generate Data Length Update complete
when PHY Update completes.
Relates to #36381.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Replace the post decrement in loop's conditional into
explicit decrement inside the loop so as to avoid
decrementing the maximum count without enqueueing free rx
buffers into the free rx buffer MFIFO.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add new custom transport type.
This allows user defined transport for MQTT communication.
The user must implement the transport procedure.
Fixes **#27015**
Signed-off-by: Vlad Tuhut <vlad.tuhut@raptor-technologies.ro>
Direct openthread API usage requires explicit locking,
which is also used internally.
Exposing a work queue through the openthread context allows
work to be submitted without the need to block other threads.
In particular with CONFIG_OPENTHREAD_MANUAL_START, application
logic can offload work which otherwise would need to wait for
the lock to become available.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The hci_le_remove_cig command shall only be sent as the
master/central. Implemented this by early termination in
bt_iso_cleanup as the slave/peripheral.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
coap_response_received returned NULL if the observe option was out of
order, however it makes more sense to return the coap_reply handler
without actually calling it.
Additionally the reorder check has been modified to partially match
the RFC.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
- bugfix: Accept initial tftp server reply from a port different than
the one used to establish the connection (typically 69) as mandated
by RFC 1350. Previous implementation was not standard compliant.
- bugfix: close socket in case of error or timeout.
- bugfix: Reset retransmit counter after receipt of a good packet.
- bugfix: Use CONFIG_TFTP_LOG_LEVEL to set log level.
- api: upon successful receipt of the file set `client.user_buf_size`
to the size of the file received.
- Restructure the code, comments.
- Limit usage of global variables.
- Limit usage of `goto`.
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
Fix peripheral maximum transmit time, maximum receive time
and radio event length time reservations when connection
established using Extended Advertisements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix central maximum transmit time, maximum receive time
and radio event length time reservations when connection
established using Extended Advertisements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
After #35702, the provisioner is unable to mark a link as closed, as
it depends on the send_end callback to be called, so it can start its
timer. PB-Adv keeps a reference to the buffers of reliable messages,
which prevents this callback to be invoked, as the buffer destructor is
never called.
Move scheduling of the retransmit timer to the initial transmission, and
replace the timer based LINK_CLOSE message tx duration with a message
counting solution.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Remove the bt_conn pointer from the AICS API, as the
instance pointer is enough to determine if it is a client
and perform client operations on the cached connection pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Initializes proxy_send's attr pointer, which in theory could be
uninitialized if neither gatt proxy or PB GATT is enabled while proxy.c
is enabled.
This scenario is not really possible with the current kconfig structure,
but is reported as a potential error by Coverity, and should be fixed
for future proofing purposes.
Fixes#36314.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The openthread initialization in turn calls platform specific
functions, lock the API during this step.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The mute_val pointer could be NULL when dereferenced in the
callback. Change to be a simple value which is just assigned
instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a function for the VCS client that gets the bluetooth
connection pointer if a given VCS client instance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Update the VCS API to use the bt_vcs struct instead
of the bt_conn. This is create a more simple API
that uses a, remote or loca, instance pointer, rather
than a specified connection (for remote) or NULL (for
local) operations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change to use the generic bt_vcs struct instead of the bt_vcs_client
struct, to align better with the future API change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the type of the vcs_inst in vcs.c to bt_vcs instead
of bt_vcs_server to align better with the future API change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add return of instance pointer in bt_vcs_discover so that a client
will get a bt_vcs pointer when doing discover, which will be
used going forward in the API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a bt_vcs struct that represents a VCS instance,
either a local (server) or remote (client) instance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Update the MICS API to use the bt_mics struct instead
of the bt_conn. This is create a more simple API
that uses a, remote or loca, instance pointer, rather
than a specified connection (for remote) or NULL (for
local) operations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change to use the generic bt_mics struct instead of the
bt_mics_client struct, to align better with the future
API change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the type of the mics_inst in mics.c to bt_mics instead
of bt_mics_server to align better with the future API change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add return of instance pointer in bt_mics_discover so that a client
will get a bt_mics pointer when doing discover, which will be
used going forward in the API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a bt_mics struct that represents a MICS instance,
either a local (server) or remote (client) instance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
- Coverity think it is out-of-bound writing
because the codes write two bytes to address (&hdr->length)
that hdr->length is uint8_t. Coverity doesn't think about
the one more byte after the hdr->length.
- Use net_buf_push to resolve this issue.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
The following options, marked to be deprecated in release 2.5, have
been finally removed from Kconfig:
FS_LITTLEFS_FC_MEM_POOL_MIN_SIZE
FS_LITTLEFS_FC_MEM_POOL_MAX_SIZE
FS_LITTLEFS_FC_MEM_POOL_NUM_BLOCKS
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The LittleFS file cache has been completely switched from k_mem_slab
to heap allocated. The *_MEM_POOL_* kconfig variables no longer
affect the code.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Added notify_timeout_cb to struct lwm2m_ctx to allow application to
handle notify timeout
Added lwm2m_rd_client_update to lwm2m.h to allow application to
trigger registration update
Added notify_message_timeout_cb which calls notify_timeout_cb from
struct lwm2m_ctx and logs an error message
Fixes#31499
Signed-off-by: John Power <john.power@xylem.com>
According to the rule MISRAC-2012 21.4.b the standard header
file <setjmp.h> shall not be used. Suppress it, because it raises
violation in a testcode, not in a runtime code.
Tag suppresses reporting of violation for the current file,
starting from the line where the suppression is located.
Found as a coding guideline violation (MISRA R21.4.b) by static
coding scanning tool.
Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
Expose a helper function to the application that searches the local
database for the given attribute from its UUID.
Provide arguments to limit the search that matches the service
declaration to make it easy to limit the search to a specific service.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allow to pass attribute as NULL pointer when using notify or indicate by
UUID. This will use the entire handle value range to search for an
attribute with a matching UUID.
Document optional parameters, and clarify attr and uuid usage in the
variable declaration in the struct for clarification.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Increase the ticker operations count in ULL high context
when Extended Advertising Connection Establishment on Coded
PHY is supported.
This fixes assertion in Controller when initiating a
connection on Coded PHY, wherein two scan instance ticker,
one window stop ticker, and a new connection instance
ticker operations needs to be enqueued.
Relates to commit a6b8eba7c5 ("Bluetooth: controller:
Implement disabling the other PHY initiator").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit fixes diag repeat command port by fixing issue with
incorrectly handled repeat timer.
Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
Add a new Kconfig option, BT_ISO_UNICAST, to make it possible
either configure unicast only, broadcast only or both.
This results in some code being moved, but not modified, and
should not effect anything.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is a small window between when socket is created and
before it is bound to a local address, where the local address
pointer might be NULL.
Fixes#36276
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
BT_DEVICE_NAME_MAX can be up to 248 bytes. This may exceed ATT MTU size,
which will cause the offset in write_name() to be non zere, resulting in
BT_ATT_ERR_INVALID_OFFSET. However, device name should be writable up to
it's defined size, using subsequent prepare write requests. Error should
be returned if offset exceeds size of device name, and if total size of
new value exceeds BT_DEVICE_NAME_MAX, BT_ATT_ERR_INVALID_ATTRIBUTE_LEN
shall be returned.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
TCP unacked_len can be set to zero in tcp_resend_data(),
and then be minus by len_acked when ACK is received,
resulting in a negative unacked_len value.
Fixes#36390
Signed-off-by: Chih Hung Yu <chyu313@gmail.com>
Update the LoRaMac-node library to the last stable release and fix
the Zephyr glue code to match it. Move CMakeLists.txt to the main
Zephyr repository to simplify loramac-node module maintenance.
Signed-off-by: Ilya Tagunov <tagunil@gmail.com>
Modify the check from checking the feature bit to
checking the command bit. This ensures that we
don't send the read buffer size V2 to a controller
that does not support it.
This also moves the entire ISO init procedure into
a separate function to avoid having a large
ISO-only block in `le_init`.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This check is present in att_read_rsp(), but att_read_mult_req and
att_read_mult_vl_req do not use it. Add this check to these functions.
This was affecting GATT/SR/GAS/BV-08-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Allow caller to specify microsecond accuracy and not convert
to milliseconds.
Fixes#36072
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Make zsock_select() a syscall so that the following commit
can call the internal poll implementation directly. This is
needed as zsock_select() will not call zsock_poll() directly
in order to allow select to use microsecond timeout accuracy.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Because it is not always possible to determine whether
a request is for Audio class or not, all requests are passed
to it. This can lead to the requests, to e.g. HID interface,
being hijacked by Audio class.
Ignore return value of Audio custom handler as it is not relevant here.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Since the settings are stored in the core now,
we can remove REQ_GET_INTERFACE part from custom handler
and simplify the code. Return value is no longer relevant
since custom callback does not need to interfere with the
request handling process.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Store alternate interface settings and
return alternate on GetInterface request.
Fixes: #24200
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This option is deciding whether bootutil_public library supports
multi-image procedures. MCUboot have its own definition which is
unavailable zephyr application. Introduced option declares similar
option for the application.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Add boot_write_confirm_multi() and boot_request_upgrade_multi() APIs so
that the user can set the image with given index as pending, confirmed.
This is needed for enabling the mcuboot multi-mage boot feature by
the zephyr.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
If all connections were refused, we haven't reached part of
le_ecred_conn_req with connecting channels - thus i was never
incremented. PDU shall be created always with the length containing
full size of scid array - we always respond with all of the CIDs filled,
they just will be all zeros when all connections were refused.
This was affecting L2CAP/ECFC/BV-26-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
If the shell root command shall be set in the application, e.g. for
implementing a login scheme, it is an advantage to set this already
during shell init.
This is now implemented using a new Kconfig variable SHELL_CMD_ROOT.
Signed-off-by: Hans Wilmers <hans@wilmers.no>
In case both, static IP address configuration and DHCP were used, and no
DHCP server was avaliable in the network, clearing the gateway address
rendered the network interface unusable as it's gateway configuration
was cleared.
Prevent this by removing the gateway clearing during the DHCP
inititalization. If the DHCP server is available in the network, the
gateway address will be overwriten after receiving the DHCP OFFER
message or cleared if there's no Router option is avaiable in the
DHCP OFFER message.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When an ACL connection with active CISes terminates, inject CIS/CIG
teardown to ensure CIS is stopped before ACL disconnection completes.
This includes stopping CIG ticker when last CIS has stopped.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Maintaining the cis_handles array in ULL/LLL ISO group data amounts to
double book-keeping. This commit eliminates the array and introduces a
'getter' for obtaining CISes owned by a specific CIG, and iterate
through them.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When an ACL changes state to disconnected, all associated ISO channels
must be disconnected and cleaned up. This commit ensures that.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Policy manager header has to be in the include for applications.
Also it had several function prototypes that are not part of the policy.
These functions were moved from the policy header to a dedicated private
header.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Use ticker_yield_abs interface to make scan window on
primary channel to yield when trying to scan auxiliary PDUs.
Fixes#30244.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add ticker_yield_abs interface to reduce ticks_slot_previous
value when radio events yield/stop earlier than their time
reservations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The old default of 1 makes provisioner devices useless, as they can only
provision themselves before they run out of space.
Increase the default value for CONFIG_BT_MESH_CDB_NODE_COUNT to 8.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Modify aics.c to use the bt_aics struct instead of the
bt_aics_server struct. This is done so that there is less
difference between the internal struct usage and the struct
type used in the API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename the struct from bt_vcs to bt_vcs_included, and
rename bt_vcs_get to bt_vcs_included_get as that is more
descriptive of the value returned.
Furthermore, this will also allow us to use bt_vcs as
an opaque pointer to a VCS service instance (local
or remote) to match the service instance pointers of
AICS and VOCS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename the struct from bt_mics to bt_mics_included, and
rename bt_mics_get to bt_mics_included_get as that is more
descriptive of the value returned.
Furthermore, this will also allow us to use bt_mics as
an opaque pointer to a MICS service instance (local
or remote) to match the service instance pointers of
AICS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
After lwm2m async io was introduced with 32989a38f0,
one instance of function lwm2m_send_message() was left unchanged,
and makes build to fail when boostrap support is enabled.
Signed-off-by: Kiril Petrov <retfie@gmail.com>
Allow caller to either set or receive various Ethernet Qbu
configuration options defined in IEEE Std 802.1Qbu-2016
specification.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Allow caller to either set or receive various Ethernet Qbv
configuration options defined in IEEE Std 802.1Qbv-2015
specification.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Zephyr Bluetooth Mesh did not check whether the proxy message
was actually sent out, so that the response message could
not be received during reset. It did not solve the status
callback of the proxy sending message, so a new problem was
introduced after PR(#28457) merged.
bt_mesh_prov_send(&buf, public_key_sent))
This PR will try to solve the above problem, and will fix
the problem due to thread competition, and PR(#26668) will
not be necessary.
Compared with PR(#30138), it no longer consumes extra RAM
space and supports synchronization of group addresses
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fixed issue that caused message to be not correctly reset even after
it is consumed after send sets errno to EAGAIN or EWOULDBLOCK
Signed-off-by: Dominik Dess <dominik.dess@grandcentrix.net>
Fix wrong channel index send by controller in connectionless
IQ samples report. Former implementation reported value from
lll->data_chan_id which is not valid channel index.
Updated implementation reports value stored in IQ samples receive
node during periodic scanning event preparation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fixes ticker_by_next_slot_get for JIT scheduler by allowing iterating
through ticker nodes without ticks_slot information, and improves
performance for legacy ticker scheduling use.
To reduce the processing and context switching overhead, a new feature
is introduced via BT_TICKER_NEXT_SLOT_GET_MATCH, by which an operation
callback may be added via the ticker_next_slot_get_ext interface, and
the match function is then called when the ticker_job is processing the
request.
By returning true in this callback, iteration stops and normal operation
callback is invoked. If the match function returns false, node iteration
continues. This reduces the number of ticker_job executions for node
iteration.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Use UUID encode macro fro 128-bit UUIDs for readability. This makes
it easier to see which service you are working with as the
bt_uuid_to_str prints the 128-bit UUIDs in this format.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use UUID encode macro fro 128-bit UUIDs for readability. This makes
it easier to see which service you are working with as the
bt_uuid_to_str prints the 128-bit UUIDs in this format.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add the packet status flag value to the iso receive info
struct. This will allow an application to handle potential
lost or erroneous messages.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The current approach with storing RPL by timeout doesn't solve all
issues as the node may loss power before the timer is fired.
In addition to that this may wear out flash quickly if short timeout is
used.
This change adds an API to store the pending RPL entry upon user
request. Additional Kconfig option allows to completely disable timer
so that the whole storing relies on the user.
The mesh stack still stays responsible for outdating RPL entries in case
of IV Index update as this happens implicitly for the user.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Allow the user to disable VT100 commands to have a plain shell
without terminal emulation in order to avoid a lot of garbage
ASCII characters in shell output.
Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
This aligns provisioner and provisionee APIs in terms of endianess
of public key provided by an application.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit allows an unprovisioned device to exchange its public key
using out-of-band techology (see MeshPRFv1.0.1, table 5.19 and section
5.4.2.3).
For in-band public key exchange, the mesh stack uses HCI commands to
generate public and private keys, and DH key. This, however, doesn't
work for OOB public key exchange since there is no command to generate
DH key with a private key provided by an application. Therefore, this
commit adds direct usage of TinyCrypto into the mesh stack for DH key
generation for OOB public key support.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Moving the key check after checking that no pairing or encryption
procedure is started fixes a race condition that is seen in some PTS
tests:
GATT/CL/GAR/BI-04-C
GATT/CL/GAR/BI-16-C
GATT/CL/GAR/BI-21-C
GATT/CL/GAW/BI-05-C
GATT/CL/GAW/BI-12-C
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The ieee802154_frame_retry will be set by the OpenThread integration
layer in the event of frame retransmission.
Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
Some centrals deal poorly with receiving a security request immediately
after reconnection whenever reconnecting with characteristics that are
notifiable or indicatable and requiring security. In particular,
Android 9 and earlier devices may lose bond information when this
happens, some Microsoft Surface devices will enter an invalid state
and, on top of that, Apple's Bluetooth Low Energy guidelines explicitly
discourage this behavior.
In order to allow interoperability with those devices, make the GATT
automatic security request sending as a peripheral optional by
introducing a new Kconfig option, BT_GATT_AUTO_SEC_REQ.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add the option to send logs to fs backend using new dictionary
formatting
This can result in much better use of filesystem space
Signed-off-by: Elliot Revell-Nash <elliot.revell-nash@wdtl.com>
When the Bluetooth stack is configured for CONFIG_BT_MAX_CONN > 1
the oldest key might currently be in use. Fix the logic to ensure the
oldest key overwritten is from the set of keys currently not in use.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/35999
Signed-off-by: Faisal Saleem <faisal.saleem@setec.com.au>
Signed-off-by: Nick Ward <nick.ward@setec.com.au>
This commit makes C++ exception handling feature depend on the full
version of newlib (i.e. `CONFIG_NEWLIB_LIBC_NANO=n`).
The `nano.specs`, which selects the nano variant of newlib, libstdc++,
and libsupc++, does not support C++ exception handling because its
lib*c++ is compiled with `-fno-exceptions`.
For more details, refer to the issue #35972.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Fill the ACK timestamp field in nRF5 driver. This is required by
OpenThread for the proper CSL transmitter functioning.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Fixed mutli-IP DNS resolution as previously the same IP address was
used to populate all AI entries and added DNS_RESOLVER_AI_MAX_ENTRIES
config entry to define max number of IP addresses per DNS name to be
handled.
Signed-off-by: Ievgen Glinchuk <john.iceblink@gmail.com>
This commit address Erratum E10395 and Errata Correction E16350
to ensure that public keys exchanged between Provisioner and
a device aren't identical.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Unmask events related with CTE report for Direction Finding
working in connected mode.
The feature is enabled conditionally, depending on KConfig
configuration provided.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add Kconfig option that will enable support for CTE reception
in connected mode. Thanks to that it will be possible to
conditionally enable or disable support of the feature and
decrease code size if the feature is not required.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove the bt_conn pointer from the VOCS API, as the
instance pointer is enough to determine if it is a client
and perform client operations on the cached connection pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify vocs.c to use the bt_vocs struct instead of the
bt_vocs_server struct. This is done so that there is less
difference between the internal struct usage and the struct
type used in the API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added an API to the HCI header that can be used to retrieve
advertising handle information from a given advertising set.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Remove unneccesary limit of host to controller packets by the host ISO
buffers and host pending buffers with TX callback.
The host always allocates the buffer before taking the semaphore so this
is already handled by the size of the host buffer pool and the
functionality of the buffer pools to wait for buffers.
In addition the ACL max limit is using the wrong define, as
CONFIG_BT_CONN_TX_MAX is the maximum amount of callback contexts for
transmitting. So the host can have more pending packets than this value.
This is also inconsistent with how the host would handle the V1 reply.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit implements the microphone input control service
(MICS) and client, The implementation supports and uses the
Audio Input Control Service (AICS) secondary service.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds a new callback structure to `<gatt.h>` for receiving notifications
of ATT MTU updates. This callback is called regardless of whether the
MTU update was initiated locally or remotely.
Fixes#32035.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Use IE variable of ieee802154 MAC frame instead of Thread specific
configuration call for configuring injection of vendor specific
data into enh ack.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
this has a number of advantages:
- allows to only create notifications for each client if there are no
messages already waiting to be send, in practice prioritizing the
memory for messages for answers, thus staying more "responsive".
- saves a fair bit of memory by eliminationg now redundant client_ctx
pointer per observer.
- fixes a potential subtle bug: previously, an observer reset would've
stopped the first observation found with a matching token, which
might've belonged to a differen client.
Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
This restructures the lwm2m_engine to use a non-blocking socket access
instead of the previously used blocking style, and eliminates any
socket-access from outside of the main work loop.
The main motivation behind this is an issue within nordics
nrf_modem_lib/modem-fw on nrf9160, that leads to socket send() calls to
block indefinitely when the shared memory used for
rpc-communication with the modem is already exhausted because of
incoming data.
This lead to the lwm2m_engine locking up on send calls when there is
also a large amount of incoming data.
This works around this issue, by only issuing send calls when poll
reports the socket to be ready for sending, and (more importantly) by
always receiving all buffered incoming data before sending anything.
There might still be a (perhaps academic) possibility where this
situation might be triggered, when the scheduler interrupts the lwm2m
thread in-between receiving and sending, but for now we have not yet
observed this.
Besides working around the aforementioned issue, this also simplifies
the way resends are handled as they are no longer send from the main
system-workqueue, and limits all interaction with the sockets to a
single thread.
Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
Keys management API for IEEE 802.15.4 drivers was specific for Thread
protocol. With this change API is more generic and aligned with Thread
needs.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
Zephyr has introduced secure random generator API after the TLS sockets
were implemented. Use this new API in TLS sockets implementation,
instead of implementing secure RNG with mbedTLS in the module itself.
This facilitates integration of the HW RNG accelerators with the TLS
sockets module.
Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Variable "level" in function z_vrfy_log_filter_set() has type unsigned.
But it is been checked if "level >=LOG_LEVEL_NONE" and
LOG_LEVEL_NONE is 0. It means check if unsigned is ">= 0" in Z_OOPS().
That is logically wrong, because unsigned is ">=0" by default.
Remove that check, to avoid static analysis tool raise
violation
Found as a coding guideline violation (MISRA R14.3) by static
coding scanning tool.
Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
If radio driver supports transmission security we need an option
to disable transmission security which by default is done by OT stack
for Thread v1.2
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
The tabulator handler creates a single structure if it is handling
dynamic commands. If the currently processed dynamic command has a
dynamic subcommand they both share the same structure.
As a result tabulation operation may result in undefined behaviour.
As a solution, a new structure was introduced to keep subcommand
information.
Fixes#35926.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Fix incorrect and redundant use of ticker user id ULL_LOW
instead of ULL_HIGH when setting up a connection using a
mayfly to disable LLL context. Also, the LLL context pointer
is invalid, where node rx is passed instead of LLL context.
Use the ULL disabled callback when done event has not yet
been processed, or a direct connection setup in ULL_HIGH
context when ULL is already disabled (reference count is
zero) is sufficient.
Regression introduced in commit 30f260dfaa ("Bluetooth:
controller: Fix adv/scan context access post release").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Shell log backend depends on logging being enabled. Lack of this
dependency leads to compilation failure when logging is disabled.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The final else {} in the if...else if is missing required
comment (non-empty, ';' is not sufficient). This adds a comment
to comply with CG 15.7.
Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
The final else {} in the if...else if is missing required
comment (non-empty, ';' is not sufficient). This adds a comment
to comply with CG 15.7.
Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
Fix CCC store on write feature for multiple connections. CCCs are only
enqueued for storing when going from no connections subscribed to any
connection subscribed.
The CCC should be stored when its value is changed for the specific
connection.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix Extended Advertising PDU population from incorrectly
populating new PDU when there is no common extended header
flags being set in the previous PDU and or the new PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising PDU population from incorrectly
populating new PDU when there is no common extended header
flags being set in the previous PDU and or the new PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising data population from corrupting
the PDU by populating fields when there is no flags in the
common extended advertising header.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a status check for the BIG sync established and
BIG sync created events such that we don't log a warning
of invalid BIS count when it is an error event.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix a regression for cleaning up BIGs added by
80c824f18ee80caa5bd162b9d2957dde1639add6 where the way
ISO connections were unref'ed was changed.
bt_iso_cleanup has been changed to only effect CIS
(as the unref from that has been removed), so instead
of calling bt_iso_cleanup we just call
bt_conn_unref directly.
This also removes some unref's from the BIG complete
and BIG Sync complete event handlers as the BIS bt_conns as
they don't increase the ref counter before anymore.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
BT_L2CAP_LE_ERR_INVALID_PARAMS shall be returned instead of
BT_L2CAP_LE_ERR_UNACCEPT_PARAMS.
This was affecting test case L2CAP/ECFC/BV-26-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
For more than one requested channels in le_ecred_conn_req only result is
overwritten in every iteration. This causes an issues if after failed
l2cap_chan_accept occures successful one: returned result will be
BT_L2CAP_LE_SUCCESS, where in reality should be returned error
and non-zero Destination CIDs will signal "Some connections refused".
Now, overwrite error only if the last one failed. If no errors occur,
result will remain BT_L2CAP_LE_SUCCESS.
This was affecting test cases L2CAP/ECFC/BV-20-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Fix missing 0x0000 CIDs in response for ecred_conn_req. Previously,
when one of "All connections refused" error i variable was set to 0,
thus no CIDs were copied to response.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Check correctness of returned sync_handle value while requesting
HCI_LE_Set_Connectionless_IQ_Sampling_Enable in controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix bug of missing sync_handle parameter in return data in
HCI_LE_Set_Connectionless_IQ_Sampling_Enable commnad
handling function.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Log failure to initiatet security for bonded peer when GATT wants to
initiate security for CCCs for the remote.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Notify application about prepare write error when continueing the write
procedure fails when RX thread is processing responses. It is possible
that this operation fails, either because of disconnection or ATT
timeout on the ATT bearer. Notify the application in case it needs to
clear up resources, e.g. the write parameters.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When a device is defined a new pointer to a device will be created in
the "z_pm_device_slots" region, effectively creating a device array with
the same size as the number of system devices. This array is then used
by the device PM subsystem to keep track of suspended devices during
power transitions.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Result to send was overwritten by BT_L2CAP_RECONF_SUCCESS just after
exiting while loop. This caused to send success response even if
reconfiguration failed. Now, result is initialized to success value,
and if reconfiguration fails, this value will be overwritten with
appropriate one. Added BT_L2CAP_RECONF_INVALID_CID (0x0003) for invalid
cid in request. Added BT_L2CAP_RECONF_OTHER_UNACCEPT (0x0004) to return
if MPS is to small. Reordered checks for mps/mtu as
BT_L2CAP_RECONF_OTHER_UNACCEPT is expected to be returned if both mps
and mtu are to small.
This was affecting L2CAP/ECFC/BI-05-C and L2CAP/ECFC/BI-05-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Add a dependency on MULTITHREADING for the
STACK_SENTINEL feature, so it may not get
enabled in single-thread Zephyr builds.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
These functions are those that need be implemented by backing
store outside kernel. Promote them from z_* so these can be
included in documentation.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
These functions and data structures are those that need
to be implemented by eviction algorithm and application
outside kernel. Promote them from z_* so these can be
included in documentation.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This makes connections of type BT_CONN_TYPE_ISO use BT_CONN_CLEANUP to
cleanup so the TX and RX queues are properly cleanup.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This prints information about the role and id along with connection
parameters in case the connection is of LE type.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The state shall be set before calling the callback as it could be check
code behind would expect the channel to be in connected state.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When handling CIS Requested event CIG and CIS IDs must be set in order
for the channel to be properly accepted.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes bt_conn_cleanup to be automatically called when the last
reference to a connection of BT_CONN_TYPE_ISO is dropped.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit allows to add callbacks to NET_EVENT_IF_UP events before
the network initialization.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Fixed several compilation errors that resulted from selecting
TRACING without specifying a tracing system (Tracerecorder,
CTF, Systemview). In this case (TRACING_NONE), some default trace hooks
(in tracing.h) were incorrectly named resulting in compilation errors.
The legacy sys_trace_isr_enter, sys_trace_isr_exit, and sys_trace_idle
also caused problems since these were only given as defines, resulting
in undefined reference errors since they are required by the assembly
files calling these. To solve this issue I've added a stub file
"tracing_none.c" (only compiled if TRACING_NONE) and declared the
functions in tracing.h if no tracing system is selected.
Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
This commit makes CONFIG_EXCEPTIONS un-selectable for the architectures
that are known to have broken C++ exception handling support
(see #32448).
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
It was just making the code hard to read. Also it was not following
the code guideline because the type was not telling us the sign
and size.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
z_pm_core_devices was hack to set some priority between devices. It
was doing it hardcoding some devices that were the first to bring up
and the last to power down. Remove it and use the same list used to
initialize devices.
Fixes#34214
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
OpenThread expects the FCS field at the end of the ACK frame to be
passed with `otPlatRadioTxDone`.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Not checking return code in fcntl can result in interpreting -1 as
flags, and cause unexpected behaviour.
Fixes#35541
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
RTT_LOCK/UNLOCK in certain configuration creates code block (curly
braces). In that case variables declared inside are local to that
block. Moved declaration of ret variable before the block. Updated
code to ensure that RTT_LOCK/UNLOCK are in the same code block.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The current iso commands in the shell only supports setting up
a bidirectional stream or unidirectional for central role.
Adding rx/tx/rxtx option to iso listen command to allow for
peripheral side configuration of an iso connection.
Signed-off-by: Casper Bonde <casper_bonde@bose.com>
The sequence number is needed in the appliaction layer to detect lost
packets in the ISO stream in cases where the timestamp is not included.
(Sequence number is mandatory to include where timestamp is optional).
The API for the public metadata have been moved to a public header file.
As the size of the ISO meta data exceeds the default 4 octets net_buf
user_data the public ISO metadata have been moved into a seperate array.
The internal metadata is still stored in net_buf user_data.
This also fixed the user_data overflow on 32 bit systems, caused by
writing the ts into user_data on index 4 to 7, which is outside the 4
allocated bytes.
Signed-off-by: Casper Bonde <casper_bonde@bose.com>
pm_device_runtime_state_set takes care of the check the reference count
and take the right action. It is not necessary check it in
pm_device_request.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Assuming that pm_device_state_set is synchronous it is possible to
simplify the mutex usage. Now there are two places where the lock is
held, one in the worqueue handler and other in pm_device_request to
cover the synchronous path. It is no longer needed held the lock in the
pm_device_state_set callback and not needed to wait on the conditional
variable after set the state in the synchronous path.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Most APIs have the default synchronous and an asynchronous version
with the sufix _async because that is the most common use.
All devices in tree right now are using the synchronous version, so
just change it to be consistent with the rest of the system.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Since we are using mutex to protect critical sections and mutexes are
reentrant, it is possible to get rid of atomic for the state because
we can lock the mutex in device_pm_callback.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Protect critical sections using the mutex.
The mutex is required to use the conditional variable and since we
need to atomically check the pm state and the workqueue before wait
the condition, it is necessary to protect them using the same mutex.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Protect critical sessions using the spinlock available. The atomic
usage was not properly protecting the critical section and was
possible to have a race condition between the usage check and state
set.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Add a function that properly uses a mutex to check a condition before
wait on the conditional variable.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Fix CONFIG_BT_EXT_ADV_LEGACY_SUPPORT option which optimizes the host
to skip checking the feature bit of the controller to check for
extended advertising commands.
This was broken because of how this was implented using an undef of the
feature bit, which was not replicated in scan.c, adv.c and id.c once
this was split out from hci_core.
Instead of doing this wierd way of redefining the feature check macro
do it in a proper way by defining a new macro.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The commit adds information to Kconfig options:
MCUMGR_CMD_SHELL_MGMT and MCUMGR_BUF_SIZE
on how the SHELL_BACKEND_DUMMY_BUF_SIZE value impacts them.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds Kconfig option to configure dummy shell buffer size.
Size of this buffer determines how mutch of command output will be
stored in buffer.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds check if offset is positive; previously negative
offset would be allowed, which means that writing flash before flash
area start was possible.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fix issue is host handling of connected and disconnected event.
Since the host wants the disconnected event to be processed as a
priority event as well as in reguler event context while the connected
event is always in reguler event context we can end up in a situation
where the disconnected priority event is processed before the connected
event.
Since the disconnected priority event is there to release unack'ed TX
pending on the connection in case the RX thread is blocked waiting
for TX resources, we need to keep this behavior. Otherwise this would
be a potential deadlock of the RX thread waiting for resources that can
only be released by the RX thread.
When this situation happens we know that there cannot be any pending TX
on this connection so we can safely skip releasing of unack'ed TX.
The second thing the disconnected priority event does is marking the TX
path on the connection as disconnected. We need to do the same in this
situation, so we make sure that the TX path is already marked
disconnected when providing the connected callback to the application.
This fixes a regression from 4be66bd33d.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When receiving the L2CAP sent callbacks the dynamic L2CAP channel may
have been disconnected already. The user of the dynamic channel should
have received the disconnected and released callbacks for this channel
to release any resources for the data being sent, so simply ignoring
this sent callback is enough.
Fix sent callbacks by providing the CID to the callback instead of a
pointer to potentially released memory, and lookup the CID to check that
it is still valid.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add check for the advertising already being enabled when attempting to
start the advertising set.
Document that the advertising set cannot be started from the connection
connected callback, and instead has to be started from the advertising
set connected callback.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix multiple advertisers with different ID support, this was added
in 98321c61fb but the guard was never
removed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix to avoid an assertion when processing an acknowledgment
in the first connection event in peripheral role.
Ensure that empty flag reflects the state of the Tx queue,
as a peripheral the first connection event has no prior PDU
transmitted, an incorrect acknowledgment by peer should
not dequeue a PDU that has not been transmitted on air.
Relates to assert added in commit 2bfaadffb8 ("Bluetooth:
controller: Add Tx fragmentation assertion").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Make custom RTT locking configurable and select it where it is needed.
When using RTT for tracing we want to use the default locking.
Update both segger and tracerecorder modules to support that.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
If we receive any data in FIN_WAIT_1, then ack it even if we
are discarding it.
Fixes#33986
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Jim Paris <jim@jim.sh>
The k_fifo_ prefix is meant for kernel API functions, and
not to our socket helper. So remove the k_ prefix in order
to avoid confusion.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we are waiting all the data i.e., the MSG_WAITALL flag is set,
then if we have not yet received all the data at the end of the
receive loop. We must use the condition variable to get the signal
when the data is ready to be received. Otherwise the receive loop
will not release the socket lock and receive_cb will not be able
to indicate that data is received.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix a regression when application is waiting data but does
not notice that because socket layer is not woken up.
This could happen because application was waiting condition
variable but the signal to wake the condvar came before the
wait started. Normally if there is constant flow of incoming
data to the socket, the signal would be given later. But if
the peer is waiting that Zephyr replies, there might be a
timeout at peer.
The solution is to add locking in socket receive callback so
that we only signal the condition variable after we have made
sure that the condition variable is actually waiting the data.
Fixes#34964
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix deadlock when db_hash_commit has to wait for the delayed work to
finish. This creates a deadlock if the delayed work for database hash
calculation needs to store the hash since the settings API is locked
when calling the commit callback.
Remove call to k_work_cancel_delayable_sync from db_hash_commit in order
to avoid the deadlock. Instead move comparing of the stored hash to the
delayed work and reschedule the work with no wait.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
If there are no sockets in the system, then do not drop the
packet immediately as there can be other L2 network handlers
like gPTP in the system. This will also allow ICMP messages
to pass to local handler.
Fixes#34865
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Coverity detected that a zero divisor can be passed to
ll_create_connection() without parameter sanitization. Conditionally
check the connection creation parameters according to spec.
Fixes#35343.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
On sending write request we should check write response.
If data prepaired to be written by peer or offset are not equal
to the data and offset we sent, we shall send Execute Write
Request with Request Flag set to 0x00 (Cancel All Prepared Writes).
This was affecting GATT/CL/GAW/BI-32-C and GATT/CL/GAW/BI-37-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Fix the missing HCI event data len limit check when encoding
incomplete advertising data report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Max data length has to be adjusted for subevent code, otherwise we'll
hit an assert when trying to add data to event due to insufficient
free space.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Enable the option to pause the fallback hardware watchdog if the MCU is
halted by a debugger.
This fixes issue #33509 where some boards with Nordic MCUs could not be
flashed anymore after using the task watchdog sample.
Signed-off-by: Martin Jäger <martin@libre.solar>
The resource description on the OMA LwM2M registry states that only the
first instance of a particular error should trigger creation of a new
error code instance.
Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
The hardware watchdog was always fed with channel ID 0. This is correct
in most cases, but we should still use the actual ID returned from
wdt_install_timeout.
Signed-off-by: Martin Jäger <martin@libre.solar>
As EVENT_OVERHEAD_START_US offset is used in ticks unit in
LLL, ULL scheduling using ticker should also use ticks unit
for EVENT_OVERHEAD_START_US when reducing the first
connection event preparation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Revert the strict preempt ticker start failure check.
Preempt ticker start can fail when enqueuing prepares into
already filled pipeline which has preempt ticker already
started for the first prepare that was added in the
pipeline.
Regression introduced in commit 5b75bdf589 ("Bluetooth:
controller: nRF5: Check preempt event on timeout").
Fixes#35476.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
From le_ext_adv_param_set we will occasionally attempt
to call bt_addr_copy where the `addr` and &adv->random_addr.a
are the same pointer. Doing a memcpy where source and destination
is the same pointer is undefined behavior and should not be
done.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The VCS client shell was never compiled before, and thus
the implementation had a few undetected errors.
This commit adds the VCS client to the shell CMakelists
as well as fixing the issues.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The common API functions in VCS had dead code in specific
configurations, causing coverity issues. Fixed by this
commit.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix side effect in assertion when checking a volatile
variable inside assert check.
Fixes#32904, #32923.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The send_reliable function was reused in multiple places as part of the
k_delayed_work changes for Bluetooth Mesh in #33782. This function
contains a line that resets the start timer, causing prov_retransmit to
continously move the goal post for when to give up sending.
Extract this line out of the send_reliable function, and put it along
with the other link.tx initialization in bearer_ctl_send and
prov_send_adv.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Change the return value from -ENOTCONN to -EINVAL as that
is a more appropriate return value for checking a NULL
pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change from -ENOTCONN to -EINVAL as that is a more appropriate
return value for checking a NULL pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of return -ENOTCONN they will now return -EINVAL as
that is a more appropriate return value for checking if
the pointer is NULL.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When application calls TCP connect(), the call is blocked
by a semaphore which is then released when the connection
is established. Unfortunately the semaphore release was done
before the connection was marked as established. Depending
on the configuration options set, it is possible that after
the semaphore release, the thread that is waiting on connect()
is run immediately. Because of this, the connection bookeeping
still thought that the connection was not established even if
it was. A simple solution is to release the semaphore after
the connection is marked as established.
Fixes#35390
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit fixes a bug where outdated RPL entries might not be removed
properly from the persistent storage making those entries dead.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
According to Bluetooth core specification v5.2, if Host set
random address when any of scanning (passive or active), the
Controller shall return the error code Command Disallowed (0x0C).
Signed-off-by: Freddie Yang <freddie.yang325@outlook.com>
Allow time for the shell to successfully echo the reboot command input
before the reboot abruptly terminates it. n This can help external
systems that interact with the shell and require the reboot command's
echo to successfully complete to synchronise with the device.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/35325
Signed-off-by: Nick Ward <nick.ward@setec.com.au>
Call on_status if the Reason-Phrase is not provided.
This allows for the numeric status code to be set.
Also, ensure the numeric status code is always set
in on_status, not just if the specific callback is set.
Signed-off-by: Justin Morton <justin.morton@nordicsemi.no>
Without TX thread support in network stack USB device stack
blocks it self by usb_transfer_sync() which is
called in the same context as usb_set_interface() in sequence
of netusb_enable(), net_if_up(), net_l2_send().
Fixes: #35338
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit fixes a bug where incorrect pointer passed to publish_sent
in access.c caused bus fault.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The testsuite was always forcing minimal logging. This is problematic
as it does not allow user to see full logging string. Allow user to
override the minimal logging if needed, the default is still to
enable minimal logging.
[DL: Commit 7f08061f0c reverts this.
Since this is useful, let's re-apply this.]
Fixes#34696
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The network layer previously decided to use the friend credentials if
there was an established friendship. During the friendship setup phase,
the friendship is not considered established until the LPN receives the
first friend poll. Before this happens, the LPN should send a friend
poll message, encrypted with the friendship credentials. This wrongly
gets encrypted with the master credentials.
Change the decision point to whether the LPN has selected a friend,
which happens after the friend offer, and before the friend poll. This
will remain set for the duration of the friendship.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This adds BT_MESH_SETTINGS_VA_PENDING to GENERIC_PENDING_BITS
as it should be stored by CONFIG_BT_MESH_STORE_TIMEOUT.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This bug was introduced in PR #31176, where setting's flags were
moved out from bt_mesh.flags to pending_flags.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This was already implemented for firmware update packages.
For other opaque resources it failed to determine the target resource
id, which is now stored in the block_context.
Signed-off-by: Jan Buenker <jan.buenker@grandcentrix.net>
Fix regression in PPIs use for nRF52805 SoC, which has
fewer of them. And the regression was introduced in
commit e603b9d59e ("Bluetooth: controller: Adjust PPI
used for nRF51x and nRF52x").
Fixes#35204.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase the default thread analyzer stack size. On ARM systems the
stack usage is higher with CONFIG_FPU enabled.
The default of 512 is not enough in this case and lead to stack
overflow.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When shell log backend was disabled fifo used only in
deferred mode was unconditionally flushed which lead to
errors in immediate mode where fifo was not present. On
the other hand, in case of LOG2_MODE_DEFERRED fifo (mpsc_pbuf)
was initialized in enable stage.
In order to clean things up, deferred v1 fifo flushing and
deferred v2 mpsc pbuf initialization were moved to fifo_reset
function which is called when shell log backend is enabled.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
OpenThread shell tries to execute commands without checking
if the shell has already been initialized. As a result, we
may hit an assertion in the OpenThread CLI code. It's
particularly painful in automated tests which spawn commands
very early in the firmware boot process.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
The naming and documentation of the parameters was inconsistent with
their actual meaning and the implementation - enc_data and plaintext
were swapped.
Also, the parameter names in the file aes_ccm.c were completely
different from the ones in the header. Since all functions in the
header file are consistent in their parameter naming, I chose to make
the implementation follow the header and not the other way around.
Signed-off-by: René Beckmann <rene.beckmann@grandcentrix.net>
The time necessary to resume from a power state has to be added to the
minimal residency time to check if there is enough time to go to a
particular state.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The return value might be uninitialized if there was no
suitable IPv4 address found for the network interface.
Coverity-CID: 224630
Fixes#35158
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
New version of Systemview has Zephyr API description that did not match
what we had, align with what the tools provides and expand hooks to
support additional APIs. We now cover most kernel APIs.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Using %s, without logstr_dup causes error when
CONFIG_LOG_DETECT_MISSED_STRDUP is enable.
Removing %s argument. LOG_FUNC_NAME_PREFIX_ERR can be used if prefix
is wanted.
Signed-off-by: Fredrik Gihl <fredrik.gihl@flir.se>
After the recent OpenThread upmerge, OpenThread changed its behaviour in
terms of CLI handling during commissioning procedure. OpenThread will
now call the registered CLI callback when it recieves the Discovery
message.
This resulted in a crash if no CLI command was executed by the user
before, because the `shell_p` pointer was only set in the command
handler. As it was not set to the actual shell backend instance, it
caused a crash (or assert if enabled) in the `shell_vfprintf()`
function.
Fix this by verifying the `shell_p` pointer in the
`otConsoleOutputCallback()` function before use. Additionally, set the
pointer to the most common UART shell backed (if enabled) in the
initialization function so that the initial messages from OpenThread are
not dropped.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When destination address is a multicast address, select the source
address from non link local address first.
This means that for example if we are responding to mDNS query,
and we have both normal IPv4 and LL (169.254.x.y) address set for
the interface, we are now able to select the normal address instead
of the LL one.
Fixes#34409
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix advertiser and scanning context being accessed on done
event when connection complete node rx that is processed
earlier has release them.
Relates to #30735.
Fixes#35013.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The ISN algorithm from RFC 6528 doesn't need Mbed TLS, but rather the
MD5 algorithm from Mbed TLS. Therefore select MBEDTLS_MD and
MBEDTLS_MAC_MD5_ENABLED in addition to MBEDTLS.
This fixes the following build failure when using TLS version 1.2 is
selected:
zephyr/subsys/net/ip/tcp2.c:1329: undefined reference to
`mbedtls_md5_ret'
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
SRP client and server require ECDSA to be enabled otherwise the build
fails. Select OPENTHREAD_ECDSA for both OPENTHREAD_SRP_CLIENT and
OPENTHREAD_SRP_SERVER options.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
OPENTHREAD_SRP_CLIENT and OPENTHREAD_SRP_SERVER are Thread features and
not Thread configuration, so move them to Kconfig.features.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
The OPENTHREAD_MAX_CHILDREN and OPENTHREAD_MAX_IP_ADDR_PER_CHILD options
make not sense for a MTD device. Make them depend on OPENTHREAD_FTD.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
With the updates to mbedTLS Kconfig it is now possible to update the
OpenThread security configurations by disabling the mbedTLS prompt and
avoid stuck symbol selection.
As part of this, the OpenThread security selection has been reworked
into a choice which ensures only a single security selection can be
chosen.
And the OPENTHREAD_MBEDTLS itself has been made promptless to ensure
other parts of the build system can select a specific OpenThread
security implementation and disable user selection, if the module or
sample require such behavior.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
In Mbed TLS:
commit eccd88871767e2fba5f3a079cfdfcb77c376cf20
Author: Gilles Peskine <Gilles.Peskine@arm.com>
Date: Tue Mar 10 12:19:08 2020 +0100
Rename identifiers containing double-underscore
changes the name of a symbol we use. As part of upgrading to newer
versions of Mbed TLS, change the name of the symbol we use.
A better fix would be to not use this symbol at all, and perhaps define
our own symbol the same way this internal symbol is defined within the
library.
Signed-off-by: David Brown <david.brown@linaro.org>
With the updates to mbedTLS Kconfig it is now possible to update the
OpenThread security configurations by disabling the mbedTLS prompt and
avoid stuck symbol selection.
As part of this, the OpenThread security selection has been reworked
into a choice which ensures only a single security selection can be
chosen.
And the OPENTHREAD_MBEDTLS itself has been made promptless to ensure
other parts of the build system can select a specific OpenThread
security implementation and disable user selection, if the module or
sample require such behavior.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Move the code responsible for aligning the flash write by writing fill
values - from stream_flash_buffered_write to flash_sync. This avoids
having to correct buf_bytes/buf_written after the write and thus
simplifies error handling.
This commit also fixes an issue where the write length passed to the
callback in flash_sync includes the fill length.
Signed-off-by: Jonathan Nilsen <Jonathan.Nilsen@nordicsemi.no>
Remove this intrusive tracing feature in favor of the new object tracing
using the main tracing feature in zephyr. See #33603 for the new tracing
coverage for all objects.
This will allow for support in more tools and less reliance on GDB for
tracing objects.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Add support for new tracing macros in test backend. Move header from
sample into the subsystem and make it available for general testing with
any application.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Adds generic trace hook macros for inserting trace hook for
function entry, exit, blocking, and object initialization
with a variable number of arguments (objects, return values,
etc.). Utilizing macro concatenation these macros produce
trace hooks of a similar format to the old trace system
with SYS_TRACING_OBJ_FUNC(k_thread, switched_in) being
turned into sys_trace_k_thread_switched_in() by the
preprocessor. Although these macros still rely on the manual
definition of each unique trace hook in tracing.h, the benefit
of not directly calling those is that we can enable/disable
trace hooks based on object type (k_thread, k_sem, etc.)
through the preprocessor while providing the ability of adding
type specific runtime trace processing similar to
SYS_TRACING_OBJ_INIT.
Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Avoid confusion with device runtime idle pm states and just use device
pm states.
This simplify the code a little bit and prepare the ground for having
a better definition of device pm states. Right now this code needed to
hijack two transitional states to not break the current code logic but
the goal is avoid it and have everything in one single place.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Devices may be initialized but started powered down for this reason
is necessary to power a device on if requested even if in pre-kernel
state.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Device pm runtime was using semaphore to protect critical section but
enable / disable functions were waiting on the semaphore. So, just
replace it with a spin lock.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The sync API was using k_poll_signal and in certain conditions is
possible multiple threads waiting on a signal leading to an undefined
behavior.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The context parameter used across device power management is
actually the power state. Just use it and avoid a lot of
unnecessary casts.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Currently when the system goes to sleep it asks *all* devices that
support PM to suspend or go to a low power state, and the system wakes
up it put *all* suspended devices in active state, even if a device
was already suspended and not being used.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The k_work handler cannot manipulate the used k_work. This means
that it is not easy to cleanup the net_pkt because it contains
k_work in it. Because of this, use k_fifo instead between
RX thread and network driver, and between application and TX
thread.
A echo-server/client run with IPv4 and UDP gave following
results:
Using k_work
------------
TX traffic class statistics:
TC Priority Sent pkts bytes time
[0] BK (1) 21922 5543071 103 us [0->41->26->34=101 us]
[1] BE (0) 0 0 -
RX traffic class statistics:
TC Priority Recv pkts bytes time
[0] BK (0) 0 0 -
[1] BE (0) 21925 6039151 97 us [0->21->16->37->20=94 us]
Using k_fifo
------------
TX traffic class statistics:
TC Priority Sent pkts bytes time
[0] BK (1) 15079 3811118 94 us [0->36->23->32=91 us]
[1] BE (0) 0 0 -
RX traffic class statistics:
TC Priority Recv pkts bytes time
[0] BK (1) 0 0 -
[1] BE (0) 15073 4150947 79 us [0->17->12->32->14=75 us]
So using k_fifo gives about 10% better performance with same workload.
Fixes#34690
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Following commits will remove k_work from net_pkt, so convert
PPP L2 to use k_fifo when sending PPP data.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Following commits will remove k_work from net_pkt, so convert
6locan L2 to use k_fifo between application and TX thread, and
driver and RX error handler.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Replace the use of LL_FEAT define with ll_feat_get() so that
feature set value can be updated at runtime with host
feature bit values.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit implements the volume control service (VCS) and
client, The implementation supports and uses the
Audio Input Control Service (AICS) and
Volume Offset Control Service (VOCS) secondary services.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix radio event scheduling stall when using BT_CTLR_LOW_LAT
feature.
Performing a Connection Update Procedure on an ACL
connection while simultaneously having continuous scanning
causes the ACL connection to drop in nRF51 series which uses
BT_CTLR_LOW_LAT by default.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The USB HID class API offers the possibility to register callbacks
for Get/SetIdle, Get/SetProtocol to the application.
Rules for these callbacks are neither obvious nor documented.
This patch remove this possibility to register Get/SetProtocol
and Get/SetIdle callbacks for the following reasons:
The possibility to call unknown application code while processing
control requests should be avoided or reduced to a minimum.
The Get/SetProtocol callbacks are redundant and do not provide any
additional value since the way to inform the application
about the change of the protocol exists via the callback
hid_protocol_cb_t protocol_change.
The core provides implementation to handle Get/SetIdle requests and
on idle reports. If this is not suitable in any way then the application
should implement everything itself.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Added Kconfig option to configure the maximum Broadcast and
Synchronized Receiver ISO PDU length.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The amount of needed done events changes when using the "must expire"
logic.
Make the amount vendor configurable (via ull_vendor.h)
Defaults to the original amount of 3.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
The HCI specification creates additional complexity to allow this
configuration:
- When a connection gets established, we need to know which
identity the HCI_LE_Connection_Complete event corresponds to.
- The identity is a property of the advertising set.
Therefore we need the advertising handle.
- The advertising handle is part of the
HCI_LE_Advertising_Set_Terminated event and is not part of
the HCI_LE_Connection_Complete event. Therefore
the information of both events needs to be combined.
By spec the LE_Connection_Complete comes first. Therefore we cache
this event until the identity is available.
The event is only cached when a connection gets established as
that is the only case where we need to resolve the identity.
As the caching requires more resources, it is only enabled if the
application requires multiple advertising sets and multiple
identities.
The host maps the HCI_LE_Advertising_Set_Terminated event with
the HCI_LE_Connection_Complete event by comparing the connection
handles.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Added function ull_conn_iso_resume_ticker_start to enable LLL ISO
peripheral/central to start the one-shot resume ticker.
At timeout the common lll_resume handler is called, and based on the
LLL state, the peripheral/central is able to resume the CIG event.
The resume acts exactly like a normal event resume from the prepare
pipeline, with the exception that the LLL must provide specific
lll_event instances.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Add BT_CTLR_ISO_TX_BUFFER_SIZE depends on Broadcast ISO
and/or Connected ISO feature being enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename LE Read Buffer Size v2 struct members to related to
Bluetooth Specification use Length and Number terminology.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Only accumulate latency when event has not been prepared but
has been aborted while being enqueued in pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
smp_shell_process() is called only once after receiving new bytes over
shell. If multiple MCUMGR frames were received over UART one after the
other, then calling smp_shell_process() resulted in consuming only the
first one. All subsequent frames were not processed unless there was
some more RX traffic.
Process received frames in smp_shell_process() in a loop until there is
no frame left. This will make sure that received packets are not stalled
waiting for more RX traffic to trigger processing again.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Sometimes it may be needed to know device name when proxy feature is
enabled.
This commit adds an option to include device name in scan response.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit implements the OpenThread APIs to configure Enhanced-ACK
Based Probing in radio for a specific Initiator. This is needed for
Link Metrics functionality.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
Change use of dedicated memory pool for linked list nodes for
node_rx_iq_report to common mem_link_rx. Former solution had
a drawback. Released link nodes may be enqueued to wrong memory
pool. E.g. link related with nopde_rx_iq_report went to common
link memory pool, whereas link nodes from common pool were enqueued
to dedicated list.
The solution was working because links have the same memory layout,
just different memory pools they originated from.
The problem may occur if one of those link memory pools is reset.
Then the same link may be used by node_rx and node_rx_iq_report
at the same time, causing controller failure.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction finding is implemented only for Nordic link layer.
Build was failing due to missing header files for Openisa (RiskV).
Added dummy lll_df_types.h header file to OpenISA lower link layer.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The function get_per_adv_sync is used by HCI events to get
reference to periodic advertising sync object related with
handle available in handled events. Due to implementation
of Direction Finding event handlers in separate source file,
direction.c instead of putting in hci_core.c the function
get_per_adv_sync has to be globally accessible.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add functions that give possibility to enable or disable
CTE receive and sample in connectionless mode.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add Kconfig option that will enable supprot for connectionless
CTE reception. Thanks to that it will be possible to conditionally
enable or disable support of the feature and decrease code size
if the feature is not required.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Set BT_CTLR_DF_ANT_SWITCH_RX enabled by default.
There is already added implementation that supports
this feature in controller, so it may be enabled by
default.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add connectionless CTE RX feature to list of features supported
by controller. Add direction finding initialization in hci_core
if the feature is enabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Disable of CTE sampling for periodic advertising sync PDUs may be
interrupted by radio event. In such situation, TX thread will be
handled before RX thread delivers IQ samples report to host. In
this case RX thread would deliver IQ samples report after CTE
sampling was disabled.
To avoid such situation RX thread has to check if:
- CTE sampling is not disabled,
- CTE sampling was not requested to be disabled after start of radio
event.
CTE sampling configuration is double buffered. Updated configuration is
swapped at the beginning of radio event.
If CTE sampling is diabled or requested to disable (next radio event
didn't start), the IQ samples report should be dropped by RX thread
and should not be delivered to host.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add reporing of IQ samples collected for CTE attached to periodic
advertising PDUs with bad CRC.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add Kconfig option that will enable possiblity to sample CTE attached to
PDUs that have bard CRC. Sampling is based on CTEInfo field available
in received PDU. If radio is able to parse the field correclty then
it will start sampling even the CRC is wrong.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add function that enables or disables CTE sampling attached to received
periodic advertising PDUs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
ULL may request LLL to start receiving and sampling CTE attached to
end of periodic advertising PDUs. When the CTE is successfully sampled,
LLL should report collected samples to ULL.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Nordic Radio perihperal provides possiblity to get value of CTEInfo
field parsed from received PDU. It is faster to get the information
from Radio register than parse a PDU content.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add function to enable CTE receive and sampling. The function
is aimed to be used by code in lll_sync.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To enable or disable CTE sampling during periodic advertising sync evnet
it is requireq to change the event duration. To make it possible new
function was added that handles the operation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
lll_sync object is used to store information for LLL to enable
or disable CTE sampling. The commit adds initialization of
lll_df_sync member of lll_sync.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To enable or disable CTE sampling in periodic advertising scanner LLL
implementation lll_sync is extended by lll_df_sync member.
The lll_df_sync is a double buffer for lll_df_sync_cfg.
It will be used by LL thread to enable or disable CTE sampling and
provide configuration for sampling CTE in AoA mode.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add handling of Direction Finding node_rx_iq_report type in ULL.
This is required to correctly deliver IQ samples collected by
LLL during receive of PDU including CTE.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CTE sampling enable or disable requests should be provided to LLL.
Double buffer of lll_df_sync_cfg is added to lll_sync for that purpose
Thanks to that:
- there is no need to synchronize LLL with LL thread
- LLL has always access to valid configuration (new or former)
The configuration is stored in double buffer as instances
of lll_df_sync_cfg, not as pointers. This is the only
difference between double buffer pattern used to store adverising PDU.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add new structure lll_df_sync_cfg to store DF configuration
for periodic advertising synchronization.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add functions that will allow to mangage IQ reports memory pool
e.g. allocate or relase new IQ report nodes.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add new kind of node_rx type that will store IQ samples report.
The structure includes node_rx_hdr and may be used by the same
queues that are used to forward regular node_rx_pdu objects
between LLL and ULL.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction Finding support requires possibility to receive and sample CTE
attached to periodic advertising PDUs. New option will be used to enable
or disable the functionality. New option is introduced to avoid using
double statements checking if BT_CTLR_DF_CTE_RX and BT_CTLR_SYNC_-
-PERIODIC are enabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To avid enabling HCI drived debugging, like in other controller source
files, Direction Finding has its own option BT_CTLR_DF_DEBUG_ENABLE.
This gives fine grained control deubgging output.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Set to disabled not yet implemented Direction Finding features.
The features will be enabled by default when they are implemented.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
IQ samples report requires information about antenna switch pattern
that was used to measure RSSI. RSSI is measured during PDU receive.
For Nordic Radio peripheral the PDU antenna is selected by first antenna
switch pattern set in SWITCHPATTERN register. That pattern is providded
by device tree. This information is already available in radio_df.c.
The information is required by LLL, that has access to functions
provided in radio_df.c. New function was provided to return PDU antenna
switch pattern.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add panic_mode flag reset to log_core_init(). It allows full logging
reinitialization which is useful for testing.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Check whether the preempt event matches with the head of the
pipeline before aborting the currently active event.
This is required to avoid preemption of events that became
active due to done event and there has been a race in
stopping the preempt ticker.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Check whether the preempt event matches with the head of the
pipeline before aborting the currently active event.
This is required to avoid preemption of events that became
active due to done event and there has been a race in
stopping the preempt ticker.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Sync up with missing LLL changes done related to moving the
handling of pipeline handling into LLL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update the L2CAP channel send command to correctly reserve the number
of bytes needed for an L2CAP SDU.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update the L2CAP OTS implementation to use the correct reserve
defitition. By not using the correct definition the stack always
allocates a new segment for the packet, which puts more stress on the
stack buffers.
Update TX data size to be more intuitive by adding the overhead, instead
of subtracting it. This increases the default MTU of the implementation.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add argument to the L2CAP channel send command so that the user can
determine the length of the packet to send, this is useful for testing
various segmentation scenarios.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update the documentation for L2CAp Connection oriented channel send
function to include better description of the L2CAP PDUs (Basic frames)
and L2CAP SDUs (Credit-based frames) so that the application can better
understand how to size the buffer pools and setting the RX mtu.
Document stack behavior on RX path and how the application has to
set up the channel in order to receive segmented packets.
Document stack behavior on TX path for reserving either mandatory or
optional header bytes.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor and simplify the bluetooth buffer configurations to improve the
easy of configurations and eliminate invalid ones.
By moving configurations out of host and controller specific
configurations and into a common one it becomes easier to configure
the host and controller separately as the same configurations can be
used as would be for a combined build.
All HCI configurations are now given exluding the matching HCI header,
which eases the configuration as the application don't have to know the
different header sizes.
The BT_RX_BUF_LEN is split into ACL and Event, as well as the suprising
use of Command size.
BT_L2CAP_RX_MTU is removed as the stack does not support reassembling of
HCI ACL data to larger L2CAP PDUs. The application will have to set
ACL RX size and account for the L2CAP PDU header itself.
BT_EATT_RX_MTU was removed as it is only used for setting a different
default value for another option which leads to the stuck kconfig symbol
problem.
The configurations can be updated according to the table below:
** New configuration | ** Old configuration
All configurations
BT_BUF_ACL_RX_SIZE | BT_L2CAP_RX_MTU + 4
BT_BUF_ACL_RX_SIZE | BT_RX_BUF_LEN - 4
BT_BUF_EVT_RX_SIZE | BT_RX_BUF_LEN - 2
BT_BUF_CMD_TX_SIZE | BT_RX_BUF_LEN - 3
BT_BUF_CMD_TX_COUNT | BT_HCI_CMD_COUNT
BT_BUF_EVT_RX_COUNT | BT_RX_BUF_COUNT
BT_BUF_ACL_RX_COUNT | BT_RX_BUF_COUNT
BT_BUF_ACL_RX_COUNT | BT_ACL_RX_COUNT
BT_BUF_EVT_DISCARDABLE_SIZE | BT_DISCARDABLE_BUF_SIZE - 2
BT_BUF_EVT_DISCARDABLE_COUNT | BT_DISCARDABLE_BUF_COUNT
Controller-build
BT_BUF_ACL_TX_SIZE | BT_CTLR_TX_BUFFERS_SIZE
BT_BUF_ACL_TX_COUNT | BT_CTLR_TX_BUFFER
HCI-bridge
BT_BUF_ACL_TX_SIZE | BT_HCI_ACL_DATA_SIZE
BT_BUF_ACL_TX_COUNT | 6
Fixed invalid configurations setting either BT_L2CAP_RX_MTU or
BT_CTLR_DATA_LENGTH_MAX larger than BT_RX_BUF_LEN could lead to buffer
overruns.
Fix advertising report max data length calculation.
This always used the BT_DISCARDABLE_BUF_SIZE macro but this feature
can be turned off and advertising reports will be allocated from the RX
buffer in that case. Also controller-build does not have this buffer
(in hci_raw.c). Also the wrong HCI header was used in the calculation,
HCI event header should have been used instead of HCI ACL header.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the L2CAP TX MTU default to fit the public key packet in a single
L2CAP fragment. This matches the configuration for RX buffer lengths
being set with this configuration.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove discardable buffer dependency on the specific implementations
except for HCI raw.
All of the in-tree Host-side HCI drivers have implemented discardable
buffer behavior.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add macros for calculating buffer sizes, accounting for the various
L2CAP and HCI headers needed as well as the reserved bytes needed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit implements the missing OpenThread APIs related to CSL
receiver configuration.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Added radio interface to save and restore radio ready
timestamp. This will be saved between ISO Subevents and
used in done event for anchor point synchronization and
drift compensation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
A badly written sector close ate that has correct crc8 could allow
jumps outside the assigned flash area. This behavior is fixed.
A possibility existed that a badly erased sector or a incomplete write
of a large item created a empty closed sector. This has been fixed by:
a. Erase verification.
b. Clearing such a sector at startup.
Fixes#34382
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Co-Authered-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Update shell L2CAP to use the new delayable work API for the delayed
received confirmation response.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update GATT to use the new delayable work API for the delayed
calculation of the database hash and the service changed indication.
When the database hash characteristic is read the hash work needs to be
canceled if in progress and if currently executing wait for it to
complete so that the threads don't both write to the stored value.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update the connections to use the new delayable work API for the
deferred work host timer.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update AVDTP to use the new delayable work API for the send host timer.
The AVDTP protocol is incomplete, there is no cancelation of the timer
but it is also never started, as there is no users of the internal
functions, and no public functions exists.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update the implementation of controller based privacy to use the new
delayable work API for the RPA timer. Always use schedule for the
timer since RPAs should not be used more than the configured RPA
timeout.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update RFCOMM to use the new delayable work API for the RTX host timer
used for disconnecting and idling.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor the SMP channel context to in order to simplify the memset of
the struct in smp_init. This makes the code easier to read, and easier
to add more structs that should not be reset by memset.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update the RPA timer to the new delayable work API.
Checking for submitted RPA timer no longer needed with the schedule
function, which does not change the deadline.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use `pm_device_*` prefix for the device runtime PM API. This adds the
API to the `pm` namespace, making it clear part of the PM subsystem.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
- Move PM related APIs to `include/pm` so that it follows API `pm_`
prefix namespace. In order to make transition easier
`include/power/power.h` is kept pointing to `include/pm/pm.h`.
- Move most of device PM related content from `include/device.h` to
`include/pm/device.h` and `include/pm/runtime.h`.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Add extra check for the LwM2M client state, to allow triggering of the
Registration Update message only when registered.
This fixes an issue, when the `trigger_update` flag could be set during
the bootstrap procedure (when the value of the Lifetime resource was
set), which resulted in an uneccessary Registration Update message just
after the successful registration.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit implements the OpenThread APIs to configure a radio
reception slot at a specific time. This is needed for the correct
functioning of a CSL receiver.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Remove the config BOOT_TIME_MEASUREMENT and corresponding #ifdef'd code
throughout (kernel/init.c, idle.c, core/common.S , reset.S, ... ) which
hold the extern hooks for z_timestamp_main and z_timestamp_idle in the
removed boot_time test suite.
Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
`write_stats` functionality implementation is guarded by
`BT_GATT_CLIENT`, but is also called from commands defined when
`BT_GATT_DYNAMIC_DB` is set. This means that now application will not
build with `BT_SHELL` used, when we set `BT_GATT_DYNAMIC_CB` solely.
Move this functionality to top of the file without guarding
ifdefs, so it can be used in all gatt shell commands.
Signed-off-by: Marek Metelski <marek.metelski01@gmail.com>
There is a choice to log btmon logs over UART or RTT.
You can choose number of RTT buffer, set its name and size.
Replaced CONFIG_BT_DEBUG_MONITOR with CONFIG_BT_DEBUG_MONITOR_UART
for UART usage and CONFIG_BT_DEBUG_MONITOR_RTT for RTT.
Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
Renamed offset and offset_units to offs and offs_unit to be
consistent with rest of the other structures.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ULL reference count decrement to be performed before the
done events are handled, so that correct reference count is
used to determine if events are pending in the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update HCI driver implementation in the controller to
process a list of controller events by traversing net buf
frags.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reorder Channel Selection Algorithm #2 and Minimum Number of
Used Channels Procedure bits.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit implements the OpenThread APIs to pass MAC keys and
frame counter to the radio layer in order to process the
transmission security. This is needed for the correct functioning
of a CSL transmitter.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Fix regression in central initiated terminate introduced in
commit 3a80785947 ("Bluetooth: controller: Fix connection
terminate to happen on event done").
The regression caused an additional central connection event
transmitting PDU after the previous connection event had
received acknowledgment for the terminate_ind PDU from the
peripheral.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not report auxiliary PDUs as advertising reports when in
initiator state on auxiliary channels.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Ensure that the advertiser address type and address is setup
in both 1M and Coded PHY scanning instance when extended
create connection is enabled on both the PHYs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When connection is initiated in one of either 1M or Coded
PHY initiating scan instance then the other scanning
instance's scheduling and memory allocation needs to be
cleaned up.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reserve an additional node rx buffer when Extended Initiator
is supported as the received ADV_EXT_IND PDU is being
buffered in the auxiliary channel scanning instance and is
only released/flushed in the done event of the initiating
auxiliary channel radio event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed incorrect LLL context used to generate done event for
auxiliary channel scanning. Other minor comments and fixes.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reset the scanning context for the PHY not selected in the
Extended Create Connection command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This allows to initiate a connection on secondary advertising channels,
i.e. when advertises uses advertising extensions.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
When in initiating state we need to handle ADV_EXT_IND as in regular
scan sice we always want to scan AUX_ADV_IND in order to be able to
connect.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We need to take RX chain delay and PHY used to send CONNECT_IND into
account when calculating 1st connection event offset.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
On secondary advertising channel transmitWindowDelay depends on PHY
used to create connection so we need to adjust it.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We will need the same checks for AdvA and TargetA/InitA in lll_scan_aux
so let's make them public and use address explicitly instead of passed
via pdu.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We can use the same code to create both CONNECT_IND and AUX_CONNECT_REQ
since they are basically that same PDUs.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Use size_t type where it makes sense and
check if the buffer is large enough before it is used.
Fixes: #33786Fixes: #33795
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
When broadcasting with ISO it would wrongly use the tx_pool
defined for CIS, instead of the broadcast TX pool.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The sysview module does not set an interrupt number when recording ISRs
using SEGGER SystemView. Added ISR numbers for Cortex-M based chips.
Signed-off-by: Jan Müller <jan.mueller@nordicsemi.no>
Fix buffer leak in L2CAP and SMP when attempting to send over a
a connection that has been disconnected.
Both L2CAP and SMP now have ownership of the buffer in case of failure
to send it and need to unref it in case of send failure.
Change the return type of bt_l2cap_send since the user of this function
has to handle releasing of the buffer when this fails.
Regression from: a77f809faa47ff9922692d2b4eab33062b8a2b4d
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove the comment about bt_l2cap_send_cb not being able to fail when
called from RX thread. It will fail in the case where the connection
has been disconnected.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Improved the documentation for the ISO data paths, as well
as making the bt_iso_setup_data_path function a bit more
clear.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Since we are only setting up a single data path for
broadcasters (either receive or transmit), we should
only remove that same path.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The BIGinfo reports were almost identical to the
periodic advertising reports when printet. Updated to
mark the start of the line with BIGinfo.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When setting the iso data path for a BIS, it shall only be set for
one direction (depending on whether we are a broadcaster or
a receiver).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds FPU sharing support with a lazy context switching algorithm.
Every thread is allowed to use FPU/SIMD registers. In fact, the compiler
may insert FPU reg accesses in anycontext to optimize even non-FP code
unless the -mgeneral-regs-only compiler flag is used, but Zephyr
currently doesn't support such a build.
It is therefore possible to do FP access in IRS as well with this patch
although IRQs are then disabled to prevent nested IRQs in such cases.
Because the thread object grows in size, some tests have to be adjusted.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Add downlink callbacks on a per-port basis. A single message will be
handled as many times as users have registered matching ports. Callbacks
will also be run on "meta" downlink packets on port 0, such as confirmed
uplink acknowledgements.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The device has sent RESET_POWER_UP message before the communication
with the host hadn't been established. It could be observed with
pyspinel which displayed `Framing error`.
This commit fixes the bug by initializing NCP after the host stated
is ready to communicate.
This commit reverts initialization the USB stack into function
otPlatUartEnable to be consistent with others OpenThread platforms.
OpenThread co-processor samples are not affected by #27071 as they use
USB for SPINEL communication with host and not for UART console.
Note:
When co-processor communicates by USB CDC ACM and it is hard reset
(what is happening in current Zephyr OpenThread platform)
the connection needs to be properly handled by the host.
For posix platform used together with RCP it was implemented in:
https://github.com/openthread/openthread/pull/6454
and for NCP:
https://github.com/openthread/wpantund/pull/492 .
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
OpenThread modified its NCP API, so we need to align with these changes
in Zephyr.
One of the major changes was removal of UART from the platform APIs.
`openthread/platform/uart.h` header file was moved to
`examples/platforms/util/uart.h` so we need to use the new location in
Zephyr. This means that OpenThread no longer impose the UART API but for
the simplicity of the upmerge I've kept the UART APIs as they are for
now.
The NCP initialization function have now to register a send handler,
and the appropriate transport driver have to call NCP callbacks when
transmission/reception is done. For now, re-use the existing code of
the UART driver, just as the upstream NCP application does.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Use OpenThread mutex in order to protect OT CLI API call instead of
halting the OpenThread thread.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The OpenThread CLI API has changed therefore it's needed to align
OpenThread Shell implementation in Zephyr with these changes.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Document the fact than NVS image of different wbs
are compatible each other if psychical ATE size
is kept.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
When existing records stored in the NVS are not properly
aligned according to the current flash driver requirements,
fs->data_wra may be initialized with an unaligned address.
Fix the initialization code, so that fs->data_wra is rounded
up to the nearest multiple of the current flash driver block
size.
The situation may occur during a firmware upgrade which
introduces a new flash driver or changes its parameters.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Add Radio configuration API that gives possiblity configure
reception and sampling of CTE.
Part of alrady implemented API was re-factored to comply
with new API and do complete initialization of registers:
DFECTRL1 and CTEINLINECONF.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Logging failed to compile when --no-gc-sections is used because
log_core is conditionally calling mpsc_pbuf.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
When PROVISIONER and CDB is enabled then IUT couldn't be a NODE.
This patch fixes this by not returning an error when CDB is not
configured. This is useful especially in testing environment, when all
the features are compiled in and we can choose role in runtime.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Since the API already has a function to create an LwM2M object instance,
it makes sense to add a corresponding delete funtion, allowing the
application to delete created objects.
Additionally, for the remote delete set the Registration Update trigger
only when not in bootstrap mode.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The Registration Update message should be sent whenever an object
instance is created or deleted. Currently this was only the case when an
object instance was created by the server and not by the application.
Fix this by triggerng the Registration Update from the API function
as well.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This PR increases the OpenThread stacks to compensate
for the runtime increase of the MPU stack guard
when the usage of the FP context is detected.
Signed-off-by: Piotr Szkotak <piotr.szkotak@nordicsemi.no>
Fixed to ensure that semaphore is not used by the log core
when multithreading is disabled.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Spin lock validation is touching threads. Allow only when
multithreading is enabled.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added support for no multithreading case where test cases are
called directly from main(). On failure in ztest assert macro,
macro returns from the function. It implies that ztest assert
macros can only be called in the test function.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Use recently introduced API, which takes care of gracefully closing any
pending DNS requests and replacing existing DNS server list with new
one.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Use recently introduced API, which takes care of gracefully closing any
pending DNS requests and replacing existing DNS server list with new
one.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
So far there was no dedicated mechanism for replacing DNS servers with
new list. Add dns_resolve_reconfigure() API that allows to achieve that
in a thread-safe manner.
Introduce 3rd state in DNS context lifetime by converting from 'bool
is_used' to 'enum dns_resolve_context_state state'. This new
DEACTIVATING state allows to mark a DNS context as busy and safely close
context without holding lock. Closing DNS context with released lock
prevents deadlock in case net_context_close() has to synchronize with a
separate thread executing handler passed to net_context_recv() (which is
the case for example with ESP-AT WiFi driver).
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
ctx->is_used member seemed to be used sometimes within a mutex acquired
block, sometimes not. Make it consistent by always using it with
acquired mutex.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Reboot functionality has nothing to do with PM, so move it out to the
subsys/os folder.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This adds a new UART backend for dictionary based logging,
where this can output binary data in both binary and
hexidecimal strings.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds dictionary based logging support. Dictionary based
logging is binary based where one big difference is that
static strings are stored as pointers instead of the whole
string. This results in reduced space requirements for
storing log messages in certain scenairos.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
NIOS2, RISC-V and SPARC are using _image_rodata_start/_end in
their linker scripts to mark the boundaries of rodata. So
they no loner need special treatment.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Adds missing handling of the m_interval and m_latency if tx QOS is
not set, and handling of the s_interval and s_latency if rx QOS is
not set.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Currently the lwm2m_path_log_strdup allocates a temporary buffer on a
stack, and then passes it to the log_strdup function to create a copy
of the string for the logger. log_strdup however will not copy the
string if for instance immediate logging is used, therefore the logging
function will still use the memory address of the already invalid buffer
allocated within lwm2m_path_log_strdup.
Fix this by passing an addittional `buf` parameter to the
lwm2m_path_log_strdup function, therefore allowing the user to provide
the buffer within a valid scope.
CID: 220536
Fixes#34005
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
zsock_select() cannot poll file descriptors with number >= 32.
When a whole word in FD_SET was skipped due to being empty,
corresponding fd number was not updated, leading to wrong
fd's being passed to poll().
Fixes#34563
Signed-off-by: Chih Hung Yu <chyu313@gmail.com>
We have a few remaining tests where ztest module is not used directly,
and instead lower-level tc_util.h is used (where ztest also uses that
header). Supposedly, there're good reasons for that. However, tc_util.h
tests have output which is somewhat inconsistent with ztest output,
which may be a problem with automated parsing of test results, e.g. in
CI systems.
So, factor out code to mark testsuite start/end from ztest.c to
tc_util.h as TC_SUITE_START() and TC_SUITE_END() macros, to allow
tc_util.h based tests to produce output fully consistent with
ztest, while avoiding duplicate of code. TC_SUITE_END() accepts
result code (TC_PASS/TC_FAIL), similar to existing TC_END_REPORT().
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Switch to the new API. Adds early exits for the ack and retransmit
timers, and replaces a remaining_time() + submit() call with schedule().
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new API. Adds check for a pending buffer in the SAR
timeout handler.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new API. Adds a link check to the protocol timeout to
ensure the link is still active.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new API. Consolidates reliable sending logic for the first
transmission and the retransmit into one. Adds check for link active in
protocol timeout.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new API in Mesh's extended advertising handler.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new API in friend, net and main.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Friend structure allocaction logic is implemented over and over
throughout the friend module. Move it into a static utility function for
readability.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
set_endpoint() and reset_endpoint() were missing final
else statement in the if else if construct. This commit
adds a final else {} with assert to comply with coding
guideline 15.7.
Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
cleanup_test() was missing final else statement in
the if else if construct. This commit adds else {}
to comply with coding guideline 15.7.
Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
Devices that do not require PM should just use NULL.
`device_pm_control_nop` is still kept as an alias to NULL untill all
in-tree usage is replaced with NULL.
Code relying on device_pm_control function now returns -ENOTSUP
(equivalent to calling device_pm_control_nop).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Replace all existing deprecated API with the recommended alternative.
Fixes: #34101
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
The error check was removed earlier as it was assumed that
we would either get an error, or the data would be valid.
However, without an error check, we are not guarded
against bad reads.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If the output description of the server is empty (legal by the
spec), then we should not return an error to the application
when read. Also added some debug statements when the value is
truncated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixes 2 issues:
1) The write callback always returned an error
2) The auto-read of the offset state did not, unlike what the
comment suggested, retry only once and fail on the second attempt,
but rather keep retrying.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds a security checks when notifying or indicating, such
that we don't send notifications for characteristics that
require encryption on an unencrypted link.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Initializing a work item from its handler will destroy the content of
the kernel structures used to process the work item. This can lead to a
system crash for example when the delayed work is being rescheduled when
the previous run is already queued for processing but not yet executed.
Fix this by initializing the work item once during trickle timer
creation and moving the logic, previously achieved by switching the work
handler, into the new work handler.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This value is used to measure the RX/TX statistics. The previous
use of the timestamp field did not work in RX path as the timestamp
value could be overwritten by the driver if gPTP timestamping
is enabled. So to fix the RX statistics, use a separate field
for the create time.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If user enables CONFIG_USERSPACE, then at least one TX or RX thread
is needed to isolate the application from the kernel space components.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Set the default behaviour of the networking subsystem so that
no TX or RX threads are created. This will save RAM as there
is no need to allocate stack space for the RX/TX threads.
Also this will give small improvement to network packet latency
shown here:
* with 1 traffic class (1 TX and RX thread)
Avg TX net_pkt (42707) time 60 us [0->22->15->22=59 us]
Avg RX net_pkt (42697) time 36 us [0->10->3->12->7=32 us]
* with 0 traffic classes (no TX and RX threads)
Avg TX net_pkt (41608) time 42 us [0->21->20=41 us]
Avg RX net_pkt (41593) time 31 us [0->9->12->8=29 us]
In this qemu_x86 test run, 40k UDP packets was transferred between
echo-server and echo-client. In TX the speed increase was 30% and
in RX it was 14%.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Set the net_pkt creation time just before the actual net_pkt
is allocated in order to get more accurate information for
statistics.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If user has set the priority of the sent net_pkt to highest
priority (NET_PRIORITY_CA) and enabled CONFIG_NET_TC_SKIP_FOR_HIGH_PRIO
option, then push that packet directly to driver instead of TX queue.
This will make the TX sending latency smaller for the high priority
packet. This is not enabled by default.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
It has been seen that when net backend is enabled stack usage
is around 1080. Setting 1152 as the default.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Exit latency time should never be greater than the residency time.
Just add an assert in case the policy does not properly handle it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Set the timeout to expire "exit_latency_us" earlier to the CPU be
capable of honor the next scheduled event.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Moves the callback structure for VOCS to the register function
which is renamed from init, as there's no reason to register
the callbacks separately.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for delayed transmission of frames for the CSL
Transmitter OpenThread function.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
The z_timeout_end_calc function was replaced by
sys_clock_timeout_end_calc in #33302. A reference to the old function
snuck into master through #30015.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Avoid possibly overflowing maximum interval when calculating interval
with preferred periodicity.
Changed calculation to round down from maximum interval and reset to
maximum in case of underflowing minimum interval.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Perform null check of default_conn in call cmd_conn_update()
and cmd_conn_data_len_update() in ./subsys/bluetooth/shell/bt.c
Signed-off-by: Kai Ren <renkaikaiser@163.com>
The net_shell only uses iface_flags2str when CONFIG_NET_NATIVE is
enabled. Disabling this produces an "unused function" warning for this
function. Wrap the function in an #ifdef to silence the warning for this
configuration.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This option was only able to collect statistics of transmitted
data. The same functionality is available if one sets the
CONFIG_NET_PKT_RXTIME_STATS and/or CONFIG_NET_PKT_TXTIME_STATS
options.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The RX statistics might not get updated properly because the used
ifdef was referring the TX options.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Query timeout handler is rescheduled if DNS context mutex is locked. So
far there was no timeout used, which means that work is simply put at
the end of system workqueue. This solves cases when mutex is locked by
any higher priority cooperative threads.
If however mutex was locked in application code within lower priority
thread (which is very likely) and query timeout has expired in the
meantime, then system workqueue is busy looping by calling query timeout
handler and trying to acquire DNS context lock.
Reschedule query timeout handler with 10ms delay, so that all
threads, including those with lower priorities, have a chance to move
forward and release DNS context lock.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Add additional API to stream_flash that can be used to make
stream write progress persistent using the settings subsystem.
This functionality makes it possible to resume a write operation
after it was interrupted, e.g. by power loss.
Signed-off-by: Jonathan Nilsen <Jonathan.Nilsen@nordicsemi.no>
This commit increases the shell stack sizes when used with
OpenThread shell and the joiner to compensate for enlarged
MPU stack guard.
Signed-off-by: Piotr Szkotak <piotr.szkotak@nordicsemi.no>
Add the BT_GAP_PER_ADV_MIN_INTERVAL and BT_GAP_PER_ADV_MAX_INTERVAL
macros in gap.h that are also reference in bluetooth.h and
used for parameter validation in adv.c.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Moved sdu_interval struct members from llcp_cis to cis group,
to match spec and enable access by ULL
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
Uninitialization of uart transport was missing disabling of TX
interrupt. It had to be done by the user before using uart.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
When selecting a random count for blink, beep or vibrate, the Bluetooth
Mesh Profile Specification v1.0.1, section 5.4.2.4 states: "the device
shall select a random integer between 0 and 10 to the power of the
Authentication Size exclusive".
This means that if size is 1, the integer should be in the range 1-9,
while the implementation chose an integer in the range 0-9. Reduce the
range and add 1 to the num to correct this for these actions.
Fixes#34209.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix undefined referenc to bt_le_adv_lookup_legacy in bt_le_oob_get_local
when bt_le_oob_get_local is used in a central only application.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The ARM64 port is currently using SP_EL0 for everything: kernel threads,
user threads and exceptions. In addition when taking an exception the
exception code is still using the thread SP without relying on any
interrupt stack.
If from one hand this makes the context switch really quick because the
thread context is already on the thread stack so we have only to save
one register (SP) for the whole context, on the other hand the major
limitation introduced by this choice is that if for some reason the
thread SP is corrupted or pointing to some unaccessible location (for
example in case of stack overflow), the exception code is unable to
recover or even deal with it.
The usual way of dealing with this kind of problems is to use a
dedicated interrupt stack on SP_EL1 when servicing the exceptions. The
real drawback of this is that, in case of context switch, all the
context must be copied from the shared interrupt stack into a
thread-specific stack or structure, so it is really slow.
We use here an hybrid approach, sacrificing a bit of stack space for a
quicker context switch. While nothing really changes for kernel threads,
for user threads we now use the privileged stack (already present to
service syscalls) as interrupt stack.
When an exception arrives the code now switches to use SP_EL1 that for
user threads is always pointing inside the privileged portion of the
stack of the current running thread. This achieves two things: (1)
isolate exceptions and syscall code to use a stack that is isolated,
privileged and not accessible to user threads and (2) the thread SP is
not touched at all during exceptions, so it can be invalid or corrupted
without any direct consequence.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Move ec_host_cmd.h out of the top level include/ dir into
include/mgmt/ec_host_cmd.h and deprecated the old location.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Move emul.h out of the top level include/ dir into
include/drivers/emul.h and deprecated the old location.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add Radio interface to perform back-to-back transmit of PDU
with a configurable inter frame spacing.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
nRF53 implementation of sw_switch always requires Radio End
event, hence optimize out redundant code due to explicit use
of radio_tmr_end_capture.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor indentation change and replaced if-then-else-if clause
with toggle implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When shell had too many pending log messages it was attempting to
drop expired messages and retrying to put the new message. There
was an assumption that enough messages are dropped and new message
can be put. It may not be the case if no message expired during
given time. Wrapped the operation in loop to continue until expired
message is freed and new message is enqueued.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This library is coded with standard POSIX names for socket functions,
so make that requirement explicit.
Also, switch it from select'ing NET_SOCKETS, to depend'ing on it. This
follows the general approach of avoiding unneeded select's in Zephyr,
which lead to conflicting dependencies and make debugging dependencies
complex overall. In this particular case, it's fair (for a user) to
expect that "simple network time protocol" requires networking API,
namely sockets, and have that explicitly on in their app configuration,
giving better overview of their app config overall.
Fixes: #34165
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Adds name length checks. The OTS spec does not
explicitely specifiy a maximum name length, but the
maximum name length in the directory listing object
shall be less or equal to 120 octets.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds additional length checks for the OTS directory listing
implementation. This will check the object name length and
the total length of the object when encoding,
as well as the length of the objects when removing objects
from the directory listing.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The log_backend_swo_init function sets the CYCCNTENA bit of the DWT
register to 0, disabling the counter (which is necessary for the timing
functions.
Avoid overwriting the CYCCNTENA bit.
Do not try to set read-only bits.
Fixes#34341
Signed-off-by: Andrés Manelli <am@toroid.io>
Fixes a typo where the BT_GAP_PER_ADV macros had MAX twice,
as well as adding a MIN timeout macro and check.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix ECC thread stack size which is to small to account for the worst
case scenario. When an interrupt happens at the point where the ECC
thread is at the highest stack size usage pushing the thread context
to service the ISR causes a stack overflow.
Increase the ECC thread stack size by atleast the size of the basic
stack frame of 32 bytes aligned on 8 byte for ARM architectures.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
By default ztest thread is running at the priority `-1`. This value is
invalid when the testcase is running in cooperative mode only. Set
default ztest thread priority to `-2` if this is the case. The fix is
modeled on the approach used to define the default
`MAIN_THREAD_PRIORITY`.
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
So far we only have log_msg_timestamp_get() function, which returns
internal timestamp representation. This is either clock cycles or uptime
in ms, depending on main clock precision.
Introduce log_output_timestamp_to_us() helper function, which allows to
convert internal logging timestamp to us.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This aligns the error handling of send function to never unref the
buffer in place so the caller retain the ownership of the buffer
whenever there is an error.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds a new flag, BT_LE_ADV_OPT_FORCE_NAME_IN_AD, which can be used
to force the Bluetooth GAP device name to appear in the advertising
data rather than the scan response data of an advert with scan response
data.
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
Just renaming the function parameter fix two violations, one is
caused because the parameter name is different from the declaration
the other violation is because the identifier was starting with
underscore.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The virtual_iface is already NULL checked by net_if_get_by_iface()
at the beginning of the function so no need to do it here too.
Coverity-CID: 220535
Fixes#34006
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Simplifying the loop in order to remove dead code (ctx_up is
always NULL after the slist loop.
Coverity-CID: 220538
Fixes#34003
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Move cmsis OS api headers under include/portability. Those are not
libraries and only serve to provide a level of abstraction using the
CMSIS OS APIs to existing Zephyr interfaces.
Removed one level and put them directly under include/portability.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Move cmsis OS apis under subsystem/portability. Those are not libraries
and only serve to provide a level of abstraction using the CMSIS OS APIs
to existing Zephyr interfaces.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Wait for MAC operations to complete when transmitting. Unconfirmed
messages still open receive windows and can cause error conditions,
which are currently dropped.
It is also possible for a second send to be requested before the first
one has finished processing, which results in `LORAMAC_STATUS_BUSY`.
Empty frames (due to insufficient payload space) now also block until
the MAC layer is ready to accept new commands.
This change means the application no longer needs to guess-and-check
when it is possible to send unconfirmed messages.
Fixes#33456.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
If the telnet client operates in a character mode, it may send
individual characters in packets. Such packets were dropped in the
telnet shell backend instead of being process by the shell engine.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Added implementation of log_msg2 which is creating log messages
using cbprintf packaging and storing them in circular ring buffer
(mpsg_pbuf).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Logging v2 is using _Generic keyword for detecting type of
log message arguments. Apparently, it does not support handling
of pointers to forward declared structures. Added casting to void *.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Logging v2 is using _Generic keyword for detecting type of
log message arguments. Apparently, it does not support handling
of pointers to forward declared structures. Added casting to void *.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix a missing encryption procedure state check which allowed
out of order receive of START_ENC_RSP PDU, which made the
controller to believe its already in an encryption procedure
in progress state.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not make the first object added to the object transfer server the
current (=selected object). This leads to the server having no
current object until one is selected by the client.
This solves a startup issue where the selected callback is not called
by the server if the first object selected by the client happens to be
the same object as the object that was first added to the server. In
that case, the user of the OTS does not know which object is selected,
and therefore may not be able to supply the correct data later.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Avoid using sizeof to access ULL and LLL struct members.
Based on the alignment requirements of structures, due to
padding between structure members, use of sizeof of previous
struct member to access next struct member is incorrect.
Continue to use explicitly stored parent pointer to access
ULL context. Combine event header and ULL header so that
the parent pointer point directly to the combined ULL
struct.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing initialization of reference count in
ull_hdr_init function.
This has not caused issues so far, but when the ref member
of the struct ull_hdr if placed in the beginning of a
context that is allocated using mem_acquire function then
first few bytes used would make the ref member to have
uninitialized value when such context is allocated by
mem_acquire. First few bytes are the next pointer and free
count stored by the mem module.
The issue was discovered in subsequent commits that
restructure the ULL context structures.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the auxiliary scan context release to be performed in
the disabled_cb callback after the ULL reference count is
decremented.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix conn_cleanup to be performed in the event done. The
regression was introduced in
commit 5412f61ac6 ("Bluetooth: controller: Introduce
separate done memq").
Now that done event is handled asynchronously outside the
handling of the terminate node rx type, it is necessary that
terminate node rx type is generated after the done event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Consolidate Kconfigs for ISO roles to make compilation guards more
concise. Just introduces aliases, does not change functionality.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
The previous implementation assumed that the dst pointer was always
aligned to a 4-byte boundary in platforms that require alignment for
storage of 32-bit integers. Since this is required for certain platforms
(eg. Arm Cortex-M0), use memcpy() instead, which always takes
alignment into account.
Fixes#33969.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Moves the beacon_enabled check in the beacon work handler to check the
beacon flag before sending anything, in case a cancel call fails.
Split out from #33782.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Ignore peer keypress notifications as a responder, allowing the pairing
procedure to continue instead of being aborted.
The Bluetooth LE specification does not specify a behavior, the
implementation has the choice of ignoring or aborting.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The Transport layer implements some checks surrounding the
lpn_msg_received call, with an accompanying comment that explains the
logic. Move this inside the msg_received call instead.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new delayed work API. Puts the scheduling for the next
poll in the response_received function instead of cancelling it, then
optionally scheduling it again later.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Made the LwM2M engine checks for pmin and pmax optional to adhere to
the LwM2M specificattion. We now first check that pmin and pmax are
actually set. Also changed the default CONFIG values for the attributes
pmin and pmax to 0 to indicate that they are not active by default.
Fixes#34329.
Signed-off-by: Maik Vermeulen <maik.vermeulen@innotractor.com>
Changes lpn_timeout_get behavior in the config server to report the
configured LPN timeout, instead of the currently remaining timeout time.
According to the Bluetooth Mesh Profile specification, section 4.2.21,
the PollTimeout list is a list of the PollTimeout timer values, and
according to table 4.32 in this section, values 1-9 are prohibited.
Although this is not explicitly stated, this indicates that the
PollTimeout value is the configured poll timeout time - not the time
remaining until the timeout value expires. This patch changes the
implementation to reflect this.
Split out from #33782.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Removing CONFIG_TRACING_CPU_STATS in favor of
CONFIG_THREAD_RUNTIME_STATS which provides per thread stats. The same
functionality is also available when Thread analyzer is enabled with the
runtime stats enabled.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The Transport layer would previously rely on the access layer to check
whether there's room for the full message and a MIC in the available
buffer space, and its own checks would ignore the MIC. This should be
handled by the Transport layer checks, so the access layer doesn't have
to.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Periodic publication would previously build and send the first
publication inside the bt_mesh_model_pub() function, before cancelling
and rescheduling the next publication. The timer handler would only
handle retransmissions, and would abandon the rest of the publication
event if one of the packets failed to send.
This design has three issues:
- If the initial timer cancel fails, the publication would interfer with
the periodic publication management, which might skip an event or
send too many packets.
- If any of the messages fail to publish, the full publication event
would be abandoned. This is not predictable or expected from the API.
- bt_mesh_model_pub() required 384 bytes of stack to build the message,
which has to be factored into all calling threads.
This patch moves all transmission into the publication timer by
replacing k_work_cancel with a single k_work_reschedule(K_NO_WAIT). It
also changes the error recovery behavior to attempt to finish the full
publication event even if some of the transmissions fail.
Split out from #33782.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Replace all existing deprecated API with the recommended alternative.
Be aware that this does not address architectural errors in the use
of the work API.
Fixes#34092
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
If `CONFIG_NET_ICMPV4_ACCEPT_BROADCAST` is enabled ICMPv4 should reply
to request packets sent to the broadcast address of an interface with
the unicast address of that interface from the same subnet.
Previously the code blindly copied the ICMP source address which meant
it would reply to broadcast packets with a broadcast source address.
Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
The `init_string` array could have been used uninitialized, fix this
by initializing it as an empty string, which is a desired content in
case it's not overwritten.
CID: 220302
Fixes#33839
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
First design towards ISO adaptation layer, this PR introduces
data-structures and framework for Rx unframed PDUs (BT RX ingress).
Two callbacks are defined for the SDU production (BT RX egress), one for
SDU allocation as well as a callback for emitting a reassembled SDU.
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
Add numeric http status code to the response struct to allow for
easier processing by the caller. Textual status already exists.
Signed-off-by: Justin Morton <justin.morton@nordicsemi.no>
This commit puts the radio in sleep mode when the diagnostics are
stopped.
This fixes an assert on MAC code when `ot diag stop` command is
issued while `ot diag send` is still ongoing.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Replace all existing deprecated API with the recommended alternative.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
chan_send does restore buffer state in case of an error which is
different than how bt_l2cap_send_cb works as it does always unref in
case of an error.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes a regression introduced by
10841b9a14 as it did remove a call to
net_buf_ref which was used not only to keep a reference for resending
but also to prevent bt_l2cap_send_cb to unref the buffer in case it
fails.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In the time between a NODE_RX_TYPE_CONNECTION node is sent from LLL and
demuxed in ULL, an ADV role disable may be executed.
This makes the LLL data referenced in the node NULL/invald, and
ull_conn_setup would operate on invalid data.
This commit introduces a check in ADV disable to disallow the operation
(including conn invalidation), if a connection has been initiated.
To prevent pipeline-queued prepares from advertising after disable has
been initiated, set 'cancelled' flag for immediate signalling to LLL.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Zephyr socket subsystem has come a long way since initial experimental
alternative to internal Zephyr networking API. Its configuration also
mirrors the usual conservative approach, where a user needs to
explicitly enable options to get "more" features. And as an
experimental API, socket subsystem was initially developed as
namespaced API, where all functions/structures are prefixed with
"zsock_", and to get standard names, CONFIG_NET_SOCKETS_POSIX_NAMES
needs to be set (or alternatively, CONFIG_POSIX_API needs to be, which
enabled full POSIX subsys overall).
However, a few years later, sockets are the standard networking API,
and in majority of cases its used under the standard POSIX names.
Necessity to explicitly set an option to achieve this effects, and
confusion which results from it - are just unneeded chores for users.
So, switch CONFIG_NET_SOCKETS_POSIX_NAMES to be on by default (unless
CONFIG_POSIX_API is already defined). It still can be explicitly
disabled if needed (but usecases for that would be peculiar and rare).
Addresses #34165
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit fixes the build error: "error implementation of
timestamp_serialize() not provided for your CPU target" for
fvp_baser_aemv8r tests.
Signed-off-by: Henry Wang <Henry.Wang@arm.com>
This option enables BT_TICKER_SLOT_AGNOSTIC which eliminates
priorities and collision resolving in the ticker.
Event scheduling states are stored in the lll_hdr, and event priority
is passed from LLL implementation, and runtime priority calculated.
LLL implementation decides whether to program radio, start preemption
timer, and/or queue prepare in the prepare pipeline.
Event arbitration is made possible via the common LLL, but not yet
implemented in Nordic LLL.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Priority in the legacy stack has been unused and "work in progress" for
some time. With this commit, the priority passing/handling is cleaned
up, preparing for the new JIT scheduling priority handling.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Split lll_prepare and lll_resume from Nordic LLL to common file for
reuse by all vendors. The split also supports new JIT Scheduling by
defining a common place to calculate event prepare priority.
The module may also house other common parts of the LLL currently
re-implemented identically by vendors.
Signed-off-by: Morten Priess <mtpr@oticon.com>
The ticker 'force' flag is propagated via the ticker elapsed callback,
in order to provide necessary information for collision resolving in the
link layer.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Added config BT_TICKER_SLOT_AGNOSTIC which configures the ticker in
a "slot agnostic" mode, in which no collision resolving or slot
reservation is possible or used. In this mode, the ticker acts as a
simple timer.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Renamed to BT_TICKER_LOW_LAT in ticker, and changed selected
conditionally compiled code to use IS_DEFINED macro.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Replace k_work_cancel_delayable() with k_work_cancel_delayable_sync()
to make sure that the submitted work becomes idle before accessing
sensitive data.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit implements the secondary service
Audio Input Control Service (AICS) server and client.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Both operands of an operator in which the usual arithmetic
conversions are performed shall have the same essential
type category.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Move the LLL done event handling from ULL to LLL, this
reduces CPU utilization and reduces overhead between radio
events.
Fixes#21993.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Defer the event early abort so that lll_done does not get
recursively invoked when called inside prepare callback.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There is a race between the pipeline enqueue by the ULL
context when processing the LLL done event, and the
pipeline queue by the ticker timeout for a new radio
event. This caused an already enqueued event prepare to be
placed after the newly arrived request to enqueue a prepare
by ticker timeout.
Fix this race by placing the new prepare in the pipeline
instead of starting the event, when ULL is still processing
the LLL done event.
As ticker timeout and ULL processing of LLL done event are
in the same ULL_HIGH context, the pipeline handling is safe
with the order of prepares maintained correctly.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Commit d6c34c4644 changed the behavior
slightly but didn't update the documentation. The callback will now be
reset to NULL once the key is generated. Calling bt_pub_key_gen()
multiple times before the key is finished would result in creation of an
infinite loop. This could happen when an application calls mesh_init()
and mesh_reset() in quick succession. Clarify the behavior of the API in
the documentation.
Also passing a NULL argument would result in an undefined behavior, so
add a check to match the behavior described in documentation.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Change to use the BT_ATT_FIRST_ATTTRIBUTE_HANDLE and
BT_ATT_LAST_ATTTRIBUTE_HANDLE instead of the literal values where
applicable.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_iso_chan_disconnected assumes a CIS, but was
also used for BIS, so whenever it was called it attempted
to get a non-existing ACL connection.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The implementation of blocking calls is common for all the client
models.
This change reduces the code duplication by introducing new API that
helps to manage acknowledged messages.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The k_mem_slab_init() calls create_free_list() which checks
the slab block alignment. Noticed with Intel ehl_crb board,
which is 64-bit architecture, that the k_mem_slab_init() fails
because the log_strdup_buf items were not aligned properly.
This commit adds the alignment requirement to log_strdup_buf so
that the elements are alignment properly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The check for NULL was on the pointer to the pointer,
rather than the pointer. The pointer of the pointer would
always be non-null, but the pointer might not be.
Moved from using a pointer of a pointer to just a
pointer to make it easier to read and understand.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds two functions:
1) Lookup periodic adv sync object by address
2) Get information about a periodic adv sync object.
These can be useful for the application verify if there is already an
existing sync to an periodic advertiser.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
During debugging I got "Got unexpected PDU" errors because a new CF was
received before the state was set to ISOTP_TX_WAIT_FC in the send state
machine. Setting the state before printing the debug information fixes
the issue.
Signed-off-by: Martin Jäger <martin@libre.solar>
Fixed addressing as specified in ISO 15765-2 encodes the source and
target address of a device or function inside the CAN ID according to
SAE J1939.
In order to allow to receive incoming requests from different nodes,
the CAN filter mask has to be set such that the source address is
ignored in the receive context. In addition to that, flow control
frames have to be sent back to the actual source of the request, which
requires adjustments to the TX CAN ID.
This commit implements above features and thus allows ISO-TP to be
used in a network based on SAE J1939 or NMEA-2000.
Signed-off-by: Martin Jäger <martin@libre.solar>
ISO 15765-2 specifies that the CAN frame length for single frames and
the last consecutive frame may or may not be optimized to the actual
length of the PDU payload. The ISO-TP implementation should only
consider the information from the N_PCI section.
The previous implementation did not allow padding. With this commit,
padding is allowed by default and can even be required to be more
compliant to AUTOSAR standards.
Signed-off-by: Martin Jäger <martin@libre.solar>
This adds a new kconfig CONFIG_TIMING_FUNCTIONS_NEED_AT_BOOT so
that the timing subsystem can be initialized at boot, instead of
being #ifdef under thread runtime statistics. This will allow
other part of kernel and other subsystems to utilize the timing
functions.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Add discovery of standard descriptor values. This provides a shorthand
instead of doing a read by UUID, allowing the application discovery
procedure to re-use the discover parameters for simple descriptors.
Fixes: #21489
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Adds a parsing mechanism for Composition data page 0 in the Config
Client API, and uses it in the shell module to parse the incoming
composition data.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The first byte of the composition data status message is the returned
page index, not the status of the request. This is now reflected in the
API.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Make bluetooth.init tests for nRF platform pass again by adding ULL/LLL
stub functions, and fixing minor compile issues.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Adds a Kconfig option to set the minimum key size accepted
by this device. This can be used to e.g. enforce 128-bit keys.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Create net_l2_send() function which will be called by each L2
sending function so that we can catch all the network packets
that are being sent. Some L2 layers send things a bit differently,
so in those cases call the net_capture_send() directly by the L2
layer.
Add network packet capture call in receive side after the pkt has
been received by the RX queue handler. This avoids calling the
net_capture_send() from ISR context.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The "net mem" command did not print external net_pkt slabs
properly (the number of free net_pkt's was not printed).
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Show detailed information about network interface that is down,
only when user asks such information about one specific network
interface. This means that for "net iface" command only
"Interface is down." is printed but the command "net iface 1"
will print detailed information even if interface is down.
This helps to view the information and user does not need
to bring interface up to see the details.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add infrastructure to allow user to configure the system so that
all the network packets, that are sent to or received from a specific
network interface, are sent to remote system for analysis.
The captured network packets are placed as a payload in UDP packet,
which is then sent inside a tunnel to a remote host. The host can
then receive the packets and for example show them in wireshark.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add get/set helpers to store information whether the net_pkt
is captured already or not. This bit is used to detect capture
loop and avoid recursion.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Instead of forcing net_pkt_clone() use the tx_pkts slab, use
the same slab that was used when allocating the original net_pkt.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The IPIP tunnel capability bit helps to detect which network
interface supports IPIP tunneling.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Implement SO_BINDTODEVICE socket option which allows to bind an open
socket to a particular network interface. Once bound, the socket will
only send and receive packets through that interface.
For the TX path, simply avoid overwriting the interface pointer by
net_context_bind() in case it's already bound to an interface with an
option. For the RX path, drop the packet in case the connection handler
detects that the net_context associated with that connection is bound to
a different interface that the packet origin interface.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
An option has been added which can be passed to setsockopt
which allows the user to set & get the dtls handshake timeout,
either before first handshake or online.
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
Fix packet reordering in ATT when putting the host under high load.
In certain conditions a packet can be transmitted while there is
elements in the TX queue in bt_att_send. This means that the packet will
skip ahead in the TX queue leading to packet re-ordering.
Fix by always appending to the queue, and then initiate sending of the
HEAD of the queue.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This functions is being called across the tree, no reason why it should
not be a public API.
The current usage violates a few MISRA rules.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The size of ctx->rx_adu.data is not CONFIG_MODBUS_BUFFER_SIZE. Coverity
flagged the potential overwrite so just use sizeof().
Fixes#33789Fixes#33792Fixes#33818
Signed-off-by: David Leach <david.leach@nxp.com>
With these changes, dial up Zephyr application/driver can use
socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW) for creating
a socket for sending/receiving data to/from ppp net link, i.e.
packet is going to/from PPP L2.
Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
Introducing PPP dialup features to enable e.g. usage of nrf9160
based board as a dialup modem for transferring ip data over PPP
(e.g. windows dial up), i.e. usage of Zephyr PPP as a server for
providing MTU/MRU, IP address and DNS addresses for a PC:
- PPP LCP MRU option (configurable)
- PPP server: IPCP ip and dns address peer options to enable
providing IP and DNS addresses for PPP peer.
Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
The specification states that the server can cancel observations "at any
moment, by sendinga GET request with Observe option=1, the LwM2M Server
cancancel an “Observe”operation on a specified Resource, or specified
Object Instance(s)."
It does not mention any token matching requirement, but RFC 7641 does.
The correct interpretation is not obvious. The EMQx LwM2M implementation
uses a new token for instance, which does not work with Zephyrs token
matching cancel-observe.
This commit introduces cancel-observe via path matching as a Kconfig
option. This could hypothetically introduce problems when we are
connected to multiple peers simultaneously, but since that is not likely
to be supported for a long time (if ever), this change should be fairly
uncontroversial since path matching is only used as a fallback.
Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
Commit 58a0ba6dbb removed the call to k_sched_unlock from
pm_system_resume() consequently the scheduler lock in
pm_power_state_force() was left unbalanced. Just fixing it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Split ARM and ARM64 architectures.
Details:
- CONFIG_ARM64 is decoupled from CONFIG_ARM (not a subset anymore)
- Arch and include AArch64 files are in a dedicated directory
(arch/arm64 and include/arch/arm64)
- AArch64 boards and SoC are moved to soc/arm64 and boards/arm64
- AArch64-specific DTS files are moved to dts/arm64
- The A72 support for the bcm_vk/viper board is moved in the
boards/bcm_vk/viper directory
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
Current implementation of poll prepare/update could end up busy looping
if `poll()` function was called before/during DTLS client handshake
(i. e. `poll()` called before an initial `send()`).
Fix this, by monitoring the handshake semaphore, already available in
the tls_context structure for DTLS client instead of underlying socket.
After the handshake is complete, switch to monitoring the underlying
socket instead.
For DTLS server this is not needed, since the handshake is initiated in
the `recv()` function, therefore any incoming data should trigger the
handshake.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fix the calculation of event delay when starting a radio
event. The calculation and check was incorrect causing
event abort when radio event was setup before the preempt
timeout by the lll_done when the next prepare was already
in the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When a CIS indication is received and CIG ticker is already started,
calculate the absolute time of the first subevent of the new CIS,
and validate the handle. This will allow the LLL prepare to see a new
valid CIS, and calculate the offset within the CIG event, where the new
CIS should start. This offset is then valid for all following events for
the duration of the CIS.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Add missing #if defined(CONFIG_BT_CTLR_DF_ADV_CTE_TX) statements
to fix build errors of Direction Finding code when
the CONFIG_BT_CTLR_DF_ADV_CTE_TX Kconfig entry is not set.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Enable possiblity to use debug pins for controller debugging
purposes with nrf52833dk_nrf52833 board.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Splits the file into radio_nrf5_ppi.h and radio_nrf5_dppi.h
and moves the nRF53 DPPI to radio_nrf5_dppi.h.
Signed-off-by: Aurora Sletnes Bjørlo <aurora.sletnes@nordicsemi.no>
Rewrite to use subscribe and publish functions for the
different peripherals. This will make it possible to test
the controller in a simulator.
Signed-off-by: Aurora Sletnes Bjørlo <aurora.sletnes@nordicsemi.no>
The ID validation check would always fail with IDs less than
OTS_OBJ_ID_START_RANGE, where the intention was that it should
allow the OTS_OBJ_ID_DIR_LIST (0) value as well if
CONFIG_BT_OTS_DIR_LIST_OBJ was enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of defining the string, that will be reported by DFU
as a name for DFU target, in code, pick it from the DTS label that
will be the DFU target.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Alternative settings are determined by number of flash partitions
available for DFU from DTS.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
IPv6 source address selection procedure selected link-local address
for any muticast destination with other scope than mesh-local. It
was a cause of problems for broader multicast scopes like admin-, or
site-local. For such broader scopes source address must be at least
as broad as the scope of multicast destination.
This patch updates IPv6 source address selection procedure. Now
link-local address is selected only for link-local destinations,
including multicast destinations. For broader destination scope,
source address with broader scope is selected.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
The interrupt_util.h provides utils of trigger irq, now move them into
testsuite. All of the needed test cases can make use of them.
Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
Fix missing big_disconnect in hci_le_big_complete when the number of
BIS in the event is invalid.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Validate the big_handle before received from the controller before
using it as an array into the bigs array.
Discover by coverity: Insecure data handling (TAINTED_SCALAR)
Using tainted variable "big_handle" as an index into an array "bigs".
Cleanup state of BIG in pending or syncing state if it exists.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix parsing BIG handle which is just one octet as a two octet field,
which could have caused problems on big-endian systems.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor the BIG initialized atomic handling to use bits instead of a
single atomic.
This allows for more bit flags to be added.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix race conditional when create connection cancel is called
and actually a connection did get setup while initiator is
being stopped.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Conditional compile adv_addr which is only used by
controller when supporting initiator/central role.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the initiated bit flag into role specific union, so that
other role specific bit flags can share bit space in the LLL
context structure.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix flash driver sync regression introduced due to changed
default ULL_HIGH in the commit 30634334a8 ("Bluetooth:
controller: Fix ULL_HIGH priority to be lower than LLL").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated ticker implementation to return lazy value for a
ticker when enumerating active tickers with time
reservations.
This is required to find offsets and to use the lazy value
to correctly calculate event and payload counter values that
needs to be filled into SyncInfo and BigInfo structures.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Previously, a non null-terminated "string" could
be passed to z_impl_net_addr_pton if the string was
exactly `INET6_ADDRSTRLEN` long.
Signed-off-by: James Harris <james.harris@intel.com>
Fixing problem where k_fifo functions have been used to get/put
data from/info net buf, where documentation has been strictly
forbidding so.
Found, reported and solution suggested by jrhees-cae.
Fixes: #32579
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This patch removes scenario which was testing deprecated
API behaviors. Needed as As flash_write_protection_set() was
deprecated and became no-operation.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Removed two unneeded `if` statements. These statements had not
effect in function results.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
flash_write_protection_set() was deprecated.
This patch removes usage of it and the test case which was
testing deprecated API behaviors.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
All IPSO objects that utilized the non-standard timestamp extension now
implement their model in version 1.1, which contains the Timestamp
resource. As it's no longer needed to add timestamp in a non-standard
way, simply remove LWM2M_IPSO_TIMESTAMP_EXTENSIONS option.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Update IPSO Pressure Sensor object implementation to support object
model version 1.1.
Add missing optional resources for the object model version 1.0.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Some of the objects redefined reusable resources IDs, while others used
a common header which defines resource IDs. Unify the approach and use
the header in every object.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Each object now have to specify the object version it implements.
Based on this information the LwM2M engine can decide whether it's
needed to report the object version during Registration/Discovery
operations or not.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If the first network interface is down when the net config init
is run, then the IP addresses etc would be set to wrong network
interface. So when initializing the network, try to first find
a network interface that is auto started and use that to configure
IP addresses etc.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When printing network interface information print index or
index + pointer, so that the output is more user friendly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
As DAD is not done for point-to-point links, we can mark them
valid immediately. If this is not done, then the address will
never be picked as a source address to a sent packet.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Useful to know what flags are set for the network interface
so print them in the shell by the "net iface" command.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This can be used to implement tunneling, VPN etc. The virtual
interfaces can be chained together to support multilayer
network interfaces.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add a function that allow caller to create IPv4 header with
possibility to set various fields in the header.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Application can disable IPv4 or IPv6 later if those are not
needed nor used for a given network interface.
Fixes#14581
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
LL_CIS_IND starts a ticker for the created CIG, using the event_counter
and offset provided. Ticker generates callbacks to
lll_peripheral_iso_prepare. Event done with ISO (extra) type is demuxed
and done handled for CIG including ticker update with drift
compensation.
TODO: Handle multiple CISes as well as pause/resume and scheduling
latency.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Implemented LL_CIS_REQ/RSP and LL_CIS_IND handling to allow a central
to establish a CIS connection. Implementation is temporary, for
test/development purpose and should be re-implemented in the new LLCP
framework when ready.
Signed-off-by: Morten Priess <mtpr@oticon.com>
In the file gatt.c, GAP service contains the Device Name
characteristic. If writable, authentication and authorization may
be defined by a higher layer specification.It means that GATT
clients can write to device name GAP characteristic without
bonding. So we add a configuration for writable name without
bonding.
Signed-off-by: Jun Huang <huangjun6@xiaomi.com>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Adds a check for the BT_LE_FEAT_BIT_PER_ADV bit for each
function related to periodic advertising, including sync and
PAST transfer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
hwinfo_get_define_id returns and ssize_t with the size og the copied
id in case of success or negative value otherwise.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
hwinfo_get_define_id returns and ssize_t. Positive value with the
size of the copied id in success or a negative value in case
of error.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Fix undefined reference to bt_key_foreach when BT_LOG_SNIFFER_INFO has
been enabled but BT_SMP is not enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Configuration Client doesn't check the address in a received
response. This means that a response from any device will be accepted.
This change ensures that the correct response will be accepted.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Init function can be called multiple times (after each shell
reinitialization). It was missing reseting ring buffers and tx_busy
flag. When called once proper state of those variable where handled
by ram sections initialization.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Shell uninitialization is not synchronous, it is deferred to shell
thread so resources used by the shell (e.g. transport resource like
uart) cannot be used until it is completed. Added callback which
notifies when all resources are released and shell is uninitialized.
Callback is called from shell thread just before it is aborted.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The bootutil_public.h, as a part of mcuboot interface, has been
providing the same definitions as mcuboot_priv.h
The commit removed the redundancy.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Move ptp_clock.h out of the top level include/ dir into
include/drivers/ptp_clock.h and deprecated the old location.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
In modes where string duplication is not used, the code is
still compiled. On some compilers it was failing due to calling
strncpy which will do nothing because n is 0. Increase
CONFIG_LOG_STRDUP_MAX_STRING to 2 to ensure that n is 1 in that
case
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add Z_SHELL_SET_FLAG_ATOMIC macro to use technique from
shell_process() to atomically set and return the previous
value.
Change all void z_flag_*_set() functions to bool z_flag_*_set()
and use macro to return previous value after setting.
Modify shell_process() to use this modified z_flag_processing_set()
function.
Reorder flags to keep last_nl on byte boundary.
Add public setters for insert_mode, echo, and mode_delete for
completeness.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
Add flag to shell_flags to control echo as obscure
character (for passwords) or not. Add setter and getter
functions. Modify shell echo to use this flag if set.
Also add public setter for color mode and obscure mode.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
Fix bluetooth audio compilation issue when BT_AUDIO is enabled but
no Bluetooth host services has been enabled.
This leads to an empty library file.
Instead of creating a new library for audio add the sources to the
parent library, similar to how bluetooth services are added.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
VOCS does not support the write long procedure, and thus
should not accept any offset in write requests.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds bt_conn_iso function to safely access the struct bt_conn_iso
within a bt_conn.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Channel direction was actually a source of confusion since the spec does
actually define the data path direction from controller point of view
meaning input actually means transmit and output receive, also direction
can be configured with different QoS settings.
To make these APIs less confusing and allow QoS to be configured
independently they are now split into RX (receiving) and TX
(transmission) settings including its data path.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
CHECKIF is preferred as it handles full runtime error handling in
addition to just asserts.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes bt_iso_cleanup when there are still channels bound to the
ACL connection.
On top of it introduce bt_iso_chan_unbind which can be used to unbind
channels and thus release the reference to the ACL connection if that
has not been disconnected in which case the channels are unbind
automatically.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When the channel has just been bound but is not connected yet there is
no need to send any command over the air but the disconnected callback
shall still be called in order to notify the channel owner that it has
reached disconnected state.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When initiating a disconnection conn_disconnect would be called to send
HCI_Disconnect but the controller may be quick enough to send Disconnect
Complete event before setting BT_CONN_DISCONNECT which will then cause
the invalid transition from BT_CONN_DISCONNECTED to BT_CONN_DISCONNECT
and the connection won't be freed properly.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes a regression introduced by 4350021f09 which prevents
references to be properly release when there is an ISO connection.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net_eth_carrier_on() and net_eth_carrier_off() call k_work_init() on
work item that can be pending or still be processed in another thread.
This results in undefined behavior.
Initialize work item once and use an atomic flag to switch between
up/down carrier state. Submit work to workqueue whenever up/down carrier
state changes, so that last state is always properly propagated to
network interface layer.
While at it, save network interface pointer during ethernet context
initialization, so that is becomes static (and thread-safe) during whole
ethernet context lifetime.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
net_ppp_carrier_on() and net_ppp_carrier_off() call k_work_init() on
work item that can be pending or still be processed in another thread.
This results in undefined behavior.
Initialize work item once and use an atomic flag to switch between
up/down carrier state. Submit work to workqueue whenever up/down carrier
state changes, so that last state is always properly propagated to
network interface layer.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Zephyr already has a directory for storage API relevant headers.
Move disk_access.h header to include/storage where it fits better
structurally.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The files disk_access_usdhc.c, disk_access_spi_sdhc.c,
disk_access_stm32_sdmmc.c, disk_access_ram.c and
disk_access_flash.c are actually drivers for block devices and SD/MMC
controllers. This patch moves this drivers to drivers/disk and
reworks the configuration so that the drivers are selected when
the corresponding node is enabled.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Without this fix, ztest_set_assert_valid() can only be used when
CONFIG_ZTEST_FATAL_HOOK is set.
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
Remove legacy TCP stack as it is replaced by the new TCP2 stack.
The TCP2 stack has been the default stack since 2.4 release.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit implements the secondary service
Volume Offset Control Service (VOCS) server and client.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added recovery for case when log file was lost somehow.
Back-end will try to create new file if possible.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
New backend is based on littleFS. After init, there is created new file
with continuous numeration. When max size of file is reached, system
creates another one. File size is limited by Kconfig option.
There is possibility to overwrite old files or drop new ones.
FS backend logging to file if the FS location is available.
Otherwise log messages are drooped.
User can also change the name of log files.
Signed-off-by: Mateusz Syc <Mateusz.Syc@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <Andrzej.Puzdrowski@nordicsemi.no>
Currently notification about exiting an idle state is sent before
post_ops and with interruptions locked. Change it to be sent after
exit_pos_ops callback be called.
Unfortunately it is not possible to just change the order these
functions are called since the idle thread can be scheduled out just
after irqs be unlocked and before has the chance to send the
notification, so we are locking the scheduler and unlocking it only
after the notification be sent.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The kernel expects irqs be unlocked after this function be called.
Add it to the weak function in case of the SoC or application has not
implemented it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Allow callers to wait for an arbitrary amount of time, instead of always
waiting for a compile-time fixed period.
Signed-off-by: Josh Gao <josh@jmgao.dev>
This feature predated the tickless kernel and has been in legacy mode
for a while. We now have no drivers or systems that do not support
tickless, so remove this option and cleanup the code to only use
tickless.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This is another API that is being used in all timer drivers and is not
internal to the clock subsystem. Remove the leading z_ and make promote
it to a cross-subsystem API.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The clock/timer APIs are not application facing APIs, however, similar
to arch_ and a few other APIs they are available to implement drivers
and add support for new hardware and are documented and available to be
used outside of the clock/kernel subsystems.
Remove the leading z_ and provide them as clock_* APIs for someone
writing a new timer driver to use.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Let the core call the modbus_tx_adu() to make
the process more comprehensible.
Move tx-wait-for-rx handling outside of client code.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Prefix internal functions and structs with modbus_.
Use unit_id consistently instead of node_addr.
Fix mbm_ remainder and rename to mbc_.
Rename struct modbus_frame to modbus_adu since
ADU is closer to what the structure represents.
Let the compiler/linker do the job and
remove ifdef around mbc_validate_fc03fp_response().
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add function to get Modbus RTU interface index according
to interface name. This can be used to clearly identify
interfaces in the application.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add support to control DE/nRE RS-485 transceiver signals
over GPIO pins. Useful if the UART controller does not
support RS-485 mode.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add MODBUS RTU (over serial line) subsystem.
MODBUS RTU implementation supports booth server and
client roles. Some components of the implementation are based
on the uC/Modbus stack, which was published under Apache license,
(https://github.com/SiliconLabs/uC-Modbus
fdd1218a28e313c1212fed5ed42e5c65d3056a2c).
Resolves: #2854
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
The SD Card Physical Layer specification states in Table 7-1
(in section 7.3.1.1) that the LSB of the 48 bit command must
be set to 1 to act as an 'end bit'.
Fixes#33479
Signed-off-by: Rich Barlow <rich@bennellick.com>
Kconfig option USB_HID_PROTOCOL_CODE does not allow to set
boot interface protocol code for specific HID device but
only to set the same value for all device.
Add new API function to allow the application to set
Protocol Code per device. Deprecate USB_HID_PROTOCOL_CODE option.
Fixes: #32778
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Fix control Tx buffer leak into data Tx pool that happens
after a cross-over control procedure response was paused due
to currently active encryption setup procedure, and a new
control Tx PDU in addition to the paused one is enqueued
thereafter.
When the control tx PDUs is resumed but not yet enqueued
towards the radio, if there is a new control Tx PDU enqueued
then the paused control Tx PDU is not set as the head of the
control PDUs in the Tx queue. This caused the paused control
Tx PDU to be associated with data Tx pool, hence causing the
incorrect release into data Tx pool.
Relates to the commit bff76b4cce ("Bluetooth: controller:
split: Fix control tx queue handling") and to the
commit 6991d09977 ("Bluetooth: controller: Fix control tx
queue handling").
Fixes#32898.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the redundant connection initiated check as the event
is closed on connection initiated and it is sufficient to
check in the prepare_cb function to abort any events in the
pipeline after the connection has been initiated.
Relates to commit 5ce5dc055e ("Bluetooth: controller:
Avoid race between ULL and LLL when initiating conn") and
commit 18f5fb99c1 ("Bluetooth: controller: Remove use of
lll_stop").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Building this file with CONFIG_COVERAGE=y and CONFIG_SHELL_LOG_BACKEND=n
fails on the llvm-clang compiler. Swapping the IS_ENABLED and
log_backend allows the compiler to optimize out the if block even with
coverage enabled.
Signed-off-by: Jeremy Bettis <jbettis@chromium.org>
Use the channel identifier calculation function in the
central and peripheral implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added function to calculate channel identifier value
required for Channel Selection Algorithm #2.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The payload of the Register/Register Update message is also formatted as
application/link-format. Therefore it's reasonable to reuse the new
content writer instead of filling the payload manually.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit adds a new content writer, application/link-format, which
can be used during the Discovery procedure, to fill the content of the
response payload.
Introducing this new content writer, which encapsulates some of the
details like attribute handling which is different for bootstrap/regular
discovery, allows to unify the discovery handler in the lwm2m_engine,
thus it's no longer needed to have spearate handler functions for
bootstrap/regular discovery.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
`.well-known/core` resource is described by the CoAP RFC as an optional
method of resource discovery. The LwM2M specification though makes no
mentionon about this mechanism and provides an alternative method of
resource discovery instead (Device Management Discover, sec 5.4.2, and
Bootstrap Discovery, sec 5.2.7.3).
Since LwM2M does not require to implement `.well-known/core` resource
and it complicates the existing Discovery mechanism (and likely cause a
security concern) remove its handling from the LwM2M implementation.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Introduce LwM2M engine helper functions that allows to work with LwM2M
attributes outside of lwm2m_engine.c.
This is a groundwork for application/lwm2m-format content writer.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There's no need to duplicate the linker section for each architecture.
Instead, move the section declaration to common-rom.ld.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The exported structures that were originally introduced for OpenOCD have
since then been reused for other debugger plugins, including PyOCD and
Segger J-Link.
Rename the Kconfig option and the implementation from openocd to debug
thread info, so that it reflects the fact that this is no longer
specifically tied to OpenOCD.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
A bunch of commands were missing from the bitmap in the Read Local
Supported Commands response. Add them accordingly.
Fixes#33324.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Ignore connection indications from peers that are already
connected. This is to bring the behavior of the controller in
accordance with [5.2, Vol 6, Part B, 4.5 Connection state]:
"If an advertiser receives a connection request from an initiator it
is already connected to, it shall ignore that request."
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Rename the peer's address in the advertising set struct from `id_addr`
to `peer_addr` to clarify what the address refers to.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
When recvfrom() was called with src_addr != NULL, then source address
was fetched from beginning of net_pkt. This works with native IP stack
obviously. However with offloaded IP stack there is no IP header, so
trying to parse missing IP header results in undefined behavior.
Check if network interface has offloaded IP stack. If positive, then
figure out if there is assigned remote address to network context on
which packet was received. Return this remote address, which SHOULD be
the source address of received packet. Otherwise, return an error.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Fix regression is central only builds when CONFIG_BT_PRIVACY and/or
CONFIG_BT_EXT_ADV is enabled, or the functions bt_id_reset or
bt_id_delete is called from application.
This resulted in build error for undefined functions
bt_le_ext_adv_foreach and bt_le_adv_lookup_legacy since the definition
for these functions are now only compiled in when CONFIG_BT_BROADCASTER
has been enabled.
Regression from:
53cea4719d
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix CONFIG_BT_HCI_ACL_DATA_SIZE default value set to 0 when data length
feature in the controller is not enabled. In this case the default value
will be set to 0 which is outside of the range specified for the option.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move access to volatile variable out of assertion to avoid warnings
about side effect in assertion.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Add hci_driver.h to include files in id.c to ensure that prototype for
bt_read_static_addr is visible. This fixes builds that define
CONFIG_BT_CTLR but not CONFIG_BT_HCI_VS_EXT.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
HID core implementation has support for Get/Set Idle requests and
on idle report processing. Basically it has little use.
Also, it has no users in the tree except samples/subsys/usb/hid,
which does not have it turned on.
There are several issues with the idle report implementation:
- Core calls hid_ops.on_idle callback with Report ID 0,
but this ID is reserved and should not be used.
Report descriptors do not use Report ID index zero.
- Calling hid_ops.on_idle with Report ID 0 cann only
be turned off by calling SetIdle(Duration = 0, Report ID = 0),
but not by SetIdle with Report ID not equal zero.
- GetIdle with Report Id not equal zero returns wrong
value after SetIdle(Duration = n, Report ID = 0)
- It may happen that hid_ops.on_idle is called for
different Report ID during one and the same SoF event.
But there can be only one hid_int_ep_write() during a frame.
This patch fixes listed issues and revises Get/Set Idle request,
and hid_sof_handler() implementation.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Moved the call to obj_id_to_index such that we can check for valid
ID before getting the index.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds a ots_obj_manager function that returns true if the object is
in the object manager, or false otherwise.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The directory listing object is an internal object which
content is the aggregation of all the metadata of all objects
(including the directory listing object itself). The client
can read this value to get a list of all objects with names,
lengths, and other metadata.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The order of Destination CIDs shall correspond the order of Source CIDs
including its amount so errors that don't result in all connection being
refused shall not break the order of CIDs.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
For errors that means all connections have been refused there is no need
to add dcids since none will be valid.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When receiving L2CAP_CREDIT_BASED_CONNECTION_REQ the remote may request
more channels than allowed so this checks if amount of channel surpasses
the maximum channels (5) and return an error.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Adds a Proxy callback structure with a callback for Node ID enable and
disable. This API follows the Friend and LPN API pattern in mesh/main.h,
and can be expanded with more callbacks later.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix an assertion when disabling Extended Advertising with
auxiliary PDUs. Stop the auxiliary PDU scheduling after the
primary PDU scheduling is stopped first. This will avoid the
assertion caused due to a search for a stopped auxiliary PDU
offset by the primary PDU scheduling that is being stopped.
Fixes#32866.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When using `OPENTHREAD_ECDSA` deterministic variant has to be
enabled after some OpenThread changes. Also generic public key
functions are required.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Add locking when accessing interface list and the DHCPv4 config
struct that is found in net_if.
Fixes#33348
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
We need to do a few things differently if we are to support
a virtual memory map, i.e. CONFIG_MMU where CONFIG_KERNEL_VM_BASE
is not the same as CONFIG_SRAM_BASE_ADDRESS.
- All sections must be specified with a VMA and LMA, where
VMA is the virtual address and LMA is the physical memory
location.
- All sections must be specified with ALIGN_WITH_INPUT to
keep VMAs and LMAs synchronized
To do this, the existing linker macros need some adjustment:
- GROUP_LINK_IN undefined when CONFIG_KERNEL_VM_BASE is not
the same as CONFIG_SRAM_BASE_ADDRESS.
- New macro GROUP_ROM_LINK_IN for text/rodata sections
- New macro GROUP_NOLOAD_LINK_IN for bss/noinit sections
- Implicit ALIGN_WITH_INPUT for all sections
GROUP_FOLLOWS_AT is unused anywhere in the kernel for years
now and has been removed.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Replace a development assertion in the implementation of
Connection Parameter Request Procedure with an internal
comment and handle transaction violation be ignoring the
PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the leak of node rx buffer used to generate the
connection complete and CSA#2 event introduced in the
commit 4a5f263e5a ("Bluetooth: controller: split: Validate
chan map and hop value") and the
commit 94d5f0854e ("Bluetooth: controller: fixing error
re. all zero chmap in conn-ind").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Switch to the new API for delayed work related to DNS queries.
In the previous solution it was assumed that the work item could be
immediately cancelled at the point the query slot was released. This
is not true. We need a secondary condition to record the fact that
the query was completed while the work item was still pending, and an
additional check to detect when the work item completed and the slot
reclaimed.
Also annotate functions to indicate when they require the lock on
query content to be held, add some helpers that abstract core
operations like invoking a callback or releasing a query slot, and fix
some more cases where query slot content was accessed outside of the
new lock infrastructure.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Instead of silently closing the link we should send a Link Close message
three times before resetting provisioning state.
From Mesh Profile Specification v1.0.1.:
```
5.3.1.4.3 Link Close message
The Link Close message is used to close a link.
```
```
5.3.2 Link Establishment procedure
The device shall start the link timer, set to 60 seconds, when the link
is open. When the link timer expires, then the device shall close the
link.
```
```
5.3.3 Generic Provisioning behavior
If the sender does not receive a Transaction Acknowledgment message
within 30 seconds after sending the first message in a transaction,
the sender shall cancel the transaction, cancel the provisioning
process and close the link.
```
From Mesh Profile Test Specification p6:
```
MESH/PVNR/PBADV/BV-01-C
Test Procedure:
[...]
6. The IUT is induced to send a Link Close message with the Reason field
set to 0x02 to terminate the link. The message is sent at least three
times to ensure the message is received by the Lower Tester.
```
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Refactor out the BR/EDR handling from hci_core.c to its own source file
in br.c.
BR/EDR consists of inquiry and discovery roles in addition to
initialization. SSP is still kept separate.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Align the SSP HCI event handlers with the rest of the functions in using
the bt_ prefix. In order to avoid name conflict with the HCI struct
definitions the infix _evt_ has been dropped.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix compilation error with BR/EDR is enabled but the feature
CONFIG_BT_KEYS_OVERWRITE_OLDEST is disabled.
This caused compilation error because the field aging_counter is not
defined in the keys struct.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor out the advertiser roles handling from hci_core.c to its own
source file in adv.c.
Advertising roles consists of legacy and extended advertiser, and
periodic advertiser.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor out the scan roles handling from hci_core.c to its own source
file in scan.c.
Scan roles consists of regular scanning and synchronization to
periodic advertiser.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Don't include checks for advertiser is enabled when the broadcaster role
is not enabled. This makes it possible to have bt_le_ext_adv_foreach
be excluded from the compilation.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor out the identity handling from hci_core to its own source file
in id.c
Identity consistes of managing the identities of the device, the privacy
feature which hides the identities. And handling of the identity
resolving list in the controller, needed to support privacy-enabled
remote devices.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor the code so that bt_adv_lookup_legacy is always called after
the IS_ENABLED(CONFIG_BT_BROADCASTER) configuration has been checked and
the code path will be excluded.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor command state state handling to one function.
When setting state outside of hci_core the cmd macro is not available,
so in order to assign the buf pointer to state the function is needed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
There was no close method implemented for AF_PACKET type
sockets. This meant that calling close() on packet socket
caused NULL pointer access.
This will allow #32949 issue to work properly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
OpenThread UART tx callback has been processed even if it was not
triggered by OpenThread otPlatUartSend function.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
This new subsystem can be used to supervise individual threads. It
is based on a regularly updated kernel timer, whose ISR is never
actually called in regular system operation.
An existing hardware watchdog can be used as an optional fallback if
the task watchdog itself gets stuck.
Signed-off-by: Martin Jäger <martin@libre.solar>
Some devices may use different reference than cpu clock. Add
support for using swo-ref-frequency property when present.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Change fixes an issue related to data access out of array bounds and
suppresses compiler warning.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Implement MSG_WAITALL flag for stream sockets. Setting this flag on
`recv()` call will make it wait until the requested amount of data is
received.
In case both, MSG_WAITALL all is set and SO_RCVTIMEO option configured
on a socket, follow the Linux behavior, i. e. when the requested amount
of data is not received until the timeout expires, return the data
received so far w/o an error.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add the option CONFIG_BT_HCI_ACL_DATA_SIZE which allows the user
to configure the max HCI ACL data payload. This is needed for platorms
where the BLE LL, HCI uart and host run on three different cores.
Fixes: #30441
Signed-off-by: Johan Stridkvist <johan.stridkvist@nordicsemi.no>
Overwrite the existing bond when the IRK of the existing bond could not
resolve the RPA of the peer. This would happen if the peer has deleted
the bond and replaced the IRK that was used.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor update_keys_check helper function to operate on input keys
input. This allows the function to be re-used on a keys structure that
is not the current connection keys.
This also avoids the helper function changing the connection state.
The conn->le.keys pointer should at this point always have been
assigned, as central when sending the pairing request, and as peripheral
when receiving the pairing request at the very latest.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Health Fast Period Divisor is stored within
the model publish parameters on the access layer.
The opposite part for divisor restoring has been missed.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Adds the const qualifier to the internal api for adding and removing
virtual addresses, to allow them to accept const hardcoded values in
tests.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Moves the debug log printing the transport packet metadata to after the
keys are resolved, so that the subnet pointer is valid.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Adds a "polled" function to the friend callback structure, that gets
called every time the friend receives a poll message. The polled
callback is called before the establish callback, to match the LPN
behavior.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
If there is no timeout, the connect will timeout immediately
and the connection is not established.
Fixes#33185
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add execution time for testing result of each ztest testcase as:
START - test_sem_multi_take_timeout_diff_sem
PASS - test_sem_multi_take_timeout_diff_sem in 2.54 seconds
Fix#32137.
Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
The SCA (sca) field of bt_iso_chan_qos did not give much
information about the expected values or what they meant,
nor any information about what the value perhaps should be.
Updated the description and the ISO shell.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
To prevent the transport layer from accepting duplicate or out of order
segmented messages, add an RPL-like check for the SeqAuth of the
segmented messages when their context is allocated. This prevents
duplicate receives of the same segmented messages in the case where a
single source address sends two segmented messages in parallel (to two
different addresses):
Previously, when receiving two segmented messages, the first message
would go through to the access layer, then the second. Then, if the
transport layer received any repeated segments for the first message, it
would fail to identify the SeqAuth as old, as all its segments were of
new sequence numbers, and the "already complete SDU" check would only
look at the second message. Thus, the segmented message got processed
again and passed to the access layer, even though it was a duplicate.
To solve this, we need a mechanism like RPL, but only for the segmented
messages' SeqAuth. We cannot re-use the actual RPL mechanism, as it
can't support the scenario provoked by the "blocking tx" mechanism in
transport. This mechanism allocates the SeqAuth when the message is
first passed to the transport layer. The ongoing message that caused the
block would keep sending segments with higher sequence numbers than
the blocked message got, which will cause the blocked message to fail
the RPL check.
This patch adds a parallel SeqAuth mechanism to the RPL module, which
only deals with the SeqAuth of the segmented messages. This list gets
checked when the segmented message is first allocated, in the same
manner as the general RPL mechanism. The storage gets hooked into the
RPL mechanism, by adding a separate seg field to each RPL entry.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
DHCPv4 client code needs to know information when network
interfaces are going down and up. So make sure that network
management config options are enabled in that case.
Fixes#33137
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When Extended Advertising terminated due to duration or
maximum number of events, the auxiliary PDU scheduling
is now correctly stopped.
Fixes#31254.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add option to disable validation callback support by setting the
validation buffer size to 0, which allows to save some memory in case
it's not needed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add a data validation callback to the resource structure, which can be
registered by an application. It allows to verify the data before
actually modifying the resource data.
If the callback is registered for a resource, the data is decoded into a
temporary buffer first, and only copied into the actual resource buffer
if the validation is successfull. If no validation is required (and thus
no callback registered) the resource value is decoded directly into the
resource buffer, as it used to be.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Mention that it's "data offset" in 32-bit words. Helpful when doing
code review and using search for "th_off".
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Replace the legacy delayed work API with the new delayable work API.
Avoid cancelling work and manually notifying when the subscription is
disabled; instead allow the work item to do this.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Replace the legacy delayed work API with the new delayable work API.
Use a zero period as a flag value to ensure that the work handler is a
no-op of the publish operation is disabled.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Switch to new work API, taking advantage of the difference between
schedule and reschedule to force an update if the new deadline is
sooner, and retain any previous deadline (or use the new deadline) if
it isn't. Do not leave a path out that could, due to races, fail to
schedule necessary work.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
A previous check and return for (maxlen <= 0) makes manlen at least 1 so
checks for (maxlen < 1) would never evaluate to true. Remove these
checks and merge those cases into one.
CID: 215392
Fixes: #33092
Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
If CONFIG_NET_TCP_ISN_RFC6528 is disabled, then mbedtls include
files are not available so check this.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Switch to new work API. Avoid a racy cancel by allowing the work
handler to deal with an immediate off when the time remaining changes
to zero.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Previously, a racing write to the provided metadata could result
in up to CONFIG_LOG_STRDUP_MAX_STRING-2 bytes after the
end of user-accessible memory being leaked into the strdup pool
or the resulting log.
For now, explicitly copy the metadata string. In an ideal world
this could directly copy from userspace into the strdup buffer, but
this obviously only works if strdup is enabled.
Signed-off-by: James Harris <james.harris@intel.com>
Verify the result of option encoding while forming Deregister message
instead of silently ignoring it.
Coverity ID: 215373
Fixes#33096
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Added initial support for BIS (broadcast ISO stream), which
adds support for creating BISes as both broadcaster and receiver,
as well as managing and creating BIGs.
Extends PA sync to handle BIGInfo adveritising reports.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If CONFIG_LOG_IMMEDIATE=n, go to panic mode with LOG_PANIC() so full
coredump is logged.
Add missing log_strdup() call.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
Calculate Initial Sequence Number (ISN) as described in RFC 6528
https://tools.ietf.org/html/rfc6528
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
k_work_pending is now called k_work_is_pending.
These two uses are correct assuming the functions that invoke them are
not involved in race conditions: that the work is not pending is an
allowed condition for modifying state that will be used by the work
handler.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The error code from gatt_service_register is being ignored to ensure
that repeated actions still complete. Do this explicitly by adding
(void) casts, resolving coverity warnings on accidental error code
ignores.
Fixes#33051.
Fixes#33074.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
If CONFIG_BT_MESH_SEQ_STORE_RATE is 1, the check in store_seq can be
reduced to a simple if (false), and the modulo code does not need to be
included in the build.
Fixes#33036.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Moves the if !(pub) check to happen before it gets used in the
initialization of the message context in bt_mesh_model_publish.
Fixes#5116.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Include virtual label's pending_store function in the LABEL_COUNT > 0
compile guard to avoid including dead iteration code in the compilation.
Fixes#32928.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Check that the assigned subnet hasn't been removed in heartbeat_send to
avoid potential NULL defererence in transport's ctl_send.
Fixes#32907.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Sometimes it is hard to tell which instance of a thread is which
in the printed list, based solely on the name (if present) and
the k_thread pointer, so also print the thread entry fn pointer.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
Added comments to explain the re-use of allocated same
connection context to both 1M and coded PHY scanning context
when both PHY is enabled for initiating connection.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Initial work in progress implementation of Create Connection
Cancel for Extended connection initiation.
Adds implementation to teardown connection initiated at ULL
layer and gracefully release allocated resources.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The address pointer cannot be null at this point so remove
the checks.
Coverity-CID: 219595
Fixes#33071
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
New power states have more granularity than deep sleep and sleep
states. Just get rid of this and keep the same behavior for now.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Currently the power subsys is sending notifications about power state
changes before doing device pm. If one device fails to low power or
suspend the system never goes to an idle state. Change to send
notifications just before call SoC to suspend and avoid misleading
information.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This function is useless and the state variable that it was
controlling is also not necessary because the same logic is being
handled by the variable post_ops_done.\
This reasonably simplifies idle thread logic.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
There is no need for this function. This function is called only in
one place and the code can be moved to the function that was calling
it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
pm_power_state_force had two different behavior, if
CONFIG_PM_DIRECT_FORCE_MODE was enabled this function immediately
calls pm_system_suspend() without wait the idle thread. Without this
option enabled, this function will wait for the idle thread run but
will use the given power state instead of asking the policy manager.
The problem in both cases is that the process involves handling
devices and the way that was implemented if at least one device failed
to go to low power or suspended the system power state would not
change / be forced.
This commit simplifies this API removing the conditional behavior
since it is not clear the need for that and effectively, and
immediately, forces the system to go to the given state without
bother with devices.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The PRMsg service and backend had hardcoded and incorrectly named log
level. Created the Kconfig options for configuring log level of this
module.
Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
Use an "initiated" flag in the lll_conn struct to guard the processing
of PDUs related to connection initiation (CONNECT_IND,
AUX_CONNECT_RSP). This avoids races between ULL and LLL when creating
a connection.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
check_interface resets the counter semaphore, but
net_config_init_by_iface first calls check_interface, then inits
the semaphore.
Initialize the semaphore up front to allow the k_sem_reset call
to work properly.
Signed-off-by: James Harris <james.harris@intel.com>
If Zephyr is running on a coprocessor we might lack I/O
such as uart or usb to output tracing datas but we might
have gigabytes of RAM available.
This patch allows to output trace datas to a ram buffer, which then
may be retrieved using gdb.
e.g:
(gdb) dump binary memory channel0_0 <ram_tracing_start> \
<ram_tracing_end>
Signed-off-by: Julien Massot <julien.massot@iot.bzh>
Currently there is no way to distinguish between a caller
explicitly asking for a semaphore with a limit that
happens to be `UINT_MAX` and a semaphore that just
has a limit "as large as possible".
Add `K_SEM_MAX_LIMIT`, currently defined to `UINT_MAX`, and akin
to `K_FOREVER` versus just passing some very large wait time.
In addition, the `k_sem_*` APIs were type-confused, where
the internal data structure was `uint32_t`, but the APIs took
and returned `unsigned int`. This changes the underlying data
structure to also use `unsigned int`, as changing the APIs
would be a (potentially) breaking change.
These changes are backwards-compatible, but it is strongly suggested
to take a quick scan for `k_sem_init` and `K_SEM_DEFINE` calls with
`UINT_MAX` (or `UINT32_MAX`) and replace them with `K_SEM_MAX_LIMIT`
where appropriate.
Signed-off-by: James Harris <james.harris@intel.com>
If a shell command is compiled out using SHELL_COND_CMD(),
a line for this command will still be printed but will
be blank. Change it so compiled out commands are not
listed as blank lines.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
Add NET_HEXDUMP_DBG/ERR/WARN/INFO macros, then use them for new
MQTT_HEXDUMP_TRC/ERR/WARN/INFO macros.
Log struct mqtt_utf8 using MQTT_HEXDUMP_TRC. One cannot safely log
mqtt_utf8 strings due to no guarantee of a NULL terminator being
present. Also, logging without log_strdup() as if it were a NULL
terminated string asserts when CONFIG_LOG_IMMEDIATE=n. This solves
both issues.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
Any value passed to a function in <ctype.h> shall be
representable as an unsigned char or be the value EOF.
So changed type of variable to unsigned char.
Signed-off-by: Spoorthy Priya Yerabolu <spoorthy.priya.yerabolu@intel.com>
Uses of k_work_pending are to be replaced by k_work_is_pending which
conforms to current proposed naming guidelines.
Switch to the new function.
Also initialize the private work structure at build time, rather than
on each iteration (it is not permitted to invoke work API on an
uninitialized work item).
The implementation here is racy: that a work item is pending does not
mean changes since it was first submitted are guaranteed to be seen
when the work item begins (began) executing.
A better solution would be to have transmit_message be able to
determine whether there is unprocessed work. Then the work item can
be submitted unconditionally.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Uses of k_work_pending are to be replaced by k_work_is_pending which
conforms to current proposed naming guidelines.
Both uses in this file are fragile: that a work item is pending does
not mean changes since it was first submitted are guaranteed to be
seen when the work item begins (began) executing.
As long as this module is expected to be replaced by tcp2 it doesn't
seem worth trying to fix the logic, so just switch to the new function
name.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Checking whether a work item is pending before submitting it is racy:
the item may be finishing up in its handler, and essentially
completed, in which case chosing not to resubmit would leave work
unhandled.
In this case it appears very wrong, since the sole call site in
net_if.c has just initialized the work item, which is not permitted if
the work item is pending.
Remove the check.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The compiler generates a warning regarding a variable being used
w/o being initialized in certian configuration. According to the logic
that's not the case, so just add some initial value to the variable to
silence the compiler.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As network interface array size might be larger than the actual
network interface count, check this condition and ignore those
interfaces that are not in use.
We cannot know for certain how many network interfaces there
are at built time, as the total count is only available at runtime.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The network interface index is very useful info to see in
debug prints so add those to debug output.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we are sending a network packet and if the remote address
is not set in the context (which means that connect() has not
been called), then we must set the target network interface
to a proper value.
This is done so that when we select the local source address,
we might select the wrong interface if we have multiple network
interfaces in the system. In this case the packet would be always
assigned to first network interface regardless of the destination
address.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Improve default logging strdup buffer count and size.
The maximum string logged with Bluetooth is a 32-byte key in hex.
The strdup buffer is empty too often.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Log the security keys that the sniffer needs in order to sucessfully
decrypt the connection.
This option allows the sniffer to work in the cases where enabling
using the SMP debug keys is not wanted, either because it changes the
way the peer behaves or is denied by the peer.
It also enables the sniffer to decrypt a connection where the bond
already exists.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Convert allowed_cmds to an array of atomic_t of size 1.
This makes it future proof in case more commands are added.
Possibly silences coverity false positives on array vs singleton usage.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix some format warning in cfg_cli.c.
Fix use CID_VNAL as param when use vendor models.
This is a resubmission of PR (#30086)
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fixed some undesired or incorrect macros, which
can cause build error.
This is a resubmission of PR (#30086)
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Correct format errors, such as oob action 2-octers
should use 0x%04x, and action in prov capalilities pdu
big-ending. When every call `bt_mesh_auth_method_set<*>`
should also clear auth value, otherwise will case confirm
failed.
Provisioner role expect peer public key should be sent
immediately, instead of requiring ACK. After all, ACK may
be lost, and the other device’s public key will be sent
over, and provisioning procedure will be failed..
This is a resubmission of PR (#30086)
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The cmd_write and cmd_ctunc have been opening/creating file for
read/write operation.
The commit changes cmd_write to open/create file for write only,
and cmd_trunc to only open file for write.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Now that the old API has been reimplemented with the new API remove
the old implementation and its tests.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The tcp2 infrastructure is using the legacy delayed work API, and
relies heavily on the transient state indicated by an estimate of
delayed time remaining to determine whether a delayed work item is
still active. While the wrappers for this work in most cases, one use
is unsanctioned: directly accessing the fields of k_delayed_work
structure to satisfy the calling parameters of the handler when
invoked directly.
The chosen solution for this specific need in the new API is to use a
schedule (rather than reschedule) operation, which leaves any previous
timer unchanged but allows immediate submission if the work is idle.
This changes behavior in that the resend is delegated to the work
queue, rather than done immediately. The former behavior can be
supported by further refactoring that turns the work handler into a
wrapper around a function that takes a connection reference, and
invoking that here, while the handler invokes it after reconstructing
the connection from the contained work item.
For now put in a hack that also uses the non-public fields of the
delayed work structure to implement the required behavior. The
complete fix if this solution is used requires replacing all use of
k_delayed_work in this module with k_work_delayable, leveraging the
new functionality of the API to avoid having to guess about the true
state of a work item based on its transient timer or flag states.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This lets an application detect when a PPP connection fails to establish
or terminates, so that the connection can be reattempted (for example,
by setting carrier off and on).
Signed-off-by: Jim Paris <jim@jim.sh>
The stream_flash_buffered_write, when invoked to do flush write, will
attempt to write the tail bytes from the buffer, filling the required
minimal write block size with erase value bytes; after write it rewinds
the buffer offset, bytes_written, by number of the "filler bytes".
Doe to lack of return code processing from flash_sync call, two things
would happen to context in case of failure:
1) the ctx->bytes_written would be rewind pass the value it had before
function call as it gets decremented by "filler bytes" even if write
failed;
2) the ctx->buf_bytes offset would be accounting for added "filler
bytes" which should not be counted as data in buffer.
Proper processing of return code has been added to remove effects
described above.
Unit tests have been expended to cover the scenarios.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The stream_flash_buffered_write used to read byte from flash, in front
of the current buffer pointer, to obtain value of errased flash;
the code has been replaced with obtaining the value from flash
parameters.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit moves block that checks if flash_stream_ctx.buf_bytes
is non-zero out of CONFIG_STREAM_FLASH_ERASE specific code, as that is
universal check and is valid also for not CONFIG_STREAM_FLASH_ERASE
code.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The flash_sync function is able to call, if specified, write
verification callback to check whether data flash has been correctly
written to a flash. Part of that procedure is to read date back of
the flash and call the verification callback on the buffer;
in case if the read would fail, the flash_sync would return,
with an error code, without updating stream_flash_ctx.
The same logic should be applied to failed verification, but, due to
missing return, the stream_flash_ctx gets updated with probably
incorrectly written bytes added to total bytes_written and buf_bytes,
representing number of bytes awaiting in buffer, being zeroed.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The stream_flash_erase_page would update stream_flash_ctx member
last_erased_page_start_offset, to page offset it attempted to erase,
even if such operation failed.
The commit changes this behaviour so that in case of failure the
last_erased_page_start_offset would still hold previously, successfully,
erase page offset.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Move the ticker job_guard reset to after
ticker_job_compare_update, so that the ticks_current and
ticks_slot_previous are updated before ticker_worker gets
to execute. Without this fix, there is a possibility that
ticker_worker will use incorrect ticks_slot_previous and
ticks_current value under race conditions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ticker job to defer itself to avoid recursive
invocation to itself due to ticker interface calls from
inside the ticker operation callbacks.
The recursive use was exposed when using ticker stop
operation callback of stopping an auxiliary PDU to stop
the primary PDU scheduling as part of generation of
Advertising Terminate event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In case the endpoint string provided by the application is longer or
equal to CLIENT_EP_LEN - 1, the strncpy() function will not add the NULL
terminator. As the endpoint buffer is treated as a C-string in other
places in the code, make sure it's NULL terminated by adding NULL
explicitly at the end of the buffer.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Make sure query string used by the lwm2m_rd_client is large enough to
encode any query string that can be sent during bootstrap/registration.
As the maximum query string length is related to the endpoint name,
which is limited by `CONFIG_LWM2M_RD_CLIENT_ENDPOINT_NAME_MAX_LENGTH`,
make the query string corellated to the value of this config.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit adds to network shell set of basic commands for UDP
protocol to receive and send datagrams.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The cmd_read function uses fs_open with FS_O_CREATE | FS_O_RDWR flags
to open file it will only read; the flags has been changed
to FS_O_READ.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This functionality is is enabled by setting CONFIG_SHELL_GETOPT.
It is not active by default.
User can call following functions inside command handlers:
- shell_getopt - getopt function based on freebsd implementation
- shell_getopt_status_get - returns getopt status
Beware when getopt functionality is enabled shell will not parse
command handler to look for "-h" or "--help" options and print
help message automatically.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Shell will not "steal" by default "-h" and "--help" each time
help functions are enabled.
This change is necessary to implement and use the getopt library.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Check NULL value when we are trying to print link address
because the link address can be null.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
As the input string can be allocated from stack, we need to use
log_strdup() in net_pkt_hexdump() to print the extra string.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add a dependency on TEST_ARM_CORTEX_M switch, so it
only gets switched on when building tests, not samples,
as originally intended.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Remove inclusion of vendor specific internal LLL include
files in ULL source code.
Prefix `lll/` include file path to correctly include vendor
defined types and function implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Removed printk.h include from log_core.h.
Since LOG_PRINTK cannot be enabled with LOG_MINIMAL removed
support for both.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
usb_hid_descriptor struct is only used internally and
is not intended to be used by the USB HID device application.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add a callback to notify applications when the datarate has changed.
This allows applications to know when payload sizes have changed without
needing to call `lorawan_get_payload_sizes` before each transmission.
This also enables:
* Monitoring of network conditions on the device
* Determining if a network connection has been lost
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Keep track of the current network datarate when ADR is enabled.
The datarate can change in two circumstances. Firstly, the datarate may
change as a result of a command from the LoRaWAN server as the link
budget varies. Secondly, the datarate may be changed due to not
receiving an expected ADRACKReq response. This necessitates querying the
datarate on both packet reception and transmission to provide timely
notifications to the application.
Due to querying the default region datarate at startup and validating
manual datarate parameters, when ADR is not enabled the datarate will
never be different from the value provided to `lorawan_set_datarate`.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add a function to query the minimum possible datarate on the network.
This value may change over the lifetime of the connection as a result
of commands from the network server.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add the ability for applications to query the maximum size of packets
that can be sent. This must be dynamically queried as the sizes change
with datarate, region, and as MAC commands are added by the stack.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The default shell configuration has heavy flash and memory requirements,
requiring project maintainers to set many configuration options to "n"
to keep flash and memory requirements within reason.
This adds a new configuration option, CONFIG_SHELL_MINIMAL, which will
disable flash and memory heavy options by default, and allow project
maintainers to select/imply only the options they want.
On a quick test from an ARM board I'm working on, enabling this option
cut flash space requirements by ~8 KB, and memory requirements by ~1 KB.
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Allow NULL pointer to be passed to bt_id_get function so
that only count can be fetched.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There's a prompt to set the TX stack size, that's documented as an
advanced setting, but attempts to override it it are rejected unless
you add another setting that allows it to be change. Tell the user
how to make changes work.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Remove compilation warning caused by currently not used
hci_df_set_conn_cte_tx_param function.
Code is sorrounded by #ifdef CONFIG_BT_CTLR_DF_CONN_CTE_RSP.
The CONFIG_BT_CTLR_DF_CONN_CTE_RSP is changed to be disabled
by default (until complete implementation of the feature is
provided).
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Change dfe-ant-num propert name to dfe-antenna-num.
The change is conde to keep the same naming style
for all properies, like dfe-pdu-antenna property.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add initialization of GPIOs that are used for antenna switching.
GPIOs provided to DFE extension in Radio peripheral, to drive
antenna switching, should be initialized in GPIO peripheral beforehand.
The initialization is optional and may be disabled by Kconfig.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Antenna switching done by Radio with use of GPIOs provided in
PSEL.DFEGPIO registers. Registers were initialized once during
controller initialization.
At preparation of new radio event, Radio peripheral is powered
down and up to resset its registers. It is related with multi
protocol handling and possible leftovers in Radio registers.
Due to that, PSEL.DFEGPIO registers should be initialized
at the preparation of every event that will transmit
or receive CTE and run antenna switching.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Anternna switching should be disabled when CTE Rx is not supported
or disabled. Added missing dependency on BT_CTLR_DF_CTE_RX.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add missing declarations of functions that are compiled in when
CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY is selected
Add missing include of header file.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix duplicate include of lll_test.c file under the
unsupported ISR profiling feature in OpenISA port.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use `#if defined(...)` instead of `#if IS_ENABLED(..)` when
conditional compilation of definitions in source code.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit prepares supporting sdmmc on
stm32l4+ devices. When trying to compile the
sdmmc driver there is a compilation error
because `HAL_SDEx_DriveTransceiver_1_8V_Callback`
is not implemented. We solve this by compiling
also `sd_ex` in cube as this function is implemented
there as weak.
Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
We should verify that the buffer has sufficient data before attempting
to parse the SDU length field. If we get a too short packet just
disconnect the channel.
Fixes#32497
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix array overrun of client features bitset, where CF_BYTE_LAST was
incorrectly defined as 2 using module instead of divide.
Also fix additional bit-logic when number of bits would exceed a byte:
- Inner for loop iterates from 0 to number of bits on a single byte.
- Same bitmask used for all bytes.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This returns the available contingous space in the packet starting from
the current cursor position.
Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
Don't auto-update the device name in the advertising data as that
would clear any other scan-response data set by the application.
Document the behavior of the advertise with device name option
and the need to update data by the application to make sure
advertising data does not get cleared.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix endianness issue in reading CPF descriptor not converting from
native endianess to little-endian on the 'unit' and 'description'
fields.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use the definitions of UUID values instead of magic constants with
explanation in comment.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This makes cbprintf_nano.c much closer to the standard printf and
therefore more useful. The following are now implemented:
- right justification for everything (only for numbers previously)
- precision value for numbers, chars and strings
- width/precision passed as arguments with *
- "unlimited" padding length
- lower/uppercase hex output
- the #, + and ' ' flags are supported
And the code was heavily reworked to reduce its size as much as
possible to mitigate the size growth. Still, the binary resulting
from cbprintf_nano.c is now between 10% and 20% bigger depending on
the architecture. This is still far smaller than cbprintf_complete.c
which remains about twice as big on average even without FP support.
Many unit tests that were skipped with CONFIG_CBPRINTF_NANO are now
enabled, and a few more were added for good measure.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Check for associated Extended Advertising set to determine
whether Broadcast ISO Group instance has been already
created.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add association between extended advertising, periodic
advertising and broadcast ISO instance, so that attempts to
create and terminate BIG can detect error conditions.
Error conditions being, trying to create BIG without a valid
periodic advertising train, or terminating BIG without prior
creation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When ticker job is disabled inside radio events then all
advertising, scanning, and slave latency cancel ticker
operations will be deferred, requiring increased ticker
thread context operation queue count.
Relates to #32430.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Consistently use the internal BT_CTLR_ADV_SET value in the
controller's implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add missing offset_adjust filed to pdu_adv_sync_info.
Add handling of the field when sync_info is added to advertising PDU.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Avoid splitting lines when possible while keeping length below 100
chars. Some other minor style corrections.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
The use of a single error variable for RX and TX operations has
shown the OpenThread code to be asserting in some conditions.
This commit splits tx_rx_result into rx_result and tx_result
to avoid such cases.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
If the network interface is down when trying to send a message,
return -ENETDOWN as we cannot send a message in this case.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix the tertiary PDU and extended header length value after
the refactoring in the commit c8475b9a3e ("Bluetooth:
controller: ULL: enable TX of CTE with per. adv. PDU").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit fixes some edge cases when using net_bufs with reserved
bytes (headroom) as fragments of a net_pkt.
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
net_buf_max_len() provides the maximum number of bytes which can be put
behind the data pointer. This provides a save alternative to using the
size field of the net_buf structure directly, which does not take the
reserved bytes (headroom) into account.
This commit also replaces the usage of the size field in places where
size got used directly. Code has not been adjusted when it is easy to
recognise that the buffer does not have any reserved bytes, which is the
case after allocation or reset. Same goes for the faulty usage by
net_pkt as exposed by the last commit and begin fixed by a separate
commit.
Even though it would be cleaner, I decided to not rename the size field
to e.g. __buf_size in order to keep the amount of code changes low.
Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
The ASSERT order is backwards, where the shell->ctx is being accessed
before it is being checked as valid. Moving the check for the
shell->ctx to before the using it.
Signed-off-by: Dan Kalowsky <dkalowsky@amperecomputing.com>
Fix the order so that it reflects the actual initialization order,
rather than putting PRE_KERNEL initializations after APPLICATION.
Add SMP in the proper location.
Use the helper function to provide unique identifiers for "devices"
that don't have a device pointer (so don't have a name).
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Refactor the output of device list to use standard API to retrieve the
list of devices, and to always display a status rather than hiding
disabled/failed devices.
Add API to associate a distinct identifier with any "device" that does
not have a name.
Where a device has requires dependencies display the devices on which
it depends.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Move USB MSC configuration to its own Kconfig file.
Align with other class designations and rename
mass_storage.c to msc.c
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Rearrange the LL interface functions in the ll.h file to
group functions use by HCI separate from other buffer and
control flow related functions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the controller version define into ll_feat.h file to
keep the version number and featureset bitmaps together.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added 3 utility functions :
- lwm2m_engine_update_period_service() which updates the period of a
given service.
- lwm2m_engine_update_period_min_observer() which updates the
min_period_sec for a given observe node.
- lwm2m_engine_update_period_max_observer() which updates the
max_period_sec for a given observe node.
Signed-off-by: Thomas LE ROUX <thomas.leroux@smile.fr>
Move LLL header files for all roles to common folder. Move
vendor-specific content to internal header files, in particular ADV
buffer handling. Define the vendor-specific type lll_adv_pdu in a
separate header file lll_adv_pdu.h to avoid cyclic dependency when
moving ADV buffer handling to internal header file. Make sure all
internal header files are in vendor-specific folders.
The goal is to have a more consistent structure for LLL header files
and allow unconditional inclusion of non-internal LLL header files.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
* Added implementations of otPlatCAlloc and otPlatFree methods
necessary for the OpenThread in case of using EXTERNAL_HEAP.
* Added CONFIG_OPENTHREAD_DNSSD_SERVER option to allow enabling
OT_DNSS_SERVER feature.
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
Remove the depency on host emulation of ECC for the Use debug keys
option.
This allows the application to use debug keys without shifting the
ECC from the controller to the host, which could potentially alter
the behavior of the application and make debugging this way less useful.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor the ECC emulation setting the supported command bits in order
to group the supported commands together with the implementation of
these commands.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
In order to avoid stalling LLCP procedures blocking done event
processing, done events are now put in a separate memory queue,
and processed by own mayfly function.
This ensures prepare/done refcount balancing and prevents assertion
due to lack of done events.
Signed-off-by: Morten Priess <mtpr@oticon.com>
We need to make sure aux is cleared on reset, otherwise we may end up
with legacy advertising with aux.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Set #0 is used for legacy advertising when legacy HCI commands are used
and in such case it's possible to enable advertising without any prior
configuration. This means we should better always have PDUs in set #0
initialized with default empty data.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We should remove all advertising sets when resetting controller. It's
enough to just clear is_created flag for each set.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Removes the 3 byte padding at the end of each proxy connection's rx
buffer.
Fixes#18509.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
If user sets CONFIG_NUM_PREEMPT_PRIORITIES=0, then the priority
of the net_mgmt thread will be -1 which is the same as idle thread.
This will trigger assert in kernel as then the minimum coop priority
is -2 in this case. Remove the net_mgmt thread priority setting from
Kconfig file as it is low value and set the coop thread priority
the same way as other network threads are doing it.
Fixes#32375
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
zassert_within should also compare on equality instead
of only greater/lower.
example:
zassert_within(1,1,0); // should return true
zassert_within(1,2,1); // should return true
Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
This patch adds implementation of socket option used to get
protocol used for given socket (e.g. IPPROTO_TCP). This option
is not defined in POSIX, but it is Linux extension.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
This patch adds implementation of socket option used to get
type of given socket (e.g. SOCK_STREAM).
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
Convert from device_get_binding to DEVICE_DT_GET. In doing this we
no longer need the label in the devicetree node so we remove that.
Removed all __ASSERT_NO_MSG(clk) since we'll get a build error if
DEVICE_DT_GET cant be satisfied, and the clock control api's will
handle reporting if the device_is_ready.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add compilation guards for the feature_rsp_send function to avoid
compilation errors for some configurations.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
It was decided that the Bluetooth audio subsystem should
be in subsys/bluetooth/audio instead of subsys/bluetooth/host/audio.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove `OPENTHREAD_CONFIG_NCP_BUFFER_SIZE` define since it does not
exist in OpenThread.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Add support for ISO feature bits. This includes extending fields that
hold features to 64 bits to be able to handle the host-controlled
"Isochronous Channels" feature.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Remove support for the Musca-A board. This board is rarely used, few
are available and superceded by Musca-B and Musca-S.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Added Tx fragmentation implementation assertion to check
invalid offset use due to any memory corruptions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the vendor specific ticker resolution margin in the
central connection initiation offset calculation.
Related to commit 89ab68f242 ("bluetooth: controller:
Vendor specific ticker resolution margin").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the redundant advanced scheduling event margin used
while finding a free space between existing active central
connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the initial connection event length calculation to
when initiating connection so that initiator with advanced
scheduling to place central connections in a non-overlapping
timeline has the correct ticks slot value available.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If userspace is enabled, then the TLS context needs to be
made a NET_SOCKET kernel object. Without this the userspace
cannot access TLS sockets.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Provide the LoRaWAN stack with an optional callback to be
called whenever the battery level needs to be read.
In the case of callback not being provided, the LoRaWAN
stack will report 255 (battery level unavailable) as per
the LoRaWAN spec.
Signed-off-by: Kuba Sanak <contact@kuba.fyi>
Simplify pm subsystem removing PM_STATE_LOCK option. Constraints API is
small and is a key component of power subsystem.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Add checks to detect ACL data lengths greater than the
configured maximum Tx buffer size in the controller.
The Host should conform to the LE_ACL_Data_Packet_Length
returned by the LE Read Buffer Size command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Optimize LOW_LAT_ULL scheduling by avoiding redundant
rx_demux mayfly enqueue. Only schedule after checking for
node rx or tx ack presence in the memq.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the Subsystem defined BT_PER_ADV_SYNC_MAX Kconfig in the
controller implementation of Periodic Advertising Sync Sets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
A line of code was guarded by CONFIG_BT_L2CAP_TX_FRAG_COUNT instead
of CONFIG_BT_ISO_TX_FRAG_COUNT.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
ISO is a building block for BT_AUDIO but it is not only
useful for AUDIO, and as such should be possible to
enable without enabling BT_AUDIO.
This commit moves iso.c and iso_internal.h to the
host directory (from host/audio) and removes
the CMakeLists.txt.
The /audio directory is left intact for the Kconfig options
it provides, and as a directory for future BLE Audio
content.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit moves the BT_ISO to a common (host and controller)
Kconfig and fixes the ISO buffers in hci_raw.c
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add release of memory acquired for periodic advetising sync. set
when:
- advertising set is removed
- advertising parameters are changed and past PDU type was
extended advertising PDU
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove LL_ASSERT from functions that return latest advertising PDU.
The LL_ASSERT was raised in situation that there is no memory to
store unused PDUs memory in a pdu_free queue or extra_data_free queue
Those functions return NULL in such sitation. The returned value is
verified by callers by LL_ASSERT. That gives better context if lack
of memory issue issue occurs.
Besides that there was removed a LL_ASSERT from lll_adv_pdu_and_extra_-
data_alloc. The reasons is the same as above, to give better context
when the lack of memory issue occurs.
This function is used in ULL context (ll_adv_sync_ad_data_set).
If it returns NULL the caller will return BT_HCI_ERR_MEM_CAPACITY_-
EXCEEDED to Host.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add set of functions that will make possible to configure
radio Direction Finding Extension to transmit CTE for periodic
advertising.
Some of the new Radio API functions are provided as separate
functions changing the same Radio peripheral registers, e.g.
radio_df_mode_set_aoa, radio_df_mode_set_aod. This is done on
purpose and is related with lack of DFE in nrf52_bsim.
To avoid use of conditionally compiled constants to represent
e.g. CTE mode; separate functions were introduced.
Thanks to that DF unit tests are able to compile successfully
without changes in nrf52_bsim platform. Also if DFE is added
to nrf52_bsim there is no need to change the code until it is
desired.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The storage for extra data is required for implementation of
CTE transmission with periodic advertising.
Data required to transmit CTE correctly are compound of two parts:
- PDU field CTEInfo
- radio configuration to transmit actual constant tone at the end
of PDU.
Extra data is a storage required for radio configuration data.
Nevertheless it must be in compliance with content of CTEInfo field.
Because of that extra data is stored as part of lll_adv_pdu and
is double buffered like PDU memory.
Bluetooth 5.1 spec. allows to enable or disable CTE TX
and change CTE TX parameters when periodic advertising is
enabled. Besides that CTE TX settings may be set before periodic
advertising parameters are set. In such situation ll_adv_sync_set
may be not yet created.
To overcome these constraints ULL should store CTE TX
settings and forward them to LLL only when CTE TX is enabled.
Because of above reasons ULL stores CTE TX settings in ll_adv_set.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add Directin Finding related features:
- transmission of connectionless CTE,
- antenna switching during CTE transmission (AoD),
to list of features supported by controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove support for nRF5340 PDK in the BLE controller.
The controller will now support only the nRF5340 DK.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Fix cancel of Periodic Synchronization on Coded PHY. Reset
the association of periodic sync instance after validation
of command disallowed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When handling CoAP Confirmable requests, there is a common
Acknowledgement initialization procedure that repeats for each
response packet initialization. This patch adds a function that
simplifies Acknowledgement initialization procedure encapsulating
repeating code.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
When address resolution is disabled, an identity address has
been added into the resolving list with peer IRK, and device
privacy has not been selected for the peer device then
connection indication shall not be sent to the peer that is
advertising using its identity address.
Fixes#24731.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
acl_read_cb does not handle incoming (ACL) data
if BT_CTLR_TX_BUFFER_SIZE is greater than
USB_MAX_FS_BULK_MPS - BT_HCI_ACL_HDR_SIZE.
Since the host adjusts the data according to
the BT_CTLR_TX_BUFFER_SIZE and does not use ZLP
we cannot start usb_transfer over the possible length of
the whole packet, with or without USB_TRANS_NO_ZLP flag.
But we can read the packet length from the header and
call net_buf_put() when the whole packet is received.
Fixes: #31922
Reported-by: Matias Karhumaa <matias.karhumaa@gmail.com>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Fail after pairing request and response have been exchanged if the
selected pairing method would not result in the required security level.
This avoids the case where we would discover this after having encrypted
the connection and disconnect instead.
This was partially attempted but lacked checking for authentication
requirement when L3 was required, as well as skipping the check if L4
was required but remote did not support Secure Connections since the
check was after we had taken the legacy branch.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the error in the security changed callback when the encryption has
not reached the required security level.
Terminate the pairing procedure in SMP on failure to avoid the security
changed callback being called twice in this case.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Terminate the pairing procedure when disconnected while this was in
progress. This notifies the application that security has failed and
removes the key entry.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the SMP flag encryption pending in the case where a bond exists
with ediv and rand equal to zero, i.e LE Secure Connections bond.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When receiving unexpected SMP PDUs with no pairing procedures in
progress don't treat it as a pairing procedure that has failed.
This causes unexpected SMP PDUs to trigger the pairing failed and
security changed callback at unexpected times.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add status only pairing failed callbacks (complete and failed) so that
these handlers can be added without providing the ability for MITM
pairing procedures.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename auth_err_get to security_err_get which better reflect the
error namespace it converts to. Also update to using the enum definition
instead of uint8_t for local variable holding returned value.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
when BT_PASSKEY_INVALID was set, it never updated the fixed
passkey which made its use ineffective
Signed-off-by: Faisal Saleem <faisal.saleem@setec.com.au>
The ATT request buffers are held until the ATT response has been
received. This means that the ATT request buffers are released by the
RX thread, instead of the from the RX priority context of
num_complete.
This can cause a deadlock in the RX thread when we allocate buffers
and all the available buffers are ATT requests, since the RX thread is
the only thread that can release buffers.
Release the ATT request buffers once they have been sent and instead
handle ATT request resending by reconstructing the buffer from the
GATT parameters.
Also re-order the order of resource allocation by allocating the
request context before the buffer. This ensures that we cannot
allocate more buffers for ATT requests than there are ATT requests.
Fixed a buf reference leak that could occur when the ATT request buffer
has been allocated, but GATT returns an error before handing the
responsebility of the buffer to ATT, for example when bt_att_req_alloc
fails.
This is fixed by moving the functionality of att_req_destroy to
bt_att_req_free.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove the ATT request destroy callback which is never assigned
by any of the ATT requests.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix indicate without func not working properly, when sent as a
non-req by GATT this has two propblems:
- The indicate would not be treated as a transaction, and back
to back indicate would be sent without waiting for the confirm
- The destroy callback would not be called on the indicate parameters
since the indicate_rsp callback would not be called.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
ATT channels do support queueing buffer so it no longer need to block
waiting the tx_sem besides the buffer allocation already serves the
same purpose as the application will not be able to have more requests
than there are buffers available.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Allow to request a higher security level during the key distribution
phase.
This is required by ATT and L2CAP since they only react to the encrypt
change event where they resend the current request.
The current request might require a higher security level still and
might have to request a higher security level before the pairing
procedure has been finished.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When ATT resends an ATT request it is sent as a "response" instead of
as a request. This causes the ATT request buffer to be released and
the ATT request cannot be resent one more time.
This causes a problem when the ATT request requires authentication
but the elevation of security is not enforcing MITM protection.
In this case the ATT will first require security level 2 and then resend
the request once this has been reached.
This will lead to a new ATT error response and ATT will require security
level L3.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the update keys check allowing to overwrite the keys when using
debug keys. Instead the check disallowed overwriting keys made using
debug keys.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix gatt write command returned "write in progress" when either
hex2bin or bt_gatt_write returned an error.
The write_params.func should not be set if the write command was not
successful.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Sets the sequence number when re-encrypting messages from the friend to
the lpn.
This is a regression from #28511.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Set app_idx and net_idx in the msg_ctx before calling
bt_mesh_keys_resolve when re-encrypting friend messages, as they'll be
referenced inside the function.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Move the public network request command from the end of `lorawan_start`
to the start of `lorawan_join`. This MAC command interacts with the
radio driver, bringing it out of sleep mode, and doesn't put it back.
The public network setting is only needed when joining a network, and
`lorawan_start` can be called well before `lorawan_join`. By moving the
command we save ~600uA before joining (for sx1262).
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Fix missing advertising PDU length initialization which
prevented advertising PDU to be transmitted by Radio. This
issue was reproduced when connectable undirected advertising
was enabled without setting an advertising data.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
llvm 11 doesn't like having preprocessor directives in the expansion
of a macro used as a preprocessor conditional expression.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
After #31176, the network would get stored immediately in
bt_mesh_net_create, causing the address and devicekey to get stored as
their zero-initialized version, as they're only being set in the
bt_mesh_comp_provision call, which fires after.
Fixes#32067.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fixes problem when fs_opendir invoked on fs_dir_t object,
which is already holding information on opened directory,
overwrites references to other memory objects within
the fs_dir_t object causing resource leak.
If fs_opendir is invoked on already used fs_dir_t object,
it will return
-EBUSY.
Note: The change requires that all fs_dir_t objects should be
initialized to 0.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The commit adds initializations of fs_dir_t variables in preparation
for fs_opendir function change that will require fs_dir_t object, passed
to the function, to be initialized before first usage.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Reduces some user confusion regarding whether it is related
to "Connection ID", "Channel ID", or "Company ID" for the
uninitiated.
Signed-off-by: Emil Hammarstrom <emil.hammarstrom@assaabloy.com>
Current 6lo implementation is unable to deal with scattered headers
(which should not happen usually, though it's a valid use case), so
let's just fail uncompressing such packet then.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Bogus fragmented packet could be sent without a FRAG1 fragment and hit
reassembly. Let's make sure this does not happen.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
In case the current packet is the same as the cached one, let's not
unreference it while clearing the cache.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Though ACK frames are not meant to reach L2 (drivers must ensure this
never happens), let's "re-enforce" the L2 by dropping them.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
All addressing mode but IEEE802154_ADDR_MODE_NONE should have a valid
address. If not, the frame is invalid.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Fix OpenISA port to include compiler memory barrier as in
commit 1a14f8b3a6 ("Bluetooth: controller: Use DMB instead
of DSB").
Relates to commit 1af2b91c23 ("Bluetooth: controller: Fix
Tx Buffer Overflow") and to commit ef2ece82c0 ("Bluetooth:
controller: openisa: Fix sanitycheck failures") and to
commit c2fc629dd2 ("Bluetooth: controller: 255 byte AD
payload support").
Fixes#31937.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for OpenISA rv32m1_vega_ri5cy board not supporting
different IRQ Priority levels for LLL, ULL_HIGH and ULL_LOW
execution contexts.
Fixes#31937.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BT_CTLR_ULL_HIGH_PRIO default value to equal
BT_CTLR_LLL_PRIO value if BT_CTLR_LOW_LAT is enabled, else
default ULL_HIGH to lower IRQ priority level in comparison
to LLL IRQ priority level. If BT_CTLR_ZLI is enabled,
BT_CTLR_ULL_HIGH_PRIO can default to a priority level value
of 0 and still be lower priority level than the LLL which
is placed at Zero Latency IRQ priority level (highest
priority in the CPU).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As network_decode needs a target buffer for decoding, the max PDU length
must be checked to prevent overflow on the target buffer. When receiving
a proxy configuration message with excessive length, there's no previous
check for this.
Also pulls the NET PDU length defines out into net.h, so they can be
used when defining the target buffers.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Restore the user requested datarate upon a successful join. Several
regions overwrite the configured datarate through `RegionAlternateDr`,
which means that for these regions, `LoRaMacQueryTxPossible` will not
be evaluating the requested datarate for the first transmission after
joining.
Fixes#31551.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Validate datarates requested by users. As a side effect of this change
the MAC layer is immediately aware of updated datarates. Therefore
`LoRaMacQueryTxPossible` in `lorawan_send` will be using the same
datarate to evaluate the payload length as `LoRaMacMcpsRequest` is
requesting.
Fixes#31551.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Query the default datarate for the configured region, instead of
assuming that the default is DR_0.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Use BOS header structure directly we have access to
instead of casting extern const pointers.
Fixes: #30330
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Attempts to disable PM_STATE_SOFT_OFF would index past the end of the
count array. Increase the array length to allow operations on
PM_STATE_SOFT_OFF.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This patch replaces magic numbers with COAP_TOKEN_MAX_LEN value and
removes unnecessary castings of token buffer type.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
RFC 7252 (CoAP) specifies value of the Version (Ver) field in the
protocol header to value 1. This patch defines value of the Version
field to make packet initialization easier. All samples and tests
are updated to use the new COAP_VERSION_1 field when initializing
a CoAP packet.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
Fix Tx Buffer Overflow caused by uninitialized node_tx
memory being used by ULL ISR context due to Compiler
Instructions Reordering in the use of MFIFO_ENQUEUE.
The MFIFO last index was committed before the data element
was stored in the MFIFO due to Compiler Instructions
Reordering.
This is fixed now by adding a Data Memory Barrier
instruction alongwith a compiler memory clobber.
Fixes#30378.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use of Data Memory Barrier instruction with memory clobber
in ARM Cortex M architectures is sufficient in the
controller implementation to keep compiler data access
instructions in order so that an ISR vectoring has memory
accesses in the correct order as intented by design.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Mark the option BT_FIXED_PASSKEY as an insecure option.
During Legacy pairing the passkey is used as encryption key, and
brute-forcing this is easy.
During LE Secure Connections the passkey is checked one bit at a time,
so when it is fixed the passkey can be deduced with series of pairing
attempts.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Bluetooth SMP protocol depends on the BT_ECC for the LE Secure
Connections pairing. Since this feature cannot be disabled we must
select this dependency.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix fixed passkey for legacy pairing. The pairing procedure fails
because the temporary key (TK) has not been set for this pairing
procedure.
Fix this by always requesting the legacy TK.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix misleading message in the bluetooth shell when the id-create
command returns en error code. In this case both failure and success
messages are printed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add options to control the behavior of the init command.
Option no-settings-load allows the user to create identities
with the id-create command after bt_enable() but before settings_load().
Option no-ready-cb allows the user to test using synchronous enable,
since this sometimes leads to different behavior of the stack.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Prevent the bt_rand function from being called before bt_enable.
Depending on the implementation of bt_rand this function cannot
be called before bluetooth has been initialized. With host supplied
crypto functions the HCI LE rand command is used for example.
The use case for calling bt_id_create before bt_enable is meant for
when the application has storage for the identity instead of the stack.
So we add the requirement that the application has to have storage
for the identity resolving key (IRK) in addition when the local
device is privacy-enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the default ULL_HIGH execution priority to be lower than
LLL execution priority to reduce Radio ISR service latency.
Also, default to Zero Latency IRQ for Radio ISR if enabled
in the kernel.
Fixes#29994.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
ad_len parameter is not length of complete advertising data, but number
of bt_data structs passed to bt_le_per_adv_set_data - we pass only one.
Also memset target buffer before converting hex string so data shorter
than specified will be right-padded with zeroes instead of some
leftovers.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
The mem_pool Kconfig API is deprecated as allocation now uses a k_heap.
Update to allocate a heap with the same amount of memory as was
defaulted with mem_pool customization.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Originally the file cache used a mem_pool, but that data structure has
been deprecated and replaced by a heap that includes metadata in the
heap area. As a result attempts to allocate all blocks will fail
because some of the reservation intended for cache data is now holding
metadata instead.
It's not immediately clear how to adjust the required heap size to
support this metadata as it depends on heap chunk units and data
structures that are not visible to the application. Experimentally a
value of 24 bytes works, while smaller values do not.
Further the previous Kconfig API to configure the allocation pool is
completely inappropriate with the new heap data structure which has
such different behavior.
So: Deprecate the old Kconfig API. Add a new Kconfig option to
directly control the cache size. Infer a default cache size that
works with the old mem_pool parameters assuming a per-block overhead.
But to avoid wasted memory use the heap allocation only when the
application customizes the size, and use a slab in other cases.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
When pushing received data to the application, check that app
was able to receive the data. If the application already closed
the socket, then we must free the received net_pkt in order to
avoid memory leak.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we cannot allocate net_pkt or net_buf, then check this condition
properly and release other resources that were already allocated.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Some targets, such as network cores on a multi-core SoC, do not
support system power management because they do not control the SoC.
Provide a flag that can be selected to inihibit enabling system power
management on those targets.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This reverts commit f38ba314ea.
nrf5340dk_nrf5340_cpunet doesn't support power management, but that
should be handled another way.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
We need to make sure that when listening a connection establishment,
the connection gets cleared if we do not receive final ACK.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix the mayfly callee id for the rx_demux scheduling under
the LOW_LAT_ULL implementation. This could be causing
undefined mayfly execution behavior in nRF51x SoC.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the deprecated bt_conn_create_slave_le function.
This was deprecated in the 2.3.0 release.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fixes problem when fs_open invoked on fs_file_t object, which is already
holding information on opened file, overwrites references to other
memory objects within the fs_file_t object causing resource leak.
If fs_open is invoked on already used fs_file_t object, it will return
-EBUSY.
Note: The change requires that all fs_file_t objects should be
initialized to 0.
Fixes: #29478
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds initializations of fs_file_t variables in preparation
for fs_open function change that will require fs_file_t object, passed
to the function, to be initialized before first usage.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds initializations of fs_file_t variables in preparation
for fs_open function change that will require fs_file_t object, passed
to the function, to be initialized before first usage.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The commit adds initializations of fs_file_t variables in preparation
for fs_open function change that will require fs_file_t object, passed
to the function, to be initialized before first usage.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Conform to Bluetooth Specification, if the LE_Scan_Enable
parameter is set to 0x01 and scanning is already enabled,
any change to the Filter_Duplicates setting shall take
effect. Disabling scanning when it is disabled has no
effect.
Fixes#31019.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There was one case where the dummy policy was returning a wrong type
in the function pm_policy_next_state.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
CoAP RFC (RFC7252) states that end points should support
the CoRE Link Format of discoverable resources as described in RFC6690
(refer section 7.2 of the RFC7252).
Fixes#31609
Signed-off-by: Kasun Hewage <kasun.ch@gmail.com>
Fix regression in adding the state for Connection Parameter
Request being rejected where in Connection Parameter Request
Procedure state machine was prematurely reset before the
reject PDU was enqueued.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing initialization of ticks_to_offset value on
instantiation of new peripheral context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix repeated offsets in LE Connection Parameter Request PDU
due to rounding errors. Use tick units of connection
interval to calculate the offset units.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix deferred Connection Parameter Request offset population
by introduction of explicit states waiting for the offset
calculations to complete in the ULL_LOW context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix deferred Connection Update offset population by
introduction of explicit states waiting for the offset
calculation to complete in the ULL_LOW context.
Fixes#29636.
The problem was, in an encrypted connection the enqueued PDU
to be transmitted is encrypt in the prepare callback by the
hardware and swapped to a different buffer for transmission;
the deferred offset population did not reflect in the
transmitted PDU as it was filled in the cleartext buffer
while encryption completed into the encrypted buffer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix error introduced by pull request:
https://github.com/zephyrproject-rtos/zephyr/pull/31591
Zephyrs CMake extension function zephyr_library_sources_ifdef()
does not allow to use complex conditions to toggle if
sources should be included in build or not.
It allows to use only single variable as an input for
feature_toggle argument because it is double-expanded
in contition statement in the function.
In case there is a requirement that source file is included
when more complicated condition is true we have to fall-back
to reqular if() statement and zephyr_library_sources().
The fix is required because without it radio_df.c source
is never compiled. If DF functionality is enabled build
will fail because of missing functions implementation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
the implementation of spinlock validation uses two LSB bits in the
bottom of a pointer union to store a CPU index, which only has space
for 4 CPUS. the MP_NUM_CPUS should be <= 4.
Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
After the latest upmerge, OpenThread requires explicit configuration
of the Master Key. This commit adds a Kconfig symbol that can be
used to setup its value. By default no Master Key is configured and
OpenThread generates a random one.
The Sockets Echo samples are configured with a fixed key with this
commit.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Syncing here is done with a semaphore declared on a function stack
and released in a callback. In case of a cancelled transfer (eg.
cable disconnect) the callback is never called.
The fix introduces a periodic check if a transfer is still valid.
Signed-off-by: Jan Pohanka <xhpohanka@gmail.com>
Only start the network logging backend if the autostarting
option CONFIG_LOG_BACKEND_NET_AUTOSTART is enabled.
Also, call init to make sure that the backend is initialized
properly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix implementation to run local peripheral initiated control
procedure with instant in parallel with remote initiated
encryption procedure.
Relates to #28887.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If a PHY update is waiting for the instant to be reached and the master
starts the encryption procedure, store the pending PHY update procedure
and handle it simultaneously with the encryption setup.
This fix prevents the encryption setup from stalling and thereby timing
out after 40s, after which the master drops the link.
The ll_conn::llcp::encryption can not longer be unioned with the
ll_conn::llcp:phy_upd_ind as one would overwrite the other.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Add conditional compilation on peripheral and central
specific control procedure implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BIG Sync Terminate Command to generate Sync Established
event if Sync initiation is in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added missing allocation of node rx buffer required for
generation of Broadcast ISO Sync Established.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Token and payload are appended from data buffers to a CoAP packet
being encoded. Keyword const was missing for parameters in functions
appending these parts to a packet.
Now token and paylod can be copied to CoAP packet from constant
buffers, that can be stored in ROM.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
This patch introduces COAP_TOKEN_MAX_LEN definition in coap.h file.
This definition replaces magic number across CoAP protocol
implementation and CoAP samples.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
Clean up logging menuconfig by grouping configuration into
sections like: mode, processing configuration, backends.
Additionlly, removed LOG_ENABLE_FANCY_OUTPUT_FORMATTING which is no
longer in use.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The net_buf was never unref'ed when the host received an
ISO package that was a SINGLE.
Also adds a few additional debug messages.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
`iso send` may take an optional "count" parameter but the
number of optional arguments was incorrect.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The DF tests are implemented to be executed with nrf52_bsim platform.
The nrf52_bsim platform does not include Direction Finding Extenstion.
Due to that, radio_df.c compilation failed with error about missing
antenna configuration in DTS.
To solve the problem, I've changed nrf.cmake to include radio_df.c
file when CONFIG_BT_CTLR_DF is defined and CONFIG_SOC_SERIES_BSIM_NRFXX
is not definded.
Thanks to that any other platform is not affected. The file will not
build if there is no appropriate configuration or there are missing
features in a hardwared.
Unit tests have provided stub imlpementation or radio functionality.
If nrf52_bsim has implemented Direction Finding Extension, the
DF unit tests code will stil work and will not require additional
changes. Also content of the file is not affected by contional
compilation entries.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove ATT modifying the L2CAP channel state by unassigning the
the connection pointer on timeout.
Unassigning this pointer does not prevent the ATT channel from receiving
since bt_l2cap_recv does not inspect this pointer before calling the
channel receive function.
This prevented the disconnected callback from being called on the
channel after the channel had timed out, but since the disconnected
callback now handles this case this workaroun is no longer needed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Handle ATT timeout on disconnected ATT channel.
When the ATT channel is disconnected with a pending request the ATT
timeout is canceled and the response processed with an error code.
However canceling of delayed work is not guaranted to succeed, e.g:
"Work queue thread has removed the work item from the queue but has not
called its handler"
This could lead to timeout handler being invoked after the disconnected
handler.
Fixes: #29098
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
So far device_pm_state_str() was built only when CONFIG_PM=y (former
CONFIG_SYSTEM_POWER_MANAGEMENT=y). 'device list' shell
command (CONFIG_DEVICE_SHELL=y) is using that function when
CONFIG_PM_DEVICE=y. This resulted in build failures when CONFIG_PM=n, as
linker could not find its implementation.
Build device_pm_state_str() function regardless of CONFIG_PM value, so
device shell module builds successfully in every case.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Parallel transfer to same endpoint is not supported and
may cause a deadlock. Adding a check to prevent starting
the transfer if tranfer is already ongoing on same endpoint.
Transfer status was not checked when accessing to transfer
from endpoint callback. Adding status check, to prevent
a double completion.
Fixes#30736
Signed-off-by: Kari Hulkko <kari.m.hulkko@gmail.com>
If we evict enough pages to completely fill the backing store,
through APIs like k_mem_map(), z_page_frame_evict(), or
z_mem_page_out(), this will produce a crash the next time we
try to handle a page fault.
The backing store now always reserves a free storage location
for actual page faults.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Backing stores and eviction algorithms will be included here.
Exactly one must be chosen, with a default option to leave
the implementation to the application.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Fix compilation error caused by use of wrong header file:
nrfx/hal/nrf_radio.h instead of hal/nrf_radio.h.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This targets was previously enabling PM but the code was doing nothing
because the logic was under an unsatisfied ifdef condition.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Change subsystem to use struct pm_state with substate-id instead of
using only the power state category.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Remove conditionals (PM_DEEP_SLEEP_STATES and PM_SLEEP_STATES) from
power management code. Now these features are always available when
power management is enabled.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Migrate the whole pm subsystem to use new power states information
from power_state.h and get states and residency properties from
device tree.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This enables to use net_buf_append_bytes without passing an allocator in
which case the code would attempt to use the net_buf_pool of the
original buffer.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This removes the z_ prefix those (functions, enums, etc.) that
are being used outside the coredump subsys. This aligns better
with the naming convention.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds some shell commands to the logging backend. Since
this is a simple backend, only get/clear errors are
implemented.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds two new APIs to the coredump subsystem to perform
query and command. These can be used to query coredump subsys
for information, and to perform commands such as finding
out if there is a stored coredump.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
The coredump frontend (mostly) consists of wrappers of backend
functions so there is really no need to track errors at
the frontend level. Let the backends deal with their own errors
and this simplifies the code a bit.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Originally there was a null backend but it was removed before
code was merged. However, some leftover code still refers to
this null backend. So remove the leftovers.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If we evict enough pages to completely fill the backing store,
through APIs like k_mem_map(), z_page_frame_evict(), or
z_mem_page_out(), this will produce a crash the next time we
try to handle a page fault.
The backing store now always reserves a free storage location
for actual page faults.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Backing stores and eviction algorithms will be included here.
Exactly one must be chosen, with a default option to leave
the implementation to the application.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Coded PHY is only enabled by default if the application is using
BT_HCI_RAW.
Coded PHY is not needed in most applications.
By disabling Coded PHY, most applications will:
* Get smaller in terms of flash and ram usage
* Not get vurnerable to devices trying to switch to Coded and
thereby increasing power consumption.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Refactor the output of device list to use standard API to retrieve the
list of devices, and to always display a status rather than hiding
disabled/failed devices.
Add API to associate a distinct identifier with any "device" that does
not have a name.
Where a device has requires dependencies display the devices on which
it depends.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This emulator pretends a generic eSPI Host. It supports basic virtual
wires and port80 operations.
There are functions to trigger actions on the host side e.g. for
setting a virtual wire from the host to the eSPI slave, use
emul_espi_host_send_vw. It will prepare data and set a proper event
on the slave side which will trigger callback (if there is any).
Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
Add routine to calculate crc of flash region. Read 32 bytes at a time
from flash instead of 4 bytes, for a significant speed up of the flash
image crc calculation.
Signed-off-by: Klaus H. Sorensen <khso@vestas.com>
The callback function canopen_odf_1f56 is called with the can od lock
held. Release the lock while performing time consuming flash reading and
crc calculations, and reacquire the lock before returning from the
function.
Signed-off-by: Klaus H. Sorensen <khso@vestas.com>
Fix compilation error if CONFIG_BT_CTLR_DF is not defined.
If DF was not enabled, there was missing CONFIG_BT_CTLR_DF_MAX_-
ANT_SW_PATTERN_LEN and undeclared symbol was found.
Split ll_df.h into two parts:
- ll_df.h that is generally includeable and allows to successfully
compile sources when DF is not enabled.
- ll_df_internal.h to be used in soucres that are compiled when
DF is enabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction Finding requires initalization of a set of registers
in Radio peripheral. Also it requires information about antenna
matrix unit that are provided by end user in DTS overlay.
Implemented initialization step is responsible for validation of
hardware information delivered by DTS and setting up DF related
registers in Radio.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add support for Direction Finding antenna configuration in
Nordic hal of Bluetooth controller.
Add handling of response for HCI_LE_Read_Antenna_Information
HCI command in controller (upper and lower link layer).
Handling of response to the command requires antenna matrix
configuration.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CoAP protocol defines registry of Content-Format option values.
This patch adds this enumeration to coap header file to make it
available to all applications using CoAP protocol. It modifies
code using CoAP service to use new enumeration.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
This patch implements a service that adds multiendpoint
capabilities to RPMsg. Multiple endpoints are intended to be used
when multiple modules need services from a remote processor. Each
module may register one or more RPMsg endpoints.
The implementation separates backend from the service, what
allows to extend this module to support other topologies like
Linux <-> Zephyr.
Co-authored-by: Piotr Szkotak <piotr.szkotak@nordicsemi.no>
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
After nrfx glue code was decoupled from nrfx sources, it is no longer
feasible to use those inclusions in the <nrfx/hal/nrf_*.h> form (there
is no point in adding the main directory of the hal_nordic module as
an include path solely for this reason). Remove then the nrfx/ part.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Fixes an issue where `lorawan_send` would return prematurely when
`LORAWAN_MSG_CONFIRMED` is mixed with unconfirmed messages.
All calls to `LoRaMacMcpsRequest` result in `McpsConfirm` being run,
where the semaphore `mcps_confirm_sem` is given. However this semaphore
is only taken when `LORAWAN_MSG_CONFIRMED` is set.
Therefore if an unconfirmed message is sent, any following confirmed
messages will return from `lorawan_send` immediately as the semaphore
will be available from the previous send. The return value would also
be wrong for the same reasons.
Fixed by only giving the semaphore in situations when it is being
blocked on.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add Kconfig option to randomize the initial ACK timeout, as specified in
RFC 7252. The option is enabled by default.
Additionally, finetune the default value of COAP_INIT_ACK_TIMEOUT_MS
option, to match the default ACK_TIMEOUT value specified by the RFC
7252. The RFC does not specify the minimum/maximum value of the
ACK_TIMEOUT parameter, but only suggests it should be no lower than 1
second, so adjust the option range to reflect this.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Introduce retransmission counter to the coap_pending structure. This
allows to simplify the retransmission logic and allows to keep track of
the number of remaining retranmissions.
Additionally, extend the `coap_pending_init()` function with `retries`
parameter, which allows to set the retransmission count individually for
each confirmable transaction.
Fixes#28117
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The commit adds Kconfig option:
CONFIG_IMG_MGMT_REJECT_DIRECT_XIP_MISMATCHED_SLOT
that enables verification of base address Direct-XIP binary, upon
upload, and rejects binaries that would not be able to start from
available address.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The definition of lock, k_spinlock type, that has been used to guard
variables holding statistical data for log_strdup has been missing
static modifier, which caused the lock structure to be reallocated
on stack each time an execution entered the block.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fix size of L2CAP disconnect request buffer pool which did not include
the size of the L2CAP signal header.
Regression from: 3346aa4d39
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Defined 625 and 1250 as context specific interval common to ULL and LLL.
Checked with bluetooth sanity checks.
Fixes#23314.
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Some proprietary protocols that reuse the Bluetooth LLCP logic requires
that the CPR interval has a valid range that differs from the Bluetooth
specification defined.
Vendor must implement the function (ull_vendor.h)
uint16_t ull_conn_interval_min_get(struct ll_conn *conn)
that returns the valid limit for the given connection.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Multi-instance resources shall report its dimension (number of
resource instances) on discovery. Since it was not possible to tell
simply on the instance count whether the resource is multi-instance or
not (there could be a multi-instance resource with only one instance
avaialble) add a new parameter to the structure representing resource,
indicating whether it's multi-instance or not.
Add dimension information to the discovery result.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Remove any references of Bootstrap Discovery from Device Management
Discovery procedure and fix some of it's logic following the
specification.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Bootstrap discovery was not implemented properly in the LwM2M engine.
Although, there were some indications in the source code that it is
implemented, it was not done according to spec (and actually broken).
Given that Bootstrap Discovery procedure differs a lot from the regular
Device Management Discovery (different permissions, different
information returned), it's easier to implement it as a separate
function (`bootstrap_discovery()`) instead of making the existing
`do_discovery_op()` function even more complicated.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In std_print(), the log arguments were casted to uint32_t before
being sent further to the output function.
For integer types which can not be represented by uint32_t, the
degraded user experience may be acceptable.
However, for string arguments, the output function will eventually
dereference the pointer, so if the "char *" can not be represented
by uint32_t, bad things are going to happen. In practice you will see
this on 64-bit systems where sizeof (char *) is 8 byte and addresses
higher than 0x80000000.
Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
This commit improves portability somewhat on machines where sizeof
(int) is less than sizeof (void *). Note that the implementation is
still not portable and will fail when you start using addresses which
can not be represented by "int cast to unsigned int".
On RISC-V 64-bit with RAM on 0x80000000 we previously got hit by
E: Exception cause Load access fault (5)
ld s0,16(a0)
a0: 0xffffffff80025610
(The int should probably be changed to intptr_t if possible.)
Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
Allow vendor specific increase of user operation capacity for LLL, to
support queuing additional ticker operations from lower link layer
context. These would typically take place in lll_xxx_prepare.
Signed-off-by: Morten Priess <mtpr@oticon.com>
For Bluetooth Mesh, counter shall be increasing by one when
every try to establishing friendship.
Counter to be used when create friendship security material.
So this value shall be consist between friend and lpn.
Due to zephyr bluetooth mesh send previous counter, after that
it will automatically increase one, which will result in the
incorrect generation of friend key when key rephase.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Make sector size used by flash disk configurable and expose new disk and
fatfs configurations to Kconfig.
Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
Now that we generate a header that extern's all possible devicetree
based device struct we can remove DEVICE_DT_DECLARE and
DEVICE_DT_INST_DECLARE as they aren't needed anymore.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This patch brings support for AF_PACKET and SOCK_RAW type of sockets.
In net_conn_input() function the new flag has been introduced -
'raw_pkt_continue' to indicate if there are other than AF_PACKET
connections registered.
If we do not have other connections than AF_PACKET, the packet is
solely handled in net_conn_input() (or to be more specific in its
helper function - conn_raw_socket()).
Otherwise, it is passed back to net_conn_input in IPv4/6 processing.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
The new function - namely conn_raw_socket(); has been introduced to
handle raw sockets processing. Its code, up till now, only was
executed when IS_ENABLED(CONFIG_NET_SOCKETS_PACKET) was defined.
After this change it can be reused when one would like to handle
raw sockets also when CONFIG_NET_{UDP|TCP} are enabled.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Some parts of subsys/dfu/boot code are re-implementations of
what is implemented in the MCUBoot repository.
Mcuboot's repository already provide implementation of function
required for application for interact with the MCUboot.
This patch introduces new MCUBOOT_BOOTUTIL module which covers
common code which is used in the bootloader and the chainnloaded
application.
dfu/boot: use MCUBoot's source code
Module was reworked so it start using MCUBoot's
bootutil_public API instead of copied code.
Reworked boot_is_img_confirmed() used MCUBoot's API
for determine image_ok flag.
mcuboot_shell switchd to use MCUboot's boot_read_swap_state_by_id()
This is MCUBoot function, use it for avoid linking conflict.
test/subsys/mcuboot: fix `test_write_confirm`
dfu/boot library was reworked so it uses MCUboot's bootutil_public
library whenever it can.
The library required that image was marked as copy-done before it
can be pending.
This patch adds such mark which fixes the test.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Add a check to stop a multicast address to be registered multiple times.
This can happen if the application is using net_if_ipv6_maddr_add()
directly.
Tested on the existing bluetooth/ipsp sample:
<wrn> net_if: Multicast address ff02::1 is is already registered.
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
6lowpan over BLE should work without solicit node multicast messages
according to RFC7668[1], but that requires Neighbor Solicitation with
Address Registration Option, which is currently not implemented in
either Zephyr or Linux. This is causing the router to fallback to normal
neighbor solicitation based discovery, but the NS frames are being
discarded in the host stack because the solicit node multicast groups
are not registered.
This drops the NET_L2_MULTICAST_SKIP_JOIN_SOLICIT_NODE as a workaround
and adds a TODO about it.
[1] https://tools.ietf.org/html/rfc7668#section-3.2.3
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
The mesh settings.c module is a giant piece of code responsible for
storing the mesh stack configuration. Such approach makes it difficult
to control the data to be stored, breaks the stack modules'
encapsulation by forcing them to reveal the internal kitchen, which
leads to unpleasant issues such as #19799.
This commit moves the responsibility of storing the configuration
to corresponding modules while keeping control of the moment of storing
the configuration and of starting the stack after the settingss loading
is completed.
This doesn't introduce any abstraction between the mesh settings.c and
other modules as it will add more complexity and overhead than necessary
for the actual task.
Fixes#19850
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Add public function to set Constant Tone Extension transmission
enabled or disabled for periodic advertising.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Enable CTE HCI command requires update of a state of its
execution after receive command completion response from
controller. Host has already implemented such functionality
but it was used only internally by hci_core.
This commit changes it to be accessible from other sourece files
in host.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add implementation of HCI_Set_Connecitonless_CTE_TX_Enable
command to HCI. Add scratch implementation of command handling
functions to controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix compilation error caused by missing header files.
Reorganized order of header files include.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Correct names of kconfig entries to mach to style of other entries.
Style correction in hci.c. Use the same approach of checking if
Kconfig entry is enabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Function shell_root_cmd_find was only used in shell_utils.c file.
Hence it is changed to static and renamed to root_cmd_find.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Add Kconfig option NET_HOSTNAME_UNIQUE_UPDATE to allow the unique
hostname - which is derived from the network interface's link
address - to be updated on both initial assignment and updates of
the link address.
Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
This is in order to reduce the redundancy code writing for fatal and
assert handler for error case testing. They can be used both in kernel
and userspace, and are also SMP safe.
Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
`delta_size` was incorrectly used to assess whether extended option
length field shall be used. In result, options larger than 268 bytes
were not encoded properly.
Fixes#31206
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
* add toolchain abstraction for coverage
* add select HAS_COVERAGE_SUPPORT to kconfig
* port gcov linker code to CKake for arc
* give user permission to gcov bss section
* expand the size of iccm and dccm to 1M
Signed-off-by: Jingru Wang <jingru@synopsys.com>
MESH/NODE/CFG/HBS/BV-01-C expects the MinHops to be 0x7f after
disabling subscription, but 0x00 for subsequent Get requests.
MESH/NODE/CFG/HBS/BV-02-C expects us to return previous
count value and then reset it to 0.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
The #if statement used IS_ENABLED to check if it was defined.
IS_ENABLED will only return true if the value is 1, and false otherwise.
If the NET_TCP_MAX_SEND_WINDOW_SIZE value would be e.g. 8, then the
check would fail.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If we receive data that is out-of-order, queue sequential
TCP segments until we have received earlier segment or a timeout
happens.
Note that we only queue data sequentially in current version i.e.,
there should be no holes in the queue. For example, if we receive
SEQs 5,4,3,6 and are waiting SEQ 2, the data in segments 3,4,5,6 is
queued (in this order), and then given to application when we receive
SEQ 2. But if we receive SEQs 5,4,3,7 then the SEQ 7 is discarded
because the list would not be sequential as number 6 is be missing.
Fixes#30364
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This is a pairing function with bt_le_scan_cb_register()
to used for remove the scanner callback from callback list.
Signed-off-by: chao an <anchao@xiaomi.com>
Modifies openthread shim layer to automatically join multicast
addresses as they are added to zephyr from openthread, unless the
address is interface-local or link-local. This allows incoming
openthread multicast group messages to avoid being filtered by
zephyr ipv6 recv.
Fixes#31085
Signed-off-by: Joel Frazier <frazieje@gmail.com>
During coverage reports generation in C++ code gcov_coverage_dump()
function would get stuck in endless loop. Fix by checking list head
pointer with current list pointer.
Signed-off-by: Marko Poljanić <mpoljanic@gmail.com>
Fixed misalignment of bitflag in ll_conn type causing unintentional
overwrite between unions. Common flag must be present in master/slave
uinons as well. Problem is only present when enabling feature
CONFIG_BT_CTLR_CONN_META, which is default disabled.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Reserve two link rx buffer for each supported Broadcast ISO
sync instance, for establishment and for sync lost node rx
generation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
For tx_power_max_get and tx_power_floor, only allow for
positive values of txpower if they are defined.
Signed-off-by: Aurora Sletnes Bjørlo <aurora.sletnes@nordicsemi.no>
The LwM2M firmware pull object no longer uses the system workqueue
to execute firmware_transfer(), but directly executes it itself.
Previously, the workqueue would be blocked because firmware_transfer()
indirectly calls a blocking connect(). This would lead to problems
with e.g. modem drivers that use UART to interface with the modem
hardware, as some UART drivers use the workqueue.
Fixes#31053.
Signed-off-by: Maik Vermeulen <maik.vermeulen@innotractor.com>
As the tcp header struct can be cast to unaligned memory, mark
it as packed and access fields using UNALIGNED_GET/PUT when
needed.
Fixes#31145
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Get rid of weak functions adding a new API to register an object to
receive notifications when the system changes power state.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Rename Kconfig BT_CTLR_SCAN_SYNC_ISO_MAX to
BT_CTLR_SCAN_SYNC_ISO_SET, to be consistent with other
Kconfig naming.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
AUX_CONNECT_RSP PDU static buffer definition was missing one
byte required for the Extended Header Flags.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Document with comments, the explanation of node rx count and
the design of the free rx PDU management.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for scenarios where in active PHY Update Procedure or
Connection Update Procedure could cause temporary depletion
of the free Rx PDUs in the queue between LL/HCI thread
context to LLL context. Symptoms being on-air NACKing during
the above said procedures, causing supervision timeouts due
to procedures not completing at instants.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the implementation of PA/LNA PPI configuration
which was done on every Tx or Rx as common code to be
executed once per radio reset. And only setup the timeout
and enabling of PPI at every Tx or Rx.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
For PA/LNA implementation use NRF_P0/P1 defines instead of
the deprecated NRF_GPIO to reference GPIO Port 0 registers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the missing GPIOTE channel disable when GPIOTE channel
is alternately used between PA and LNA use.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in PA/LNA support wherein the GPIO pins where
left in undefined state after each radio event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression, add back missing call to radio_setup HAL
interface. This is needed to setup the initial PA/LNA GPIO
states.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix crash in ATT when the response for a request is received after
the ATT timeout has fired and the ATT channel has been detached.
Add similar handling for all ATT channel operations.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Both RS and DAD timeouts are simplified because the delay is a
constant, and by construction the list of timeouts is in increasing
time remaining.
Refactor to avoid repeating the expression that represents the time
until DAD state expires. Uniformly use unsigned operands in deadline
calculation.
Note a case where the racy idiom for retaining an existing timeout is
required in the current work API, but can be replaced with a robust
solution in the proposed new API (the reschedule API replaces any
existing pending update, but the schedule API will leave an existing
scheduled submission in place).
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The existing implementation is inconsistent in that checking for
expired routers when a timeout is processed detects end-of-life
correctly (when the remaining duration exceeds the signed maximum),
but the calculation of time remaining before expiration uses only
unsigned calculation. So when the set of routers is changed the newly
calculated timeout will not recognize routers that have expired, and
so those routers expired late. In the worst case if the only
remaining router had expired the timer may be set for almost two
months in the future.
Refactor to calculate remaining time in one place and as a signed
value. Change a function name to more clearly reflect what it does.
Avoid unnecessary race conditions in k_work API.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The net_timeout structure is documented to exist because of behavior
that is no longer true, i.e. that `k_delayed_work_submit()` supports
only delays up to INT32_MAX milliseconds. Nonetheless, use of 32-bit
timestamps within the work handlers mean the restriction is still
present.
This infrastructure is currently used for two timers with long
durations:
* address for IPv6 addresses
* prefix for IPv6 prefixes
The handling of rollover was subtly different between these: address
wraps reset the start time while prefix wraps did not.
The calculation of remaining time in ipv6_nbr was incorrect when the
original requested time in seconds was a multiple of
NET_TIMEOUT_MAX_VALUE: the remainder value would be zero while the
wrap counter was positive, causing the calculation to indicate no time
remained.
The maximum value was set to allow a 100 ms latency between elapse of
the deadline and assessment of a given timer, but detection of
rollover assumed that the captured time in the work handler was
precisely the expected deadline, which is unlikely to be true. Use of
the shared system work queue also risks observed latency exceeding 100
ms. These calculations could produce delays to next event that
exceeded the maximum delay, which introduced special cases.
Refactor so all operations that use this structure are encapsulated
into API that is documented and has a full-coverage unit test. Switch
to the standard mechanism of detecting completed deadlines by
calculating the signed difference between the deadline and the current
time, which eliminates some special cases.
Uniformly rely on the scanning the set of timers to determine the next
deadline, rather than assuming that the most recent update is always
next.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
SWI IRQ line mapping for nRF5340 shall use
CONFIG_SOC_NRF5340_CPUNET for conditional compilation
instead of the board define, so as to allow new boards to
use the BLE controller implementation.
Fixes#30488.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If UART_INTERRUPT_DRIVEN isn't selected the CDC ACM class driver won't
build. Don't require the user's intervention to avoid this.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Adds a new family of `struct net_buf` operations that remove data from
the end of the buffer.
The semantics of `net_buf_remove_mem` have been chosen to match those of
`net_buf_pull_mem`, i.e. the return value is a pointer to the memory
that was removed.
The opposite of this function, `net_buf_remove`, would need to return
the old end of the data buffer to be useful. However this value is
always an invalid target for reading or writing data to (It points to
the middle of unused data).The existance of the function would be
misleading, therefore it is not implemented.
Fixes#31069.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add publicly accessible function to set Constant Tone Extension
parameters for CTE transmission with periodic advertising.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add implementation of a wrapper for HCI_LE_Set_-
Connectionless_CTE_Transmit_Parameters send command.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add Direction Finding to host initialization sequence.
It allows to get information about Direction finding
optional CTE settings supported by controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove is_enabled flag in LLL of BIS events context, as the
status returned from ticker_stop interface is sufficient to
determine if the Broadcast ISO Sync was established or not.
HCI Command Disallow as reason is to be returned if sync was
not established or sync was loss prior to call of HCI LE
BIG Terminate Command was called.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move lll_sync_iso.h as common to all vendors, as currently
there is nothing that is vendor specific.
Fixes#31044.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Leftover from old renaming commits. This function is not private and
should not start with underscore.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
When there are more timing_stop() calls then timing_start(),
the reference counter will go negative, resulting in the next
timing_start() call not starting the timer. Without timer
running, getting cycles elasped would not work. So fix
the ref counting so it won't dip below zero.
Fixes#30397
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If there are multiple interfaces a change to the timeout for one
cannot determine the correct delay until the next timeout event. That
can be determined only by checking for the next event over all
interfaces, which is exactly what's done by the timeout worker.
Refactor interface timeout configuration to just set the start time
and request time, and trigger the worker to calculate the next
scheduled event.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
When a renewal occurs the client enters RENEWING, sends a request,
then sets a short timeout (about 4 s) for the response. In the common
case the response will arrive immediately, which will trigger an
attempt to reset the timer with T1 which is generally large.
However the check for updating the timer performs the update only if
the new deadline is closer than the currently set one. Thus the timer
fires at the time the RENEWING request would have been retransmitted,
and only then updates to the correct deadline (T1) for the current
machine state.
Remove the extra timeout by unconditionally setting the timeout to the
new value.
This works when there is one interface; it could be wrong if there
were multiple interfaces one of which had a closer deadline, but
multiple interfaces are mishandled anyway and will be fixed next.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
When there is only a single interface the timeout infrastructure can
correctly calculate time to next event, because timeouts only occur
when an event for that interface is due. This is not the case when
multiple interfaces are present: the timeout is scheduled for the next
event calculated over all interfaces.
When calculating the next event for an interface where the timeout is
not due the current code returns the original absolute delay
associated with its current state, without accounting for the time
that has passed since the start time.
For example if interface A's T1 is 3600 s and is due at 3610, but at
3605 a timeout for interface B occurs, the contribution of A to the
delay to the next scheduled event would be 3600 rather than 5,
preventing the renewal from occurring at the scheduled time.
Fix this by replacing the boolean timed-out state with the number of
seconds remaining until the interface event will occur, and
propagating that through the system so the correct delay over all
interfaces can be maintained.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
If send_request() fails it would return UINT32_MAX as the next
timeout. Callers pass the returned value to update_timeout_work
without validating it. This has worked only because
update_timeout_work will not set a timeout if an existing timeout
would fire earlier, and the way the state is currently structured it
is likely there will be an existing timeout. However, if work thread
retransmission from REQUESTING failed the timer would not be
rescheduled, causing the state machine to stop.
A more clean solution, which matches the behavior of send_discover(),
is to return the timeout for the next transmission even in the case
when the send fails. The observed behavior is the same as if the
network, rather than the sender, failed to transport the request.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
A variable named "timeout" is used to represent the current time in
comparisons against timeouts calculated from a start time and an
interval. Since this current time is not the timeout change its name
to "now" to reduce maintainer confusion.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
If assertions are disabled the send operation would continue on to
transmit a message. Stop it from doing so.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The flag value UINT32_MAX is returned from manage_timers() when a send
operation did not succeed. This indicates that the timeout should not
be rescheduled, but because it will never replace the starting update
value UINT32_MAX-1 the check will never pass, and in cases where it
should work will be submitted to run at UINT32_MAX-1 seconds.
Fix the upper bound.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
When a connection is lost the client will first attempt to renew, and
then to rebind, and finally to select. Options like gateway may have
been provided by the original connection, but not the new connection,
resulting in an inconsistent configuration for the new network.
Remove the partial state clearing when entering INIT, and expand the
state cleared when entering SELECTING to be more comprehensive.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The start time is negative only if the interface came up in the the
first milliscond since startup; even then changing the sign of the
start is not appropriate. Presumably a left-over from signed 32-bit
timestamps.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
It is documented that using transient information like whether a work
item is pending or a delayed work item has time left to determine the
state of the work item before subsequent reconfiguration is prone to
race conditions, and known to produce unexpected behavior in the
presence of preemptive threads, SMP, or use of the work item from
interrupts. As a best practice such pre-validation steps should be
avoided unless algorithmically necessary.
All comparisons of remaining delayed time before canceling a delayed
work item in this module appear to be optimizations subject to the
above race conditions. Remove the checks so that only the inherent
race conditions in the implementation of canceling a work item remain.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
When using BT_GATT_AUTO_DISCOVER_CCC if the ccc_handle is not set
bt_gatt_subscribe would initiate a discovery to locate the CCC handle
but instead of awaiting it to complete the code does proceed to call
gatt_write_ccc even with ccc_handle being 0x0000 which is invalid.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Use the devicetree filesystem bindings to populate an fs_mount_t
object that is preconfigured for a particular set of file system
properties on a specified partition.
At this time the mount point data is accessed by reference using the
partition's devicetree node identifier.
Note: While a file system can register itself before its devices
are available, it cannot do the automount. In this commit the
initialization priority is increased to compensate, but that's not
a long-term solution.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Make generally available the macro that provides the flash device in
which a particular partition can be found.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
With this patch the resolver module can resolve literal IPv6
and IPv4 addresses even when DNS client is not presnet in
the system.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
Refactor the file structure for USB DFU class to facilitate
separate PID for USB DFU when in DFU mode. As required by USB DFU
1.1 Section 2, the PID in the USB device descriptor must be
different between the Run-time and DFU mode device descriptor to
avoid problems caused by the host OS caching the remaining
descriptors when switching to DFU mode, thus hiding the new
interface descriptors from applications on the host and reporting
the Run-time descriptors when the device is in DFU mode.
To avoid adding too much clutter to the root USB class Kconfig and
CMakeLists files, move the DFU class files into their own directory
with dedicated Kconfig and CMakeLists.txt.
Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
The USB device descriptors for DFU mode should only change after a
USB reset, not in appDETACH as the device is still in run-time mode
until reset; thus should still return the run-time descriptors when
requested.
Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
In accordance with USB DFU 1.1 Section 5.1, a device should only
stay in appDETACH for a given period of time, either from the
DFU_DETACH request (wValue ms) or from the wDetachTimeout property,
after which the device should return to appIDLE.
Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
We have convenient PHY_1M, PHY_2M and PHY_CODED symbols defined but
they are not used too much in the code. This replaces all usages of
magic numbers and other symbols as PHY constants with those symbols.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Adds an assert on the "old" ref counter when doing unref, that
checks if there indeed is a reference to unref. This prevents
any underflows of the ref counter.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implements the ull_sync_iso_setup function which starts the
ticker for ISO sync. Furthermore, ll_big_sync_terminate
will not stop the ticker as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implements handling of the BIG sync commands in the ULL.
LLL support and handling of ACAD (biginfo) remaining.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adjust the PPI used by nRF51x and nRF52x so that PPI 0-5 is
available for application's use or for SW PWM driver use.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Under CONFIG_BT_TICKER_EXT configuration, the ticker interface has been
extended to support enabling/disabling must-expire scheduling. This
means that conn and slave ticker start calls can now omit must-expire
default-on configuration, relying on LLL updating the mode as needed.
Signed-off-by: Morten Priess <mtpr@oticon.com>
The idle, when power management is enabled, requires system clock to
be present.
This commit adds dependency, to PM option, on SYS_CLOCK_EXISTS.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Convert drivers to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Convert drivers to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit replaces the 'select SHELL' statement with
'depends on SHELL' in OPENTHREAD_SHELL config option.
This ensures, that shell will not be implicitly enabled
when OpenThread stack is built.
Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
During recent upmerge OPENTHREAD_CONFIG_PLAT_LOG_FUNCTION__COUNT_ARGS
macro was renamed to OPENTHREAD_CONFIG_PLAT_LOG_MACRO_NAME__COUNT_ARGS
but the code wasn't updated where the macro is actually used.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Align bt_le_per_adv_sync_get_index, bt_conn_index and
bt_le_ext_adv_get_index in use of uintptr_t.
This fixes an issue where the cast to uint8_t happened before the
assert for a valid index, which could lead to invalid pointers passing
this assert.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Improve logging of pairing procedure when it fails with error code
unspecified. Since this is returned in many places debugging this
failure is not easy without adding additional debugging.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix parallel pairing procedures using LE SC requiring the DHKey
calculation at the same time. This would otherwise end all other
pairing procedures with the SMP error code "unspecified" since
the call to bt_gen_dh_key would fail.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the allowed command bitmask before sending the SMP packet. This
avoids a race-condition in case the sending of the PDU made the
current thread not ready and would not be scheduled back in time
to set the bit before receiving the next SMP packet.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Improve multiple DHKey handling by allowing the next DHKey calculation
to be started in the dhkey ready callback.
Return error code EALREADY if the provided callback is the current
callback generating the DHKey.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
We allocate nodes on receiving AUX_CONNECT_REQ, but we can only use
them if AUX_CONNECT_RSP is sent successfully. If that fails, we need
to release those nodes.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
If we allocate a node in LLL and it turns out that we don't need it
(e.g. allocated connection on AUX_CONNECT_REQ, but connection handshake
did not complete and we don't need it) we still need to send it to ULL
to be released. We can use existing NODE_RX_TYPE_DC_PDU_RELEASE node
type for this purpose, but we just need to make sure it's passed from
LLL to ULL properly.
Also, since this now does not only release DC PDUs, let's change its
name to a more generic one.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
After slave connection is created only adv instance is stopped, we also
need to stop aux separately if enabled.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Make sure phy is properly initialized to 1M when ext adv is supported
and legacy advertising instance is being enabled.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds handling for received AUX_CONNECT_REQ PDU which enables slave
connection with extended advertising.
Once AUX_CONNECT_REQ is received, standard checks are performed to
determine if we have resource to create connection, however unlike for
CONNECT_IND an rx node is temporarily kept in LLL until AUX_CONNECT_RSP
is successfully sent. This is to prevent creating a connection in case
response PDU was not sent for whatever reason.
A separate scratch buffer is created for AUX_CONNECT_RSP since default
radio scratch buffer is already used by received AUX_CONNECT_REQ.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Connection structs need to be initialized when advertising is enabled
on connectable extended advertising instance.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Connection created from extended advertising instance uses the same phy
as on secondary channels.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
transmitWindowDelay is either 2.5ms or 3.75ms when AUX_CONNECT_REQ is
used (for 1M/2M and Coded respectively). It also uses the same unit
as transmitWindowOffset (1.25ms) so we can just simply add both.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
The same helper will be used for legacy and extended advertising so we
better pass AdvA and TargetA directly instead of complete advertising
PDU. This is because those fields are at different locations in legacy
and extended advertising PDUs so caller can figure them out.
Also, we can now check for directed advertising using TargetA since it
will be only supplied for such advertising (NULL otherwise).
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Release the LF clock requested in blocking mode used to wait
to settle, which has already been asynchronously requested.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix lll_clock_wait function to wait for LF clock to settle
only once after power up.
Regression introduced in commit 2b4763076e ("bluetooth:
controller: Adapt to onoff clock control").
Fixes#30480.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Clean up included header files, remove including
zephyr/types.h and other deprecated or redundant
header files.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reordering of the struct elements to match the Linux format.
The __packed() is not necessary anymore.
std_id and ext_id is merged to id in the frame and filter.
Additionally, the frames are ready for CAN-FD.
Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
The previous API can't change the sampling-point and only allowed
bitrates that fit the time segments.
The new API allows for shifting the sampling-point and adjusts the
number of time quantum in a bit to all more possible bitrates.
The functions to calculate the timings are moved to the can_common file.
They can be used for all drivers.
Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
If the SRC field of the received message is a unicast
address of an element of the Low Power node, then the
message shall not be stored in the Friend Queue.
Otherwise, lpn will discard this message, eventually
it breaks friendship.
Fixes: #30657
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
If getaddrinfo() was called with AI_PASSIVE flag in hints,
returned address defaulted to SOCK_STREAM and IPPROTO_TCP.
Fixed so that SOCK_DGRAM leads to correct address type
that can be fed to bind() directly.
Same hard coding was visible when numerical IPv4 address string
was converted to binary. That is also fixed to respect hints now.
Also, added functionality to get IPv6 address, when hints contained
AF_INET6.
Fixes#30686
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Validate the disconnect reason in the disconnect command, according
to the the core specification.
7.1.6 Disconnect command:
Authentication Failure error code (0x05), Other End Terminated Connec-
tion error codes (0x13 to 0x15), Unsupported Remote Feature error code
(0x1A), Pairing with Unit Key Not Supported error code (0x29) and Unac-
ceptable Connection Parameters error code (0x3B).
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Return the error code from the disconnect command to the application
when an invalid disconnect reason has been provided.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When needing to lock non-connection related access, use k_mutex
instead of locking irq. There is really no reason to prevent the
system from generating interrupts.
Fixes#30636
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add thread runtime statistics to the thread analyser.
With CONFIG_THREAD_RUNTIME_STATS enabled:
Booting from ROM..*** Booting Zephyr OS build zephyr-v2.4.0-2330-g77be0e93e65b ***
thread_a: Hello World from cpu 0 on qemu_x86!
Thread analyze:
thread_b : STACK: unused 740 usage 284 / 1024 (27 %); CPU: 0 %
thread_analyzer : STACK: unused 8 usage 504 / 512 (98 %); CPU: 0 %
thread_a : STACK: unused 648 usage 376 / 1024 (36 %); CPU: 98 %
idle 00 : STACK: unused 204 usage 116 / 320 (36 %); CPU: 0 %
thread_b: Hello World from cpu 0 on qemu_x86!
thread_a: Hello World from cpu 0 on qemu_x86!
thread_b: Hello World from cpu 0 on qemu_x86!
thread_a: Hello World from cpu 0 on qemu_x86!
thread_b: Hello World from cpu 0 on qemu_x86!
thread_a: Hello World from cpu 0 on qemu_x86!
thread_b: Hello World from cpu 0 on qemu_x86!
thread_a: Hello World from cpu 0 on qemu_x86!
Thread analyze:
thread_b : STACK: unused 648 usage 376 / 1024 (36 %); CPU: 7 %
thread_analyzer : STACK: unused 8 usage 504 / 512 (98 %); CPU: 0 %
thread_a : STACK: unused 648 usage 376 / 1024 (36 %); CPU: 9 %
idle 00 : STACK: unused 204 usage 116 / 320 (36 %); CPU: 82 %
thread_b: Hello World from cpu 0 on qemu_x86!
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Add new shell module for mcuboot enabled application. It provides
information about image slots and allows to perform such operations as:
confirm, erase and request upgrade.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
is_rodata() can now determine if an object is the rodata section
on SPARC. This eliminates spurious run-time error messages about
"missinglog_strdup()".
Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
Add implementation of HCI_LE_Set_Connectionless_CTE_-
Transmit_Parameters command in HCI.
Add implementation of command handling in controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Sets the LPN state to WAIT_UPDATE when waiting for the initial poll
response when disabling LPN_ESTABLISHMENT. Previously, the LPN node
would stay in the wait offer state even after the offer was processed,
which led to it aborting the friend establishment completely if it
failed to receive the first poll.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
While the friend node considers the friendship established as soon as it
sends the friendship offer, the LPN only considers the friendship
established once it receives the first update after its poll. This
update is encrypted with the friendship credentials, which aren't
available, as they're protected by an if (lpn_established()) check.
Changes the check to lpn_waiting_update(), which makes the LPN check its
friendship credentials only when it's expecting a response to a poll
message. This is the only time the friend will send messages encrypted
with the friendship credentials.
This is a regression from #28511.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Explicitly sets the LPN credentials when sending a friend request.
This fixes a regression from #28511.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Do not abort pairing when peer sends a SMP command with an opcode
reserved for future use, as per spec.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Add a dummy SMP command handler for keypress notification, that does
nothing (yet). This allows the next commit to work properly.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Remove NET_CONFIG_SETTINGS Kconfig option. The net settings should
be enabled from now at project config or at any overlay. This is
necessary to allow better control when application should start.
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Current logs only prints default logs level. Add LOG_LEVEL at updatehub
to switch to another variation based on CONFIG_UPDATEHUB_LOG_LEVEL.
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Fix TIMER0 and RTC0 being selectable when using out-of-tree Bluetooth
controller.
Generalize the Kconfig to have the features that use the HW peripheral
select them as reserved to make the dependencies more manageable.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
A dedicated LwM2M execute callback type has been implemented which
supports execute arguments. The lwm2m engine, lwm2m_client sample and
lwm2m objects have been updated accordingly. Also the API change has
been documented, and the lwm2m engine reference has been updated.
Fixes#30551.
Signed-off-by: Maik Vermeulen <maik.vermeulen@innotractor.com>
Put everything inside an if, we should not see anything related to
hawkbit in generated .config if it is not enabled.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Put everything inside an if, we should not see anything related to
updatehub in generated .config if it is not enabled.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Bluetooth Mesh require minimum limit time to enter iv update
state or return to iv nornal state.
For Zephyr bluetooth mesh implementation, use`ivu_duration`
type `uint8_t` to represent current time, but if the time is
more than 255 hours, there will be problems due to the
overflow of 8-bit unassigned variables.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The K_MSEC macro evaluates its argument twice, which causes double
evaluation of some function calls in the mesh stack.
This removes all instances of function calls inside K_MSEC macros in the
mesh stack.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Added a new Bluetooth API that can be used to read the current and
maximum transmit power level of the radio. The reading operation is
performed over HCI.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Previously, if the peer address was not set, the host would
do undirected advertising even if the application applied
options only applicable to directed advertising.
Adding this additional parameter validation reduces the confusion
of application developers when they have configured something wrong.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
`POLL_TIMEOUT_MAX` should use `CONFIG_BT_MESH_LPN_POLL_TIMEOUT`
instead of `CONFIG_BT_MESH_LPN_INIT_POLL_TIMEOUT`. The described
algorithm to grow the poll timeout implemented in function
poll_timeout does not work with this implementation.
It's a regression in 3b4d58a
Bluetooth: Mesh: optimize performance for lpn node
Fixes: #30338
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Release the CUI/CPR lock if the connection owning the lock is
terminated.
This can happen if a device performing a CUI/CPR procedure gets a LSTO
before the procedeure completes or the procedure itself TO.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
`app_key_del` first param should be key_app_idx,
not key_net_idx.
The effect is that app_key_del is broken.
It's a regression in eca014115
Bluetooth: Mesh: Isolate cryptographic material
Fixes: 30468
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Add option to enable software CSMA backoff in the OpenThread MAC layer.
This allows to run CSMA procedure correctly in radios that do not
support hardware CSMA backoff, and use them as RCP, where this feature
is required.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit adds a missing otPlatSettingsDeinit function
to the Zephyr OpenThread platform implementation.
Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
Cleanup code for power management and remove some duplication and
isolate power management code from the kernel code.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
- Remove SYS_ prefix
- shorten POWER_MANAGEMENT to just PM
- DEVICE_POWER_MANAGEMENT -> PM_DEVICE
and use PM_ as the prefix for all PM related Kconfigs
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Adds support for extended advertiser commands in the mesh. This doubles
throughput for common packet sending, and significantly improves timing
accuracy for the Friend and Low Power features.
The proxy module's advertisement control has been moved inside the adv
module to abstract away the different advertiser modes.
The extended advertiser mode does not need an advertising thread to
operate, and ends up with a net reduction in RAM usage.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Previously, lwm2m_engine set would check against the max_data_len
parameter of the ressource, but didn't take into consideration the
(possibly changed) max_data_len returned by the pre_write callback.
Fixes#30541
Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
In mqtt_keepalive_time_left(), return -1 if keep alive messages are
disabled by setting CONFIG_MQTT_KEEPALIVE=0.
This allows to use mqtt_keepalive_time_left() directly as an input
for poll(). If no keep-alive is expected, -1 would indicate
that poll() can block until new data is available on the socket.
Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
Use the core k_heap API pervasively within our tree instead of the
z_mem_pool wrapper that provided compatibility with the older mempool
implementation.
Almost all of this is straightforward swapping of one alloc/free call
for another. In a few cases where code was holding onto an old-style
"mem_block" a local compatibility struct with a single field has been
swapped in to keep the invasiveness of the changes down.
Note that not all the relevant changes in this patch have in-tree test
coverage, though I validated that it all builds.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This tiny header uses non-builtin types but includes no headers that
would define them. Recent header motion seems to have exposed a case
where this file can get built before its dependencies are included.
Add the header directly.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Mark all k_mem_pool APIs deprecated for future code. Remaining
internal usage now uses equivalent "z_mem_pool" symbols instead.
Fixes#24358
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
When CONFIG_BT_CTLR_CONN_META is enabled and the ticker "must_expire"
feature is used, collisions may cause incorrect decrement of the
supervision_expire counter, resulting in a too early link supervision
timeout.
Signed-off-by: Morten Priess <mtpr@oticon.com>
The commit removes a leftover configuration of the log management that
has never worked and has been removed with the commit
0bb466c34e4fe863733a929baa8f51981263ce3d to apache/mynewt-mcumgr.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Fix incorrect initiator window offset used when in continous
initiator scanning. Calculated window offset to free time
space after existing central connections is not decremented
correctly when there is change in window at every initiator
scan interval.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix corruption of ftr auto-variable due to reuse to insert
new node rx into the received auxiliary PDU chain, which can
cause corrupt reference used later in the implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix PHY Update control procedure to accept the preferred Tx
coding options (S2 or S8) requested even if there is no
actual PHY change happening on procedure completion.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Both AdvA and TargetA have constant offset in extended header so it
makes sense to have dedicated definitions for those numbers.
AdvA is always placed at the beginning on extended header while TargetA
follows AdvA directly. There are no PDUs without AdvA and with only
TargetA.
Offsets of other fields depends on extended header contents and thus
are non constant.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
'ext_hdr' member only covers extended header part of 'ext_hdr_adv_data'
and with addition of 'data' member to 'pdu_adv_ext_hdr' those can be
used to quickly access both extended header flags and data directly
from 'pdu_adv' without need for extra local variables and casts.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
pdu_adv_hdr name is quite confusing since it suggests some generic
header for advertising PDUs while this in fact is extended header
which is a part of common extended advertising payload and only applies
to extended advertising PDUs.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
The 'adi' part of that member name does not make sense since ADI is
already part of extended header, so we only have 'extended header' and
'advertising data'.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
If handle mapping is enabled, we need to use proper advertising set
handle in HCI event.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
When legacy set is configured we need to make sure scan response is
properly initialized with empty data. For extended sets we should not
touch scan response on configure since data for those sets have to be
set explicitly, e.g. we cannot enable scannable advertising set if no
data was set.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
It was possible that settings_line_entry_copy() did unaligned
flash write.
This patch introduce respecting the flash write-block-size.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
AdvA in extended advertising PDUs was only set if random address was
used. This patch enables proper support for AdvA/TgtA in those PDUs
also with LL Privacy enabled.
On enable, we always update advertising PDU (i.e. ADV_IND, ADV_EXT_IND
or ADV_AUX_IND, depending on advertising set parameters) as well as
scan response PDU.
On RPA timeout, we simply copy old PDU as-is and update AdvA in new
PDU, since both PDUs are exactly the same (except AdvA) so no need to
recreate it step-by-step.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Guards the functions with CONFIG_BT_CTLR_HCI_ADV_HANDLE_MAPPING
and added a non-HCI inline function for them.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Removed the node_rx argument for the BIG create/terminate
functions. The event should not be sent right after the
command, but needs to wait for transmissions of
empty BIS packets or BIG terminate indications.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Moves the ISO tx pool and functions from ull_adv_iso.c to
ull_iso.c as the pool and functions will be shared between
BIS and CIS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rearranged the functions so the order of functions match
the common pattern in other ULL files.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implements the BIG terminate command that terminates a
BIG and returns the appropriate events.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When a BIG is create, it will now start sending empty BIS PDUs;
at least from an ULL perspective, as the LLL support is still
missing.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implements handling of the BIG create command in the upper link layer.
Does not yet handle sending any BIS events.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The immediate logging option cannot be used with network logging
support CONFIG_LOG_BACKEND_NET as that would cause the generated
rsyslog messages to be malformed. The UDP packets would only have
one byte payloads which is not correct. So make sure that user is
not able to select a configuration with immediate mode and network
logging.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix Extended Scanning on Coded PHY, auxiliary PDUs on Coded
PHY where not received due to redundant conditional code
only applicable in connection role being copy-pasted during
the development of Extended Scanning feature.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use memmove to copy overlapping memory when populating the
Common Extended Advertising Header Format in the advertising
PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix maximum PDU len configuration when advertising and/or
scanning on primary channels.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The message should only be returned if the requested pending/reply
pointer is not NULL. Otherwise it could get an incorrect match (for
instance if specific pending pointer is searched for and reply is NULL
the function could return any message that doesn't expect a reply (and
thus has its reply pointer set to NULL).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
LwM2M engine by default sends piggybacked responses for requests after
all callbacks are executed. This approach however isn't good enough if
the application callback executes some lenghty operations (for instance
during FW update). Delaying the ACK may result in unnecessary
retransmissions.
This commits adds an API function which allows to send an early empty
ACK from the application callback. This prevents further retransmissions
from the server side. After all callbacks are executed, the LwM2M engine
will send the response as a separate CON message.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Change type of advertising set handle to 8 bit to comply with
Bluetooth Core spec. type.
Fixes wrong usage of adv. set handle variable in function
bt_le_per_adv_set_param.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove irq_lock around connection lookup, this is no longer needed
now that the lookup functions always have a valid reference.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Make the connection lookup functions thread-safe by re-using the
bt_conn_ref returning NULL mechanism and keeping a valid reference.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Make bt_conn_ref return NULL if the reference count has reached zero.
This makes it possible to re-use bt_conn_ref internally to re-use the
reference count mechanism to check if the reference is in use.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use common definitions of HAL_USED_PPI_CHANNELS and HAL_USED_PPI_GROUPS
macros that will provide (through z_bt_ctlr_used_nrf_ppi_* variables)
information about either PPI or DPPI (depending on the SoC) resources
used by the Bluetooth controller.
Update also the hal_nordic module revision, to make the related nrfx
allocator aware of those reserved DPPI resources.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Remove no longer needed definition of NRFX_PPI_CHANNELS_USED_BY_PWM_SW
(after recent changes in the nrf_hw_models models, also for simulated
nRF boards the nrfx_glue.h file is processed, so this symbol is always
defined).
Remove also a couple of *_PPI_x_INCLUDE macros, to make the code a bit
clearer and to avoid things like a build assertion (also removed here)
that checks if HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_0_INCLUDE is indeed
defined as BIT(HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI(0)).
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
For USB mass storage class, a fixed size 16 KiB FAT12 ramdisk
is forced. This is not really visible to the user and
the DISK_RAM_VOLUME_SIZE option is ignored.
There is no use of such a small file system and for USB MSC
testing, like throughput or USB3CV, a file system is not necessary.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
When testing the bmi160 I've come across an issue where the readings
didn't make sense to me. The issue comes from reading the
BMI160_SAMPLE_BURST_READ_ADDR which is 0x0C assuming both accelerometer
and gyroscope. At this point we would normally read 12 bytes
(2 bytes per sample * 3 axes * 2 sensors). This reading takes place in
bmi160_sample_fetch and begins writing to data->sample.raw
Without this change, the first byte written is actually to the dummy
byte which effectively gets tossed. The issue is that this is the
GYR_X<7:0>(LSB) according to the BMI160 data sheet. When we later call
either bmi160_gyr_channel_get or bmi160_acc_channel_get we're looking
at sample.gyr and sample.acc (which is effectively shiften by 1 byte).
This change gets rid of the dummy byte which re-alignes gyr with the
start of the raw buffer.
Signed-off-by: Yuval Peress <peress@chromium.org>
Verify if block tranfer is used and not an initial block when skipping
directly to data processing during FW update in PUSH mode.
This fixes a bug, which caused TLV not to be processed when the FW
object was updated as a whole, and actual resource number was encoded in
a TLV (for instance when writing FW Update URI).
Fixes#30135
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When ctr_drbg_initialize fails the function returns without unlock irq
that was previously locked.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
entropy_get_entropy return is not being checked what may result in a
vulnerability because tc_ctr_prng_reseed will not get proper entropy
data.
Fixes#29869
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Rework the bootstrap DELETE operation, to support deletion of multiple
resources.
Current implementation had several oversimplifications, making it not
spec-compliant:
* DELETE `/` removed only Security object instances (!= 0)
* DELETE `/x` was handled as DELETE `/x/0`, therefore not removing all
of the object instances.
Since the above is only supported during bootstrap and not regular
Device management, this functionality was implemented in the
`bootstrap_delete` function, which now will be called for all DELETE
operations initiated during bootstrap. The regular LwM2M DELETE handler
will only be called during regular Device management, as it has more
strict limitations on what can be deleted.
Additionally, handle empty URI Path option as `/`, therefore indicating
deletion of all resources.
Fixes#29964
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>