Commit graph

9523 commits

Author SHA1 Message Date
Andrzej Kaczmarek
bca3560100 Bluetooth: controller: Use set handle for LE Scan Request Received
Set handle is passed in node_rx header.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-24 13:28:31 +02:00
Andrzej Kaczmarek
37badf0afa Bluetooth: controller: Enable LE Scan Request Received Event
Just need to pass HCI command parameter to LLL.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-24 13:28:31 +02:00
Andrzej Kaczmarek
28238fef71 Bluetooth: controller: Add public scan_req_report function
This will be also used by lll_adv_aux code.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-24 13:28:31 +02:00
Joakim Andersson
c7ad66157d Bluetooth: host: Elevate security to L4 when SC only is enabled
Elevate connections always to security mode 1 level 4 when
Secure Connections Only Mode has been enabled in the Security Manager.

Elevate connections always to security mode 1 level 3 when
Legacy pairing with OOB only has been enabled in the Security Manager.

Fixes: #27338

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-24 10:16:51 +02:00
Andries Kruithof
7ecc55ac84 Bluetooth: controller: consistent HCI error messages
Return BT_HCI_ERR_INVALID_CONN_ID if an invalid handle is
given by the HCI; currently sometimes BT_HCI_ERR_CMD_DISALLOWED
is returned

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2020-08-19 12:10:33 -04:00
Emil Gydesen
66bd06a7d1 Bluetooth: shell: per_adv_sync cb removed pointer to selected inst
Removed the check for selected_per_adv_sync as it was unused by the
create/delete functions (which take the index as parameters), and
caused the shell not to print any values.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-17 13:44:35 -04:00
Emil Gydesen
6cc0487c46 Bluetooth: shell: Fixed pointer in cmd_per_adv_sync_create
The `free_per_adv_sync` pointer in `cmd_per_adv_sync_create`
did not work as intended, as it didn't actually update the
pointer in the array, which caused the
`cmd_per_adv_sync_delete` to not function as intended.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-17 13:44:35 -04:00
Emil Gydesen
2f527092ca Bluetooth: host: Fixed warning when legacy adv support disabled
If CONFIG_BT_EXT_ADV was enabled but
CONFIG_BT_EXT_ADV_LEGACY_SUPPORT was disabled and
CONFIG_NO_OPTIMIZATIONS was enabled, then there was a
maybe-initialized warning. Fixed by adding additional
checks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-08-14 17:16:25 +02:00
Andrzej Kaczmarek
236759b18a Bluetooth: controller: Add advertising set handle mapping
Core 5.2, Vol 4, Part E, section 5.3.1 clarifies that advertising set
handle is assigned by host when advertising set is created and this
happens only on LE Set Extended Advertising Parameters.

An advertising set handle is an arbitrary number within allowed range,
i.e. 0x00-0xEF and not 0..max_supported-1.

This patch adds option to enable advertising set handle mapping from
HCI range as defined by Core specification to zero-based handles used
by LL. If enabled, HCI handle will be remapped to LL handle for each
command, otherwise HCI handle will be used as an LL handle. The latter
effectively skips mapping logic and should be used with Zephyr host
which uses zero based indexes.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
c6db3c275a Bluetooth: controller: Remove redundant flags for advertising set
There's not need to mark advertising set as created by either legacy
or advertising command since this is determined by current so-called
HCI advertising mode which determines whether host uses legacy or
extended advertising commands.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
ae987f3f3a Bluetooth: controller: Disallow mixing legacy/ext adv HCI commands
As per Core 5.2, Part B, section 3.1.1 controller should not allow
mixing of legacy and extended advertising commands. Once 1st command
is received from host, we should only allow commands of the same type
and return an error on other commands.

If legacy advertising interface is selected by 1st command received,
we need to make sure that set with handle=0 is created since it's
used by all legacy commands.

When not using external host, we assume that only extended advertising
interface will be used thus all checks can be skipped (optimized and
compiled-out).

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
dd1ac8d0a6 Bluetooth: controller: Add helper for CC event with status only
A lot of commands return CC event with status parameter only, especially
when error is returned. This patch adds a helper to create such event,
similar to cmd_status.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
c088b02872 Bluetooth: controller: Fix error code on invalid adv set handle
Proper error code should be returned if advertising set with given
handle does not exist instead of generic "invalid parameters" one.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
5f8dd00a6a Bluetooth: controller: Fix return value type
This should match prototype in ll.h.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
11cf7ad3ff Bluetooth: controller: Fix set_ext_adv_param returned status
Should not always return success.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 16:14:29 +02:00
Andrzej Kaczmarek
ca99404832 Bluetooth: controller: Update scan request handling for ext adv
AdvA in extended advertising PDUs is put at different offset than in
legacy PDUs thus it's better to let caller calculate and pass AdvA and
TxAdd explicitly. This way we won't need to check whether scan request
was on legacy or extended PDU every time.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-08-13 12:26:31 +02:00
Erik Brockhoff
94d5f0854e Bluetooth: controller: fixing error re. all zero chmap in conn-ind
When a connect indication contains a channel map of all zeros, the
adv->conn is left NULL'ed after return and next connect attempt leads
to a crash.

This was identified via the Sweyntooth test suite executing the script
re. issue 6.14 towards an Oticon target.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2020-08-13 12:24:28 +02:00
Joakim Andersson
b0d8758fb6 Bluetooth: host: Split SSP to it's own module
Refactor the BR/EDR SSP feature out into it's own source file.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-11 19:32:35 +02:00
Joakim Andersson
487d2be749 Bluetooth: host: Move reset_pairing call to bt_conn_security_changed
Move call to reset_pairing to bt_conn_security_changed, since this
should always be done at the same time, and should be done in the same
order for all calls. For auth_complete this was reset after the
callbacks, which is inconsistent with the other events.

Also call it even if not connected anymore, the disconnection complete
event will be delivered after this event. Callback should alway be
called if security was initiated.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-11 19:32:35 +02:00
Emil Gydesen
5580cb4391 Bluetooth: host: Periodic adv sync shell support
Added shell support to create and delete a periodic adv sync
object.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-11 14:17:19 +02:00
Emil Gydesen
aea6afe3fa Bluetooth: host: Perodic advertisement synchronization
Added support for syncing to periodic advetisements.
The API and usage is heavily inspired by the extended advertisement
and connection APIs.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-11 14:17:19 +02:00
Emil Gydesen
262a0501de Bluetooth: host: Added scan support for periodic advertisement
Added the ext adv report interval to bt_le_scan_recv_info which
denotes whether or not there is periodic advertisement data
associated with the advertisement report.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-11 14:17:19 +02:00
Emil Gydesen
d5801316d7 Bluetooth: host: periodic adv shell support
Added shell support for periodic advertisement params,
data and enable.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-11 14:17:19 +02:00
Emil Gydesen
8cf01ab590 Bluetooth: host: Add periodic advertising API
Added API to set periodic adv parameters, periodic adv data
and to enable/disable periodic advertisement.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-08-11 14:17:19 +02:00
Rubin Gerritsen
38295e0b73 bluetooth: controller: Add BT_QUIRK_NO_AUTO_DLE for BT_LL_SW_SPLIT
It does not auto-initiate the DLE procedure if the default data length
parameters are not equal to the initial parameters.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2020-08-10 12:14:49 +02:00
Rubin Gerritsen
5b034e103f bluetooth: hci_driver: Add BT_QUIRK_NO_AUTO_DLE
Some controllers do not follow the recommendation of auto-initiating
a data length update if the host writes default data length parameters.

If the controller follows this recommendation, calling
LE Write Suggested Default Data Length command is sufficient
to ensure that the LL will auto-initiate the DLE procedure. Performing
a second procedure is unecessary.

In Core v5.2, Vol 4, Part E, Section 7.8.35:
The HCI_LE_Write_Suggested_Default_Data_Length command allows the
Host to specify its suggested values for the Controller's maximum
transmission number of payload octets and maximum packet
transmission time for packets containing LL Data PDUs to be used
for new connections. The Controller may use smaller or larger values
for connInitialMaxTxOctets and connInitialMaxTxTime based on local
information.

In short, this command sets connInitialMaxTxOctets
and connInitialMaxTxTime.

In Core v5.2, Vol 6, Part B, Section 4.5.10:

For a new connection: connMaxTxOctets shall be set to
connInitialMaxTxOctets and connMaxRxOctets shall be chosen by the
Controller. If either value is not 27 then the Controller should
initiate the Data Length Update Procedure at the earliest practical
opportunity.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2020-08-10 12:14:49 +02:00
Joakim Andersson
35201d86ba Bluetooth: GATT: Unregister CCC when unregistering services
Fix issue with bt_gatt_service_unregister not clearing CCC information.

If the service is unregistered while an unbonded peer is connected and
subscribed then this CCC would be restored again when registering the
service even if the peer is now disconnected.

If the service is unregistered with bonded peers CCCs stored in settings
then this value would never be cleared. If the service is registered
again then the peer would receive a service changed for this service,
but it's CCC value would still be enabled.

Fixes: #26924

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-10 12:11:57 +02:00
Joakim Andersson
b2d852be95 Bluetooth: GATT: Extract en queuing of GATT CCC write to a function
Extract enqueue of GATT CCC when CONFIG_BT_SETTINGS_CCC_STORE_ON_WRITE
is enabled to a helper function gatt_ccc_conn_enqueue so that it can be
reused.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-10 12:11:57 +02:00
Joakim Andersson
2919eac891 Bluetooth: GATT: Move clear_ccc_cfg for reuse
Move the clear_ccc_cfg function further up to be re-used without a
forward declaration in bt_gatt_service_unregister.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-10 12:11:57 +02:00
Trond Einar Snekvik
af944ff665 Bluetooth: Mesh: Heartbeat period starts at tx
Starts the periodic heartbeat publish period at the end of the
publication, instead of at the ordering time. This ensures that the
heartbeat period doesn't get shortened by other enqueued messages.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-08-09 09:33:00 -04:00
Trond Einar Snekvik
0221853386 Bluetooth: Mesh: Silence proxy not connected log
When performing node reset over a proxy connection, the disconnection is
asynchronous, and will finish after the reset callback goes to the
application. If the application restarts provisioning in this callback,
the disconnected-event is triggered after PB GATT is reactivated, and
this error is printed without any faults actually occurring.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-08-06 12:56:54 +03:00
Joakim Andersson
97ec4a775e Bluetooth: Host: Notify L2CAP that security change failed
Notify L2CAP when pairing procedure fails during SMP pairing
process. L2CAP needs to be notified so that it can cancel
ongoing connection-oriented channel requests.

Rename bt_l2cap_encrypt_change to bt_l2cap_security_changed and
call it from bt_conn_security_changed always, so that L2CAP
is informed when changing security fails.

This also fixes security_changed conn callback not called when
auth_complete returns an error.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
42b4719947 Bluetooth: ATT: Avoid warning when no ATT request is pending
Avoid warning in att_handle_rsp, only call this when there is a
pending ATT request. This avoids a warning happens when elevating
security fails but higher security had not been requested by an
ATT request.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>

squash! Bluetooth: ATT: Remove warning when no ATT process pending
2020-08-06 11:47:03 +02:00
Joakim Andersson
53435fdd8f Bluetooth: shell: Add sec_level argument to l2cap connect command
Add argument to set required security level when connection
an L2CAP channel.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
521034c63d Bluetooth: L2CAP: Release channel when connect request fails
Release the l2cap channel when sending the l2cap connect request
fails.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
5f00ee1e88 Bluetooth: L2CAP: Elevate security level if requested by application
Elevate the security level before sending the connection request if
the application has set a required security level on the channel.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
9c3d006471 Bluetooth: L2CAP: Elevate security level when connect request denied
Elevate the security level of the connection when the l2cap channel
connect request is denied with encryption or authentication error
code.
The l2cap channel required_sec_level was used, but this is not
correct as this is set by the user of the API. This resulted in
the call to bt_conn_set_security seeing that the current security
level was already set, decide there is nothing to be done and return
success.

Fixes: #27220

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
81e297aa88 Bluetooth: L2CAP: Use safe for-each loop where channel can be removed
Use safe for-each loop in bt_l2cap_encrypt_change since dynamic
channels with pending connection-oriented channel requests will
be canceled and removed from the list if the encryption change
failed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:47:03 +02:00
Joakim Andersson
1d66c1e491 Bluetooth: host: Use CONFIG_BT_L2CAP_RX_MTU always to set L2CAP RX MTU
Remove dependency on CONFIG_BT_ACL_FLOW_CONTROL and use
CONFIG_BT_L2CAP_RX_MTU always to set L2CAP RX MTU.
The ATT MTU is set from two different KConfig options depending
on if CONFIG_BT_ACL_FLOW_CONTROL is enabled, which makes it
a confusing option and hard to provide a conf file that
supports multiple board configurations.

This changes the behavior when CONFIG_BT_ACL_FLOW_CONTROL and
CONFIG_BT_BUF_RX_LEN was used to set the L2CAP RX MTU, and by
extension the ATT MTU.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-08-06 11:46:48 +02:00
Andrew Boie
d0e4b24453 bluetooth: use kernel stacks
These threads don't run in user mode, save some memory if
userspace is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-05 21:30:32 -04:00
Dag Bjarvin
e93963b719 Bluetooth: controller: Add ll_adv_aux_set_clear function
Add ll_adv_aux_set_clear, add to bsim test

Signed-off-by: Dag Bjarvin <Dag.Bjarvin@nordicsemi.no>
2020-08-05 12:52:42 +02:00
Vinayak Kariappa Chettimada
77b820a9ea Bluetooth: controller: Fix incorrect use of ticker user id
Fix incorrect use of LLL ticker user id in ULL_LOW execution
context.

Regression introduced in commit 23ef75f6d9 ("Bluetooth:
controller: split: Fix Low Latency Prepare Done").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-08-05 12:02:05 +02:00
chao an
5328adcff5 Bluetooth: Mesh: Fix tx seg buffer with NULL pointer reference
Fix tx seg buffer with NULL pointer reference if enable mesh friendly

Signed-off-by: chao an <anchao@xiaomi.com>
2020-08-04 12:47:05 +03:00
Luiz Augusto von Dentz
6c7a387e9f Bluetooth: ATT: Fix handling to EATT channels
EATT channels use bt_l2cap_chan_send which does return the number of
bytes sent on success not 0 as bt_l2cap_send.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-08-04 10:38:27 +03:00
chao an
9e64d379f0 Bluetooth: Mesh: configurable advertiser stack size
Add a configurable Kconfig option for advertiser thread stack size

Change-Id: Ia59a03311706de929d1833fa46cff66652620e7a
Signed-off-by: chao an <anchao@xiaomi.com>
2020-08-03 13:50:21 +02:00
Vinayak Kariappa Chettimada
dc48999ee1 Bluetooth: controller: Fill event counter in sync info
Fill the referenced event counter of the Periodic
Advertising SYNC_IND PDU into the sync info struct in the
Common Extended Advertising Header Format.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-07-31 19:04:23 +02:00
Vinayak Kariappa Chettimada
807ee0c849 Bluetooth: controller: Fill Periodic Adv interval in Ext Adv Report
Fill the missing Periodic Advertising interval in the
Extended Advertising Report when Auxiliary PDUs contain
Sync Info fields.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-07-29 16:39:59 +02:00
Dag Bjarvin
bc0b8cfae1 tests: Bluetooth: shell: Add ll_adv_aux_set_remove function
Add call to ll_adv_aux_set_remove in shell app

Signed-off-by: Dag Bjarvin <Dag.Bjarvin@nordicsemi.no>
2020-07-29 16:37:15 +02:00
Dag Bjarvin
cb3b7863dc Bluetooth: controller: Add ll_adv_aux_set_remove function
Add ll_adv_aux_set_remove function

Signed-off-by: Dag Bjarvin <Dag.Bjarvin@nordicsemi.no>
2020-07-29 16:37:15 +02:00
Joakim Andersson
e82b688c72 Bluetooth: SMP: Reject legacy pairing early in SC only mode
Reject the security request immediately when receiving a security
request that does not support LE Secury Connections pairing.
This would have been rejected during the pairing procedure, but
PTS testing expects the security request to be rejected.

Ref: GAP/SEC/SEM/BV-29-C

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-07-29 16:07:29 +02:00