Commit graph

9523 commits

Author SHA1 Message Date
Lingao Meng
61370f171c Bluetooth: host: Fix host send cmd complete to dis-conn
Fixes: #38054

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-09-16 21:29:09 +03:00
Vinayak Kariappa Chettimada
9e2b9c7a91 Bluetooth: Host: Fix Periodic Advertising Sync using Advertiser List
Fix Periodic Advertising Sync Establishment to accept
synchronization establishment to device listed in the
Periodic Advertisers List when filter policy was used.

Fixes #38520.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-16 16:35:45 +02:00
Vinayak Kariappa Chettimada
380a800b88 Bluetooth: Controller: Fix incorrect common header length calc
Fix incorrect calculation of received common extended header
length. Due to this a zero length advertising data is
reported in Extended Advertising and Periodic Advertising
report as one byte AD data.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-16 15:20:12 +02:00
Asbjørn Sæbø
e8620a7416 Bluetooth: Object Transfer Service: Defines for allowed object ID values
Add #defines for the maximum and minimum allowed values for object
IDs.

Moves the #define for the directory listing object ID to the public
header file

Having these limits available is useful for applications wanting to
ensure they pass in (or handle) valid object ID values.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2021-09-16 10:32:19 +02:00
Carles Cufi
6de4747979 Bluetooth: Update terms in public API to spec v5.3
The Bluetooth Core Specification, version 5.3, has introduced multiple
changes to several widely-used terms in order to make them inclusive.
Update the public API to reflect this, excluding hci.h, which will be
done in a subsequent commit.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-09-15 14:02:50 +03:00
Trond Einar Snekvik
035d877967 Bluetooth: Mesh: Inclusive terminology
Implements the Bluetooth appropriate language mapping for the Bluetooth
mesh subsystem.

Changes the following terms:

- Master security credentials -> Flooding security credentials
- Whitelist filter -> Accept filter
- Blacklist filter -> Reject filter
- Removes CDB's NODE_BLACKLISTED, which was not in use.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-09-14 19:30:18 +02:00
Kamil Gawor
50ff77fa91 bluetooth: Split configuration into separated Kconfigs
Extracted new Kconfig file for the Extended Advertising
and for the Bluetooth Isochronous Channel from the
Bluetooth subsystem Kconfig.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2021-09-14 09:57:03 +02:00
Kamil Gawor
3f09f94bd2 bluetooth: Add missing choice names in Kconfig
This commit adds missing choice names in Bluetooth
subsystem Kconfig files.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2021-09-14 09:57:03 +02:00
Kamil Gawor
c95ee1744f bluetooth: services: Use log template for BAS
The BAS serivce Kconfig uses now a log template instead of
defining logger configuration itself.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2021-09-14 09:57:03 +02:00
Andrzej Kaczmarek
defda27969 Bluetooth: Controller: Properly terminate per adv HCI on failed rx
If one of AUX_CHAIN_IND is not received properly we need to send an
extra report over HCI to indicate that data are incomplete.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-09-13 21:41:04 -04:00
Michał Narajowski
88b60f31c7 Bluetooth: Mesh: Verify if Remote confirmation is not identical
MESH/PVNR/PROV/BI-18-C verifies that the IUT rejects invalid
Confirmation Value.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-09-13 11:56:52 -04:00
Rubin Gerritsen
f79fbeabd5 Bluetooth: Host: Allow setting more than 251 bytes of adv data
When the application sets more than 251 bytes of advertising data,
the data is sent over multiple HCI commands.
This is only allowed if the advertiser is not running
as defined by the HCI specification.

The data is sent to the controller one AD-field at the time.
If an AD-field is larger than BT_HCI_LE_EXT_ADV_FRAG_MAX_LEN,
the data is split over two commands.
This introduces some additional complexity.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2021-09-09 14:22:53 -04:00
Krzysztof Kopyściński
fa2f83bf8b Bluetooth: host: add testing API (disconnect one EATT channel)
To test fallback to remaining bearers PTS might request IUT to
disconnect one of the connected EATT channels, while the others remain
intact. Test function must be added, because we cannot create L2CAP
server on EATT PSM and manage this server as normal and have EATT
enabled at same time.

This is affecting GATT/SR/GAW/BV-14-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-09-09 10:30:31 +02:00
Michał Narajowski
343c0bd2d3 Bluetooth: Mesh: Check if app key is bound in Model Publication Set
Th Configuration Server should respond with and Invalid AppKey Index
status code when the AppKey identified by AppKeyIndex is not known to
the node or is not bound to the model identified by the ModelIdentifier.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-09-07 11:32:16 -04:00
Emil Gydesen
5b602eab90 Bluetooth: ISO: Add missing negation for valid_chan_io_qos
A check for valid_chan_io_qos in big_init_bis was missing
a negation when checking for invalid parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-09-07 16:31:32 +02:00
Vinayak Kariappa Chettimada
99bdd27100 Bluetooth: Controller: Fix multiple advertising set assert
Fix assert at line 1085 in ull_adv_aux.c due to auxiliary
offset calculation scheduling on ticker timeout under must
expire which can happen for overlapping multiple advertising
sets without previous calculation not complete, a single
mayfly instance is used hence the assertion.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-06 17:25:37 +02:00
Lingao Meng
ecc7ca1b69 Bluetooth: Mesh: Fix friend buf send end not called.
As frnd->last will keep reference, so that net buffer
destructor function will not be call.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-09-06 08:42:05 -04:00
Piotr Pryga
aecdf4c242 Bluetooth: controller: df: fix error in remove CTE from per adv
cte_info_clear function is responsible for remove of CTE from
periodic advertising PDUs, including remove from optional chained
PDUs. The function uses subortinate function rem_cte_info_from_per_-
adv_chain to remove CTE from chained PDUs.

The rem_cte_info_from_per_adv_chain had pdu_prev and pdu as arguments.
After return from the function the pdu_prev should point to last
PDU from previously used periodic advertising data and pdu should
point to last new periodic advertising data.

The rem_cte_info_from_per_adv_chain function removes CTEInfo from
all but last one PDU. Last PDU must have removed AuxPtr field also.
Remove of CTEInfo and AuxPtr from last PDU is done explicitly in
the cte_info_clear function.

Unfortunately rem_cte_info_from_per_adv_chain had wrong type of
parameters for pdu_prev and pdu. These parameters were pointers
instead od double pointers.
That caused cte_info_clear function to remove CTEInfo and AuxPtr
from first PDU in a chain, which is AUX_SYNC_IND.

Changed parameters pdu_prev and pdu in the rem_cte_info_from_per_adv_-
chain to be double pointers.

Added small corrections in comments.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Co-authored-by: Emil Gydesen <Thalley@users.noreply.github.com>
2021-09-04 10:54:36 -04:00
Lingao Meng
790ec89048 Bluetooth: Mesh: Fix missing destructor function
Zephyr Bluetooth Mesh move adv send cb to buf destructor
callback, There are two net_buf_pool define, one to adv.c
and ore to friend.c, we are missing destructor in friend.c.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-09-03 06:32:08 -04:00
Emil Gydesen
0ffb084bfb Bluetooth: iso: Fixes ISO paramter checking issues
Two checks reported wrong value if the value was invalid.
CIS parameter check would always fail on correct values
due to missing negation of valid_chan_qos.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-09-03 06:31:45 -04:00
Michał Narajowski
f51cf9ab86 Bluetooth: mesh: Fail provisioning when RFU values are used
When Public Key field is set to RFU value then we should send
Provisioning Fail with Invalid Format error.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-09-02 19:38:52 -04:00
Vinayak Kariappa Chettimada
b51021af3c Bluetooth: Host: Fix MPU fault due to incorrect EV_COUNT
Fix MPU fault due to incorrect EV_COUNT, `conn_change`
signal was not accounted for in the array used by k_poll.

Relates to commit 7854088116 ("Bluetooth: ISO: Fixes
missing handling of broadcast ISO TX").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-02 19:38:16 -04:00
Emil Gydesen
12a26649f5 Bluetooth: ISO: Wait for ISO disconnect event
Instead of disconnecting ISO channels on ACL,
we put them in a non-connected state, and wait for
the ISO disconnect events.

This ensure that the controller has free'd the
ISO channels when the iso disconnect callbacks
are received. It will thus be possible to e.g.
terminate the CIG on the ISO disconnect callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-09-02 19:37:28 -04:00
Emil Gydesen
5d14cddaa8 Bluetooth: ISO: Fixes ISO central disconnect and cleanup issues
When an ISO channel is disconnect on the central, it is
not deallocated, but merely disconnected. This is because,
as per the HCI spec, the CIS handle lives on in the CIG.

Instead of unref'ing the bt_conn to 0, we simply put the
channel and connection in the disconnected state.

This also fixes a few missing returns for
terminating a CIG.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-09-02 19:37:28 -04:00
Emil Gydesen
3a77308c97 Bluetooth: ISO: Add sent callback
Add a sent callback to bt_iso_chan_ops so that the application
can be notified when an SDU has been sent. This can help the
application decide whether to queue up multiple, or only
have a single ISO PDU enqueue for reduced latency.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-09-02 05:58:39 -04:00
Kumar Gala
13ba7c7825 Bluetooth: ISO: Fix build on native_posix_64 with debug
On native_posix_64 we get the following compile error in CI:

error: format %u expects argument of type unsigned int

Fix by using %zu instead of %u as type is of size_t.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-09-01 12:27:41 -04:00
Emil Gydesen
93bfe7a2c9 Bluetooth: ISO: Update BIS index to start from 0x01
The HCI spec defines the BIS index range as starting from
index 0x01. We had previously implemented it such that it
starts from 0x00, and then simply adding 1 to the index
when sending over HCI. However, this may cause issue with
other HCI, or other SIG defined specification, commands
and events, and thus it is probably simpler if we just
use the HCI defined range.

This commit disallows BIT(0) (representing the BIS
index 0x00) to be set, and removes the addition
of 1 when sending over HCI.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-09-01 10:57:07 -04:00
Vinayak Kariappa Chettimada
ced2116428 Bluetooth: Controller: Fix null pointer dereferencing in periodic sync
Fix null pointer deferencing in Periodic Synchronization
when ULL execution context could not assign an auxiliary
context when in LLL scheduling to receive chain PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-01 08:38:37 -04:00
Vinayak Kariappa Chettimada
a63158fdde Bluetooth: Controller: Fix null pointer dereferencing in Extended Scan
Fix null pointer dereferencing in Extended Scanning when
there are more peer devices than the allocated auxiliary
contexts.

When LLL scheduling does not get an auxiliary context
assigned in the ULL execution context, then further chain
reception is aborted, access to `lll->lll_aux` which is
NULL causes null pointer dereferencing in
`ull_scan_aux_release`.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-01 08:38:37 -04:00
Vinayak Kariappa Chettimada
b26c27f307 Bluetooth: Controller: Use lll_aux param for aux context release
When Extended Initiating a connection, release auxiliary
context memory referenced by the lll_aux pointer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-01 08:38:37 -04:00
Vinayak Kariappa Chettimada
a633c00096 Bluetooth: Controller: Update Periodic Sync drift compensation
Update Periodic Advertising Synchronization's drift
compensation to save radio ready and address capture on
AUX_SYNC_IND reception, restore and apply at the end of
reception of all AUX_CHAIN_IND PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-01 08:38:37 -04:00
Emil Gydesen
0c7eda9777 Bluetooth: ISO: Pointer check in bt_iso_connected was incorrect
Instead of checking `if (iso == NULL)` it simply checked
`if (iso)` which is the opposite of what it should have done.

This completely blocks iso from connecting channels.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-09-01 08:38:12 -04:00
Michał Narajowski
e93b41a21a Bluetooth: host: Fix Limited Advertising timeout cancel
Timeout cancel should only be done for connections established in
peripheral role.

Enhanced connection complete event could still be delivered without
extended advertising support (i.e no advertising set terminated event)
so this handling should be moved to the common conn complete function.

Fixes #37467

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-08-31 15:35:47 -04:00
Trond Einar Snekvik
c5757ca4a1 Bluetooth: Mesh: Initialize UUID in shell's mod_pub_set
PR #35774 introduced a uuid field in the bt_mesh_cfg_mod_pub structure.
The shell does not initialize this pointer before passing it to the
access layer. Add a line to initialize this pointer.

Fixes #38016.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-08-31 11:03:06 -04:00
Trond Einar Snekvik
4eb047d1af Bluetooth: Mesh: Remove lpn timeout param check
param can never be NULL here, so the check is redundant. Coverity is
complaining because param is accessed before the NULL check.

Fixes #37949.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-08-31 11:03:06 -04:00
Trond Einar Snekvik
fd6f51c410 Bluetooth: Mesh: Remove krp param check
param can never be NULL, so this check is redundant. Coverity complains
about this, as the param variable is accessed before the check, which
would be wrong if param could be NULL.

Fixes #37948.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-08-31 11:03:06 -04:00
Vinayak Kariappa Chettimada
5f55d8ef78 Bluetooth: Controller: Fix uninitialized pointer read of SR ADI
When Extended Scan Response data of length zero is set, the
Scan Response do not have the Common Extended Payload Format
and hence no ADI field. Fix uninitialized pointer to Scan
Response Data's ADI to avoid copy of ADI from primary
channel PDU.

Fixes #38015.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-31 14:04:28 +02:00
Lingao Meng
faf9efcb47 Bluetooth: host: Fix missing attr when indicate
When call bt_gatt_indicate with param->attr set to null.
and attr->uuid set to given uuid, the internal notify will
search uuid, but not assigned to param->attr, which cauce
null point reference when:
notify --> gatt_indicate --> bt_gatt_check_perm

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-30 13:41:03 -04:00
Lingao Meng
6ebdbe5974 Bluetooth: Fix missing rewrite attr
When call `bt_gatt_notify_cb` with param->attr set to null.
and attr->uuid set to given uuid, the internal notify will
search uuid, but not assigned to param->attr, which cauce
null point reference when:
   notify --> gatt_notify  --> bt_gatt_check_perm

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-30 13:41:03 -04:00
Michał Narajowski
a9db9a3aa8 Bluetooth: host: Cancel limited adv timeout when advertising stopped
Advertising might stop when:
- it was stopped by application
- device connected to a peer
- extended advertising reached stop condition
  defined in BT_LE_EXT_ADV_START_PARAM - this is handled in ll

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-08-30 14:41:20 +02:00
Michał Narajowski
cca76f157c Bluetooth: host: Fix advertise stop in adv_timeout()
Call bt_le_adv_stop() if adv == bt_dev.adv (Meaning it is the legacy
advertiser and was started with bt_le_adv_start()), otherwise use
bt_le_ext_adv_stop(), because it was started with bt_le_ext_adv_start().

Failing to stop advertising shouldn't result in assert.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-08-30 14:41:20 +02:00
Andrzej Kaczmarek
f2f99c0784 Bluetooth: Controller: Remove redundant local variable
'err' is already defined in parent scope, we can use. Just need to set
it back to 0 before returning from function.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
b308192bb1 Bluetooth: Controller: Add todos for per adv chain scan
Add todos for few useful improvements that can be done later.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
993838edbf Bluetooth: Controller: Make lll_create_iq_report static again
This was changes when sync chain handling was done in lll_scan_aux, we
can now revert to original code.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
1e6c69bc89 Bluetooth: Controller: Update BT_CTLR_ADV_EXT_RX_CNT for ea and df
We need more RX nodes when scanning either extended/periodic advertising
trains and CTE samples so pudate those values based on observer and DF
features enabled.

The number of nodes for non-DF allows to scan complete chain for each
aux scan set (assuming max data length and optimal fragmentation by
advertiser), for DF it allows to scan max possible PDUs and CTE samples.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
11da89cff1 Bluetooth: Controller: Remove unused flag
This seems not to be needed anymore, it's only written.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
88b4f45eae Bluetooth: Controller: Move aux sync scanning to lll_sync
Periodic advertising train scanner implemented in lll_scan_aux adds lots
of branches that cannot be compiled out with periodic advertising sync
disabled.

This commit moves sync parts of the code from lll_scan_aux to lll_sync.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
f353202eb7 Bluetooth: Controller: Fix DF for per adv chains scanning
This updates DF to properly receive CTE in per adv chains scanning.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
0723e7dc5e Bluetooth: Controller: Rework support for periodic adv reports
Periodic advertising PDUs are now dispatched immediately one by one
(i.e. without list of PDUs as when flushed from aux context) so we
do not need to iterate such a list.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
139711fd74 Bluetooth: Controller: Fix parsing sync report PDU
AdvA, TargetA, ADI and SyncInfo are RFU in periodic advertising PDUs so
we should ignore them when present in PDU.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00