Commit graph

9523 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
38905eb0ab Bluetooth: Controller: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned
variable.
MISRA-C rule 7.2

Relates to commit b97db52de7 ("misra-c: Add 'U' to
unsigned variable assignments in subsys/").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:02:28 +02:00
Vinayak Kariappa Chettimada
0feb34363f Bluetooth: Controller: Add missing margin to BIG ticks_anchor
Add the missing ticker resolution margin when calculating
the ticks_anchor to be used to get non-overlapping BIG
events.

Relates to commit fab4511164 ("Bluetooth: Controller: Fix
overlapping advertising events").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 17:55:56 +02:00
Pirun Lee
8e0f003112 Bluetooth: OTS - Object Write check parameter properly
Check sum of len and offset with properties.
Check offset with obj cur size.

Signed-off-by: Pirun Lee <pirun.lee@nordicsemi.no>
2022-09-19 10:57:10 +02:00
Jonas Woerner
6432e100aa Bluetooth: Host: Make adv error reporting more consistent
this changes adv_new_legacy to adv_get_legacy.
without this fix the function would return NULL if BT_EXT_ADV is enabled.

Signed-off-by: Jonas Woerner <jonas.woerner@online.de>
2022-09-16 10:53:31 +01:00
Pavel Vasilyev
24af6031e2 Bluetooth: Mesh: Use separate pool for relayed messages
Sharing the same pool for both, local and relayed messages has some
disadwantages. In a high-traffic environment the relayed messages may
occupy the whole pool without letting the node to send own messages,
neither to process segmented messages. The vice versa situation is
possible when local messages takes the whole pool so that the node is
not able to relay other messages. Another thing is that it doesn't let
to controll amount of local and relayed messages that the node can send
at once. Controlling the number of messages that the node can relay may
help to reduce the message latency.

This change adds separate net_buf_pool for the relayed messages that
helps to avoid problems described above.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-16 08:39:04 +00:00
Aleksander Wasaznik
a89d5edb92 Bluetooth: Shell: Remove a debug-print
I don't think it was intentional to leave this line.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-09-15 17:27:42 +01:00
Pavel Vasilyev
85e7818ff2 Bluetooth: Mesh: Don't process unprovisioned beacon without callback
If `struct bt_mesh_prov::unprovisioned_beacon` callback is not set,
don't process the beacon.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-14 14:37:54 +01:00
Herman Berget
372b7869df Bluetooth: Shell: Fix L2CAP ecred commands
The channel arrays must be null-terminated if it is less than 5 elements
long.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-09-14 09:38:39 +00:00
Erik Brockhoff
5951cd4c9b Bluetooth: controller: fixing missing reset of proc context greedy flag
For the encryption procedure exists a flag used to indicate that the
procedure expects all PDUs to be delivered to the procedure STM.
This flag was not cleared during creation of new procedure. This could
lead to unexpected PDUs being passed to local procedure STM

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-09-14 09:36:56 +00:00
Vinayak Kariappa Chettimada
8636766e57 Bluetooth: Controller: Fix compile error BT_CTLR_JIT_SCHEDULING enabled
Fix compile error when BT_CTLR_JIT_SCHEDULING is enabled but
BT_CTLR_ADV_EXT is disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-14 09:36:28 +00:00
Pavel Vasilyev
cf953de484 Bluetooth: Mesh: Check pending_buf in bt_mesh_send_cb in friend.c
When friend entry is cleared by `friend_clear` after an adv buffer has
been sent to that friend in `friend_timeout`, another friend request
coming after this may reuse the same entry. It is possible that
`friend_timeout` will be scheduled twice: once by the friend request
and once by `buf_send_end` of the previously sent buffer.
In that case, the code will assert on line friend.c:1234. It is not
possible to cancel an adv buffer for the friendship that is to be
cleared, therefore, we need to ensure in correctness of the pending_buf
value in start and end callbacks.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-13 16:26:39 +00:00
Lingao Meng
fcbe88d598 Bluetooth: Mesh: Fix iv recovery unable clear replay list
When local node enter iv recovery procedure, should clear
replay list at first due to avoid possible wrong replay attack.

At present, `bt_mesh_rpl_clear` schedule a timer to clear rpl,
this would cause local node unable precess mesh message(IV Updated).

Also, in `bt_mesh_rpl_pending_store` also not clear rpl, which check
`BT_MESH_VALID` flag, always valid for iv recovery.

So, Add `rpl_clear_pending` work handler process rpl clear.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-09-13 16:24:46 +00:00
Szymon Czapracki
85639f78bd Bluetooth: audio: Fix error message in PACS
Change error code in PACS source/sink
write operation to Write Request Rejected.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-09-13 08:55:39 +00:00
Anders Storrø
97ed0061cb Bluetooth: Mesh: Remove experimental tag from CDB
The CDB module is a mandatory part of provisioning features in BTM, and
can not be regarded as experimental anymore.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-09-12 14:14:27 +00:00
Pavel Vasilyev
1357be36b0 Bluetooth: Mesh: Fix print of newly allocated node in CDB
Using the passed address is incorrect since the passed address can be
zero to find the lowest available address.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-12 10:52:50 +00:00
Pavel Vasilyev
33b9f3e361 Bluetooth: Mesh: Prevent CDB reusing address of deleted nodes
According to MshPRFv1.0.1, section 3.10.7, the Provisioner shall only
use reuse addresses of the deleted nodes after IV Index is updated.

This change prevents CDB reusing addresses of the deleted nodes until IV
Index is updated. Due to a high range of the unicast addresses, CDB only
stores the highest deleted address once a node is deleted. This creates
a limitation where allocating a node with the high primary unicast
address and then deleting it will make CDB skip big range of address
until next IV Index update.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-12 10:52:50 +00:00
Vinayak Kariappa Chettimada
0954185e81 Bluetooth: Controller: Fix periodic advertising re-enable assertion
When periodic advertising with chaining is re-enabled after
changing interval or just re-enabled then the chain PDUs
where not duplicated causing the LLL to assert detecting the
presence of aux pointer but no linked chain PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-09 16:29:28 -04:00
Michał Barnaś
dae8efa692 ztest: remove the obsolete NULL appended to zassert macros
This commit removes the usage of NULL parameter as message in
zassert_* macros after making it optional

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-09-09 07:05:38 -04:00
Szymon Czapracki
66e6572a0f Bluetooth: audio: shell: Add command to change contexts
Allow to change available audio contexts from shell

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-09-09 10:50:06 +00:00
Emil Gydesen
34d4501e8a Bluetooth: Shell: Add connect-name command
Add a new command, connect-name, which takes a string
as the single input and uses that to setup a scan filter
and connect to the first device that matches the name.

This command is thus basically shorthand for
bt scan-filter-set <name>
bt scan on
bt scan off
bt connect
bt scan-filter-clear-name

The idea of this command is to not only make it easier
find and connect to devices in a crowded environment,
but also to more easily connect to devices that changes
their advertised address.

The implementation is minimal as it uses existing
shell commands.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-09 10:10:52 +02:00
Hang Fan
fd4d18852d Bluetooth: Audio: Set transparent coding format for default ISO path
As per BAP_v1.0, Section 5.6.3.1:

If HCI is used when setting up their respective audio data paths,
and if the codec in use resides in the Bluetooth Host of the device
using the LE Setup ISO Data Path command, the Unicast Client and/or
Unicast Server shall:
* Write the LE Setup ISO Data Path command Codec_Configuration_Length
parameter with the value 0x00.
* Write octet 0 (Coding_Format) of the LE Setup ISO Data Path command
Codec_ID parameter with the value 0x03 (Transparent).

We can assume the codec in use resides in the Bluetooth Host default.

Signed-off-by: Hang Fan <fanhang@xiaomi.com>
2022-09-09 10:08:34 +02:00
Szymon Czapracki
35c0d5ef67 Bluetooth: audio: shell: Add command to set location
Allow to set audio locations from shell

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2022-09-09 10:07:49 +02:00
Ahmed Moheb
cb5ba5bea8 tests: bluetooth: host: Add mocks for buf.c
Add required mocks to be able to compile and test /bluetooth/host/buf.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-09 10:06:19 +02:00
Szymon Czapracki
ac6c35728a Bluetooth: Add IAS shell
This commit adds IAS functionality to the shell.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>

shell fixes
2022-09-09 10:05:46 +02:00
Szymon Czapracki
f4d23b6cd7 Bluetooth: Immediate Alert Client
Implement Immediate Alert Client
Move IAS into separate subdirectory

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>

general fixes
2022-09-09 10:05:46 +02:00
Vinayak Kariappa Chettimada
8191423950 Bluetooth: Controller: legacy: terminate condition to check role first
Refactor to revert back the terminate check condition to
check the connection role first.

Reverts legacy code changed in
commit 8b1d50b981 ("Bluetooth: controller: llcp: fix issue
 re. missing ack of terminate ind").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-08 15:12:22 +02:00
Vinayak Kariappa Chettimada
4da89756b3 Bluetooth: Controller: Dont prioritize ticker slot window that yield
Do not use lazy value to prioritize ticker with ticks slot
window that yield to other tickers. Primary channel PDUs
use ticks slow window to nudge themself after an
overlapping ticker within the ticks slot window, but such
ticker may be skipped to next interval. At the next
interval if they again overlap with other tickers then
lazy value shall not be used to prioritize but rather
continue to yield again. This is required to avoid BIG
events from being skipped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-08 14:31:23 +02:00
Emil Gydesen
717b4fee56 Bluetooth: ISO: Remove TS size from SDU len check
The timestamp is not part of the SDU, and should
thus not be used to get the maximum SDU size.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-08 11:32:53 +00:00
Troels Nilsson
ba810303c5 Bluetooth: controller: Big-endian fix for aux_ptr offs and phy
pdu_adv_aux_ptr no longer uses a bitfield for offs and phy, so
we can properly adjust for BE

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-09-08 10:08:51 +00:00
Vinayak Kariappa Chettimada
b8a959ee47 Bluetooth: Controller: Fix BIG Create silently fail on RTN/SDU_interval
Fix BIG Create implementation from silently failing on
values of RTN and SDU_interval that lead to BIG events that
cannot be acheived when using sequential or interleaved
subevents by the Controller Implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-08 10:14:09 +02:00
Vinayak Kariappa Chettimada
b304eaa29b Bluetooth: Controller: Add Kconfig for experimental AD Data Chaining
Add a Kconfig for Advertising Data Chaining in Extended and
Periodic Advertising, permitting AD data lengths of upto
1650 bytes. The implementation is experimental and needs
further testing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-08 10:12:56 +02:00
Vinayak Kariappa Chettimada
34154e3efe Bluetooth: Controller: Fix BT_CTLR_ADV_DATA_LEN_MAX Kconfig dependency
Fix BT_CTLR_ADV_DATA_LEN_MAX and other Kconfig dependencies,
and clean up the use of PDU_AC_LL_SIZE_MAX which is used to
allocate scratch packet to be atleast able to accommodate
the minimum 31 bytes AD data such that it is sufficient to
transmit and/or receive scan response PDUs when either
broadcaster or observer alone is supported.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-08 10:12:56 +02:00
Anders Storrø
bfb4e1bac4 Bluetooth: Mesh: Shell: Split out mdl shell feat
This commit splits out the model related commands from mesh shell to
separate shell modules. The purpose of this alteration is to make model
commands more flexible by letting the application itself define the
model instances.

- Move Health Client commands to separate shell module.
- Move Config Client commands to separate shell module.
- Remove Health Client instance from shell.c.
- Add Health Client instance to mesh_shell test application.
- Add util library for Mesh shell.
- Some refactoring of shell menu layout.
- Update Mesh shell documentation.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-09-07 15:02:58 +02:00
Anders Storrø
548f850192 Bluetooth: Mesh: Move shell.c to subfolder
Moves shell.c to shell subfolder. Done as a separate step to preserve
diff between previous and new revision of shell.c.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-09-07 15:02:58 +02:00
Timothy Keys
194cb8abab Bluetooth: Controller: Request any TX Power
Allow requesting any TX power in SDC via kconfig. This enables easily
setting higher TX values when using a FEM.

Signed-off-by: Timothy Keys <timothy.keys@nordicsemi.no>
2022-09-07 10:30:55 +02:00
Vinayak Kariappa Chettimada
61a44f1af2 Bluetooth: Controller: Use macros in num complt implementation
Use macros to encode the counting of number of completed
packets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-06 17:44:38 +02:00
Morten Priess
eb025d0497 Bluetooth: Controller: Fix ISO TX pool corruption and missing release
- Fix ISO TX data pool corruption due to multiple calls to
  tx_cmplt_get, without removing the nodes
- Added missing release of TX node link in case of ISOAL error

Signed-off-by: Morten Priess <mtpr@oticon.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-06 17:44:38 +02:00
Vinayak Kariappa Chettimada
4a74f97a9a Bluetooth: Controller: Fix ISO Tx PDU memory pool corruption
Fix ISO Tx PDU memory pool corruption due to duplicate ISO
Tx PDU buffers repeatedly released into the memory pool.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-06 17:44:38 +02:00
Vinayak Kariappa Chettimada
8eee8430d4 Bluetooth: Controller: Add implementation to flush Tx on BIG terminate
Add implementation to flush pending ISO Tx PDUs when BIG
events are terminated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-06 17:44:38 +02:00
Vinayak Kariappa Chettimada
73e0b415ce Bluetooth: Controller: Fix removal of BIG association with Periodic Adv
Move the removal of BIG context association with the
Periodic Advertising context to when the BIG streams are
release and BIG terminate message is generated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-06 17:44:38 +02:00
Anders Storrø
36e34fce41 Bluetooth: Mesh: Add CDB depend on to prov Kconfig
The current implementation of provisioning features is dependent on CDB
to compile, which is reflected poorly in the Kconfig options for mesh.

This commit alters the Kconfig options for provisioning to be dependent
on the CDB option to compile.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-09-06 12:35:48 +02:00
Vinayak Kariappa Chettimada
d5f94e632f Bluetooth: Controller: Support for multiple BIS sync selection
Added implementation to use the BIS array parameter and
selectively synchronize to subset of multiple Broadcast
Isochronous Streams in a Broadcast Isochronous Group.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-05 17:37:47 +02:00
Vinayak Kariappa Chettimada
4f02f05378 Bluetooth: Controller: BIG event timing reservations
Added implementation to calculate BIG event timing
reservations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-05 17:37:47 +02:00
Vinayak Kariappa Chettimada
1d4a5dd0ef Bluetooth: Controller: Fix calculation of BIS subevents
Fix calculation of BIS subevents that was missing num_bis
when calculating the PDU latency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-05 17:37:47 +02:00
Vinayak Kariappa Chettimada
f738f494eb Bluetooth: Controller: Fix incorrect cond compile scheduling BIG
Fix incorrect conditional compile to disable Controller
advanced scheduling feature which is required for Broadcast
ISO implementation.

Regression in commit 6fe1299c33 ("Bluetooth: controller:
llcp: fix CI tests for new LLCP").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-05 17:37:12 +02:00
Vinayak Kariappa Chettimada
052136841e Bluetooth: Controller: Restrict max ISO Tx PDU size to ISO Tx MTU
In a Host plus Controller combined build for ISO feature
restrict the maximum ISO Tx PDU size to minimum of 251 bytes
and Host ISO Tx MTU. This will allow controller to use
reduced Tx time (subevent interval).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-05 17:37:01 +02:00
Gerard Marull-Paretas
79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Michal Narajowski
5c27067dcd Bluetooth: Mesh: Align Config Client API with Health Client API
This PR adds a `*_cli_*` infix to the Config Client API to match
the changes in Health Client. The old API is marked as deprecated.

Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
2022-09-05 13:56:25 +03:00
Ahmed Moheb
c7d37d956e bluetooth: host: keys: Rename bt_keys_foreach() to bt_keys_foreach_type()
Use the name bt_keys_foreach_type() to be more descriptive.

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-05 12:22:13 +02:00
Ahmed Moheb
f1884e5083 bluetooth: host: keys: Remove CONFIG_BT_MAX_CONN from key in use check
Eliminate key in use check dependency on (CONFIG_BT_MAX_CONN > 1).

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-05 12:22:13 +02:00