Commit graph

9523 commits

Author SHA1 Message Date
Emil Gydesen
55de0fd353 Bluetooth: ASCS: Fixed wrong state for detaching stream
The audio stream should be detached from the endpoint
when the endpoint goes into the releasing state, instead
of the idle state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-28 14:18:11 +02:00
Emil Gydesen
cf89447442 Bluetooth: ASCS: Remove redundant if statement
ase_process had a check for the IDLE state, but the
check did not do anything, so was removed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-28 14:18:11 +02:00
Emil Gydesen
a61cbb8182 Bluetooth: ASCS: Add no-op case for setting releasing state
The releasing state does not trigger any stream ops,
but will be a no-op case to avoid the error log
message.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-28 14:18:11 +02:00
Thomas Ebert Hansen
20cb60ecd2 Bluetooth: controller: Fix central enc termination
Terminate connection with a MIC failure if an unexpected control PDU
is received during the Encryption Start procedure.

Add a greedy option to pdu_is_expected() to make sure the procedure
processes all unexpected control PDU in all cases.

Add unit test inspired by Bluetooth Qualification test
LL/SEC/CEN/BV-14-C,
Central Receiving unexpected PDU during encryption start

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-28 12:55:48 +02:00
Thomas Ebert Hansen
70e38b1cbb Bluetooth: controller: Fix central enc reject
Add support for both LL_REJECT_IND and LL_REJECT_EXT_IND when waiting
for the the response to the LL_ENC_REQ and LL_START_ENC_REQ.

Add unit test to test both LL_REJECT_IND and LL_REJECT_EXT_IND as
responses to LL_ENC_REQ.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-28 12:55:48 +02:00
Thomas Ebert Hansen
268d00623b Bluetooth: controller: Fix periph enc reject
Chose correct rejection PDU based on features supported on remote peer
when rejecting due to missing LTK.

Update unit test setup with faking that a feature exchange procedure
has run.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-28 12:55:48 +02:00
Thomas Ebert Hansen
06feb0202c Bluetooth: controller: Fix periph enc termination
Terminate connection with a MIC failure if an unexpected control PDU
is received during the Encryption Start procedure.

Add unit test inspired by Bluetooth Qualification test
LL/SEC/PER/BI-05-C,
Peripheral Receiving unexpected PDU during encryption start

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-28 12:55:48 +02:00
Thomas Ebert Hansen
934279a48f Bluetooth: controller: Fix enc APPTO
The logic condition for when to enable APPTO needs to look at both
enc_rx and enc_tx.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-28 12:55:48 +02:00
Szymon Janc
57a94bff10 Bluetooth: controller: Add validation of received LLCP PDUs
This adds suport for validation of received PDUs before they are
pass further to LLCP state machines. If PDU size is invalid it is
rejected with LL_UNKNOWN_RSP.

This was affecting following qualification test cases:
LL/PAC/PER/BI-01-C
LL/PAC/CEN/BI-01-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-04-28 12:52:57 +02:00
Reto Schneider
9c286e50f6 Bluetooth: shell: Fix unused function warning
Prevent warnings by conditional compilation of static functions.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-04-28 10:26:25 +02:00
Pavel Vasilyev
a63c515679 Bluetooth: Mesh: Check SegN when receiving Transaction Start PDU
When receiving Transaction Start PDU, assure that number of segments
needed to send a Provisioning PDU with TotalLength size is equal to SegN
value provided in the Transaction Start PDU.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-04-28 08:56:01 +03:00
Emil Gydesen
1e02dd0dc1 Bluetooth: Audio: Add conn check for the VOCS client notify handler
Add a NULL check for the conn pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Emil Gydesen
964df6d4da Bluetooth: Audio: Add conn check for MICS client notify handler
Add a NULL check for the conn pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Emil Gydesen
1f60adf1df Bluetooth: Audio: Add conn check for the OTC notify handler
Add a NULL check for the conn pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Emil Gydesen
b734487eaa Bluetooth: Audio: Add conn check for MCC notify handler
Add a NULL check for the conn pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Emil Gydesen
5dfea31e83 Bluetooth: Audio: Add conn check for CSIS client notify handlers
Add a NULL check for the conn pointer in the CSIS client
notify handlers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Emil Gydesen
50ccf861b8 Bluetooth: Audio: Add conn check for AICS client nofity handler
Add a NULL check for the conn pointer in the AICS client
instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-27 10:09:10 +02:00
Erik Brockhoff
dd5119fdb3 Bluetooth: controller: check for instant on reception of CONN_UPD_IND
Instead of waiting one connection interval, as a result of the state
change, perform the check for instant already on reception of
CONNECTION_UPDATE_IND

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-27 10:09:03 +02:00
Erik Brockhoff
26f6941048 Bluetooth: controller: using REJECT_IND when EXT_IND was not negotiated
Unless a feature exchange determines support for REJECT_EXT_IND use
REJECT_IND for collision rejection

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-27 10:09:03 +02:00
Erik Brockhoff
0d94ad69f6 Bluetooth: controller: removing unused functionality
Removing llcp_tx_flush() as it turns out it is not needed.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-27 10:09:03 +02:00
Erik Brockhoff
025b9745d3 Bluetooth: controller: implementing state check for ENC reply API
Now checking that encryption procedure is in correct state to accept
a reply from host.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-27 10:09:03 +02:00
Erik Brockhoff
06078ee54e Bluetooth: controller: DO TODO, compile out members of struct re. CPR
Compile out misc. members not used when Connection Parameter Request
is not supported.
Implement missing tests re. unsupported features in CU/CPR procedure

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-27 10:09:03 +02:00
Aleksandr Khromykh
768e0d7a01 Bluetooth: Mesh: encapsulate tinycrypt dependency
Bluetooth Mesh uses tinycrypt library for security related
algorithms. This PR encapsulates tinycrypt dependency within
one file to make the current implementation more portable.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-04-27 10:07:47 +02:00
Erik Brockhoff
d8f0c1adf6 Bluetooth: controller: implement connection termination on invalid pdus
When a running procedure receives a REJECT or UNKNOWN_RSP PDU that is
not an expected part of the procedure flow this leads to termination
of the connection

This affects procedures:
CU/CPR, CTE, PHY, PING, DLE, FEX, VEX, CHMU

Unit tests are updated to cover the updated behaviour.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-04-26 14:06:16 +02:00
Emil Gydesen
c972ffddac Bluetooth: ISO: Add additional information for ISO streams
Add all information from the ISO established events
and provide the information in the get_info function.

The use cases of each field heavily depends on what
the ISO streams are used for.

Most, if not all, of the field can be used by the
higher layers to improve quality and/or reliability
of e.g. audio streams that use ISO.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-26 11:35:45 +02:00
Aleksandr Khromykh
6896075b62 Bluetooth: Mesh: add check for rx buffer overflow in pb adv
There is potential buffer overflow in pb adv.
If Transaction Continuation PDU comes before
Transaction Start PDU the last segment number is set to 0xff.
The current implementation has a strictly limited buffer size.
It is possible to receive malformed frame with wrong segment
number. All segments with number 2 and above will be stored
in the memory behind Rx buffer.

Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
2022-04-26 11:35:33 +02:00
Aleksander Wasaznik
77ad017672 Bluetooth: Shell: Fix off-by-one in address length validation
Fixes Coverity defect id 248346.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-04-26 11:35:19 +02:00
Emil Gydesen
a796927961 Bluetooth: Audio: Make PACS location optional
Make the PACS location characteristic optional, and
also optionally writable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-26 09:00:48 +02:00
Vinayak Kariappa Chettimada
31f49936e2 Bluetooth: Controller: Fix missing cond. compile for ext. scan filter
Fix missing conditional compile when Advertising Extensions
is enabled without Extended Scan Filter Policy support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-25 11:44:22 -07:00
Thomas Ebert Hansen
d1c9efa83d Bluetooth: controller: LLCP PRT rewrite
Rewrite the entire Procedure Response Timeout mechanism.

Use two separate timers for local and remote initiated procedures.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-04-25 15:36:16 +02:00
Andries Kruithof
ecae7a9c7f Bluetooth: controller: llcp: terminate connection on collission
As per bluetooth spec Vol. 6 part B section 5.3 we need to terminate
the connection under given situation

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-04-25 15:35:45 +02:00
Piotr Pryga
0ead951649 Bluetooth: Controller: llcp: Fix PHY update instant val if no PHY change
BT Core spec 5.3 Vol 6, Part B section 2.4.23 LL_PHY_UPDATE_IND says:
"If both the PHY_C_TO_P and PHY_P_TO_C fields are zero then there is no
Instant and the Instant field is reserved for future use."
Fields that are reserved for future shall be filled with zeros.

New LLCPs implementation didn't handle this case and set the instant
as if there were a PHY change. That caused qualification tests to fail.

The commit fixes the issue.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-04-25 13:10:42 +02:00
Vinayak Kariappa Chettimada
4efd9b80c8 Bluetooth: Controller: Fix typo in BT_CTLR_ISOAL_SOURCES prompt
Fix typo in BT_CTLR_ISOAL_SOURCES Kconfig prompt message.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-24 19:47:46 +02:00
Herman Berget
c8b2279f89 Bluetooth: Host: Make tx complete callback work for EATT channels
Previously, if a callback was set for notifications, they would always be
sent over unenhanced ATT.

The nfy_mult_data was bigger than the buffer user_data and we were this
overflowing the buffer when setting the tx callback user_data. Now the
data is stored separately and only a pointer to it is added to the
buffer user_data.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-24 19:46:41 +02:00
Herman Berget
cf3832f0bf Bluetooth: Host: Add support for tx complete callback for ECRED channels
Previously callbacks were only supported on unenhanced channels.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-24 19:46:41 +02:00
Aleksander Wasaznik
8e5c177233 Bluetooth: Host: Validate IRK ID in range
Validate `id` so that `bt_dev.irk[id]` cannot result in an out-of-bounds
access.

This fixes coverity report 239569.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-04-22 10:24:43 -05:00
Kamil Gawor
3defc3dfc2 Bluetooth: Controller: Fix timings for Tx test
The Tx interval is now calculated at the beginning
of the Tx test and the next transmission is
triggerd by the switch timer instead of event
timer. This fixes a corner case issue when
timer rollover.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2022-04-22 13:46:34 +02:00
Piotr Pryga
77ae58ee72 Bluetooth: Controller: fix wrong use of LE Features in CTE REQ llcp
When Host calls HCI_LE_Connection_CTE_Request_Enable with cte type
set to AoD with 1us slots or AoD with  2 us slots, the Controller
verifies if peer device supports Antenna Switching During CTE
Transmission (AoD) feature.

That is wrong because the feature is marked as optional when send
to peer, so it shall be igonerd by remote device.

There are no means to check if peer device supports particular
CTE type, hence the check has to be removed.

The check causes enable CTE REQ procedure to fail after feature
exchange has happened.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-04-22 09:45:27 +02:00
Piotr Pryga
45bba8e5f8 Bluetooth: Controller: df: Fix missing disable CTE req LLCP after compl
The CTE request procedure can be run in periodic and non-periodic mode.
In periodic mode it stays enabled until Host call HCI_LE_Connection_CTE-
_Request_Enable(Enable=0x0).
In non-periodic mode the command is disabled after completion,
LL_CTE_RSP is successfully received.

There is missing disable of the procedure in the current code,
so Host is not able to run the command HCI_LE_Connection_CTE_Request_-
Enable(Enable=0x1) again without explicit call to HCI_LE_Connection_-
CTE_Request_Enable(Enable=0x0).

The commit adds missing code responsible for disable of the procedure.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-04-22 09:45:14 +02:00
Aleksandr Khromykh
a7bb928420 Bluetooth: Mesh: subscription on fixed group addresses
There is errata clarification (Errata ID:18700)
about subscriptions on fixed group addresses.
It is possible to subscribe models on non primary elements
on any fixed group address except all nodes address.
Devices should be able to receive messages on fixed addresses
even if they do not support the feature
to which the fixed group address belongs.

Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
2022-04-22 09:44:00 +02:00
Emil Gydesen
102a6210bb Bluetooth: Kconfig: Increase TX stack size for BT_CTLR && BT_LL_SW_SPLIT
Increase the default TX stack size for BT_CTLR && BT_LL_SW_SPLIT,
as we have seen applications/samples nearing and even reaching
the stack size, causing stack overflows. This is especially
true if CONFIG_FPU=y which takes 96 bytes of the TX stack.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-04-22 09:43:12 +02:00
Vinayak Kariappa Chettimada
13fe3bb6c3 Bluetooth: Controller: Fix assert on LL BIG terminate
Fix assert on LL BIG terminate call before BIG sync is
established. Assert was caused due to duplicate calls to
release stream contexts, once in LL BIG terminate function
then when releasing the HCI BIG sync failed to be
established node rx was being released.

Use iso_broadcast and iso_receive samples, power cycle the
iso_broadcast device when iso_receive sample is waiting for
BIG sync to be established, iso_receive sample will perform
a BIG sync terminate that leads to the assert.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-22 09:41:50 +02:00
Vinayak Kariappa Chettimada
335315fc71 Bluetooth: Controller: Fix spurious transmit after mic failure
Fix spurious transmit of corrupt PDU after reception of PDU
with MIC failure.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-04-22 09:41:32 +02:00
Omkar Kulkarni
12553800f1 Bluetooth: Mesh: Update defaults - proxy filter, msg cache
This updates the default proxy filter size to 16. Previous value of 3
is too less for the most practical uses and demos. The default proxy
filter type is accept list type and in this mode proxy server rejects
incoming messages from source addresses not in the accept list. The
addresses are added to the accept list when proxy client sends
messages to unicast addresses or manually adds certain addresses to
the accept list. Once this list is full more addresses cannot be added.

This also updates the default network message cache size to 32. The
network message cache helps in preventing duplicate messages getting
repeatedly relayed and helps in reducing unnecessary network traffic.
Previous value of 10 is quite less for most usecases and makes the
node appear to generate much more traffic in mixed network. The
updated value should suffice for most use cases.

Additional explannation is added in Kconfig to help users understand
the significance of this setting.

These two changes result in 176 bytes of additional RAM usage in mesh
samples.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2022-04-20 16:36:42 +02:00
Herman Berget
0916eba4ad Bluetooth: Host: Send the "Out of Sync" error only once on each channel
The "Database Out Of Sync" error response shall only be sent once on
each channel after a client becomes change-unaware.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-20 16:10:46 +02:00
Herman Berget
1732ec061b Bluetooth: Host: Add CF_DB_HASH_READ flag
This fixes the case where the client reads the DB hash without reading
another attribute first after becoming change-unaware.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-04-20 16:10:46 +02:00
Asbjørn Sæbø
79d96b8112 Bluetooth: Audio: Add void() cast to memcpy
Cast memcpy to void().

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-04-20 15:51:01 +02:00
Asbjørn Sæbø
b0d5db147b Bluetooth: Audio: Media control - pass structs by reference
Changes the media_proxy API to pass structs by reference instead of by
value.

Also pass structs by reference in internal functions in media player
and in media controller test.

Add pointer checks to the public API implementation where
user/application code provides structs by reference.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-04-20 15:51:01 +02:00
Asbjørn Sæbø
ebaad4501c Bluetooth: Audio: Media - search to not modify parameter
Update the search parser to not modify the supplied parameter.
This will allow the parameter to be made 'const'.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-04-20 15:51:01 +02:00
Asbjørn Sæbø
1d66729a0a Bluetooth: Audio: Remove zero-ing of variable
Commit dc812539b8 ("Bluetooth: MPL: Fix use of uninitialized
command.param value") fixed the use of a potentially un-initialized
variable, by
- splitting a log statement, so that the variable is only
  logged (=used) if in use (and therefore hopefully also initialized)
- setting the variable to zero if not in use

The second part is not required, as all other code in the module
checks whether the variable is in use before using it.  And this
second part also prevents the parent struct from being made 'const'.

This commits removes the zeroing of the variable, so that the struct
can be made 'const'.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-04-20 15:51:01 +02:00