A bad peer responding to read-by-uuid can return handles outside the
requested range. This confuses the stack. In particular, the "continue"
and "end" logic in the same function relies on this assumption.
This bad peer was a real issue at UPF, and it caused an infinite loop
during discovery.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/50686
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The recommendation to have 20ms is fair for two
consecutive messages over a single bearer. When mesh
sends two messages it can be interpreted as two
bearers working in parallel. No need to keep
an artificial 20ms delay for that. Delay was
removed and all related bsim tests were fixed.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Implement the CAP Commander discovery function.
Adds support for it in the shell.
This includes initial babblesim and unit testing as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The condition for channel-map are CONFIG_BT_CENTRAL ||
CONFIG_BT_BROADCASTER, change the corresponding handler ifdef so that
it's included in the build if CONFIG_BT_BROADCASTER is enabled but
CONFIG_BT_CENTRAL is not.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commits create the dts binding for Ambiq BT HCI instance.
And create the SPI based common HCI driver for Ambiq Apollox
Blue SoC and the extended soc driver for HCI.
Signed-off-by: Aaron Ye <aye@ambiq.com>
Adds test that verifies correct Proxy advertisement behavior for
a device where the Proxy adv requirements changes over time,
both for single and multiple subnets.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Refactors proxy advertising implementation to allow fair sharing of
advertising resources between all subnets.
In the new implementation, each subnet is agnostic to any other subnet
that might have active proxy advertisement work. When proxy
advertisement is triggered, the implementation will first check how
many subnets that has active work. If there are more than one active
subnet, a maximum timeslot will be calculated to ensure that all active
subnets get access to the medium. The implementation will then poll
the next eligible subnet for a proxy advertising request. If the
duration of this request exceeds the maximum timeslot, the duration
for the next advertisement will be set to the maximum value.
If a proxy advertisement for a subnet is interrupted by other
advertising activity, the implementation will now ensure that the
interrupted proxy adv continues from the point where it was
interrupted so that the subnet gets to utilize the entire allocated
timeslot.
This PR also alters the priv_proxy_net_id_multi Bsim test to align
with the refactored proxy advertising scheme.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
The section 3.7.3.1 of the mesh specification recommends to delay
a message publication in certain cases:
- at power-up or upon state change for a time between 20 to 500 ms
- for periodic publications for a time between 20 to 50 ms
This change implements this recommendation by adding the
`CONFIG_BT_MESH_DELAYABLE_PUBLICATION` Kconfig option which enables
the randomization code and by adding the `bt_mesh_model_pub.delayable`
bit field which allows each model decide whether the publications
should be delayed for this model or not.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This is just as arbitrary as what was before, but simpler.
Before this change, the callback were invoked upon receiving the num
complete packets event.
This did not necessarily work with all spec-compliant controllers.
Now the callback is invoked as soon as the lower layer destroys the
buffer. ATT shouldn't care whether L2CAP sends it over RFC1149 or
something else after that point.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Why?
- metadata is easier to manage as an array + index
- less error-prone -> less memory-management bugs
- we can. because of the previous refactor
- PDU allocations are more predictable
- ATT buffer size can be optimized by app
- isolates ATT from the rest of the ACL users
- decouples ATT PDU size from e.g. SMP w/ LESC
Drawbacks:
- higher memory usage
- kconfig change
The higher memory use is only temporary, as this will be followed-up
with more refactors that should bring it back down.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Simplify track and group changes by moving the
notifications into the functions that changes the states.
This removes some code duplication, and makes the code easier
to read, as well, as ensuring that notifications are always
sent.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The set_track_position handles both correct clamping of the
position, as well as the notification, so use that instead
of setting the value and sending notifications manually.
Also adds a new function, set_relative_track_position,
to help set relative positions.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixed the stream_start_sine function when omitting the all argument.
The verification of the sine checked reversed return value, and was
placed in incorrect order.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
This fixes regression introduced in recently.
Redundant connection reference is taken twice in connected()
callback. The redunant reference was then not returned, and
as a result we had a leak.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This starts using CONTAINER_OF macro instead of inst_by_conn function
wherever possible. It's better approach as the client instance is
a container for parameters passed to the callbacks.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Renames "prov device" references and options to
"provisionee" to align implementation with Mesh
Protocol specification v1.1, section 5.4.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
This fixes the return error code for Preset Write operation that shall
be returned when preset is not writable (or disabled via Kconfig like in
this case).
As per HAS_v1.0; 3.2.2.3 Write Preset Name operation
"If the Writable bit in the Properties field of the preset record which
is identified by the Index parameter is set to 0b0, then the server
shall return an ATT_ERROR_RSP PDU to the ATT_WRITE_REQ PDU with
the Error Code parameter set to Write Name Not Allowed."
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This avoids unexpected assert that may happen when the client tries to
QoS configure ASE that is in state which does not allow to be configured.
In such case the assert shall not be not be triggered, as it's not stack
fauly. The assert check has been moved after the state check, so the ASCS
implementation will just return an error code to the client.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes CCC subscriptions that were removed if the automatic
resubscription was aborted by ACL disconnection.
As the client renews subscriptions, there is no point of removing those
if the link is disconnected unexpectedly.
The API user won't be notified about the failure, as the automatic
resubscriptions are implicit, and after reconnection the subscriptions
will be still valid.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes issue where API use is able to register writable preset even
if the CONFIG_BT_HAS_PRESET_NAME_DYNAMIC Kconfig option was disabled.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add the GMAP shell module with support for running the
various audio configurations in an easy way.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add initial implementation of Gaming Audio Profile (GMAP).
This is a top layer profile in the LE Audio stack,
designed for low latency audio ideal for gaming.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt connect and bt connect-name commands should only
attempt to connect to connectable devices that we are not
already connected to.
This commit moves the check for BT_GAP_ADV_PROP_CONNECTABLE
as well as checks that we do not already have a connection
to that device with the current ID.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use helper function to convert string to int for appearance value.
This makes the code more clear, as the big-endian conversion function
gives the wrong impression about the byte order of advertising data.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Commit adds implementation of the specification
recommendations regarding randomization of
responses on the access layer.
3.7.3.1 Transmitting an Access messages
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
This error message may confuse when `CONFIG_BT_MESH_ACCESS_LAYER_MSG` is
enabled and all messages are processed by the callback anyway.
This error message also confuses when a node is subscribed to the same
address as it publishes to, which makes it generating the error message
every time it publishes a message.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This change allows a custom RPL use pending mechanism and the mesh
settings work to store pending RPL entries. `bt_mesh_rpl_pending_store`
is a public API and should be implemented anyway. The custom RPL
implementation has to trigger settings with the
`BT_MESH_SETTINGS_RPL_PENDING` flag to ask the mesh settings work to
call `bt_mesh_rpl_pending_store`.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Modify the VCP volume controller callbacks to support
multiple registers by making it into a linked list.
This allow for multiple applications to get the information
from procedures or notifications.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add const prefix for service uuid and char uuid.
Since Service UUID and Char UUID should not change in the service
definition, they are most reasonably defined as rodata, also for
save some ram footprint.
The field `attr->user_data` type is `void *`, as this PR change
all Service UUID to rodata, so there must add (void *) to avoid warning.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The CAP Initiator and the CAP Commendar share quite a lot of
functionality in terms of discovery and performing set-based
procedures.
The code for handling most of this has been moved to
cap_common.c to avoid duplicating code.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
It's bad form, especially since in that case, it's always the same function
that is called `bt_att_sent()`.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
To avoid having "notification scheduled in 0ms" in the log,
check to verify that the delay is not K_NO_WAIT.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds the function that sets the available contexts value per
connection object so that API user can set different available contexts
per connection.
The lifetime of such overriden value is the same as connection lifetime,
so on reconnection or device reboot all devices return to having the
same available contexts value again.
Fixes: #64968
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes client lookup that was done with use of bt_conn_index while
the size of the client array is CONFIG_BT_MAX_PAIRED.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Disallow further changes of supported audio contexts characteristic is
the GATT Characteristic Notify Property is not set.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Enforcing the peer's behavior is not strictly necessary. All the host
should do is make sure it is resilient to a spec-violating peer.
Moreover, a growing number of platforms were disabling the check, as the
spec allows "batching" HCI num complete packets events, stalling ATT RX.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Add function to get a volume controller from a connection
pointer.
This is required for the CAP to get a vol_ctlr pointer
from the provided bt_conn.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>