This was originally added as a work-around to avoid the heavy stack
consumption of the TinyCrypt PRNG when generating NRPAs. This is
no-longer an issue, and there are in fact no (in-tree) users of this.
Remove it before it gains any wider users, since it was in many ways a
hack/work-around to begin with.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In some cases the app may want to force using the identity address
regardless of privacy support or what type of advertising is done.
Provide such an option in bt_le_adv_param.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
With upcoming ICs that are not in the nRF5x family, rename the flash
driver and all its dependencies from nrf5 to nrf.
Should also fix the issue introduced by f49150cab6 which broke the
assignment of the flash device due to a partial rename.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Upcoming Nordic ICs that share many of the peripherals and architecture
with the currently supported nRF5x ones are no longer part of the nRF5
family. In order to accomodate that, rename the SoC family from nrf5 to
nrf, so that it can contain all of the members of the wider Nordic
family.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
If the thread that sends the configuration messages has low priority
and is sending to the local node (a common use case currently) it's
possible that the response arrives before the cli->op_* state
variables are set, resulting in the message never getting properly
processed and the client API call timing out.
Split the initialization into a separete cli_prepare() call and add a
cli_reset() to clean up the variables in case of premature completion
of the client operation (e.g. due to message sending failure).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
It's not always guaranteed that param->status will be non-NULL,
especially not after a subsequent patch to fix a race condition with
the response waiting.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
After porting the rand driver to drivers/entropy, replace the usage of
the old, Buetooth-specific driver with the generic entropy one.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
With the introduce of VFS the typedef for fs_file_t & fs_dir_t don't
exist anymore so we need to use 'struct fs_dir_t' or 'struct fs_file_t'.
Fix up some places that got missed in the VFS conversion.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
When using the LE Create Connection Cancel command, the controller is
supposed to return a Command Complete first and then an LE Connection
Complete Event after. Since the Link Layer does not generate an event in
this case emulate the behavior in the HCI layer instead.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When reconnecting the code will attempt to recover the subscriptions
but it was not setting any callback causing the bt_att_req.func to be
NULL.
Fixes#5982
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This check is needed to not send command that is not supported
by controller. LE Set Privacy Mode command was introduced in
Bluetooth 5.0 so that it will fail on older controllers.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes intercompatibility issues with controllers supporting
privacy feature.
Core Spec requires to use network privacy mode as a default when
peer device provides its IRK during bonding when LL Privacy is used,
which is the case for Zephyr. We've seen devices including PTS
which exchanges it's IRK but is not aware about network privacy
mode. This results in Zephyr not able do be reconnect to such bonded
devices.
This workaround sets device privacy mode to be able to reconnect
to such devices.
Fixes#4989Fixes#5486
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The Linux Foundation has been assigned a Company Identifier, and with it
a means of identifying Zephyr over the air. Default to the LF Company
Identifier, which can be overridden by silicon vendors.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fixed the controller implementation for the missing advDelay
for connectable directed advertising events used in a low
duty cycle mode.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In order to address anomalies 102, 106 and 107 in nRF52, add a generic
hal_radio_reset() that does additional processing when required by a
particular IC or IC family. Implement the fix for the nRF52.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
As per TSE 10009 the TS will enforce that a Friend ever only uses a
single transmission when sending packets to an LPN. Make sure that our
implementation follows this.
https://www.bluetooth.org/tse/errata_view.cfm?errata_id=10009
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use RADIO_TIES_US to define minimum inter event space
between concurrent master and slave roles below which it
will be detected as a probable drift towards each other
leading to them overlapping on each other.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added missing HCI Supported Commands bit fields for PHY
Update feature. Also, refactored with missing conditional
compilation for other bit fields.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Revert incorrect calculation introduced in
commit ec5a787da2 ("Bluetooth: controller: Fix multiple
master role event scheduling") and revert a related
incorrect fix in commit a02606cbf9 ("Bluetooth:
controller: Fix missing ticks to us conversion").
Fixes the controller assert in ctrl.c line number 1477. A
64-bit arithmetic took ~35 us in Radio ISR for nRF51 causing
the ISR to take too much time before packet buffer could be
set.
Also, fixed master scheduling by correctly accounting for
the jitter between each master event.
Relates to: #5486
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect calculation of unreserved timespace which
should take into account the ticks_slot of current event,
and compensation for any reduced prepare in the current
event as well as in the next event.
This regression relates to the commit ad7c9d3d76
("Bluetooth: controller: Improved continuous scanning")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Define a macro HAL_TIMER_SIGN_BIT to correspond to the most
significant bit support by counter hardware used by ticker.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use XON_BITMASK define instead of raw BIT(31) or bit shift
operations in code to represent use of reduced prepared by
an event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If there's no more room to store new pairings, send a proper error
instead of letting the SMP timeout expire.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This makes things slightly cleaner, and we don't need to rely on the
deprecated net_buf_simple_init() API (which was a bit hackish for
these custom-constructed net_buf_simple objects anyway).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This fixes the issue when after incomplete timer expiration
host sent ACK.
The host failed in two cases:
1. Sending ACK right after the incomplete timer expiration;
2. Sending ACK from new RX context. Now, seq_auth of cancelled
message is not cleaned on RX reset, so segments of cancelled message
will be discarded when resend.
According to the Mesh Profile v1.0
"When the incomplete timer expires, the lower transport layer
shall consider that the message being received has failed and
cancel the acknowledgment timer. Any segment of a canceled
message shall be ignored."
Fixes#6023
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
In the case of an unexpected PDU we need to send the right response.
This was already taken care of for PB-ADV, but not for PB-GATT.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Provisioner might have missed our earlier Link Acknowledgement, so
if we receive another one with matching Link ID and link.expect state,
simply send another acknowledgement.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When sending a segmented message, the state could get stuck if the
advertising bearer fails in transmitting and we don't detect that it
happened. Add a send_start callback for all packets so we can always
know if sending fails.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When both PB-ADV and PB-GATT are enabled, the PB-ADV code (prov.c)
uses the bt_mesh_proxy_get_buf() API to get a net_buf_simple buffer.
Unfortunately this function also suffers from the same issue that was
fixed by commit 2b273444c1.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The conversion to the new net_buf_simple API was done incorrectly
here. The buffer initialization should use net_buf_simple_init()
instead of net_buf_simple_reset(), so that buf->__buf gets properly
initialized (and not left pointing at NULL).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There's a risk of a deadlock if we use the same pool for ACL fragments
as we use for general ACL TX buffers: all TX buffers are queued up,
and we try to segment one of them, a segment buffer will never become
available. To work around this risk, introduce a dedicated fragment
pool.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Refactor ticker execution context dependency out into HAL
folder. This decouples ticker from mayfly, enabling porting
towards a more tasklet (if and when kernel gets the support)
style execution contexts type implementation support.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Convert the mesh code to use the new net_buf_siple APIs. This has the
benefit of saving 4 bytes off the stack due to the not needed pointer.
Also update the publication context helpers to map to the new
net_buf_simple API in an intuitive way.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Application should normally declare a bt_uuid with proper type and then
use bt_uuid_cmp.
Fixes#5162
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
New advertising started while scanning is already enabled
would delay the first advertisement event until the end of
the current overlapping scan window in the Zephyr native BLE
controller implementation. Hence, consider this scan window
duration when calculating the advertising stop.
Relates to: #6083
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix, add the missing code for the removal of any accumulated
soft latencies or negative drift ticks when scheduling next
interval expiry with added laziness.
Typically a first interval would accumulate soft latencies
and this has to be removed if the interval is rescheduled
with any added laziness (scheduled to the next soft real
time interval).
Example, scan windows block any new scheduling until the end
of the window, adding latencies to any soft real time ticker
expiry which should try to execute as early as possible after
the scan window.
Fixes: #6083
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor BT_CTLR_ADV_INDICATION feature by moving the
implementation closer to the implementation that is closing
the advertisement event so that in the future new members
can be added as necessary (example, advertised channels).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
No one was setting this to any other value than its default, which
happens to be the same as BT_BUF_USER_DATA_MIN.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The HCI command buffers are the only ones with more than 4 bytes of
required user data. Move the user data into a separate array and do
the mapping with the help of net_buf_id(). After this, it will be
possible to reduce the default net_buf user data size from 8 to 4.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix incorrect radio timing for Tx chain delay for S2 and S8
coding. Regression introduced in commit 55d3ce111c
("Bluetooth: controller: Refactoring nRF5 radio driver").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>