Commit graph

9523 commits

Author SHA1 Message Date
Asbjørn Sæbø
1ef1ca5dd1 Bluetooth: Audio: Media control - add const keyword
Add const keyword to variables that shall not change their value.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-25 10:41:29 +01:00
Asbjørn Sæbø
fb2df17933 Bluetooth: Audio: Media - move variables to innermost scope
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>
2022-03-25 10:41:29 +01:00
Asbjørn Sæbø
98fa332527 Bluetooth: Audio: Media control - guard callback
Exclude callback from struct when not needed.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-25 10:41:29 +01:00
Asbjørn Sæbø
2c12328edd Bluetooth: Audio: Media control - correct return value
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>
2022-03-25 10:41:29 +01:00
Asbjørn Sæbø
b4dd2d934a Bluetooth: Audio: Media control - update guard
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>
2022-03-25 10:41:29 +01:00
Asbjørn Sæbø
59b26061cd Bluetooth: Audio: Fix spelling in comment
Correct spelling in a comment

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-25 10:41:29 +01:00
Mariusz Skamra
35188c41ec Bluetooth: shell: Adapt to the ATT MTU API changes
This handles -EALREADY return error.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-25 10:41:19 +01:00
Mariusz Skamra
6eafc64855 Bluetooth: audio: Enable auto ATT MTU Exchange for BASS and unicast client
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>
2022-03-25 10:41:19 +01:00
Mariusz Skamra
e9becda611 Bluetooth: gatt: Add support for automatic ATT MTU Exchange
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>
2022-03-25 10:41:19 +01:00
Mariusz Skamra
a5d9322105 Bluetooth: gatt: Skip MTU exchange if already initiated by peer
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>
2022-03-25 10:41:19 +01:00
Mariusz Skamra
f619ca24d4 Bluetooth: gatt: Disallow repeated attempts to exchange MTU
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>
2022-03-25 10:41:19 +01:00
Mariusz Skamra
f6d0dc355f Bluetooth: has: Add stubs for handling control point requests
This adds server stubs for handling the preset control point requests.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-03-25 10:41:11 +01:00
Asbjørn Sæbø
570bc0d4bb Bluetooth: Media proxy - move mcc callbacks into instance struct
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>
2022-03-25 10:39:40 +01:00
Dominik Ermel
e20f72f7cb kconfig: Remove unneeded ${ZEPHYR_BASE} from template import
The commit removes, from various Kconfigs, ${ZEPHYR_BASE} in
sourcing of logging template.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-03-24 18:07:28 -04:00
Piotr Pryga
3604a7bf9a Bluetooth: Controller: df: Fix CTE req send wrong ntf in single shot run
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>
2022-03-24 15:26:50 +01:00
Emil Gydesen
f474e5075e Bluetooth: Audio: Fix bad string format for ARRAY_SIZE
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>
2022-03-24 12:50:05 +01:00
Piotr Pryga
09cd296962 Bluetooth: Controller: radio: Fix num of antennas returned by controller
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>
2022-03-24 11:59:31 +01:00
Emil Gydesen
b0a01ac82f Bluetooth: Audio: Fix broadcast sink PA sync callbacks register
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>
2022-03-24 10:48:00 +01:00
Emil Gydesen
868806c211 Bluetooth: Audio: Fix broadcast sink null pointer in cleanup
Fix potential null pointer acceess in
broadcast_sink_cleanup_streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-24 10:48:00 +01:00
Emil Gydesen
9e765a2004 Bluetooth: Audio: add BIS index check for broadcast sink
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>
2022-03-24 10:48:00 +01:00
Emil Gydesen
ec3793b154 Bluetooth: Audio: Fix broadcast audio endpoint disconnect state
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>
2022-03-24 10:48:00 +01:00
Emil Gydesen
2df9077307 Bluetooth: Audio: Add missing break for broadcast source ep state
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>
2022-03-24 10:48:00 +01:00
Emil Gydesen
9efa22940c Bluetooth: Audio: Add broadcast source subgroup count Kconfig
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>
2022-03-24 10:48:00 +01:00
Emil Gydesen
23e45c937a Bluetooth: Audio: Add subgroup count check for broadcast sink
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>
2022-03-24 10:48:00 +01:00
Emil Gydesen
a50e41b059 Bluetooth: Audio: Remove unicast guard for some stream functions
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>
2022-03-24 10:48:00 +01:00
Emil Gydesen
8e34701e19 Bluetooth: Audio: Move CONFIG_BT_CODEC out of unicast-only
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>
2022-03-24 10:48:00 +01:00
Lingao Meng
b76d74cd64 Bluetooth: Mesh: Fix adv_send call before enabled.
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>
2022-03-24 10:46:07 +01:00
Lingao Meng
58a501d6cd Bluetooth: Mesh: Fix unref null pointer
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>
2022-03-24 10:46:07 +01:00
Casper Bonde
0874ff5cfd Bluetooth: Audio: ASCS: do not fail on preferred value check
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>
2022-03-24 10:43:38 +01:00
Vinayak Kariappa Chettimada
68f63246a0 Bluetooth: Controller: Fix filter accept list with periodic adv list use
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>
2022-03-23 16:32:49 +01:00
Piotr Pryga
e6f685991f Bluetooth: Controller: llcp: fix missing remote CTE REQ was handling
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>
2022-03-23 14:10:47 +01:00
Emil Gydesen
ae55dae454 sys: util: Change return type of ARRAY_SIZE to size_t
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>
2022-03-23 14:09:23 +01:00
Jordan Yates
01402429cc Bluetooth: check if Bluetooth has been enabled
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>
2022-03-23 13:38:47 +01:00
Michał Barnaś
a1ab8da862 kconfig: fix dt_node_has_prop and add nodelabel functions
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>
2022-03-23 13:25:21 +01:00
Vinayak Kariappa Chettimada
fef56b3223 Bluetooth: Controller: Fix aux context release before aux done event
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>
2022-03-23 13:15:12 +01:00
Vinayak Kariappa Chettimada
11db2d95f8 Bluetooth: Controller: Increase event done max count for Coded PHY
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>
2022-03-23 13:15:03 +01:00
Rubin Gerritsen
414329f329 Bluetooth: Host: Fix addr type when syncing using list and privacy
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>
2022-03-23 13:11:12 +01:00
Vinayak Kariappa Chettimada
1f973f4330 Bluetooth: Controller: Fix Extended Scan disable livelock
Fix implementation from enqueueing duplicate node_rx which
leads to infinite loop processing the node_rx list.

Relates to commit a5fb434705 ("Bluetooth: Controller: Fix
to stop Extended Auxiliary Scan context").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-23 12:57:08 +01:00
Vinayak Kariappa Chettimada
4548bd9a25 Bluetooth: Controller: Use ticker yield to allow chain PDU receive
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>
2022-03-23 12:53:38 +01:00
Vinayak Kariappa Chettimada
53996ba459 Bluetooth: Controller: Yield stopped ticker time reservations
Update ticker_yield_abs implementation to allow yielding
expired single shot tickers.

Relates to commit bce82ad49b ("Bluetooth: controller: Add
ticker_yield_abs interface").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-23 12:53:38 +01:00
Vinayak Kariappa Chettimada
8482c95884 Bluetooth: Controller: Use minimal time reservation for aux receive
Use minimal time reservation for aux receive.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-03-23 12:53:38 +01:00
Vinayak Kariappa Chettimada
5dc29b2c8c Bluetooth: controller: Fix aux offset overhead calculation and margin
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>
2022-03-23 12:53:38 +01:00
Asbjørn Sæbø
75e6680086 Bluetooth: Audio - media: Make local control of local player default
Make local control of local player the default if control of local
player is configured.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
6ca4cf8ff5 Bluetooth: Audio - media - add more guarding
Add include guards for local player local control

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
9c43315d4f Bluetooth: Audio - media - guard instance members
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>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
347181866e Bluetooth: Audio: Media - change default kconfig values
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>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
476ff198bb Bluetooth: Audio - MCS kconfig - fix spacing in comments
Change double-space after period to single space.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
308390f5af Bluetooth: Audio: MCS config file cleanup
- Rename MCS configs that are only used by MCC to "MCC", add some more
  documentation.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
e494debdc8 Bluetooth: Audio: Use new media control configs in media proxy
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>
2022-03-23 12:50:53 +01:00
Asbjørn Sæbø
29aa654600 Bluetooth: Audio: Media control Kconfig
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>
2022-03-23 12:50:53 +01:00