Commit graph

9523 commits

Author SHA1 Message Date
Pavel Vasilyev
91c87fdc7d Bluetooth: Mesh: Fix publication period measurement
Period measurement should be started right after a message is updated.
That is because `struct bt_mesh_send_cb.start` callback is called from
the advertiser thread which is not necessary to be scheduled immeditely
and a user may see some delays between update handler calls.

The publication timer still needs to be scheduled after a message being
actually sent out to the air so that access layer doesn't overflow the
advertiser's buffer. To achieve some specific use cases, where a
published message needs to be retransmitted with 50ms interval, a user
has to switch off network retransmissions to make the legacy advertiser
sleep for the shortest possible time.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-12-23 14:57:54 +01:00
Piotr Pryga
49f0aba94c Bluetooth: Controller: Fix wrong variable passed to isr_done
Wrong variable was passed when isr_done was registered. It lead to
memory faults and exceptions. It should be a pointer to lll_adv_sync
instance instead of lll_adv.

The commit fixes the issue.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-12-23 11:20:00 +01:00
Vinayak Kariappa Chettimada
0b47645cd7 Bluetooth: Controller: Fix Periodic Advertising Sync aux context leak
Fix Periodic Advertising Synchronization Auxiliary context
leak when failing to receive chain PDUs.
Auxiliary context has not being associated with sync context
when ULL scheduling was used.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-22 16:55:17 +01:00
Vinayak Kariappa Chettimada
6c8ff338b8 Bluetooth: Controller: Remove redundant extra list release
Periodic Advertising Synchronization Reports do not use a
list for the received chain PDUs, remove the stale code that
free extra list.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-22 16:55:17 +01:00
Vinayak Kariappa Chettimada
079e7976fe Bluetooth: Controller: Fix erroneous merge conflict resolution
Fix erroneous merge conflict resolution.

Regression in commit f023b5f611 ("Bluetooth: controller:
push topic branch to main") and
commit 2e2900f1bb ("Bluetooth: controller: revert
erroneous deletion").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-22 16:53:37 +01:00
Vinayak Kariappa Chettimada
bf2bb51035 Bluetooth: Controller: Fix Periodic Adv Sync to private address
Fix Periodic Advertising Synchronization to private address
when public and static identity address is supplied as peer
device address to synchronize to.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-22 16:53:30 +01:00
Vinayak Kariappa Chettimada
5d42bf5a70 Bluetooth: Controller: Fix Extended AD data and Scan Rsp total len type
Fix Extended Advertising Report's AD data and Scan Response
total data length type to use uint16_t.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-22 16:51:35 +01:00
Vinayak Kariappa Chettimada
fd9c89d8d0 Bluetooth: Controller: Fix HCI fragment of Extended Advertising Report
Fix HCI fragment of Extended Advertising Report when chain
PDUs are received. Implementation was missing HCI event
generation for last frag of each PDU when there was a next
chain PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-22 16:51:35 +01:00
Vinayak Kariappa Chettimada
7b78c4e534 Bluetooth: Controller: Fix Extended Scan Response Secondary PHY value
Fix Extended Scan Response report Secondary PHY value to use
AUX_ADV_IND PHY.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-22 16:51:00 +01:00
Vinayak Kariappa Chettimada
ac3f12f9b3 Bluetooth: Controller: Fix Periodic Adv EVENT_OVERHEAD_START_US jitter
As EVENT_OVERHEAD_START_US offset is used in ticks unit in
LLL, ULL scheduling using ticker should also use ticks unit
for EVENT_OVERHEAD_START_US when reducing the first Periodic
Advertising event preparation.

Relates to commit 858dc7fab4 ("Bluetooth: controller: Fix
EVENT_OVERHEAD_START_US jitter").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-22 16:50:15 +01:00
Vinayak Kariappa Chettimada
0813d09df9 Bluetooth: Controller: Fix undefined reference in FEM support
Fix undefined reference to radio start time in FEM support
in ISO Synchronized Receiver implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-22 13:30:27 +01:00
Vinayak Kariappa Chettimada
519a4a36c6 Bluetooth: Controller: Fix ISO Data payload number for BIS payloads
In the ISO Data the payload number shall be the value of
bisPayloadCounter for the PDU containing that payload.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-22 13:30:07 +01:00
Piotr Pryga
aa3090dd7d Bluetooth: controller: lll: add TX configuration of CTE in conn mode
Add configuration of transmission of CTE in connected mode.
The transmission is enabled only for PDUs that have CTE present (CP)
bit set to 1.
Radio peripheral is configued by df_cte_tx_configure to transmit CTE.
The same parameters are set for connected and connectionless mode.
The function was changed to re-use the same code for configuration
of CTE in both modes.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-12-22 12:18:17 +01:00
Piotr Pryga
1dcbe73cc8 Bluetooth: controller: radio: add setting of S1 byte in radio packet
To transmit CTE with data channel packet the CTE configuration must
be stored in S1 field, that is placed just after length field.

The commit changes radio_pkt_configure function to allow configuration
of S1 field. When S1 field is used to store information about CTE
then its length is 8 bits. The content of the field is filled with
CTEInfo data. The same as the one used in periodic advertising.

The signature of the radio_pkt_configure function was not changed.
There were not used bits in flags parameter of the function.
From now on, bit 3 of the flags parameter will be used to store
information whether CTE will be added to the packet.

Besides that changed, the commit provides set of macros that
help in preparation and validation of the flags parameter content.
Macros provide information about bits that are currently used.
Ther are also macros that help to retrieve particular information
stored in the flags parameter.

Every place of code where the radio_pkt_configure function occurs
was changed to use provided macros.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-12-22 12:18:17 +01:00
Piotr Pryga
1ff9baf010 Bluetooth: controller: complete DF TX params set in conn mode
HCI_LE_Set_Connection_CTE_Transmit_Parameters host command was
not completely implemented in controller. There were missign
storage of TX parameters in ll_conn instance.

The commit adds missing part of the command handling.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-12-22 12:18:17 +01:00
Piotr Pryga
f650fd99e0 Bluetooth: controller: Add CTE present bit to pdu_data
If the CTE is attached to data channel packet, the packet must
include information about CTE. The information is stored in
CTEInfo structure that is available in S1 byte of a packet.
Radio checks if the S1 byte is present by verification of
CTE present (CP) bit in byte S0.

The commit add these data to pdu_data structure declaration.
That allows to prepare packet before it is parsed and send
by Radio peripheral.
Besides that there added a new function ull_pdu_data_init that
initlializes fields in pdu_data object that are read only by
lower link layer. CP bit in S0 byte and content of S1 bytes
are examples of such fields.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-12-22 12:18:17 +01:00
Piotr Pryga
ef24a141fb Bluetooth: controller: radio: add fun to switch to RX after PHYEND evt
When PDU has CTE added to the end, the PHYEND event must be used
to correclty switch between TX and RX. END event is triggered just
before start of CTE.
The commit adds new function that configures radio to disable after
PHYEND is generated and then swtich to RX.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-12-22 12:18:17 +01:00
Jacob Siverskog
3114726356 bluetooth: fix callback name
there has never been a remote_version_available callback.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2021-12-21 18:19:24 +01:00
Jacob Siverskog
d3c0692e04 bluetooth: correct kconfig help
bt_conn_get_remote_info contains version fields.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2021-12-21 18:19:24 +01:00
Jacob Siverskog
b9583ddcdc bluetooth: remove duplicate kconfig entry
this entry is already defined in subsys/bluetooth/Kconfig. let's keep
that one since it's used by the controller as well.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2021-12-21 18:19:24 +01:00
Henrik Brix Andersen
682f261c95 Revert "Bluetooth: Mesh: Fix publication period measurement"
This reverts commit 1f9c606f95.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-12-21 07:46:26 +01:00
Lingao Meng
ba3b7cc610 Bluetooth: Mesh: Replace net_buf with mem_slabs
Use memslabs for loopback, for save some ram footprint.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-12-20 17:43:06 +01:00
Bernhard Wimmer
51a89e161f Bluetooth: Reassemble periodic advertising reports
Adds a buffer to the host to reassemble potentially fragmented
periodic advertising reports.
The buffer size is configurable through BT_PER_ADV_SYNC_BUF_SIZE.
Reports that cannot be reassembled because there is no buffer or because
the buffer is full will be dropped.

Signed-off-by: Bernhard Wimmer <bernhard.wimmer@nordicsemi.no>
2021-12-20 18:42:44 +02:00
Pavel Vasilyev
1f9c606f95 Bluetooth: Mesh: Fix publication period measurement
Period measurement should be started right after a message is updated.
That is because `struct bt_mesh_send_cb.start` callback is called from
the advertiser thread which is not necessary to be scheduled immeditely
and a user may see some delays between update handler calls.

The publication timer still needs to be scheduled after a message being
actually sent out to the air so that access layer doesn't overflow the
advertiser's buffer. To achieve some specific use cases, where a
published message needs to be retransmitted with 50ms interval, a user
has to switch off network retransmissions to make the legacy advertiser
sleep for the shortest possible time.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-12-20 17:42:24 +01:00
Michał Narajowski
58b47ad091 Bluetooth: Mesh: Update Health Client API use
Unack API is now separate from Ack.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-12-16 10:15:36 +01:00
Michał Narajowski
ef1fcd0e82 Bluetooth: Mesh: Fix Config/Health Client async API
The previous PR was not fully baked, so this PR fixes issues by:
- Adding checks when dereferncing pointers stored in params.
- Clearing ack context if a return argument is NULL to not block and
wait for response.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-12-16 10:15:36 +01:00
Asbjørn Sæbø
9d71af1e15 Bluetooth: Audio: Media control - set L2CAP buffers
Set the number of L2CAP TX buffers suffiently high if MCS (media
control) is enabled.

Add BUILD_ASSERT if number is too low.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2021-12-15 14:59:55 -05:00
YanBiao Hao
5b7e823ebd Bluetooth: Mesh: check cfg cli status param
check cfg cli status param befor use

while the status returns

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2021-12-13 20:37:12 -05:00
Marek Pieta
32580c2b06 Bluetooth: host: Enable CONFIG_BT_SETTINGS_CCC_STORE_ON_WRITE
Storing CCC right after it's written reduces risk of inconsistency
of CCC values between bonded peers. The option should be enabled by
default. The developer could explicitly disable it to reduce memory
usage. After disabling the option explicitly, the developer is
aware of related potential issues.

Fixes: #40758

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2021-12-13 20:30:52 -05:00
Casper Bonde
c6d7a6648e Bluetooth: Fix build error for printing LTK
CONFIG_BT_LOG_SNIFFER_INFO allows print of LTK for debugging.
If CONFIG_BT_SMP_SC_PAIR_ONLY is set a non-existing struct
entry was printes, which caused a compile-time error.

Signed-off-by: Casper Bonde <casper_bonde@bose.com>
2021-12-13 17:21:24 -05:00
Carles Cufi
6b46ea3d65 Bluetooth: controller: Fix access to members of packed structs
Fix all instances in the controller of -Waddress-of-packed-member by
casting through an intermediate variable and verifying the alignment
with an assertion.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-10 14:08:59 +01:00
Piotr Pryga
a26ee7ce73 Bluetooth: host: Add IQ reports handing in DF connecte mode
Add reception of IQ sample report from controller.
Add applications notification about received reports.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-12-09 19:44:15 -05:00
Piotr Pryga
f18637fe30 Bluetooh: host: Add CTE RX and sample enable for conn mode
Add enable of CTE reception and sampling in connected mode.

The implementation allows an application to decide what type
of CTE is expected to be reported. Bluetooth Core specification
does not provide such functionality, so it is provided as part
of host implementation. Host will filter out all reports for not
enabled CTE types.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-12-09 19:44:15 -05:00
Emil Gydesen
815dd27d8c Bluetooth: buf: Update BT_BUF_RX_SIZE with ISO
The BT_BUF_RX_SIZE did not take the CONFIG_BT_ISO_RX_MTU
into account. Add BT_BUF_ISO_RX_SIZE which
depend on CONFIG_BT_ISO and use that for the
BT_BUF_RX_SIZE macro.

Furthermore, move the BT_BUF_RX_COUNT macro definitions
into buf.h and update that to account for ISO RX as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-12-09 12:38:12 -05:00
YanBiao Hao
332ca93c15 bluetooth: mesh: check hb_pub_status param
check hb_pub_status param befor user

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2021-12-09 11:11:24 -06:00
YanBiao Hao
bb8fda2654 bluetooth: mesh : fix relay get param check
check relay get param before use, check
relay status param before use

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2021-12-09 11:10:34 -06:00
YanBiao Hao
46952106e2 Bluetooth: Mesh: check hb-sub-status param
check hb-sub-status param before use

Signed-off-by: YanBiao Hao <haoyanbiao@xiaomi.com>
2021-12-09 11:09:34 -06:00
Andreas Rudolf
92fbd7da14 Bluetooth: shell: Register callbacks dynamically
Bluetooth callbacks are now registered dynamically again. When Bluetooth
callbacks were registered statically, they could be invoked before the
Bluetooth shell (ctx_shell) is initialized. The callbacks try to
shell_print(ctx_shell, ...), which results in a fatal error if ctx_shell
is undefined.

Fixes #40881.

Signed-off-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>
2021-12-09 15:01:16 +01:00
Michał Narajowski
ab063acf04 Bluetooth: Mesh: Fix Composition Data Status
Page field was pulled twice resulting in malformed composition data.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-12-08 09:09:02 -05:00
Emil Gydesen
8251a65575 Bluetooth: Conn: Guard tx_complete_work with CONFIG_BT_CONN_TX
Add new Kconfig BT_CONN_TX which is true if the ACL and
ISO configuration allows for sending data. This is mainly
used to avoid initialization of the tx_complete_work
for ISO sync receiver only builds.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-12-08 08:54:48 -05:00
Emil Gydesen
ad69de6e8c Bluetooth: conn: Fix tx on iso broadcaster only builds
If CONFIG_BT_ISO_BROADCASTER=y and CONFIG_BT_CONN=n, i.e
an ISO broadcaster only build, then the handling of the
TX callback was not properly initialized, causes a fatal
issue when sending.

This commit moves the tx_complete_work out from the ACL group
and into the common area, so that it will be enabled
for connected ISO as well as broadcaster ISO.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-12-08 08:54:48 -05:00
Asbjørn Sæbø
b7f8365a57 Bluetooth: Audio: Bugfix: Fix output message
Correct ouput message in media shell track change notification
callback.
No functional change.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2021-12-07 09:42:00 -06:00
Vinayak Kariappa Chettimada
f6fd4444b6 Bluetooth: Controller: Use a common ISO_PDU node rx type
Refactor implementation to use a single common ISO PDU
node rx type for ISO Synchronized Receiver.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-06 09:17:44 -05:00
Morten Priess
2d781ddfb2 Bluetooth: controller: ISO-AL CIS RX framed and ISO bugfixes
Adds reassembly of framed PDUs to ISO adaptation layer.
Reference times are also computed based on anchor points,
transmission latency components and a PDU specific time offset.

Some partial preparations for ISO broadcast can be found for
convenience. This needs to be properly merged, and currently will not
work with both CONFIG_BT_CTLR_CONN_ISO and CONFIG_BT_CTLR_SYNC_ISO
enabled.

Includes fixes and improvements for unframed mode.

Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-12-06 09:17:44 -05:00
Vinayak Kariappa Chettimada
45c24454a0 Bluetooth: Fix Periodic Advertising Receive Enable
Fix state flags set on Periodic Advertising Receive Enable
API call.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-06 08:12:45 -05:00
Marek Pieta
8b880f781a Bluetooth: host: Wait for callback before clearing SC data
The GATT Server should wait with clearing Service Changed
indication configuration data until the response callback is
called. Otherwise the indication may not be properly delivered
to a given GATT Client.

Fixes: #40761

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2021-12-06 08:08:46 -05:00
Michał Narajowski
7002b64e35 Bluetooth: Mesh: Refactor Configuration Client into async API
- Do not ignore unsolicited status messages to allow for the API to be
- used asynchronously

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-12-06 08:04:02 -05:00
Michał Narajowski
4c30895a1a Bluetooth: Mesh: Refactor Health Client into async API
- Add optional callback to receive status messages even when using async
  API
- Split acked and unacked API

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-12-06 08:04:02 -05:00
Emil Gydesen
4b822395ed Bluetooth: Audio: Add check conn in VCS client notify handler
As per the GATT documenation, the conn pointer may actually
be NULL in the notify callback, indicating that the connection
is being unpaired.

Add a check for conn == NULL to avoid calling bt_conn_index
on a NULL pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-12-03 17:40:21 +02:00
Marek Pieta
0a1f553dc2 Bluetooth: host: Remove CCC update from GATT connected callback
The CCC update should be done after the connection is encrypted.
Before the connection is encrypted, the GATT Server does not know
if the reconnecting peer was actually bonded.

Fixes: #40759

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2021-12-02 10:54:22 +01:00