Commit graph

9523 commits

Author SHA1 Message Date
Emil Gydesen
f7ca9b4afa Bluetooth: Audio: MICS client change to use bt_mics
Change to use the generic bt_mics struct instead of the
bt_mics_client struct, to align better with the future
API change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:34:37 +02:00
Emil Gydesen
8ca8dabc19 Bluetooth: Audio: MICS use bt_mics struct instead of bt_mics_server
Change the type of the mics_inst in mics.c to bt_mics instead
of bt_mics_server to align better with the future API change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:34:37 +02:00
Emil Gydesen
f42d6c475c Bluetooth: Audio: MICS client return pointer to instance on discover
Add return of instance pointer in bt_mics_discover so that a client
will get a bt_mics pointer when doing discover, which will be
used going forward in the API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:34:37 +02:00
Emil Gydesen
d6fd79f65d Bluetooth: Audio: MICS introduce opaque bt_mics struct
Add a bt_mics struct that represents a MICS instance,
either a local (server) or remote (client) instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-24 12:34:37 +02:00
Mark Wang
5daf0b2fad bluetooth: rfcomm: fix the coverity 203443 memory corruptions
- Coverity think it is out-of-bound writing
because the codes write two bytes to address (&hdr->length)
that hdr->length is uint8_t. Coverity doesn't think about
the one more byte after the hdr->length.
- Use net_buf_push to resolve this issue.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2021-06-24 11:57:33 +03:00
Pavel Vasilyev
5513b86864 Bluetooth: Mesh: Update SNB beacon before sending it
Authentication value must be recalculated before sending it.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-06-23 08:02:38 -04:00
Joakim Andersson
b4ce2ba481 Bluetooth: host: Add helper function to find an attribute from its uuid
Expose a helper function to the application that searches the local
database for the given attribute from its UUID.
Provide arguments to limit the search that matches the service
declaration to make it easy to limit the search to a specific service.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-06-22 09:06:00 -04:00
Joakim Andersson
3ad3a72caf Bluetooth: host: Allow attribute as NULL with notify / indicate by UUID
Allow to pass attribute as NULL pointer when using notify or indicate by
UUID. This will use the entire handle value range to search for an
attribute with a matching UUID.
Document optional parameters, and clarify attr and uuid usage in the
variable declaration in the struct for clarification.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-06-22 09:06:00 -04:00
Vinayak Kariappa Chettimada
d76baf9bbb Bluetooth: Controller: Fix ticker ops count for extended initiator
Increase the ticker operations count in ULL high context
when Extended Advertising Connection Establishment on Coded
PHY is supported.

This fixes assertion in Controller when initiating a
connection on Coded PHY, wherein two scan instance ticker,
one window stop ticker, and a new connection instance
ticker operations needs to be enqueued.

Relates to commit a6b8eba7c5 ("Bluetooth: controller:
Implement disabling the other PHY initiator").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-22 08:24:00 -04:00
Emil Gydesen
a1cf45b26e Bluetooth: ISO: Split connected and broadcast ISO Kconfig
Add a new Kconfig option, BT_ISO_UNICAST, to make it possible
either configure unicast only, broadcast only or both.

This results in some code being moved, but not modified, and
should not effect anything.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-22 08:21:00 -04:00
Krzysztof Kopyściński
e62c3c533a Bluetooth: gatt: allow writing long device name
BT_DEVICE_NAME_MAX can be up to 248 bytes. This may exceed ATT MTU size,
which will cause the offset in write_name() to be non zere, resulting in
BT_ATT_ERR_INVALID_OFFSET. However, device name should be writable up to
it's defined size, using subsequent prepare write requests. Error should
be returned if offset exceeds size of device name, and if total size of
new value exceeds BT_DEVICE_NAME_MAX, BT_ATT_ERR_INVALID_ATTRIBUTE_LEN
shall be returned.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-06-19 16:55:56 -05:00
Emil Gydesen
22cfbd3dbd Bluetooth: Host: Modify check for read buffer size v2
Modify the check from checking the feature bit to
checking the command bit. This ensures that we
don't send the read buffer size V2 to a controller
that does not support it.

This also moves the entire ISO init procedure into
a separate function to avoid having a large
ISO-only block in `le_init`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-18 11:21:14 +02:00
Krzysztof Kopyściński
9bf65e557b Bluetooth: gatt: add checks for db out of sync on read mult requests
This check is present in att_read_rsp(), but att_read_mult_req and
att_read_mult_vl_req do not use it. Add this check to these functions.

This was affecting GATT/SR/GAS/BV-08-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-06-18 00:41:23 +03:00
Lingao Meng
3e492665c0 Bluetooth: Controller: Add net_buf_ref ret value to variables
Return value should assigns to variables instead of ignoring them.

Related to PR(#36259).

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-06-17 12:46:05 +03:00
Lingao Meng
4820989195 Bluetooth: Add missing store net_buf_ref ret value
... related to(#36259)

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-06-17 12:46:05 +03:00
YanBiao Hao
d466a807ee Bluetooth: Mesh: comp pointer check
comp data pointer check before using

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2021-06-16 22:58:44 -05:00
Krzysztof Kopyściński
5f9d760755 bluetooth: l2cap: fix ecred conn response for all connections refused
If all connections were refused, we haven't reached part of
le_ecred_conn_req with connecting channels - thus i was never
incremented. PDU shall be created always with the length containing
full size of scid array - we always respond with all of the CIDs filled,
they just will be all zeros when all connections were refused.

This was affecting L2CAP/ECFC/BV-26-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-06-16 10:41:51 +02:00
Morten Priess
d1f71e93a0 Bluetooth: controller: CIS/CIG teardown at ACL disconnect
When an ACL connection with active CISes terminates, inject CIS/CIG
teardown to ensure CIS is stopped before ACL disconnection completes.
This includes stopping CIG ticker when last CIS has stopped.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-06-16 10:38:38 +02:00
Morten Priess
01e7dd853f Bluetooth: controller: Remove cis_handles array from ISO groups
Maintaining the cis_handles array in ULL/LLL ISO group data amounts to
double book-keeping. This commit eliminates the array and introduces a
'getter' for obtaining CISes owned by a specific CIG, and iterate
through them.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-06-16 10:38:38 +02:00
Morten Priess
ab40e57894 Bluetooth: host: Disconnect all ISO channels on BT_CONN_DISCONNECTED
When an ACL changes state to disconnected, all associated ISO channels
must be disconnected and cleaned up. This commit ensures that.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-06-16 10:38:38 +02:00
Lingao Meng
c45ec6fc0d Bluetooth: Mesh: Fix missing proxy send status
Add an error judgment during `proxy_send` to avoid
missing `net_buf_unref`.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-06-16 11:01:41 +03:00
YanBiao Hao
f6d7f8f36f bluetooth: mesh: sequence number limit config
set sequence number limit by Kconfig

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2021-06-15 12:51:50 +03:00
Vinayak Kariappa Chettimada
97598c4d61 Bluetooth: controller: Yield scan window when scanning Aux PDUs
Use ticker_yield_abs interface to make scan window on
primary channel to yield when trying to scan auxiliary PDUs.

Fixes #30244.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-14 15:19:33 +02:00
Vinayak Kariappa Chettimada
bce82ad49b Bluetooth: controller: Add ticker_yield_abs interface
Add ticker_yield_abs interface to reduce ticks_slot_previous
value when radio events yield/stop earlier than their time
reservations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-14 15:19:33 +02:00
Trond Einar Snekvik
f2579cb3f2 Bluetooth: Mesh: Increase default CDB node count
The old default of 1 makes provisioner devices useless, as they can only
provision themselves before they run out of space.

Increase the default value for CONFIG_BT_MESH_CDB_NODE_COUNT to 8.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-06-14 15:19:07 +02:00
Emil Gydesen
b450e63f28 Bluetooth: Audio: AICS use bt_aics instead of bt_aics_server
Modify aics.c to use the bt_aics struct instead of the
bt_aics_server struct. This is done so that there is less
difference between the internal struct usage and the struct
type used in the API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-14 14:54:59 +02:00
Emil Gydesen
6b2cc7e57e Bluetooth: Audio: Rename bt_vcs to bt_vcs_included
Rename the struct from bt_vcs to bt_vcs_included, and
rename bt_vcs_get to bt_vcs_included_get as that is more
descriptive of the value returned.

Furthermore, this will also allow us to use bt_vcs as
an opaque pointer to a VCS service instance (local
or remote) to match the service instance pointers of
AICS and VOCS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-14 14:25:55 +02:00
Emil Gydesen
d52b4ac4bf Bluetooth: Audio: Rename bt_mics to bt_mics_included
Rename the struct from bt_mics to bt_mics_included, and
rename bt_mics_get to bt_mics_included_get as that is more
descriptive of the value returned.

Furthermore, this will also allow us to use bt_mics as
an opaque pointer to a MICS service instance (local
or remote) to match the service instance pointers of
AICS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-14 14:25:49 +02:00
Emil Gydesen
b683bea5d7 Bluetooth: Audio: VOCS client add function to get conn pointer
Add a function that returns the bluetooth connection
pointer of a given VOCS client instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-14 14:25:42 +02:00
Lingao Meng
7531d2e3c8 Bluetooth: Mesh: Add proxy send callback
Zephyr Bluetooth Mesh did not check whether the proxy message
was actually sent out, so that the response message could
not be received during reset. It did not solve the status
callback of the proxy sending message, so a new problem was
introduced after PR(#28457) merged.

bt_mesh_prov_send(&buf, public_key_sent))

This PR will try to solve the above problem, and will fix
the problem due to thread competition, and PR(#26668) will
not be necessary.

Compared with PR(#30138), it no longer consumes extra RAM
space and supports synchronization of group addresses

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-06-14 11:52:21 +03:00
Lingao Meng
a63f2d8d60 Bluetooth: Mesh: Reconstructing adv callback logic
The adv callback logic is reconstructed to coexist
with proxy send callback.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-06-14 11:52:21 +03:00
Kumar Gala
3f149f0828 bluetooth: Removed deprecated bt_set_id_addr function
The function have been deprecated for 2 releases so remove the code
associated with it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-11 16:35:19 -05:00
Piotr Pryga
15375d4478 Bluetooth: controller: Fix wrong channel index in IQ samples report
Fix wrong channel index send by controller in connectionless
IQ samples report. Former implementation reported value from
lll->data_chan_id which is not valid channel index.
Updated implementation reports value stored in IQ samples receive
node during periodic scanning event preparation.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-06-11 17:14:29 +02:00
Morten Priess
fa20fa95d0 Bluetooth: controller: Improve ticker_by_next_slot_get
Fixes ticker_by_next_slot_get for JIT scheduler by allowing iterating
through ticker nodes without ticks_slot information, and improves
performance for legacy ticker scheduling use.

To reduce the processing and context switching overhead, a new feature
is introduced via BT_TICKER_NEXT_SLOT_GET_MATCH, by which an operation
callback may be added via the ticker_next_slot_get_ext interface, and
the match function is then called when the ticker_job is processing the
request.
By returning true in this callback, iteration stops and normal operation
callback is invoked. If the match function returns false, node iteration
continues. This reduces the number of ticker_job executions for node
iteration.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-06-11 16:18:55 +02:00
Joakim Andersson
946cf25f78 Bluetooth: shell: Use UUID encode macro for 128-bit UUIDs
Use UUID encode macro fro 128-bit UUIDs for readability. This makes
it easier to see which service you are working with as the
bt_uuid_to_str prints the 128-bit UUIDs in this format.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-06-11 16:13:35 +02:00
Emil Gydesen
18f1745d29 Bluetooth: ISO: Add packet status flag to iso recv info
Add the packet status flag value to the iso receive info
struct. This will allow an application to handle potential
lost or erroneous messages.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-11 16:12:34 +02:00
Pavel Vasilyev
65f798a00a Bluetooth: Mesh: Add API to manually store pending RPL entries
The current approach with storing RPL by timeout doesn't solve all
issues as the node may loss power before the timer is fired.
In addition to that this may wear out flash quickly if short timeout is
used.

This change adds an API to store the pending RPL entry upon user
request. Additional Kconfig option allows to completely disable timer
so that the whole storing relies on the user.

The mesh stack still stays responsible for outdating RPL entries in case
of IV Index update as this happens implicitly for the user.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-06-11 15:47:09 +02:00
Pavel Vasilyev
f5ba999257 Bluetooth: Mesh: Fix setting remote public key in provisioner
This aligns provisioner and provisionee APIs in terms of endianess
of public key provided by an application.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-06-10 17:14:03 -04:00
Pavel Vasilyev
0335d5fb01 Bluetooth: Mesh: Add OOB Public Key support for provisionee role
This commit allows an unprovisioned device to exchange its public key
using out-of-band techology (see MeshPRFv1.0.1, table 5.19 and section
5.4.2.3).

For in-band public key exchange, the mesh stack uses HCI commands to
generate public and private keys, and DH key. This, however, doesn't
work for OOB public key exchange since there is no command to generate
DH key with a private key provided by an application. Therefore, this
commit adds direct usage of TinyCrypto into the mesh stack for DH key
generation for OOB public key support.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-06-10 17:14:03 -04:00
Jonathan Rico
ecae33740d Bluetooth: host: Prevent race condition in pairing procedure
Moving the key check after checking that no pairing or encryption
procedure is started fixes a race condition that is seen in some PTS
tests:

GATT/CL/GAR/BI-04-C
GATT/CL/GAR/BI-16-C
GATT/CL/GAR/BI-21-C
GATT/CL/GAW/BI-05-C
GATT/CL/GAW/BI-12-C

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2021-06-10 17:13:41 -04:00
Carles Cufi
d9848b155d Bluetooth: host: Optionally disable GATT sec re-establishment
Some centrals deal poorly with receiving a security request immediately
after reconnection whenever reconnecting with characteristics that are
notifiable or indicatable and requiring security. In particular,
Android 9 and earlier devices may lose bond information when this
happens, some Microsoft Surface devices will enter an invalid state
and, on top of that, Apple's Bluetooth Low Energy guidelines explicitly
discourage this behavior.

In order to allow interoperability with those devices, make the GATT
automatic security request sending as a peripheral optional by
introducing a new Kconfig option, BT_GATT_AUTO_SEC_REQ.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-06-09 21:10:14 +03:00
Faisal Saleem
c9fd7a6099 Bluetooth: Keys: Fix BT_KEYS_OVERWRITE_OLDEST logic for BT_MAX_CONN > 1
When the Bluetooth stack is configured for CONFIG_BT_MAX_CONN > 1
the oldest key might currently be in use.  Fix the logic to ensure the
oldest key overwritten is from the set of keys currently not in use.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/35999

Signed-off-by: Faisal Saleem <faisal.saleem@setec.com.au>
Signed-off-by: Nick Ward <nick.ward@setec.com.au>
2021-06-08 20:18:49 +02:00
Pavel Vasilyev
33fafe1e2f Bluetooth: Mesh: Reject identical public keys
This commit address Erratum E10395 and Errata Correction E16350
to ensure that public keys exchanged between Provisioner and
a device aren't identical.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-06-07 18:56:26 +03:00
Piotr Pryga
7afc31a834 Bluetooth: host: Unmask CTE report related events for DF connected mode
Unmask events related with CTE report for Direction Finding
working in connected mode.
The feature is enabled conditionally, depending on KConfig
configuration provided.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-06-07 17:09:01 +02:00
Piotr Pryga
a717e8c2a6 Bluetooth: host: Add option to enable connection CTE RX
Add Kconfig option that will enable support for CTE reception
in connected mode. Thanks to that it will be possible to
conditionally enable or disable support of the feature and
decrease code size if the feature is not required.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-06-07 17:09:01 +02:00
Emil Gydesen
f500e0fb9c Bluetooth: Audio: VOCS remove need for bt_conn pointer
Remove the bt_conn pointer from the VOCS API, as the
instance pointer is enough to determine if it is a client
and perform client operations on the cached connection pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-07 12:08:10 +02:00
Emil Gydesen
301cedbad5 Bluetooth: Audio: VOCS use bt_vocs instead of bt_vocs_server
Modify vocs.c to use the bt_vocs struct instead of the
bt_vocs_server struct. This is done so that there is less
difference between the internal struct usage and the struct
type used in the API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-07 12:08:10 +02:00
Kamil Piszczek
eff957b764 Bluetooth: HCI: add api for getting advertising handle
Added an API to the HCI header that can be used to retrieve
advertising handle information from a given advertising set.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2021-06-07 12:08:02 +02:00
Joakim Andersson
3aaf50ae6e Bluetooth: host: Remove unneccesary limit of host to controller packets
Remove unneccesary limit of host to controller packets by the host ISO
buffers and host pending buffers with TX callback.
The host always allocates the buffer before taking the semaphore so this
is already handled by the size of the host buffer pool and the
functionality of the buffer pools to wait for buffers.

In addition the ACL max limit is using the wrong define, as
CONFIG_BT_CONN_TX_MAX is the maximum amount of callback contexts for
transmitting. So the host can have more pending packets than this value.
This is also inconsistent with how the host would handle the V1 reply.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-06-07 12:06:48 +02:00
Emil Gydesen
20f0bff05f Bluetooth: Audio: MICS shell commands
Add the shell commands for both MICS server and client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-07 12:04:28 +02:00