Commit graph

1248 commits

Author SHA1 Message Date
Piotr Pryga
ddece2501d include: Bluetooth: hci: Add LE set connectionless IQ sampling enabled
Add new command HCI_LE_Set_Connectionless_IQ_Sampling_Enable that
will allow host to enable CTE sampling in controller.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-06 16:27:16 +02:00
Piotr Pryga
8ceaea179c include: Bluetooth: hci: move command to appropriate position in file
All commands are put in the file according to OpCode Command Field
increasing order. bt_hci_cp_le_set_cl_cte_tx_enable was written in
wrong position. This commit moves it to correct one.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-06 16:27:16 +02:00
Joakim Andersson
69613626ed Bluetooth: host: Document L2CAP channel send buffer sizes
Update the documentation for L2CAp Connection oriented channel send
function to include better description of the L2CAP PDUs (Basic frames)
and L2CAP SDUs (Credit-based frames) so that the application can better
understand how to size the buffer pools and setting the RX mtu.
Document stack behavior on RX path and how the application has to
set up the channel in order to receive segmented packets.
Document stack behavior on TX path for reserving either mandatory or
optional header bytes.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Joakim Andersson
6483e12a8a Bluetooth: Refactor bluetooth buffer configuration for simplification
Refactor and simplify the bluetooth buffer configurations to improve the
easy of configurations and eliminate invalid ones.
By moving configurations out of host and controller specific
configurations and into a common one it becomes easier to configure
the host and controller separately as the same configurations can be
used as would be for a combined build.

All HCI configurations are now given exluding the matching HCI header,
which eases the configuration as the application don't have to know the
different header sizes.
The BT_RX_BUF_LEN is split into ACL and Event, as well as the suprising
use of Command size.
BT_L2CAP_RX_MTU is removed as the stack does not support reassembling of
HCI ACL data to larger L2CAP PDUs. The application will have to set
ACL RX size and account for the L2CAP PDU header itself.
BT_EATT_RX_MTU was removed as it is only used for setting a different
default value for another option which leads to the stuck kconfig symbol
problem.

The configurations can be updated according to the table below:

** New configuration         | ** Old configuration
All configurations
BT_BUF_ACL_RX_SIZE           | BT_L2CAP_RX_MTU + 4
BT_BUF_ACL_RX_SIZE           | BT_RX_BUF_LEN - 4
BT_BUF_EVT_RX_SIZE           | BT_RX_BUF_LEN - 2
BT_BUF_CMD_TX_SIZE           | BT_RX_BUF_LEN - 3
BT_BUF_CMD_TX_COUNT          | BT_HCI_CMD_COUNT
BT_BUF_EVT_RX_COUNT          | BT_RX_BUF_COUNT
BT_BUF_ACL_RX_COUNT          | BT_RX_BUF_COUNT
BT_BUF_ACL_RX_COUNT          | BT_ACL_RX_COUNT
BT_BUF_EVT_DISCARDABLE_SIZE  | BT_DISCARDABLE_BUF_SIZE - 2
BT_BUF_EVT_DISCARDABLE_COUNT | BT_DISCARDABLE_BUF_COUNT
Controller-build
BT_BUF_ACL_TX_SIZE           | BT_CTLR_TX_BUFFERS_SIZE
BT_BUF_ACL_TX_COUNT          | BT_CTLR_TX_BUFFER
HCI-bridge
BT_BUF_ACL_TX_SIZE           | BT_HCI_ACL_DATA_SIZE
BT_BUF_ACL_TX_COUNT          | 6

Fixed invalid configurations setting either BT_L2CAP_RX_MTU or
BT_CTLR_DATA_LENGTH_MAX larger than BT_RX_BUF_LEN could lead to buffer
overruns.

Fix advertising report max data length calculation.
This always used the BT_DISCARDABLE_BUF_SIZE macro but this feature
can be turned off and advertising reports will be allocated from the RX
buffer in that case. Also controller-build does not have this buffer
(in hci_raw.c). Also the wrong HCI header was used in the calculation,
HCI event header should have been used instead of HCI ACL header.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Joakim Andersson
eba6350a12 Bluetooth: host: Add macros for calculating buffer sizes
Add macros for calculating buffer sizes, accounting for the various
L2CAP and HCI headers needed as well as the reserved bytes needed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-06 14:56:18 +02:00
Joakim Andersson
b9ea5d9910 Bluetooth: host: Update RFCOMM to new delayable work API
Update RFCOMM to use the new delayable work API for the RTX host timer
used for disconnecting and idling.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Joakim Andersson
afc29f3a1c Bluetooth: host: Update L2CAP to use the new delayable work API
Update L2CAP to use the new delayable work API for the signaling
RTX host timer.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-05 19:44:09 -04:00
Andrzej Kaczmarek
7eabf1cdf2 Bluetooth: host: Add adv parameters def for connectable ext adv
This is the same as for legacy, but with ext adv flag.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-05-05 14:15:05 +02:00
Emil Gydesen
87df76c7f7 Bluetooth: ISO: Improved text for setting ISO data paths
Improved the documentation for the ISO data paths, as well
as making the bt_iso_setup_data_path function a bit more
clear.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-05-03 11:59:25 +02:00
Emil Gydesen
910e0c63f4 Bluetooth: Audio: VOCS: Move callback structure to register function
Moves the callback structure for VOCS to the register function
which is renamed from init, as there's no reason to register
the callbacks separately.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-26 13:42:50 +02:00
Emil Gydesen
a4108e7b0b Bluetooth: GATT: Add documentation for empty notifications in callback
Adds documentation specifically for empty notification in the
bt_gatt_notify_func_t callback, as that works a bit different
from e.g. reading an empty characteristic.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-23 15:01:40 +02:00
Emil Gydesen
2bada95482 Bluetooth: Host: Adds periodic advertising min/max interval macros
Add the BT_GAP_PER_ADV_MIN_INTERVAL and BT_GAP_PER_ADV_MAX_INTERVAL
macros in gap.h that are also reference in bluetooth.h and
used for parameter validation in adv.c.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-23 15:01:32 +02:00
Emil Gydesen
cfe0849072 Bluetooth: services: Adds OTS name length checks
Adds name length checks. The OTS spec does not
explicitely specifiy a maximum name length, but the
maximum name length in the directory listing object
shall be less or equal to 120 octets.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-22 11:32:25 +02:00
Emil Gydesen
59f3e2c502 Bluetooth: host: Fix typo in PA defines and missing min check
Fixes a typo where the BT_GAP_PER_ADV macros had MAX twice,
as well as adding a MIN timeout macro and check.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-21 20:41:17 -04:00
Luiz Augusto von Dentz
d7b42d8129 Bluetooth: ISO: Add note for bt_iso_chan_send
This adds a note about buffer ownership and error handling of
bt_iso_chan_send so it is aligned with recent changes.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-04-20 18:20:04 -04:00
Luiz Augusto von Dentz
e981e40ffa Bluetooth: L2CAP: Add note for bt_l2cap_chan_send
This adds a note about buffer ownership and error handling of
bt_l2cap_chan_send so it is aligned with recent changes.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-04-20 18:20:04 -04:00
Jamie McCrae
840d1d9381 bluetooth: Add flag to force device name to appear in AD data
This adds a new flag, BT_LE_ADV_OPT_FORCE_NAME_IN_AD, which can be used
to force the Bluetooth GAP device name to appear in the advertising
data rather than the scan response data of an advert with scan response
data.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2021-04-20 18:19:30 -04:00
Joakim Andersson
a7daeebf0e Bluetooth: host: Document default behavior of le_param_req with no cb
Document the default behavior of LE connection parameters request when
the application has not defined a callback.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-04-19 10:59:43 -04:00
Emil Gydesen
1690f27658 Bluetooth: Audio: Fixes a few minor editorial things in aics.h
Changes
ERRNO => errno
and renames the init/register parameter.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-19 10:58:42 -04:00
Trond Einar Snekvik
820cfc52ad Bluetooth: Mesh: Rework publication timer
Periodic publication would previously build and send the first
publication inside the bt_mesh_model_pub() function, before cancelling
and rescheduling the next publication. The timer handler would only
handle retransmissions, and would abandon the rest of the publication
event if one of the packets failed to send.

This design has three issues:
- If the initial timer cancel fails, the publication would interfer with
  the periodic publication management, which might skip an event or
  send too many packets.
- If any of the messages fail to publish, the full publication event
  would be abandoned. This is not predictable or expected from the API.
- bt_mesh_model_pub() required 384 bytes of stack to build the message,
  which has to be factored into all calling threads.

This patch moves all transmission into the publication timer by
replacing k_work_cancel with a single k_work_reschedule(K_NO_WAIT). It
also changes the error recovery behavior to attempt to finish the full
publication event even if some of the transmissions fail.

Split out from #33782.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-15 20:31:44 +02:00
Marek Pieta
cc21ff5a8c Bluetooth: GATT: Fix undefined symbols
Change fixes build issues for configurations without Bluetooth.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2021-04-14 18:19:42 +02:00
Asger Munk Nielsen
b9b1c7e19b Bluetooth: controller: ISO adaptation layer, Rx unframed
First design towards ISO adaptation layer, this PR introduces
data-structures and framework for Rx unframed PDUs (BT RX ingress).
Two callbacks are defined for the SDU production (BT RX egress), one for
SDU allocation as well as a callback for emitting a reassembled SDU.

Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
2021-04-14 18:17:09 +02:00
Mark Wang
b6217e1bec Bluetooth: hci: add HCI_Write_Class_Of_Device
add the op code and the parameter structure.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2021-04-14 12:58:57 +03:00
Emil Gydesen
2016509756 Bluetooth: Audio: Audio Input Control Service and client
This commit implements the secondary service
Audio Input Control Service (AICS) server and client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-12 11:47:00 -04:00
Kumar Gala
c5e4011e29 bluetooth: Fix build issue with <bluetooth/mesh/access.h>
Add include <bluetooth/mesh/msg.h> into <bluetooth/mesh/access.h> to get
definition of 'struct bt_mesh_msg_ctx'.

We see this when trying to build the mesh_badge sample for the
reel_board.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-04-09 17:41:11 +03:00
Emil Gydesen
2b849f07b6 Bluetooth: ATT: Add ATT first/last handle defines
Adds #defines for the minimum (first) and maximum (last)
attribute handles in ATT. These are useful for when setting e.g.
the start and end handle when doing a full GATT discover.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-08 16:35:57 +02:00
Pavel Vasilyev
a94c7e3a23 Bluetooth: Mesh: Introduce acknowledged message API
The implementation of blocking calls is common for all the client
models.

This change reduces the code duplication by introducing new API that
helps to manage acknowledged messages.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-04-08 13:44:24 +02:00
Emil Gydesen
026da2df03 Bluetooth: host: Add ISO disconnect reason
Adds a disconnect reason in the ISO disconnect callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-07 14:16:54 +02:00
Emil Gydesen
5a1afaa47a Bluetooth: host: Add functions for periodic adv sync objects
Adds two functions:
1) Lookup periodic adv sync object by address
2) Get information about a periodic adv sync object.

These can be useful for the application verify if there is already an
existing sync to an periodic advertiser.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-07 14:16:46 +02:00
Joakim Andersson
9f7061a83d Bluetooth: host: Add discovery of standard descriptor values
Add discovery of standard descriptor values. This provides a shorthand
instead of doing a read by UUID, allowing the application discovery
procedure to re-use the discover parameters for simple descriptors.

Fixes: #21489

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-04-06 10:50:18 -04:00
Joakim Andersson
37ea9ac8a7 Bluetooth: host: Add Server Characteristic Configuration definitions
Add Server Characteristic Configuration definitions for bit values
and attribute value.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-04-06 10:50:18 -04:00
Lyle Zhu
8fd1605372 Include: Bluetooth: Add GATT uuids
Add BT_UUID_IAS for Immediate Alert Service
Add BT_UUID_LLS for Link Loss Service
Add BT_UUID_HPS for HTTP Proxy Service
Add BT_UUID_ALERT_LEVEL for Alert Level
Add BT_UUID_URI for URI
Add BT_UUID_HTTP_HEADERS for HTTP Headers
Add BT_UUID_HTTP_STATUS_CODE for HTTP Status Code
Add BT_UUID_HTTP_ENTITY_BODY for HTTP Entity Body
Add BT_UUID_HTTP_CONTROL_POINT for HTTP Control Point
Add BT_UUID_HTTPS_SECURITY for HTTPS Security

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2021-04-06 15:29:59 +02:00
Trond Einar Snekvik
b84fee5190 Bluetooth: Mesh: Composition data page 0 traversal
Adds a parsing mechanism for Composition data page 0 in the Config
Client API, and uses it in the shell module to parse the incoming
composition data.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-06 16:19:13 +03:00
Trond Einar Snekvik
9259b199bb Bluetooth: Mesh: Rename bt_mesh_cfg_comp_data_get's status param to rsp
The first byte of the composition data status message is the returned
page index, not the status of the request. This is now reflected in the
API.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-06 16:19:13 +03:00
Pavel Vasilyev
8bcc85b38c Bluetooth: Mesh: Check response address in Configuration Client
The Configuration Client doesn't check the address in a received
response. This means that a response from any device will be accepted.

This change ensures that the correct response will be accepted.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-03-25 07:09:47 -04:00
Luiz Augusto von Dentz
9d0fb5ec47 Bluetooth: ISO: Remove channel direction
Channel direction was actually a source of confusion since the spec does
actually define the data path direction from controller point of view
meaning input actually means transmit and output receive, also direction
can be configured with different QoS settings.

To make these APIs less confusing and allow QoS to be configured
independently they are now split into RX (receiving) and TX
(transmission) settings including its data path.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-03-23 17:49:08 -04:00
Luiz Augusto von Dentz
af0fc963d8 Bluetooth: ISO: Fix cleanup connection
This fixes bt_iso_cleanup when there are still channels bound to the
ACL connection.

On top of it introduce bt_iso_chan_unbind which can be used to unbind
channels and thus release the reference to the ACL connection if that
has not been disconnected in which case the channels are unbind
automatically.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-03-23 17:49:08 -04:00
Emil Gydesen
ed2162c700 Bluetooth: Audio: Volume Offset Control Service and Client
This commit implements the secondary service
Volume Offset Control Service (VOCS) server and client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-03-22 13:05:56 -04:00
Rubin Gerritsen
2affd52339 bluetooth: host: EAGAIN when initiating a connection when scanning
Also improve the documentation.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2021-03-17 15:33:43 -04:00
Emil Gydesen
a3b6bc212f Bluetooth: services: Refacter OTS dir list to avoid circular dependency
Refactors the OTS directory listing object implementation to avoid
circular dependency.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-03-17 11:30:07 +01:00
Emil Gydesen
e90ec2df44 Bluetooth: services: Adds directory listing object to OTS
The directory listing object is an internal object which
content is the aggregation of all the metadata of all objects
(including the directory listing object itself). The client
can read this value to get a list of all objects with names,
lengths, and other metadata.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-03-17 11:30:07 +01:00
Trond Einar Snekvik
318d0928c1 Bluetooth: Mesh: Add Proxy callback structure
Adds a Proxy callback structure with a callback for Node ID enable and
disable. This API follows the Friend and LPN API pattern in mesh/main.h,
and can be expanded with more callbacks later.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-03-17 11:28:46 +01:00
Johan Stridkvist
a81765bbe4 Bluetooth: HCI: Add option CONFIG_BT_HCI_ACL_DATA_SIZE
Add the option CONFIG_BT_HCI_ACL_DATA_SIZE which allows the user
to configure the max HCI ACL data payload. This is needed for platorms
where the BLE LL, HCI uart and host run on three different cores.

Fixes: #30441

Signed-off-by: Johan Stridkvist <johan.stridkvist@nordicsemi.no>
2021-03-12 20:40:21 +02:00
Trond Einar Snekvik
243e29cc29 Bluetooth: Mesh: Add poll callback for friend role
Adds a "polled" function to the friend callback structure, that gets
called every time the friend receives a poll message. The polled
callback is called before the establish callback, to match the LPN
behavior.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-03-12 16:14:58 +02:00
Jingsai Lu
c4b0064913 Bluetooth: Fix a comment typo for bt_l2cap_server.sec_level in l2cap.h
Change "minimim" to "minimum" for for bt_l2cap_server.sec_level comments

Signed-off-by: Jingsai Lu <jingsai.lu@oss.nxp.com>
2021-03-11 08:59:02 -05:00
Emil Gydesen
d48b040a78 Bluetooth: Host: Updated ISO SCA description
The SCA (sca) field of bt_iso_chan_qos did not give much
information about the expected values or what they meant,
nor any information about what the value perhaps should be.

Updated the description and the ISO shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-03-11 06:38:08 -05:00
Peter Bigot
81b9ba3a9b bluetooth: mesh: health_srv: update k_work API
Switch to new work API.  Avoid a racy cancel by allowing the work
handler to deal with an immediate off when the time remaining changes
to zero.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-03-10 15:18:10 +02:00
Emil Gydesen
a264efbcbc Bluetooth: host: Initial support for BIS
Added initial support for BIS (broadcast ISO stream), which
adds support for creating BISes as both broadcaster and receiver,
as well as managing and creating BIGs.

Extends PA sync to handle BIGInfo adveritising reports.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-03-09 08:06:02 -05:00
Asbjørn Sæbø
66f699b8ea Bluetooth: Audio: Add maintainers/codeowners
Add Thalley (emil.gydesen@nordicsemi.no) and asbjornsabo
(asbjorn.sabo@nordicsemi.no) as additional maintainers/codeowners for
bluetooth audio.

(Also adds empty audio.h file, that will later be expanded, so that
the include/bluetooth/audio directory now listed in CODEOWNERS
actually exists.)

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2021-03-04 18:00:35 -05:00
Lingao Meng
71fd8e1d01 Bluetooth: Mesh: Add CDB handle key refresh phase
Fixed some undesired or incorrect macros, which
can cause build error.

This is a resubmission of PR (#30086)

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-03-04 14:10:56 +02:00