Remove is_enabled flag in LLL of BIS events context, as the
status returned from ticker_stop interface is sufficient to
determine if the Broadcast ISO Sync was established or not.
HCI Command Disallow as reason is to be returned if sync was
not established or sync was loss prior to call of HCI LE
BIG Terminate Command was called.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move lll_sync_iso.h as common to all vendors, as currently
there is nothing that is vendor specific.
Fixes#31044.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Leftover from old renaming commits. This function is not private and
should not start with underscore.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
When there are more timing_stop() calls then timing_start(),
the reference counter will go negative, resulting in the next
timing_start() call not starting the timer. Without timer
running, getting cycles elasped would not work. So fix
the ref counting so it won't dip below zero.
Fixes#30397
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If there are multiple interfaces a change to the timeout for one
cannot determine the correct delay until the next timeout event. That
can be determined only by checking for the next event over all
interfaces, which is exactly what's done by the timeout worker.
Refactor interface timeout configuration to just set the start time
and request time, and trigger the worker to calculate the next
scheduled event.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
When a renewal occurs the client enters RENEWING, sends a request,
then sets a short timeout (about 4 s) for the response. In the common
case the response will arrive immediately, which will trigger an
attempt to reset the timer with T1 which is generally large.
However the check for updating the timer performs the update only if
the new deadline is closer than the currently set one. Thus the timer
fires at the time the RENEWING request would have been retransmitted,
and only then updates to the correct deadline (T1) for the current
machine state.
Remove the extra timeout by unconditionally setting the timeout to the
new value.
This works when there is one interface; it could be wrong if there
were multiple interfaces one of which had a closer deadline, but
multiple interfaces are mishandled anyway and will be fixed next.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
When there is only a single interface the timeout infrastructure can
correctly calculate time to next event, because timeouts only occur
when an event for that interface is due. This is not the case when
multiple interfaces are present: the timeout is scheduled for the next
event calculated over all interfaces.
When calculating the next event for an interface where the timeout is
not due the current code returns the original absolute delay
associated with its current state, without accounting for the time
that has passed since the start time.
For example if interface A's T1 is 3600 s and is due at 3610, but at
3605 a timeout for interface B occurs, the contribution of A to the
delay to the next scheduled event would be 3600 rather than 5,
preventing the renewal from occurring at the scheduled time.
Fix this by replacing the boolean timed-out state with the number of
seconds remaining until the interface event will occur, and
propagating that through the system so the correct delay over all
interfaces can be maintained.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
If send_request() fails it would return UINT32_MAX as the next
timeout. Callers pass the returned value to update_timeout_work
without validating it. This has worked only because
update_timeout_work will not set a timeout if an existing timeout
would fire earlier, and the way the state is currently structured it
is likely there will be an existing timeout. However, if work thread
retransmission from REQUESTING failed the timer would not be
rescheduled, causing the state machine to stop.
A more clean solution, which matches the behavior of send_discover(),
is to return the timeout for the next transmission even in the case
when the send fails. The observed behavior is the same as if the
network, rather than the sender, failed to transport the request.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
A variable named "timeout" is used to represent the current time in
comparisons against timeouts calculated from a start time and an
interval. Since this current time is not the timeout change its name
to "now" to reduce maintainer confusion.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
If assertions are disabled the send operation would continue on to
transmit a message. Stop it from doing so.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The flag value UINT32_MAX is returned from manage_timers() when a send
operation did not succeed. This indicates that the timeout should not
be rescheduled, but because it will never replace the starting update
value UINT32_MAX-1 the check will never pass, and in cases where it
should work will be submitted to run at UINT32_MAX-1 seconds.
Fix the upper bound.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
When a connection is lost the client will first attempt to renew, and
then to rebind, and finally to select. Options like gateway may have
been provided by the original connection, but not the new connection,
resulting in an inconsistent configuration for the new network.
Remove the partial state clearing when entering INIT, and expand the
state cleared when entering SELECTING to be more comprehensive.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The start time is negative only if the interface came up in the the
first milliscond since startup; even then changing the sign of the
start is not appropriate. Presumably a left-over from signed 32-bit
timestamps.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
It is documented that using transient information like whether a work
item is pending or a delayed work item has time left to determine the
state of the work item before subsequent reconfiguration is prone to
race conditions, and known to produce unexpected behavior in the
presence of preemptive threads, SMP, or use of the work item from
interrupts. As a best practice such pre-validation steps should be
avoided unless algorithmically necessary.
All comparisons of remaining delayed time before canceling a delayed
work item in this module appear to be optimizations subject to the
above race conditions. Remove the checks so that only the inherent
race conditions in the implementation of canceling a work item remain.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
When using BT_GATT_AUTO_DISCOVER_CCC if the ccc_handle is not set
bt_gatt_subscribe would initiate a discovery to locate the CCC handle
but instead of awaiting it to complete the code does proceed to call
gatt_write_ccc even with ccc_handle being 0x0000 which is invalid.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Use the devicetree filesystem bindings to populate an fs_mount_t
object that is preconfigured for a particular set of file system
properties on a specified partition.
At this time the mount point data is accessed by reference using the
partition's devicetree node identifier.
Note: While a file system can register itself before its devices
are available, it cannot do the automount. In this commit the
initialization priority is increased to compensate, but that's not
a long-term solution.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Make generally available the macro that provides the flash device in
which a particular partition can be found.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
With this patch the resolver module can resolve literal IPv6
and IPv4 addresses even when DNS client is not presnet in
the system.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
Refactor the file structure for USB DFU class to facilitate
separate PID for USB DFU when in DFU mode. As required by USB DFU
1.1 Section 2, the PID in the USB device descriptor must be
different between the Run-time and DFU mode device descriptor to
avoid problems caused by the host OS caching the remaining
descriptors when switching to DFU mode, thus hiding the new
interface descriptors from applications on the host and reporting
the Run-time descriptors when the device is in DFU mode.
To avoid adding too much clutter to the root USB class Kconfig and
CMakeLists files, move the DFU class files into their own directory
with dedicated Kconfig and CMakeLists.txt.
Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
The USB device descriptors for DFU mode should only change after a
USB reset, not in appDETACH as the device is still in run-time mode
until reset; thus should still return the run-time descriptors when
requested.
Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
In accordance with USB DFU 1.1 Section 5.1, a device should only
stay in appDETACH for a given period of time, either from the
DFU_DETACH request (wValue ms) or from the wDetachTimeout property,
after which the device should return to appIDLE.
Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
We have convenient PHY_1M, PHY_2M and PHY_CODED symbols defined but
they are not used too much in the code. This replaces all usages of
magic numbers and other symbols as PHY constants with those symbols.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Adds an assert on the "old" ref counter when doing unref, that
checks if there indeed is a reference to unref. This prevents
any underflows of the ref counter.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implements the ull_sync_iso_setup function which starts the
ticker for ISO sync. Furthermore, ll_big_sync_terminate
will not stop the ticker as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implements handling of the BIG sync commands in the ULL.
LLL support and handling of ACAD (biginfo) remaining.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adjust the PPI used by nRF51x and nRF52x so that PPI 0-5 is
available for application's use or for SW PWM driver use.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Under CONFIG_BT_TICKER_EXT configuration, the ticker interface has been
extended to support enabling/disabling must-expire scheduling. This
means that conn and slave ticker start calls can now omit must-expire
default-on configuration, relying on LLL updating the mode as needed.
Signed-off-by: Morten Priess <mtpr@oticon.com>
The idle, when power management is enabled, requires system clock to
be present.
This commit adds dependency, to PM option, on SYS_CLOCK_EXISTS.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Convert drivers to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Convert drivers to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit replaces the 'select SHELL' statement with
'depends on SHELL' in OPENTHREAD_SHELL config option.
This ensures, that shell will not be implicitly enabled
when OpenThread stack is built.
Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
During recent upmerge OPENTHREAD_CONFIG_PLAT_LOG_FUNCTION__COUNT_ARGS
macro was renamed to OPENTHREAD_CONFIG_PLAT_LOG_MACRO_NAME__COUNT_ARGS
but the code wasn't updated where the macro is actually used.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Align bt_le_per_adv_sync_get_index, bt_conn_index and
bt_le_ext_adv_get_index in use of uintptr_t.
This fixes an issue where the cast to uint8_t happened before the
assert for a valid index, which could lead to invalid pointers passing
this assert.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Improve logging of pairing procedure when it fails with error code
unspecified. Since this is returned in many places debugging this
failure is not easy without adding additional debugging.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix parallel pairing procedures using LE SC requiring the DHKey
calculation at the same time. This would otherwise end all other
pairing procedures with the SMP error code "unspecified" since
the call to bt_gen_dh_key would fail.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the allowed command bitmask before sending the SMP packet. This
avoids a race-condition in case the sending of the PDU made the
current thread not ready and would not be scheduled back in time
to set the bit before receiving the next SMP packet.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Improve multiple DHKey handling by allowing the next DHKey calculation
to be started in the dhkey ready callback.
Return error code EALREADY if the provided callback is the current
callback generating the DHKey.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
We allocate nodes on receiving AUX_CONNECT_REQ, but we can only use
them if AUX_CONNECT_RSP is sent successfully. If that fails, we need
to release those nodes.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
If we allocate a node in LLL and it turns out that we don't need it
(e.g. allocated connection on AUX_CONNECT_REQ, but connection handshake
did not complete and we don't need it) we still need to send it to ULL
to be released. We can use existing NODE_RX_TYPE_DC_PDU_RELEASE node
type for this purpose, but we just need to make sure it's passed from
LLL to ULL properly.
Also, since this now does not only release DC PDUs, let's change its
name to a more generic one.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
After slave connection is created only adv instance is stopped, we also
need to stop aux separately if enabled.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Make sure phy is properly initialized to 1M when ext adv is supported
and legacy advertising instance is being enabled.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds handling for received AUX_CONNECT_REQ PDU which enables slave
connection with extended advertising.
Once AUX_CONNECT_REQ is received, standard checks are performed to
determine if we have resource to create connection, however unlike for
CONNECT_IND an rx node is temporarily kept in LLL until AUX_CONNECT_RSP
is successfully sent. This is to prevent creating a connection in case
response PDU was not sent for whatever reason.
A separate scratch buffer is created for AUX_CONNECT_RSP since default
radio scratch buffer is already used by received AUX_CONNECT_REQ.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Connection structs need to be initialized when advertising is enabled
on connectable extended advertising instance.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>