When we reconnect to a bonded device we always attempted to
send the changed PACS notifications, regardless of
whether the remote device has subscribed to them or not.
This resulted in a lot of failed attempts to send
notifications when
CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION is enabled (which it is
by default).
Ideally we would not set the flags for devices that have not
subscribed, but since we cannot call bt_gatt_is_subscribed for
non-connected devices, we need to do this when the notify_cb
is called.
It would be possible to use BT_GATT_CCC_MANAGED instead
of BT_AUDIO_CCC to keep track of the writes for each client,
but that would be a minor optimization which would require
significant rework and additions to PACS. The current
solution is inspired by the implementation used in has.c
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Define BT_AVDTP_SIGNAL_SDU_MAX Kconfig item to limit the max avdtp signal
SDU size, then use avdtp self defined net buf pool to prepare data. Use
default acl_tx_pool pool do to the fragmentation.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
In USB "in" refers to data going from device to host,
and "out" refers to data going from host to device.
From a BT perspective "usb_out" then refers to the data
we receive from the host, to be sent over BT, so the "out"
terminology still works for that, and vice versa for
incoming BT data.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Commit removes `Wrong state` warning from some DFU API.
This information has value only for debugging.
No any value for application to generate warning
on the regular basis.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The bt_bap_unicast_client_qos function was recently
modified to check for presentation delay, however it did
not consider that a unicast group may contain streams that
are not configured, and thus do not have endpoints.
Add a stream->ep != NULL check to only consider configured
streams.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is an issue found that the L2CAP BR channel attempts to send
signaling commands through fixed channel when the ACL connect is
broken. At this time, the ACL connect of fixed channel is invalid.
Then the `__assert` occurs in function `bt_conn_ref()`.
Fixed the issue by checking the ACL conn of the L2CAP channel before
sending the data.
Here is a referred fault case for this changes,
There are two connected L2CAP Channels. The first one is primary
connection of the profile. And the second one is secondary connection
of the profile. When the primary connection is broken, the secondary
connection should also be disconnected.
In normal case, if the primary connection is disconnected by calling
L2CAP channel disconnection function, the secondary connection will
be disconnected by calling L2CAP channel disconnection in the
disconnected callback of primary connection.
But there is a corner case is that, the ACL connection is broken.
When the disconnected callback of primary connection is called, the
function call of L2CAP channel disconnection for secondary connection
will be asserted. Because the signaling channel (fixed channel ID
0x01) is disconnected and the `chan->conn` of the fixed channel is
NULL in this time.
The call stack is,
o bt_conn_ref() -> Asserted in this function.
o bt_conn_data_ready() -> The parameter is `br_chan->chan.conn`.
It is the NULL.
o raise_data_ready() -> The parameter `br_chan` is fixed channel.
o bt_l2cap_br_send_cb() -> The parameter is ACL conn and CID of fixed
channel (cid = 0x01). The channel can be found, but `chan->conn` is
NULL.
o l2cap_br_chan_send_req()
o bt_l2cap_br_chan_disconnect()
o bt_l2cap_chan_disconnect() -> The parameter is the channel of
secondary connection. The state of secondary channel is connected,
because the stack is handling the primary channel disconnecting.
And the function is called in disconnected callback of primary
channel.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
In current implementation, the ATTR ID list is set with fixed value
(0x0000, 0xffff). For the case that responding a lot of SDP record
data, the responded data cannot be processed properly due to the
receiving buffer size limitation. In this case, the ATTR ID list can
be used to reduce the length of the responding data. In this way, it
will help reduce the SDP's requirement for receiving data buffer size.
Add the attribute ID list configuration to the SDP discovery request
structure `struct bt_sdp_discover_params`.
If the `struct bt_sdp_discover_params::ids` is NULL, or
`struct bt_sdp_discover_params::ids::count` is 0, the default range
(0x0000, 0xffff) is used.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
In current implementation, if the response total data length is more
than the receiving buffer size, the request cannot be completed
properly.
Improve the SDP client with the following changes,
o Notify the received completed SDP records if the case occurs, and
then start the continuing SDP discovery,
o Stop the SDP discovery if the hold SDP record cannot be saved to the
receiving buffer,
o Stop the SDP discovery if the `BT_SDP_DISCOVER_UUID_STOP` is
returned by upper layer.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
In current implementation, after parsing the received service search
pattern and all matched SDP records are saved in the local variable
`matching_recs`. The max count of SDP records within its SDP
database that match the given service search pattern is
BT_SDP_MAX_SERVICES when parsing the received Service Search Pattern.
And it causes the max count registered SDP records is limited to
BT_SDP_MAX_SERVICES.
Refactor the parsing of service search pattern to remove the
limitation with the following steps.
1. Save the service search pattern to a simple buffer by calling
the function `parse_service_search_pattern()`.
2. Traverse all registered SDP record and check for each SDP record
if it is matched with given service search pattern by calling
function `service_search_pattern_matched()`.
3. Use the matched SDP records to response the SDP request.
And also remove the limitation of the max count of registered SDP
records.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Use slist instead of custom singly linked list to manage SDP records.
Check if the SDP record has been registered in the function
`bt_sdp_register_service()`.
Append the new SDP record to the tail of the SDP record list.
Check if the index of SDP record is overflow in the function
`bt_sdp_register_service()`.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Fix incorrect LLL scheduling of subsequent subevents when
using single timer implementation, due to missing call to
accumulate the last PDU end timestamp which is essential to
setup next radio start and to setup header complete timeout.
Relates to commit 373dc0db71 ("Bluetooth: Controller:
Single timer use Extended Advertising nRF54L support").
Relates to commit 6e8f081385 ("Bluetooth: Controller: Fix
peripheral assert under single timer use").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The bt_csip_set_member_unregister function unregisters
a CSIS instance and restores the attributes to the original
state (the attributes may change during registration).
The previously solution had some issues with a check when
using picolib (‘__ssp_bos_check3’ undeclared), and this
fixes that by using a proper variable for the memcpy.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of re-implementing or assuming that POPCOUNT is available
we now use the generic function from Zephyr.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the big_disconnect function to do cleanup_big before
calling the `stopped` callback. This will allow the ISO channels,
as well as the BIG itself, to be reused for other purposes directly
in the stopped callback, without having to offload such actions
to a separate thread.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds a function that verifies if an endpoint pointer is
part of ASCS before performing CONTAINER_OF operations on it.
Adds checks for this in the BAP Unicast server public API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_ascs_ase_status was stored directly in the
struct bt_bap_ep, which was an issue as
bt_ascs_ase_status is a variable sized struct.
The struct could have been moved to the end of
bt_bap_ep to avoid the issues it caused, but
there is no actual reason to use that struct
rather than storing the ID and state as
seperate values.
The ascs_ep_get_state exists but was not widely
used in ascs. Modify places to use the function
instead of directly accessing the state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This moves the declaration of the utf8 utils defined in lib/utils/utf8.c
in their own header. Main reason to do this is that the current setup
requried adding an include for sys/types.h in util.h, which can result
in a build falure due to a circular header depdenecy when using:
CONFIG_POSIX_API=y
CONFIG_NEWLIB_LIBC=y
_GNU_SOURCE
the loop and error are:
- include/sys/types.h:50: <- this is a NEWLIB one
- include/zephyr/posix/sys/select.h:9:
- include/zephyr/posix/posix_types.h:30:
- include/zephyr/kernel.h:17:
- include/zephyr/kernel_includes.h:25:
- include/zephyr/sys/atomic.h:18:
include/zephyr/sys/util.h:705:1:
error: unknown type name 'ssize_t'
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fix missing ISO Receiver access address capture that caused
ISO PDU reception error. Missing access address capture for
subsequent subevent when prior subevent did not have an
anchor point sync prevent proper drift compensation hence
causing ISO PDU reception error for the entire BIG event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the jitter considered in the PDU reception in the
subevents of ISO Sync Receiver to not exceed such that the
reception is scheduled late (causing assertion).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
sdp matching_recs maybe filled with uninitialized record. if
sdp_svc_search_req come from remote with invalid max_rec_count,
which is greater than num_services, matching_recs would response
uninitialized record result.
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
Commit 39cb574 changed the log level from LOG_DBG to LOG_ERR in
bt_le_adv_resume(). This causes the error log
"No valid legacy adv to resume" to appear during normal connection
establishment when using bt_le_ext_adv_start(), even though the
system is functioning correctly.
Revert the change to restore the original LOG_DBG level.
Fixes: #94954
Signed-off-by: Samuel Tsai <stsai@atmosic.com>
If the cmd fail to receive response (for example: timeout), the buf is
NULL, then need to callback the result.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
Add support for setting and getting the bearer provider
name. For now the name will be duplicated by the TBS
implementation, but will be optimizied in the future
so only one copy of the name exists.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add bt_cap_unicast_group_get_info to get information about
a CAP unicast group. For now this just contain the pointer
to the BAP unicast group, which then can be used with
bt_bap_unicast_group_get_info to get information specific
to BAP. The bt_cap_unicast_group_info struct can later be
expanded with any additional information CAP may add.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add bt_bap_unicast_group_get_info to get information
about a unicast group. In this first iteration the info
struct only contains the sink and source presentation
delay, but the info struct can easily be expanded on
later to contain more.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
BAP section 7.1 states that all streams in a direction shall
have the same presentation delay. To achieve this, we need to
store the configured presentation delay for a unicast group,
so that we can compare with the new presentation delay.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Relax the radio packet pointer assignment deadline assertion
until access address being transmitted. The PDU buffer is
probably only needed just after access address is being
transmitted or received by the radio. This will give some
more breathing room for slow CPUs like in nRF51x SoCs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There was an issue where terminating the BIG while in the
ISO connected callbacks could lead to continueing the loops
would cause access to cleared memory.
The simple solution to this is to simply prevent
bt_iso_big_terminate from terminating the BIGs while we are
processing the BIG HCI events.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The broadcast code was attempting to read from argv[1] instead
of argv[2] that actually contains the broadcast code.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implement the function bt_cap_initiator_broadcast_foreach_stream that
allows users to iterate on all BAP streams in a BAP broadcast source.
This can be used to easily get references to other broadcast streams in
the same group.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Check that SegN is not 0. SegN = 0 is invalid as the first segment is
sent in Transaction Start PDU.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Instead of add BT_UUID_BROADCAST_AUDIO_VAL for either BAP or
CAP, we now only do it one place (in BAP). This can now be done
since the default_source.broadcast_id was recently added.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a broadcast_id field in broadcast_source so that it can be
lookup later, which is useful for doing broadcast assitant
procedures on a local broadcast source.
The broadcast ID is now created at the same time as the
broadcast source(s), instead at the time of retriving
the advertising data.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Check that the buffer length of the received advertising data is less
than reported TotalLength in Transaction Start PDU.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Fix building with Privacy feature without enabling LE
Encryption support. This should allow being either Observer
or Broadcaster role with Privacy features.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>