Modify the struct bt_bap_stream to have a direct reference to the
bt_iso_chan, rather than having a reference to the parent
bt_bap_iso.
This change will allow users to more easily and directly access
the bt_iso_chan, instead of getting the reference via
bt_bap_ep_get_info.
Additionally, this allows users to access the bt_iso_chan for
streams that are not codec configured, and thus not have a
bt_bap_ep reference.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Expose the IDs, handles and numbers of CIGs, BIGs, CISes and BISes
via the ISO info struct. This information may be needed by higher
layer (such as the Basic Audio Profile (BAP)) or used as indexes
for arrays in the application layer.
The location of the CIG_ID, CIS_ID, BIG_Handle and BIS_Number
are moved to the location struct inside of struct bt_conn_iso
instead of being stored directly in it.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the bis_id in struct bt_conn_iso to be bis_number
and correctly initialize it for both the broadcaster and
the sync receiver.
The field is currently unused and the term bis_id does not
exist in the core spec. The BIS Index was renamed to BIS
Number in Core 6.1, and thus the Zephyr code base will
reflect that.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
bt_cap_initiator_started did not have a check for aborted like
all the other callbacks, which could cause the procedure to
continue even if it was aborted.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A public API call that sends ACL data — for example, `bt_gatt_notify` —
can be invoked from a preemptive thread context. This API, in turn,
calls the `raise_data_ready` function, which adds an L2CAP channel to
the `l2cap_data_ready` list.
The atomic variable used to create a critical section around
`l2cap_data_ready` did not work, because a preemptive thread can be
pre-empted at any time. This means that regardless of the `atomic_set`
result, we cannot trust it — the thread could be preempted after the
call, and the atomic variable state could be changed (specifically by
the TX processor in this case). The same issue applies to
`bt_conn_data_ready`, which is called next.
When making an L2CAP channel ready for sending data, we need to use a
critical section when appending a channel to the `l2cap_data_ready`
list. The same applies to the `conn_ready` list.
Since cooperative threads can only be rescheduled explicitly, we must
ensure there are no rescheduling points when accessing either the
`l2cap_data_ready` or `conn_ready` lists.
For `l2cap_data_ready`, this occurs in `get_ready_chan`, which is called
from `l2cap_data_pull`, which in turn is called by the TX processor. For
`conn_ready`, it occurs in `get_conn_ready`, which is also called from
the TX processor. Both functions have no rescheduling points when
working with their respective lists, so they do not require a critical
section.
This change removes the atomic variables previously used to create a
critical section for both lists, as they were ineffective. Instead,
`k_sched_lock`/`k_sched_unlock` are used where code may be executed from
a preemptive thread context. The `sys_slist_find` function is used to
check whether a channel or connection is already in the corresponding
list.
Fixes#89705
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
In current implementation, the attribute of the registered SDP record
will not be included in responding packet if the attribute data length
is more than the MAX payload size(`MIN(SDP_MTU, sad->sdp->chan.tx.mtu)
- sizeof(struct bt_sdp_hdr)`). And it causes the failure of ssa or sa
discovery.
Improve the SDP server to support the case by extending the
continuation state length. A 4 bytes space is extended to store the
attribute offset.
In this way, the attribute can be transmitted in segments according
to the reaming space of the responding buffer.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The function should stop iterating if the callback provided to
bt_cap_unicast_group_foreach_stream returns true.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implement the function bt_bap_broadcast_source_foreach_stream that
allows users to iterate on all BAP streams in a BAP broadcast source.
This can be used to easily get reference to other broadcast streams in
the same group as any other stream via the stream->group pointer
or a broadcast source pointer directly.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
We already have bt_conn_tx for outgoing buffer user data, so name the
struct for incoming (rx) buffers similarly. Also, update ISO to use this
struct instead of a custom iso_data struct, since the content and purpose
is identical.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Removes the BT_LE_ADV_OPT_USE_NAME and BT_LE_ADV_OPT_FORCE_NAME_IN_AD
advertiser options and related flags, macros and functions. The
application now needs to include the device name explicitly.
The API was deprecated in
https://github.com/zephyrproject-rtos/zephyr/pull/71700
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Removed the LOG_WRN if the started or stopped callback
for streams are not set. The reasoning is that there is also
the group-wide started and stopped callbacks, and an application
may want to use those instead of the per-stream callbacks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Removed the LOG_WRN if the started or stopped callback
for streams are not set. The reasoning is that there is also
the group-wide started and stopped callbacks, and an application
may want to use those instead of the per-stream callbacks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_bap_unicast_client_ep_qos function attempts to access
ep->iso->chan.iso->iso, but where some of the pointers may be
invalid. Add an additional check for these.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In addition to aligning the destination address of all connection
objects during the identity resolution phase, we also need to update the
corresponding address field in the `struct bt_keys` structure for each
of these connection objects.
If we don't do this, `bt_keys_get_type` for that connection won't find
the `bt_keys` structure in the pool and will allocate a new one. This
will result in orphaned `bt_keys` structures in the pool.
This completes the change done in https://github.com/zephyrproject-rtos/zephyr/pull/61030/commits/637dabc3c9b018f47dee656d2ca0fe8f2fa21984
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The event header is already accessed in `bt_recv_unsafe`. If length is
valid there, no point in checking it again in `hci_event` or
`hci_event_prio`.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
During debugging multiple.sh test, a race condition was observed where
advertiser state on Host and Controler was desynchronized.
Below is the sequence of actions led to this issue:
0. Host has queued few priority events at this moment.
1. Controller establishes a connection and stops the advertiser.
2. Controller sends to Host BT_HCI_EVT_LE_ENH_CONN_COMPLETE.
3. Host deprioritizes BT_HCI_EVT_LE_ENH_CONN_COMPLETE event and doesn't
process it immediately.
4. Controller sends to Host other priority events which are processed
immediately.
5. Host wants to disable the advertiser in order to update the Resolving
List (see `bt_id_add`).
6. Host sends to Controller BT_HCI_OP_LE_SET_ADV_ENABLE(Disable)
command.
7. Controller sends to Host BT_HCI_EVT_CMD_COMPLETE event on
BT_HCI_OP_LE_SET_ADV_ENABLE command.
8. Host prioritizes this BT_HCI_EVT_CMD_COMPLETE event, processes it
immediately and clears `BT_ADV_ENABLED` flag for the advertiser.
Note that Controller already has the advertiser disabled after
establishing connection on step 1.
9. Host sends few commands in a row and Controller sends
BT_HCI_EVT_CMD_COMPLETE events that are prioritized (see
`bt_id_add`).
10. Host wants to re-enable the advertiser after updating the Resolving
List.
11. Host sends to Controller BT_HCI_OP_LE_SET_ADV_ENABLE(Enable)
command.
12. Controller sends to Host BT_HCI_EVT_CMD_COMPLETE event on
BT_HCI_OP_LE_SET_ADV_ENABLE.
13. Host prioritizes this BT_HCI_EVT_CMD_COMPLETE, processes it
immediately and sets `BT_ADV_ENABLED` flag for the advertiser.
14. Controller has the advertiser enabled.
15. Host now processes the delayed BT_HCI_EVT_LE_ENH_CONN_COMPLETE
event.
16. Host resets the advertiser state, thinking the Controller's
advertiser is also stopped.
This commit prioritizes LE Connection Complete and LE Enhanced
Connection Complete events to drop advertiser state on Host immediately
once the corresponding event was received.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
- "bt_tbs_set_uri_scheme_list()" function does not setting URI for
GTBS instance. Using "inst_lookup_index()" fixes issue to find
registered GTBS instance for provided bearer_index.
- "bt_tbs_set_uri_scheme_list()" function overrides URI scheme list
with latest provided list. But the expectation is that it should
keep previously added URI schemes and only update new scheme which
are not part existing list. Code is updated to fix this.
- The same function uses net-buf to combine all URI schems for all
TBS bearer if current request is not for GTBS instance. Currently,
the code only uses combined URI scheme list for logging purpose and
it is not used to send for URI Scheme notification to provide
updated GTBS URI scheme to remote. Code is now updated to add
dynamic buffer to add all TBS URI scheme list for GTBS instance
and notify it similar to other functions to optimise memory usage.
Signed-off-by: Nirav Agrawal <nirav.agrawal@nxp.com>
If the chrc->uuid is somehow an invalid UUID, we log it and
terminate the discovery procedure.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Some TBS API functions attempted to take the mutex
of an instance before the NULL check.
Reorder the checks of the functions, and also modify function
to be more similar (using the same terms and structure).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There are two main issues found with using DLC TX thread,
Issue 1, the RAM consumption. Every DLC will have a dedicated thread
and thread stack.
Issue 2, the thread stack overflow issue. There is no way to strike a
balance between stack size and RAM consumption. Since the deep of call
stack is depended on the upper layer, the thread stack needs to set by
application. Due to the thread stack of DLC is dedicated, RAM
consumption is the product of the added value and the number of DLCs.
Use a TX worker to replace DLC TX thread.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add a Kconfig `BT_L2CAP_CONNLESS` to enable the feature.
Add an API `bt_l2cap_br_connless_register()` to register the monitor
to receive the unicast connectionless data.
Add an API `bt_l2cap_br_connless_unregister()` to unregister the
registered callbacks.
Add an API `bt_l2cap_br_connless_send()` to send unicast
connectionless data.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Implement the unicast to broadcast handover procedure,
as per the Bluetooth CAP specificiation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Commit f499ea0 made it so that the compiler optimization flags are also
passed to the assembler. However, this breaks for the IAR toolchain
since it uses the GNU assembler which does not have the same
optimization flags as the IAR compiler.
This commit separates the compiler and assembler optimizations to make
it possible to specify appropriate flags in a toolchains corresponding
`compiler_flags.cmake`
Signed-off-by: Daniel Flodin <daniel.flodin@iar.com>
A recent change triggered a warning in LLVM that was promoted to error
when run with twister.
```shell
goep.c:102:3: error: label followed by a declaration is a C23 extension
[-Werror,-Wc23-extensions]
102 | int err;
```
Add a scope to the switch case so that the declaration has proper scope.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
After the #93703 PR was merged we get a possibility to remove _node field
from bt_conn_cb struct if the BT_CONN_DYNAMIC_CALLBACKS option is disabled.
The list conn_cbs can also be safely removed by more macro usage.
Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
CONFIG_BT_CTLR_DATA_LENGTH_MAX should set its default value up to
and including the maximum value supported by the Bluetooth spec
(251 bytes).
Signed-off-by: Sam Friedman <sam@golioth.io>
According to the OBEX Version 1.5, the Name header could be a empty
string.
Update function `bt_obex_add_header_name` to support the case that the
length of name could be 0.
Update function `bt_obex_get_header_name` to support the case that the
name header is found but the name length is 0.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add a TLV array `tlvs` to keep the pending TLV data.
Update `app_param`, `auth_challenge`, and `auth_rsp` to set the one
TLV information each time. When the optional argument `last` set,
write the all pending TLVs to the tx buffer.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add a structure `struct bt_obex_tlv` to pass/save the one TLV info.
Use a array of `struct bt_obex_tlv` as the set of all TLV-triplets.
Update the following functions to support the feature, including
`bt_obex_add_header_app_param`, `bt_obex_add_header_auth_challenge`,
and `bt_obex_add_header_auth_rsp`.
Add a function `bt_obex_tlv_parse` to parse the encoded TLV-triplets.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
There are types of string can be added by using OBEX adding header
function bt_obex_add_header_*(). One is byte sequence. Another is null
terminated Unicode text.
Add a function bt_obex_string_is_valid() to check if the added string
is valid. And add a function bt_obex_unicode_is_valid() dedicated to
check Unicode string.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add commands for GOEP to test OBEX features.
Add command `alloc-buf` and `release-buf` to allocate and release TX
buffer.
Add command set `add-header` to add the OBEX headers to allocated TX
buffer.
Add command set `client` to send OBEX client requests with allocated
TX buffer.
Add command set `server` to send OBEX responses with allocated TX
buffer.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add commands for GOEP to test transport features.
Add commands for transport over RFCOMM, including `register-rfcomm`,
`connect-rfcomm`, and `disconnect-rfcomm`.
Add commands for transport over L2CAP, including `register-l2cap`,
`connect-l2cap`, and `disconnect-l2cap`.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The MTU of the GOEP should be not less than 255. So, if the transport
is RFCOMM, the CONFIG_BT_BUF_ACL_RX_SIZE should be not less than 264.
It includes,
- 255 bytes for the minimum MTU of GOEP,
- 4 bytes for L2CAP Header,
- 5 bytes for RFCOMM header and FCS.
And if the transport is L2CAP, the CONFIG_BT_BUF_ACL_RX_SIZE should
be not less than 259.
It includes,
- 255 bytes for the minimum MTU of GOEP,
- 4 bytes for L2CAP Header.
Add Kconfig `BT_GOEP_RFCOMM_MTU` to configure the maximum size for
RFCOMM transport. The range of `BT_GOEP_RFCOMM_MTU` is
`[264, BT_RFCOMM_L2CAP_MTU]`. And the GOEP MTU via RFCOMM transport
should be in the range `[255, (BT_GOEP_RFCOMM_MTU-9)]`.
Add Kconfig `BT_GOEP_L2CAP_MTU` to configure the maximum size for
L2CAP transport. The range of `BT_GOEP_L2CAP_MTU` is
`[259, BT_BUF_ACL_RX_SIZE]`. And the GOEP MTU via L2CAP transport
should be in the range `[255, (BT_GOEP_L2CAP_MTU-4)]`.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add a Kconfig BT_GOEP to control the GOEP feature.
Implement the GOEP protocol and transport, both for GOEP 1.1 and GOEP
2.x.
For GOEP transport, OBEX over RFCOMM, and OBEX over L2CAP are
supported.
For GOEP protocol, `put`, `get`, `abort`, `setpath`, and `action` are
supported. And only one operation can be processed at the same time.
The feature `Reliable Session` is unsupported.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
L2CAP channels will now, along with the ident, store the opcode of the
pending request. This commit expands the ident lookup function to also
compare received response types to this opcode, and will ignore
unsolicited responses.
Setting of idents for channels are moved after verification of buffer
allocation for the request to be sent. A TODO is added for improving
this functionality at a later time.
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
This functionality is implemented in the HCI-facing side of the
controller and the ULL. LLL functionality is not implemented in this
commit.
Furthermore, this removes a dependency for LE Power Control, as the
features are related, but not necessarily required.
Signed-off-by: Tyler Joseph Huffman <tyhu@demant.com>