When compiling a sample like a beacon, none of the `if defined()`
statements in the switch case are actually compiled in, so the compiler
complains of an orphan mem_release();break; sequence.
Add a type that we know will always be compiled in in order to avoid
this issue.
Relates to commit 76bfea7cf9 ("Bluetooth: controller: Ensure that a
`case` statement is present").
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This makes the identity initialization consistent and actually catches
a few branches where it may not have properly happened.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Make it possible to initiate new connections from within the
disconnect callback. This wasn't completely trivial since there was
connection cleanup done through deferred action using the CONN_CLEANUP
flag.
This patch moves the disconnected callbacks to be run after all
cleanup is done. We can't directly do this in the TX thread, since
that's internal, so we instead take advantage of the deferred work
support and do it using the update_work callback. Since the same
cleanup is needed also for BR/EDR connections the work definition is
moved from the LE-specific struct to the generic struct bt_conn.
A valid bt_conn object in disconnected state is a likely indication of
a connection reference leak, so there's a new BT_WARN() for this case
in bt_conn_create_le().
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Adds additional model callback that gets called on node_reset. Will also
erase any user data when this happens.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Adds user data file in the model settings, allowing each model instance
to store some application specific data without having to reinvent the
settings path encoding for model element/ID combinations. Exposes the
settings_handler interface in the model callback structure and adds a
data store function.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Adds a structure of callbacks for each model instance. This allows for
more flexible model implementations, that can interact with the Mesh
stack without going through the application.
For now, only an init callback is added, replacing the init mechanism in
the foundation models. The init callback does not provide the primary
flag that used to be in the foundation model callbacks, but replaces
this with an inline function in access.h.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When both central and peripheral are supported, one each Rx
node will be needed by connectable advertising and the
initiator to generate connection complete, hence
conditionally set the count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor to abstract the use of software interrupts in nRF5
Series.
Also, reduce the number of SWI used when interrupt priority
level configured is same for ULL High and ULL Low contexts.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit completes the refactoring of radio.c, so it
calls abstract functions for PPI handling for LE Coded
PHY (e.g. enable, disable channels, or configure endpoints),
which, then, call the platform-specific functions for PPI
handling. The abstract functions are simple wrappers,
implemented in radio_nrf5_ppi.h, conditionally, if we
build the controller with support for LE Coded PHY.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Make the definitions of LE Coded PHY-specific macros
and inline functions conditional, i.e. only if we
actually build the controller with support for LE
Coded PHY.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit refactors radio.c, so it calls abstract functions
for PPI handling (e.g. enable, disable channels, or configure
endpoints), which, then, call the platform-specific functions
for PPI handling. The abstract functions are simple wrappers,
implemented in radio_nrf5_ppi.h.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit defines generic macros for the software interrupt
(SWI) IRQ lines that are used for LLL and ULL LOW interrupts.
This is done for both the cases of the legacy and new (split)
controller architectures. In addition, it abstracts some of
the functionality around software-IRQ signals, to generic
functions, which have platform-specific implementations.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Stores friend queue packets unencrypted, removing any out-of-order
issues caused by seqnum allocation. Also moves as much of the metadata
storage as possible into the packet, allowing us to free up some bytes
of net_buf user data for friend packets.
Fixes#18488
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Makes a define for the seqzero 13-bit mask in transport, and exposes it
in the header for use in the friend module.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Convert how we get the various chosen properties like "zephyr,console"
to use the new kconfig functions like dt_chosen_to_label.
Because of how kconfig parses things we define a set of variables of the
form DT_CHOSEN_Z_<PROP> since comma's are parsed as field seperators in
macros.
This conversion allows us to remove code in gen_defines.py for the
following chosen properties:
zephyr,console
zephyr,shell-uart
zephyr,bt-uart
zephyr,uart-pipe
zephyr,bt-mon-uart
zephyr,uart-mcumgr
zephyr,bt-c2h-uart
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Changed documentation in Bluetooth Controller
Kconfig for BT_CTLR_ASSERT_HANDLER
Signed-off-by: Kristoffer Rist Skøien <kristoffer.skoien@nordicsemi.no>
Host shall ignore the unknown ATT PDU that has Command Flag set.
Fixes regression introduced in 3b271b8455.
Fixes: GATT/SR/UNS/BI-02-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit adds an explicit inclusion of toolchain.h from pdu.h.
The endianness preprocessor definitions (__BYTE_ORDER__,
__ORDER_LITTLE_ENDIAN__, __ORDER_BIG_ENDIAN__) are used by pdu.h;
these being not defined can easily go unnoticed and cause unexpected
behaviours, as detailed in PR #18922.
toolchain.h ensures that these preprocessor definitions are defined and
*must* be included in a file that uses these definitions.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
The bt_mesh_fixed_group_match() function is intended to match the
various well-known group addresses, however it was never updated when
Proxy support was added.
Fixes#19015
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
As element addresses are sequential, there's no need for iterating
through the elements to find the one matching a unicast address.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Added ll_rx_link_inc_quota to allow vendor to manipulate
mem_link_rx.quota_pdu when cleaning up nodes via ull_vendor.h.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix a bug where in tx data PDU enqueued, while a ctrl PDU is
deferred due to Encryption setup being in progress, is
leaked causing HCI Tx Buffer Overflow crash.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix check in start encryption to disallow new encryption
setup while there is one already in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix MIC failure on re-encryption procedure when responding
at the same time to peer initiated feature request.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix control tx queue handling to correctly pause control PDU
responses during encryption setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to cache Data Length Procedure when
another control procedure is in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Workaround, defer peer initiated encryption while local
initiated procedure with instant is not complete. Peer
master has sent CONN_UPDATE_IND in response to
CONN_PARAM_REQ, and also has initiated a Encryption Setup
thereafter. In this case, avoid corruption of the connection
update context by deferring the Encryption Setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to correctly cache the control procedures
initiatable by local and peer. And, fix feature exchange and
version information procedures from being disallowed by
having then as cached requests to the controller.
Relates to #15256.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add iterator function to iterate over all connection objects.
Make type a bitmap so that it can be used as a bitmask to select which
conns to receive foreach callback.
Use foreach function internally where possible.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allows the user to pass a provisioning input complete callback to the
provisioning module, letting the application stop displaying its output
OOB value when the other party finishes their OOB input.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Made BT_HCI_TX_STACK_SIZE configurable and added BT_HCI_ECC_STACK_SIZE.
These changes are necessary to allow vendors to adjust for other
achitectures.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Rework the BT_ASSERT infrastructure with the following changes:
- Transition from LOG() macros to printk()
- Allow the BT_ASSERT() macro to map directly to stancard __ASSERT()
- Allow printing of the assert reason to be disabled
- Switch from k_oops() to k_panic() configurable
There are 2 reasons for using printk() instead of LOG():
- BT_ERR uses deferred logging by default, which is problematic with
ASSERTs
- The __ASSERT() macro in Zephyr uses printk()
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix issue when checking if SMP pairing procedure is allowed to use the
SMP debug keys. This check did not consider the case where the keys
pointer was assigned, but did not contain a valid LTK key.
This resulted in being unable to pair with debug keys without an
existing bond.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix shell build dependencies, subsys/bluetooth/controller is only added
for CONFIG_BT_LL_SW_SPLIT or CONFIG_BT_LL_SW_LEGACY.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The return code of set_random_address is not always handled. This could
lead to connection using the wrong Identity address.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
nrf_timer.h and nrf_ppi.h are included by including
radio_nrf5.h, so we do not need to include them in
radio.c.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Remove incorrect LL_ASSERT check in Lower Link Layer that
checked for invalid connection handle on reception of PDU.
The assert is not needed as PDUs can be received until the
Upper Link Layer is aware of the acknowledgement of the
terminate ind PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add workaround for advertising data issue in the internal bluetooth
controller. The advertising data must be set after advertising
parameters in order to successfully update the advertising data after
an directed advertiser has been active.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix handling of Rx-ed PDU on termination, do not process
Rx-ed control PDUs and release the PDU buffer back to the
free pool.
Without this fix, Rx-ed control PDU was responded with a
Tx PDU, which did not get acknowledged or released.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Endianness bug fix in bt_uuid_create function.
Replaced bt_uuid_create_le with bt_uuid_create which
handles both UUID from air and internal varaiable.
Fixed bug with endianess in case of big endian targets.
Signed-off-by: Akshatha Harishchandra <akhr@oticon.com>
When an opcode doesn't have a handle that doesn't mean it is unknown
just that it will not be handle as it could have been disabled.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
SMP shall be considered internal TX notify callbacks so they are
allowed to be run from TX thread context like the others.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When CONFIG_BT_GATT_CLIENT is not set att_op_get_type would return
unkown operation instead of properly return the opcode.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Since bt_l2cap_create_pdu can return NULL when used under syswq context
the code should always check its result, this also changes the timeout
to have a specific value (RTX maximum timeout) so signalling PDUs still
wait for a buffer to become available.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>