Commit graph

9523 commits

Author SHA1 Message Date
Asbjørn Sæbø
fa5b8a1e38 Bluetooth: Audio: MCC - pass structs by reference
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>
2022-04-20 15:51:01 +02:00
Jordan Yates
855f4b9c96 Bluetooth: hci: correct ext adv cmd definition
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>
2022-04-20 15:49:54 +02:00
Omkar Kulkarni
dbc7689404 Bluetooth: Mesh: Foundation model Client timeout setting
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>
2022-04-20 10:44:23 +02:00
Bartosz Bilas
95f3b4bc70 bluetooth: audio: remove superfluous default n for boolean
bool symbols implicitly default to n so
there is no need to redundant those values.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-19 11:49:27 +02:00
Szymon Czapracki
827890c075 Bluetooth: audio: Add initial Hearing Access Service shell
This adds initial shell support for HAS.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-04-15 10:32:54 -07:00
Mariusz Skamra
4ac9eba3d5 Bluetooth: has: Add initial support for presets
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>
2022-04-15 10:32:54 -07:00
Piotr Pryga
b53657a058 Bluetooth: Controller: hci: Wrong opcode when handling CTE req failed
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>
2022-04-13 13:40:59 -07:00
Herman Berget
97d64cf104 Bluetooth: Host: Fix assert in L2CAP ECRED connection response
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>
2022-04-13 13:40:00 -07:00
Szymon Janc
31b148ab64 Bluetooth: host: Fix crash in bt_l2cap_chan_recv_complete
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>
2022-04-13 13:29:12 -07:00
Szymon Janc
1f27849457 Bluetooth: controller: Fix build with new LLCP enabled
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>
2022-04-12 12:57:44 +02:00
Szymon Czapracki
af2e781f5a Bluetooth: Immediate Alert Service
This commits adds IAS for zephyr bluetooth.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-04-12 09:59:34 +02:00
Erik Brockhoff
f056eb516d Bluetooth: controller: Implementing LL param checks for refactored CPR
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>
2022-04-12 09:57:43 +02:00
Piotr Pryga
ab17f6d9f7 Bluetooth: Controller: Fix missing event counter sub by one
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>
2022-04-12 09:54:07 +02:00
Piotr Pryga
7dd3d8ff87 Bluetooth: Controller: df: Fix wrong value of event counter in iq report
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>
2022-04-12 09:54:07 +02:00
Carles Cufi
070c93f0d7 Bluetooth: host: Invert the logic to re-trigger the RX work queue
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>
2022-04-12 09:53:33 +02:00
Carles Cufi
ca54a4201c Bluetooth: host: Use a linked list instead of a FIFO as the RX queue
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>
2022-04-12 09:53:33 +02:00
Lingao Meng
37e561f42e Bluetooth: Host: Add choice select whether BT RX
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>
2022-04-11 10:58:09 +02:00
Mariusz Skamra
e9b40ebc69 Bluetooth: has: Satisfy profile security requirement
This enables Secure Connections pairing (actually disables legacy)
to satisfy security requirements of the Hearing Access Profile.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-04-11 10:23:13 +02:00
Pavel Vasilyev
0f3e473f06 Bluetooth: Mesh: Remove argc check in mesh shell commands
The shell submodule already checks number of arguments.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-04-11 10:16:28 +02:00
Pavel Vasilyev
ae2841877b Bluetooth: Mesh: Use shell_print_ctx macro to print from callbacks
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>
2022-04-11 10:16:28 +02:00
Pieterjan Camerlynck
53327e30f2 Bluetooth: Controller: Fix null pointer dereference
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>
2022-04-08 10:22:22 +02:00
Abe Kohandel
f1e75dea50 bluetooth: ots: notify application prior to object name change
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>
2022-04-08 09:31:31 +02:00
Vinayak Kariappa Chettimada
eef7d67926 Bluetooth: Controller: Add +3dBm Tx power support in nRF53 Series
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>
2022-04-08 09:30:52 +02:00
Vinayak Kariappa Chettimada
11d81f8e0a Bluetooth: controller: Add radio_stop interface
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>
2022-04-08 09:30:52 +02:00
Alexandru Carbuneanu
f3444ce00b Bluetooth: Host: Check encryption level for EATT channels
Check the encription level before sending on EATT.

Signed-off-by: Alexandru Carbuneanu <alexandru.carbuneanu@nordicsemi.no>
2022-04-08 09:30:45 +02:00
Jonathan Rico
ef2e31a686 Bluetooth: host: Prevent null pointer dereference
bt_le_lim_adv_cancel_timeout(adv) de-references adv.
Reported by https://github.com/zephyrproject-rtos/zephyr/issues/44480.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-04-07 13:18:02 +02:00
Herman Berget
60d42966e8 Bluetooth: Host: Update change-aware requirements for Bluetooth 5.3
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>
2022-04-07 09:38:26 +02:00
Emil Gydesen
d98cfd1f8a Bluetooth: Audio: Improve unicast client handling of CIG
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>
2022-04-07 09:38:09 +02:00
Emil Gydesen
777a5801ea Bluetooth: Audio: Add missing null check for ep idle state
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>
2022-04-07 09:38:00 +02:00
Mariusz Skamra
db59647c0a Bluetooth: has: Add initial Hearing Access Service client
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>
2022-04-07 09:37:53 +02:00
Lingao Meng
97a0151004 Bluetooth: Host: Fix bt_recv_thread_id assignment
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>
2022-04-07 09:37:45 +02:00
Lingao Meng
502ca3b788 Bluetooth: host: Move to l2cap_internal.h
BR_CHAN should be moved to l2cap_internal.h instead of redefining it.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-04-07 09:37:12 +02:00
Lingao Meng
20ff55e234 Bluetooth: host: Optimize L2CAP resource usage
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>
2022-04-07 09:37:12 +02:00
Jakob Krantz
4f05240cec Bluetooth: controller: df: Fix check for saturated IQ samples.
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>
2022-04-06 11:24:02 +02:00
Casper Bonde
4d6b0ee47d Bluetooth: Stream: Add functions to parse codec parameters
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>
2022-04-06 11:00:20 +02:00
Emil Gydesen
04cfb06875 Bluetooth: ISO: Add ISO recv timestamp flag
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>
2022-04-06 11:00:10 +02:00
Emil Gydesen
ffedee6e39 Bluetooth: ISO: Change ISO recv flags to bitfield
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>
2022-04-06 11:00:10 +02:00
Vinayak Kariappa Chettimada
de5510668a Bluetooth: Controller: Fix Extended Scan and Periodic Sync terminate
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>
2022-04-05 14:50:18 +02:00
Vinayak Kariappa Chettimada
2ed87e13cd Bluetooth: Controller: Fix missing check already stopped periodic aux
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>
2022-04-05 14:50:18 +02:00
Vinayak Kariappa Chettimada
6321b9666e Bluetooth: Controller: Add additional assert check for aux release
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>
2022-04-05 14:50:18 +02:00
Vinayak Kariappa Chettimada
5cf39c4755 Bluetooth: Controller: Fix missing Tx demux for LOW LAT ULL variant
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>
2022-04-05 14:47:23 +02:00
Timothy Keys
e34c63012e Bluetooth: Controller: Fix -40 tx power kconfig for nrf53
Fix -40 dbm kconfig tx power option dependency rules preventing use
on nrf53 boards.

Signed-off-by: Timothy Keys <timothy.keys@nordicsemi.no>
2022-04-05 14:47:13 +02:00
Anders Storrø
e4aed1cfbd Bluetooth: Mesh: Add err check to shell input
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>
2022-04-05 09:21:52 +02:00
Andries Kruithof
94f7bb9194 Bluetooth: controller: llcp: remove extra initialisation
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>
2022-04-04 15:34:17 +02:00
Thomas Ebert Hansen
060ac37166 Bluetooth: controller: Fix RX data pause
Reset pause_rx_data to 0 during adv enable or connection creation.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-04 15:34:09 +02:00
Thomas Ebert Hansen
fefa83d5ed Bluetooth: controller: Rework procedure pause logic
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>
2022-04-04 15:34:09 +02:00
Thomas Ebert Hansen
79092c3cf4 Bluetooth: controller: Rework TX data pause
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>
2022-04-04 15:34:09 +02:00
Andries Kruithof
b909647d0a Bluetooth: controller: llcp: serialize phy update notifications
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>
2022-04-04 15:33:59 +02:00
Thomas Ebert Hansen
3c5243fa9c Bluetooth: controller: Rewrite LLCP PDU RX handling
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>
2022-04-04 15:20:16 +02:00
Herman Berget
101a9a7525 Bluetooth: Host: Automatically create EATT channels on connection
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>
2022-04-04 14:22:22 +02:00