Now that bt_l2cap_send_cb can fail the buffer state needs to be save
and restored otherwise the data stored on it would be lost.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This introduces BT_L2CAP_STATUS_SHUTDOWN which is used to indicate when
a channel has been shutdown.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This offloads the processing of tx_queue to a work so the callbacks
calling resume don't start sending packets directly which can cause
stack overflow.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Drop packets received while disconnecting since they would most likely
be flushed once peer respond there is no gain in keeping them on a
queue.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This prevents disconnect request packets to not being sent due to lack
of buffers normally caused by flooding or congestion.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If NET_L2_BT is enabled we need enough acl_in_pool needs to be big
enough to contain a full IP packet since that is no longer processed by
RX thread buffer would be queued to syswq to reassemble the SDU.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When NET_L2_BT the memory pressure for fragments can be quite high
since that would be transfering IP packets which are considerable big
so this makes our frag_pool to be of the same size as NET_BUF_TX_COUNT.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This enable chaning the function and line number making it easier to
debug where a buffer allocation is blocking.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When a segment could not be allocated it should be possible to resume
sending it later once previous segments complete, the only exception is
when there is no previous activity and we are unable to alocate even the
very first segment which should indicate to the caller that it would
block since that only happens on syswq the caller might need to defer to
another thread or resubmit the work.
Fixes#20640
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add command to print all existing connections. Useful for verifying that
connections are actually released when debugging.
More information can be retrieved with `bt info <addr>` using the
address printed by this command for each connection.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add command to print all existing bonds. Useful for verifying that bonds
are actually cleared when debugging.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix implementation for the missing reset of version
information procedure request state value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The whitelist API uses the controller directly through HCI commands.
Bluetooth device must have been initialized before sending HCI commands.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move invalidation of connection handle when flushing TX buffers into
LLL context. Otherwise, LLL may or may not see invalidated handle
depending on mayfly scheduling.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
If the duration to publish is roughly the same as the period, we might
end up with elapsed == period, which returns 0 and cancel the periodic
publication. Instead 1 should be returned, just like when the elapsed
time is greater than the period.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Unifies the Mesh CCM implementation parts for encryption and decryption
into a crypt and an auth step, reducing stack usage and code size.
This change also brings several performance improvements, most notably
reducing copying of the nonce and unrolling the 16 byte XOR operations.
Performance for the Mesh worst case of a 382 byte payload with 16 bytes
of additional data (full transport encrypt with virtual address) goes
from an average of 889us to 780us on nRF52840 with default optimization
flags.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.
Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.
Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Handle invalid ACL flags in HCI transport.
Only Point to Point is supported over HCI in both directions.
Fix flushable start HCI ACL packets not allowed on LE-U connections
from Host to controller.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
In bt_l2cap_br_chan, rx.cid is the local cid and tx.cid is the
remote cid. According to Core-5.0 Vol3.Part A 4.6-4.7,
l2cap_br_remove_tx_cid should be searched using tx.cid
Signed-off-by: ZhongYao Luo <LuoZhongYao@gmail.com>
According to BT Spec v5.1 Vol 2 Part E Section 7.8.16, if the
device is already in the White List, the controller should not
add the device to the White List and should return success.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
According to BT Spec v5.1 Vol 2 Part E Section 7.8.16, if the
device is already in the White List, the controller should not
add the device to the White List and should return success.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If the whitelist already exists in the controller then the controller
should not add the device tot the whitelist and should return success.
In that case the counting of entries in the whitelist in the host will
be wrong.
Remove all whitelist counting in the host, and instead rely on the error
reported by the controller for this.
The controller should return error if the whitelist is full.
The controller should return error if use of whitelist was requested but
the whitelist was empty.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When Friend node tries to send Friend Clear message to other
Friend nodes, it should use the subnet information based on
the net_idx from friendship.
Fixes#21165
Signed-off-by: Maximus Liu <maximus.liu@gmail.com>
Expose the bt_uuid_to_str function as an API to the application.
This aligns this function with the bt_addr_to_str function call. This
allows the application to use this function without having to enable
the BT_DEBUG option.
Move the in-place bt_uuid_str to internal logging, this is mainly done
due to the limitation in the log_strdup that shouldn't be exposed to the
application.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Bool symbols implicitly default to 'n'.
A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.
Also replace some
config
prompt "foo"
bool/int
with the more common shorthand
config
bool/int "foo"
See the 'Style recommendations and shorthands' section in
https://docs.zephyrproject.org/latest/guides/kconfig/index.html.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Check that the bluetooth device has in fact been initialized before
continuing with public API calls. This could lead to crashes when using
state that has not yet been initialized.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When set, the BT_GATT_SUBSCRIBE_FLAG_NO_RESUB flag indicates that the
subscription should not be renewed when reconnecting with the server.
This is useful if the application layer knows that the GATT server
persists subscription information.
Signed-off-by: François Delawarde <fnde@oticon.com>
Added configuration for accepting pairing requests only if both devices
has bonding flag set in order to reject other devices at an early stage,
thus leaving more chance for devices expected to bond.
With the CONFIG_BT_BONDING_REQUIRED flag the device only accept pairing
requests if it has CONFIG_BT_BONMDABLE set and the device requesting
pairing has Bonding_Flags field set to Bonding (0x01) in its AuthReq.
Note: When using bt_set_bondable(false) pairing requests will be
rejected when CONFIG_BT_BONDING_REQUIRED is set.
Signed-off-by: Martin Rieva <mrrv@demant.com>
Fix issues that surfaced when trying out GCC 9.2, official release name
gcc-arm-none-eabi-9-2019-q4-major, both related to invalid pointers in
GATT when declaring UUIDs in if-scope.
1. Fix the discovery callback giving an invalid pointer in the discovery
callback in two instances.
2. Fix gatt_find_type sending invalid data during discovery procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Send connection parameter update request only if it contains the valid
range of values for connection intervals, latency and timeout.
Signed-off-by: Kiran Paramaswaran <kipm@oticon.com>
Fix ATT MTU size of length variables resulting in wrong length values
reported to the user. Communicating with an Android device using an MTU
of 517 resulted in write commands reported as length 2 instead.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Since bt_conn_send_cb can fail to send buffer causing it to unref this
may cause buffer leaks as the caller is not aware of the error assuming
the buffer could be sent.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add support for Zero Latency IRQs, which avoids any Zephyr
OS or application influenced ISR latencies on the
controller's ISRs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Processing of data received on dynamic channels is still done via syswq
so the buffer shall not be unrefed when they are queued.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Now that the TX callbacks happen from the system workqueue but fixed
channels get processed from the RX thread there's a risk that the
ordering of these gets messed up. This is particularly bad for ATT
when it's trying to enforce flow control.
To fix the issue store the completed TX packet information in a
per-connection list and process this list before processing any new
packets for the same connection. We still also schedule a workqueue
callback, which will simply do nothing for this list if bt_recv()
already took care of it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This define is not of use anymore since there's a global net_buf user
data Kconfig variable and its definition already guarantees a
sufficient minimum for Bluetooth.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The "sent" tracking doesn't have to be a signed integer. Use a fixed
size so that the consumed size doesn't change between different
architectures. Use a u16_t since bigger sizes are needed and because
this is mapped to an int function return higher up in the stack.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixed handling of HCI events in the HCI driver over RPMsg. Now,
the driver makes use of discardable buffer pool when allocating
memory for certain HCI event types (e.g. Advertising Report Event).
Applications that are flooded with Advertising Reports will run
much better after this change (e.g. Mesh applications).
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
If LL Connection Parameter Request or LL Connection Update
or LL PHY Update procedure is started by the local device
while a LL Length Update Request PDU has been sent by peer
then a Rx node has been stored in the llcp_rx place holder
for generation of Length Update procedure complete.
The failing assert check is incorrect in the above scenario
hence remove. Instead a missing append of the allocated Rx
node to the llcp_rx list has been added to the controller
implementation.
This issue relates to commit d12c53f89f ("Bluetooth:
controller: split: Fix missing data len update event").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Now that the TX path and TX context (bt_conn_tx) has been redesigned
to free the contexts always in the system workqueue, it means the
system workqueue is the only context where their allocation may also
fail. This is particularly problematic with us having all L2CAP
channels (fixed & CoC alike) deferred to the system workqueue. It is
especially bad for fixed channels where being able to send responses
for SM, L2CAP signaling and ATT is critical to avoid timeouts for the
connection.
This patch moves the processing of all fixed L2CAP channels back to
the RX thread, thereby making it possible (and safe) to block while
waiting for a TX context to become available.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that we've removed the TX allocation dependency from the TX thread
we no longer have the need to do special-casing for the system
workqueue when allocating buffers. Instead, we do have to special-case
the system workqueue when allocating TX contexts since the system
workqueue is the only place where they get freed up.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This is a moderate redesign of the pending TX packet handling that
aims to eliminate potential deadlocks between the TX thread and the
system workqueue thread. The main changes are:
- TX context (bt_conn_tx) is allocated during buffer allocation, i.e.
not in the TX thread.
- We don't allocate a TX context unless there's an associated
callback. When there's no callback simple integer counters are used
for tracking.
- The TX thread is no longer responsible for TX callbacks or
scheduling of TX callbacks. Instead, the callbacks get directly
scheduled (k_work_submit) from the RX priority thread.
- CONFIG_BT_CONN_TX_MAX defaults to CONFIG_BT_L2CAP_TX_BUF_COUNT,
and in most cases wont need changing. The value now only indicates
how many pending packets with a callback are possible.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The `node` and `work` members are never used simultaneously.
Additionally k_work already has built-in support for being in a linked
list, however a union makes this change a bit cleaner.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In seg_tx_reset() in transport.c, set the busy flag to 0U
before doing adv buf unref, which will avoid sending
unnecessary adv packets in case the adv buf is already put
in the mesh adv_queue.
Fixes#20970
Signed-off-by: Maximus Liu <maximus.liu@gmail.com>
A recent patch increased struct cmd_data from 8 to 12 bytes, which is
more than the default user data for Bluetooth. We generally don't want
the core stack to require more than 8, so instead of increasing the
requirement, move the data out from the buffer into its own array with
the help of the net_buf_id() API.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix race condition in bt_conn_create_le for the state of the scanner in
the Host. This leads to the host issuing a create connection command
without stopping the scanner first. This leads to command disallowed and
failing to establish connection. As well as inconsistent state in the
host which does not allow to stop the running scanner.
The race condition exists because the processing of le_adv_report
handler is done before the thread that called bt_conn_create_le was
woken up to continue after the command_complete event.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the initiator so that connection request PDU is not abort
mid-air by preemption by the overalapping first connection
event.
If the connection establishment is in progress, then the
first connection event trying to abort the initiator will
wait the connection request to be transmited completely.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable ticker job mayfly as soon as possible when
establishing connection. This is required so as to not miss
the first connection event in slow CPU like in nRF51 series.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix command status for LE Command Param Update HCI command silently
dropped by the host without notifying the application that this command
has failed. This happens because the host does not wait for the command
status event to check the status code returned.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix deadlock in Bluetooth Host. Deadlock could happen from the SMP
callbacks when calling Bluetooth API functions. This is because the
callbacks was given directly from the HCI TX thread. If the calling
API function resulted in trying to send a new HCI command it would post
this HCI command to the HCI TX thread and then wait for command complete
event. This would result in the HCI TX thread blocked waiting for the
itself to process the command.
Example:
Calling bt_conn_le_conn_param_update from pairing_complete callback.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
There are some changes that were introduced to the Nordic SW LL,
and as such, in order to maintain compatibility, propragate them
to the OpenISA SW LL as well.
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
In nRF51 which uses CONFIG_BT_CTLR_LOW_LAT, the advertising
PDU tend to get aborted in directed advertising at event slot
durations.
Dont not use continuous directed advertising event in nRF51
where CONFIG_BT_CTLR_LOW_LAT scheduling design alternative
is used. Instead close the event after each triplet of PDU
has been tx-ed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the directed advertising event interval calculation.
When CONFIG_BT_CTLR_LOW_LAT is used then prepare duration
has to be included in the event slot reservation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The HCI transport implemented by an application using the HCI raw
interface may have its own buffer headroom requirements. Currently the
available headroom gets completely determined by the selected HCI
driver. E.g. most of the time this is the native controller driver
which doesn't reserve any headroom at all.
To cover for the needs of HCI raw users, add a new Kconfig variable
for the apps to set to whatever they need. Correspondingly, use the
maximum of the HCI driver and HCI raw headroom requirements for the
buffer pool definitions and the headroom initializations.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix the implementation of slow encryption setup design
alternative to send ENC_RSP PDU before sending REJECT_IND
or REJECT_EXT_IND PDU.
Fixes#19917.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix dependency on the Host to include the PHY update procedure and the
data length update procedure. In a host-only build this feature should
be possible to select without relying on the supported features of the
controller. The host will check support using HCI command to read
attached controller features and commands supported.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix GCC9 warning "warning: taking address of packed member of
'struct sc_data' may result in an unaligned pointer value"
Issue is that the on-air structure of sc_data was re-used for the gatt
service changed data.
Added build assert because data is stored in settings, so the structure
should be the same size to be compatible.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the regression introduced as part of
commit 57d9411837 ("bluetooth: kconfig: disable some
options for openisa/RV32M1").
Also, prior to PR that introduced this regression, the Coded
PHY support selection was incorrectly depending on PHY update
support Kconfig BT_PHY_UPDATE. This was already fixed as part
the previous PR.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The BT_HCI_TX_STACK_SIZE is carefully calculated from other
options. When those options change, e.g. from a menuconfig update, it
is important that the stack size is re-calculated, but it is not when
there is a prompt.
Therefore, make the prompt conditional such that the previously set
value is only used when it has been explicitly configured to be so.
Now users can still change the value through menuconfig and prj.conf,
by also enabling <option>_WITH_PROMPT, but when the value is
calculated by the defaults, it will continue to be calculated by
defaults instead of inheriting the intial value.
This is AFAIK a novel approach, but testing has shown that it gives
the users the behaviour they want, at the cost of some boilerplate of
course. This pattern can be applied to other options if it proves to
work as intended.
Alternatively one could remove the prompt, but then it would no longer
be possible to override the value through menuconfig.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
When Config client model send publish message, app_idx will
be need, however, currently code clear this value use `&`,
this will be generate error when app_idx not zero.
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
This commit adds support for bluetooth in nRF52833 SoC.
Bluetooth radio related files created and added to Zephyr.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
The code was not properly taking into account CONFIG_BT_HCI_RESERVE,
which would cause buffer underruns for any HCI driver where this value
defaults to non-zero. Also, all the allocation functions use the same
pool, so we can map them simply to bt_buf_get_rx() instead of
repeating the same code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use semaphore to synchronize lll_reset completion with HCI thread for
returning (command complete) only when all is done.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix connection update procedure to be cacheable if any other
local or remote control procedure is in progress.
Relates to commit 9c14567ce2 ("Bluetooth: controller: Fix
conn update to be cacheable").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Non-direct ISRs are supposed to take a void pointer as an argument,
unliike direct ones, which take no arguments. Since the radio ISR is not
declared as direct, the void pointer argument was missing, likely due to
a copy-paste mistake from the nordic LLL, which indeed uses a direct ISR
for the radio ISR.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
bt_conn_create_pdu_timeout() may return NULL if no buffer
is available, l2cap_chan_create_seg() does not check the
subsequent return value.
Fix possible null pointer dereference in l2cap_chan_create_seg()
and l2cap_chan_le_send().
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
An issue with DT generation where instance defines are not determinstic
generating values that collide with existing IRQs.
Fixes#20558
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Move functions in order to avoid function prototype and use IS_ENABLED
instead of #if defined where possible.
Signed-off-by: François Delawarde <fnde@oticon.com>
This commits adds a BT_SETTINGS_CCC_LAZY_LOADING option to allow for
CCC settings to be loaded on demand when a peer device connects in
order to reduce memory usage.
Signed-off-by: François Delawarde <fnde@oticon.com>
Maintain Service Changed entry as long as the peer device is subscribed
to SC indications and bonded. This allows to save indication data for
disconnected peers peers when CCC settings are not available (loaded
on-demand).
Signed-off-by: François Delawarde <fnde@oticon.com>
This commit provides the DPPI configuration for the Radio
driver for nRF5340 SoC, supporting LE Coded PHY.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit provides the DPPI configuration for the Radio
driver for nRF5340 SoC.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Add the require #ifdef blocks in radio.c, in order to support
building for nRF53 SoC series (and, in particular, for nRF5340
CPU1 SoC).
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Conditionally include nrf5340_radio.h when building the
BLE controller for nRF5340 SoC. Introduce the header for
nrf5340.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit adds a string representation of the
nRF53 variant in bluetooth host.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit enables support in bluetooth/controller/Kconfig
for nRF53 series of SoCs.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
nRF5340 does not support a Radio TX power of 4dBm, so we
introduce a dependency for the respective Kconfig option
for TX power, so the option is never defined for nRF5340.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Define the nRF53 HW variant in include/bluetooth/hci_vs.h
and pass the define in hci_vendor.h
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
The Company ID concept is not restricted to the controller, and should
be part of the wider Bluetooth scope, so it can be used on a
controller-less device. It's used in multiple host level modules, most
notably the Bluetooth Mesh and Device Information Service.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Some Bluetooth options are currently not supported by the experimental
BLE SW LL implementation done on VEGABoard. As such, hide them from
the user altogether.
The full list of disabled config options is as follows:
- CONFIG_BT_PHY_UPDATE
- CONFIG_BT_DATA_LEN_UPDATE
- CONFIG_BT_HCI_VS
- CONFIG_BT_CTLR_LE_ENC
- CONFIG_BT_CTLR_CONN_PARAM_REQ
- CONFIG_BT_CTLR_EXT_REJ_IND
- CONFIG_BT_CTLR_SLAVE_FEAT_REQ
- CONFIG_BT_CTLR_LE_PING
- CONFIG_BT_CTLR_PRIVACY
- CONFIG_BT_CTLR_EXT_SCAN_FP
- CONFIG_BT_CTLR_CHAN_SEL_2
- CONFIG_BT_CTLR_ADV_EXT
- CONFIG_BT_CTLR_XTAL_ADVANCED
- CONFIG_BT_CTLR_SCHED_ADVANCED
- CONFIG_BT_CTLR_TIFS_HW
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
This patch updates the config files required to enable the
BLE SW defined controller to be built on RV32M1 SoCs. Only the split
version is supported.
Signed-off-by: George Stefan <george.stefan@nxp.com>
Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Ionut Ursescu <ionut.ursescu@nxp.com>
This commit takes the Nordic LLL and adapts it for RV32M1 SoCs, using
the blocks that are specific to this SoC: the GenFSK & LPTMR IP
blocks.
Signed-off-by: George Stefan <george.stefan@nxp.com>
Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Ionut Ursescu <ionut.ursescu@nxp.com>
This commit adds the HAL layer needed for the BLE controller
LL on RV32M1 SoCs on OpenISA boards. Specifically, the controller
makes use of the the GenFSK and LPTMR IP blocks.
Signed-off-by: George Stefan <george.stefan@nxp.com>
Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Ionut Ursescu <ionut.ursescu@nxp.com>
Having a pin toggle when the code reaches a certain point
is really useful for debugging; the infrastructure is already
in place for Nordic boards, so just build upon and enable the
mechanism on the Vega board as well.
Signed-off-by: David Leach <david.leach@nxp.com>
Update calls to nrfx HAL functions to reflect API changes introduced in
nrfx 2.0.0. All these functions are now called with the first parameter
pointing to the structure of registers of the relevant peripheral.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Fix Data Length Procedure to use Feature Exchange values to
send correct parameters based on whether Coded PHY is
supported by remote peer.
Relates to BT TS.5.1.1 tests:
LL/CON/MAS/BV-129-C
LL/CON/MAS/BV-130-C
LL/CON/SLA/BV-132-C
LL/CON/SLA/BV-133-C
Relates to commit fca32e41e6 ("Bluetooth: controller: Fix
DLE for remote unsupported Coded PHY").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the implementation of slow encryption setup design
alternative to send ENC_RSP PDU before sending REJECT_IND
or REJECT_EXT_IND PDU.
Fixes#19917.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix feature exchange event generation to be correctly
deferred to wait for Rx node availability for cases when
the procedure has already been performed on air.
Without this fix, remote feature request from host may not
get back a HCI event back.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Port missing implementation of the slave latency break
when there is data to be sent to peer master. Without this
initial data send from slave is delay by upto the slave
latency number of connection events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is a port of the commit 4135fb55f1 ("Bluetooth:
controller: Fix rejected enc procedure not terminated") and
commit 4d59ef306b ("Bluetooth: controller: Check if enc
procedure is in progress").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Disallows all unauthenticated pairing attempts made by the
peer where an unauthenticated bond already exists.
This would enable cases where an attacker could copy the peer device
address to connect and start an unauthenticated pairing procedure
to replace the existing bond. Now in order to create a new bond the old
bond has to be explicitly deleted with bt_unpair.
Added option to disable this rule in order to maintain backwards
compatibility in case this behavior is accepted.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Mark the old time conversion APIs deprecated, leave compatibility
macros in place, and replace all usage with the new API.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Adds the model extension concept to the access layer, as described in
the Mesh Profile Specification, Section 2.3.6. Extensions are
implemented as a tree, using two pointers in each model:
The extends pointer points to the first extended model, and the next
pointer points to the next sibling or (if the NEXT_IS_PARENT flag is
set) the parent model in the tree, forming a cyclical "Left-child
right-sibling" (LCRS) tree. The tree root can be obtained by calling
bt_mesh_model_root_get(), and the extended models can be walked by
calling bt_mesh_model_tree_walk().
According to the Mesh Profile Specification Section 4.2.3, all models in
the same extension tree share one subscription list per element. This is
implemented by walking the model's extension tree, and pooling the
subscription lists of all models in the same element into one. If the
config server adds a subscription to a model, it may be stored in any of
the model tree's models' subscription lists. No two models in the same
extension tree and element will have duplicate groups listed. This
allows us to increase extended models' capacity for subscriptions
significantly.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix missing log_strdup when loading bt/name setting. It should be done
on every string which is not in read only memory.
Signed-off-by: François Delawarde <fnde@oticon.com>
Reduces the severity of warnings that happen from normal behavior, or
can't be prevented by the user:
- "No ID address" in hci_core.c: Reduced to an informational warning, as
this will always output with the expected usage. This isn't useful
information for 99.9% of users, and pollutes the output of all samples
using the module.
- "Composition page %u not available" in cfg_srv.c: According to the
Mesh Profile Specification section 4.4.2.2.2, the client is expected
to send page=0xff. Reduced to a debug message.
- "Connectable advertising deferred" in proxy.c: Gets logged every 10
seconds when in a Mesh Proxy connection. This is not useful
information unless the user is debugging the proxy module. Reduced to
a debug message.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
A single connections may take up to 4 buffers at the same time. Make
number of connections that support this worst-case number
configurable.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Added implementation to cache Data Length Procedure when
another control procedure is in progress.
Relates to commit 26317491e04b ("Bluetooth: controller: Add
data length procedure queueing").
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.
Relates to commit 560d6ddb964c ("Bluetooth: controller: Fix
Re-encryption procedure").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix dropped ENC_REQ PDU when retransmitting, if slave was
not listening or nack-ed it.
Relates to commit 31256568a283 ("Bluetooth: controller: Fix
ENC_REQ PDU retransmission").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix control tx queue handling to correctly pause control PDU
responses during encryption setup.
Relates to commit 4b4b650174bf ("Bluetooth: controller: Fix
control tx queue handling").
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 and commit 0dcfa3853782 ("Bluetooth:
controller: Fix cmd disallowed and collision disconnects").
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.
Relates to commit 120eba45f81b ("Bluetooth: controller: Fix
start encryption in progress check").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
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.
Relates to commit 671ccc4b0ee6 ("Bluetooth: controller: Fix
data PDU leak during ctrl PDU defer").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in Data Length Update procedure that caused the
connection to drop due to the implementation sending bigger
PDU before the peer has acknowledged the receipt of Length
Response PDU.
Relates to commit ffbbec7a89ca ("Bluetooth: controller: Fix
DLE during data transmission").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We use the nRFx API nrf_get_irq_number(.) to retrieve the IRQ
line of the CCM peripheral, instead of the hard coded enum
value from MDK. We do this for portability, since these
enums may be different for different nRF SoC series.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Fix conditional compilation error in building the central
only samples as all peripheral structure member accesses in
the controller where not correctly compiled out.
Regression introduced in commit 6d8b12468e ("Bluetooth:
controller: split: Refactor LLL conn structure").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use this short header style in all Kconfig files:
# <description>
# <copyright>
# <license>
...
Also change all <description>s from
# Kconfig[.extension] - Foo-related options
to just
# Foo-related options
It's clear enough that it's about Kconfig.
The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)
git ls-files '*Kconfig*' | \
xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
We make a minor simplification in the way we define
RADIO_PDU_LEN_MAX in Nordic nRF LE radio driver; as
nRF51 SoC series is the only series where the LL PDU
max length representation is limited to a 5-bit field,
we simplify the conditional preprocessor expression,
to avoid having to list all nRF5x SoCs with PDU LEN
MAX is represented by an 8-bit integer field.
In addition, we modify the preprocessor conditional,
that compiles in the CCM support for 8-bit length field,
PDUs to be an #ifndef CONFIG_SOC_SERIES_NRF51X, instead
of #ifdef CONFIG_SOC_COMPATIBLE_NRF52X; this will
simplify the expression when adding nRF53X series
support.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
GATT parameters need to remain valid while the procedure is active.
Disallow GATT commands while the procedure is active to avoid asserting.
Fixes: #20232
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add the missing initialization of master role terminate_ack
flag. This caused slave initiated remote termination as
procedure timeout.
Fixes#20135.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the LLL connection context to move out the member
fields not accessed in LLL execution context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
C++ does not allow chaining of data members when identifying the
designator. Since the generic structure has only one member remove
the designator from its internal initializer.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Move calculation of max_tx_octets from Nordic lll_conn.c to ULL, to
allow usage by other vendors and prevent duplicate code.
Signed-off-by: Morten Priess <mtpr@oticon.com>
With sub-microsecond resolution in ticker, it is not necessary to add a
precision margin to the conn_offset. A macro is created to allow setting
the margin to something other than the hard coded 2 * EVENT_JITTER_US.
Signed-off-by: Morten Priess <mtpr@oticon.com>
TX pdu buffers may need to be augmented for fragmentation or other
purpose, depending on vendor LLL implementation. Introduced define to
add extra bytes to TX buffer size, defaulting to 0 if unused.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).
Go for the most common style:
- Indent properties with a single tab, including for choices.
Properties on choices work exactly the same syntactically as
properties on symbols, so not sure how the no-indentation thing
happened.
- Indent help texts with a tab followed by two spaces
- Put a space between 'config' and the symbol name, not a tab. This
also helps when grepping for definitions.
- Do '# A comment' instead of '#A comment'
I tweaked Kconfiglib a bit to find most of the stuff.
Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Make it possible to provision devices over advertising bearer (PB-ADV).
Many messages in the provisioning protocol are the same for provisioner
and device so much of the code could be reused by only changing when
they are expected to arrive.
This introduces to concept of local and remote device keys. The models
for cfg_cli and cfg_srv have been updated to reflect this concept. Both
the send and receive path in the transport layer have been updated to
support encrypting/decrypting with local and remote device keys.
When a node has been provisioned it is stored in bt_mesh_net.nodes. If
CONFIG_BT_SETTINGS is enabled, they are also saved to settings. If the
callback node_added in bt_mesh_prov has been set, it will be called for
every node that gets provisioned. This includes when they are retrieved
from settings.
The configuration CONFIG_BT_MESH_NODE_COUNT controls how many nodes that
can be provisioned.
Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
Remove ifdef guard around inclusion of nrf_clock_control.h in bluetooth
controller as the defines in this header are needed anyway.
Signed-off-by: Solveig Fure <solveig.fure@nordicsemi.no>
Since the LE (Enhanced) Connection Complete that comes as part of
cancelling a connection does not come through the priority rx thread in
hci_driver.c, the event class was not being calculated and cached.
Hence, calculate and cache the class whenever an event is received as
part of invoking a command.
Fixes#20110.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit adds an macro to allow UUID 128
to be written in more user-friendly form.
UUID in 128 bit form requires an array creation.
To complicate the whole thing - it requires the array to start from LSB,
so using the readable form, we have to write it down backwards.
Old way to declare example UUID 6E400001-B5A3-F393-E0A9-E50E24DCCA9E:
0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0,
0x93, 0xF3, 0xA3, 0xB5, 0x01, 0x00, 0x40, 0x6E
A form provided by this commit:
BT_UUID_128_ENCODE(0x6E400001, 0xB5A3, 0xF393, 0xE0A9, 0xE50E24DCCA9E)
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
On connection callback generated by host, application
reading the RSSI value by using HCI LE Read RSSI Command
received -127 dB as the first connection event has not
occured yet in order to measure the RSSI value.
Fix this by using the RSSI value of received advertising
PDU by the initiator, and using the RSSI value of the
received CONNECT_REQ PDU by the connectable advertiser as
the initial value at connection setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
On connection callback generated by host, application
reading the RSSI value by using HCI LE Read RSSI Command
received -127 dB as the first connection event has not
occured yet in order to measure the RSSI value.
Fix this by using the RSSI value of received advertising
PDU by the initiator, and using the RSSI value of the
received CONNECT_REQ PDU by the connectable advertiser as
the initial value at connection setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix connection update procedure to be cacheable if any other
local or remote control procedure is in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
MD bit was set based on whether a memq link's next pointer
being NULL, instead the check should be that the memq has
more elements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in porting slave latency, slave latency
enabled was not used, cause slave latency to be applied
before first packet being acknowledged by the master.
Regression in commit 5dff214d57 ("Bluetooth: controller:
split: Fix missing slave latency impl.").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The CONFIG_* prefix was missing, making the #ifdef always false.
Found with a script (CONFIG_BT_SETTINGS_USE_PRINTK was unused).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Fix GATT buffer leak when bt_att_send returns error the allocated
buffer is never freed. Discovered case where the link was disconnected
during the function call, so when GATT checkd the link was still
connected, but ATT checkd the link was disconnected.
Fixes: #19889
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Added in commit 1475402d41 ("Bluetooth: controller: Introduce ULL LLL
architecture"), then never used.
Found with a script.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Key overwrite feature allows to overwrite old pairing key
records when key storage is full and a new pairing request occurs,
or new keys are distributed. If enabled when key storage is full and
a keys storage slot is requested, the oldest keys added will be
removed. So new devices can be paired with no limitations and no need
to determine, which devices should be unpaired to free key storage
space explicitly in application. To enable the feature set
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y.
Oldest keys are determined by minimum value of up-counting aging
counter. If you set CONFIG_BT_KEYS_SAVE_AGING_COUNTER_ON_PAIRING=y
aging counter values will be updated each time the secure connection
is established. This might increase flash wear out if at least two
secure connections are established and shut down periodically. When
the option disabled aging counter is still updated on each new secure
connection, but not stored to flash.
Signed-off-by: Sergiy Nikolayenko <sergiy_nikolayenko@jabil.com>
Remove the
# Omit prompt to signify a "hidden" option
comments that appear on some symbols. They seem to have been copy-pasted
at random, as there are lots of promptless symbols that don't have them
(that's confusing in itself, because it might give the idea that the
ones with comments are special in some way).
I suspect those comments wouldn't have helped me much if I didn't know
Kconfig either. There's a lot more Kconfig documentation now too, e.g.
https://docs.zephyrproject.org/latest/guides/kconfig/index.html.
Keep some comments that give more information than the symbol having no
prompt.
Also do some minor drive-by cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
The 16-bit format group addresses will be stored,
but we don't store (or restore) the virtual label UUIDs,
i.e. after a power cycle the 16-bit group addresses
would be meaningless.
Fixes#19342
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Add public API function to get the connection handle of the connection.
The connection handle is needed by applications that intend to send
vendor specific commands for a given connection.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add pre-empt timer stop when a prepare is executed so that
when the pipeline has another event queued, the firing of
the pre-empt timer does not pre-empt the just executed
prepare.
Relates to #19685.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrectly calculated ticks slots for a connection on
connection update. The reservation incorrectly included the
prepare offset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in bt_gatt_attr_next when given an attribute that has static
allocation. The handle is then 0 and the function would always return
the attribute with handle 1.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix compilation issue when wanting to use whitelist in bluetooth
applications that does not have CONFIG_BT_CENTRAL defined.
These functions are useful even for broadcaster and observer roles.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add public API function in GATT to check if a specific connection has
subscribed to the given attribute.
Without this function the application has to keep track of which
connections has subscribed using the callbacks from BT_GATT_CCC_MANAGED
since the cfg_changed callback of the CCC doesn't carry connection
context.
The other alternative is for the application to parse the information
in the struct _bt_gatt_ccc object. Although this object has structure
information available to the application the structure is marked as
internal, so the application shouldn't rely on this definition.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix Data Length Procedure to use Feature Exchange values to
send correct parameters based on whether Coded PHY is
supported by remote peer.
Relates to BT TS.5.1.1 tests:
LL/CON/MAS/BV-129-C
LL/CON/MAS/BV-130-C
LL/CON/SLA/BV-132-C
LL/CON/SLA/BV-133-C
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for persisted Service Changed data, to fix the case of a
paired device not reconnecting before a reboot and thus not receiving
SC indication. It also enables support for GATT database being changed
during a firmware update.
Move Service Changed data outside of the CCC struct and make it
persistent by adding support for a bt/sc/... setting.
Signed-off-by: François Delawarde <fnde@oticon.com>
The Service Changed characteristic support should also work when the
GATT database has been modified after reboot (firmware update scenario)
This commit introduces a BT_GATT_SERVICE_CHANGED config option that is
independent from BT_GATT_CACHING and BT_GATT_DYNAMIC_DB.
Signed-off-by: François Delawarde <fnde@oticon.com>
Rx nodes are reserved during control procedures for
generation of HCI event on completion. Fix the allocation
and reservation in the form of a linked list per connection
context. Worst case, this list will hold one rx node for
overlapping non-instant control procedure (Data Length
Update) plus two rx node for control procedure with instant
(PHY update with Data Length Update support).
Fixes#19198.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The remote version information event needs to be processed by the
prio_recv_thread() thread in order to unblock the Host RX thread
(effectively hci_driver's recv_thread()) when it blocks waiting for a
response to a remote version information.
Add the same time gate the inclusion of the feature behind a new Kconfig
option: CONFIG_BT_REMOTE_INFO.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In order to be able to distinguish between connection-related events
that are generated by the controller and others genrated by LL control
procedures, introduce a new class for LLCP.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Cache the result of calling hci_get_class() to avoid repeatedly invoking
it on the same data. In order to cache it we take advantage of the fact
that both radio_pdu_node_rx_hdr and node_rx_hdr are not packed
structures and they currently have a spare padding byte (between type
and handle).
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Hide the details of obtaining a pointer to the PDU data from a node_rx
structure to simplify the code.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Call LLL reset functions when calling ll_reset to avoid carrying LLL
state across HCI resets. Respective functions already exist in LLL but
had not been called from anywhere.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Unless explicitly blacklisted, the Proxy node will forward all messages
for the ALL_NODES address to the GATT proxy client.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix missing generation of data length update HCI event when
effective tx and rx timings change due to PHY update
procedure.
Fixes BT LL TS 5.1.0 test:
LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI
Change]
Relates to #17097.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When ULL High and ULL Low are not at same execution priority
level, it is not necessary to disable ULL Low execution when
updating ticker using stop and start. Also, ULL Low need not
be disable inside Radio Events. This commit corrects some of
the conditional compiles.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Kconfig conditional include of Minimum Channels Used
and Channel Selection Algorithm #2.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ticker previous slot value with elapsed ticks value from
the time stopped ticker has expired. When a ticker is
stopped, if it was in its reserved time space, then the
currently occupied slot (was set to 0) should be the amount
of time that has elapsed in the expired and stopped ticker's
reserved time space and beyond until the stop.
This is required to ensure that any other new ticker does
not get scheduled over the stopped ticker's reserved time
space.
Fixes#19515.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for Zero Latency IRQs, which avoids any Zephyr
OS or application influenced ISR latencies on the
controller's ISRs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for Zero Latency IRQs, which avoids any Zephyr
OS or application influenced ISR latencies on the
controller's ISRs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Creates macros for determining model message lengths based on opcode,
payload length and MIC size. Also adds macro wrapping
NET_BUF_SIMPLE_DEFINE to serve the most common use case.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When running a ticker node as "must expire", the node would invoke the
ticker callback even when programmed with latency. As "must expire" is
intended for scheduled events which are skipped due to collision, and as
such expected by LLL, purposefully skipped events should not generate
"must expire" callbacks.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix ULL implementation that uses conditional compilation by
replacing back to use of #if defined(...) in code accessing
compiled out struct members.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for possible Tx Buffer leak during disconnection when
the buffers are in ULL context and not yet enqueued towards
LLL context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When more than one simultaneous connections are active,
transmitting data packets to peer, a termination causes
host to use the flushed pending number of completed packets
count for other active connections. This is on reception
of HCI disconnection complete event. But the controller has
not yet released any of the pending enqueued Tx buffers
which was happening after the disconnection event was
dispatched to HCI layer.
The fix here is to dispatch the disconnection complete event
from the LLL context after pending Tx buffers have been
flushed and the buffers get returned to Tx pool in the ULL
context. This way buffers are in the Tx pool before host
get to process the disconnection complete event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for possible Tx Buffer leak during disconnection when
the buffers are in HCI thread context and not yet demux-ed
and enqueued towards LLL context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the mayfly scheduling of the Tx buffer flushing on
connection termination to be immediate (not to tailchain).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Uses net_buf_simple_clone to access the sdu of an unsegmented app packet
for re-encryption.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Local messages are already enqueued for the LPN in the tx path, and
don't have to be added again in the rx path.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Re-encrypts single-segment application messages when the network seqnum
has changed, to avoid encrypting messages with different seqnums in
network and transport. This operation is only required for unsegmented
messages, as segmented messages don't need to use the same seqnum in
network.
Reinstates the special adv data for friend messages to store the app key
index.
Fixes#19265.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Provides a utility function for getting an application key given a
subnet and an app ID. Primary use-case in friendship re-encryption.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Provides utility function for parsing network headers outside of the
network layer. The primary intended use-case is friendship.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Check if the encryption procedure is in progress when receiving
rejection for the procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix issue in the handling of LL_REJECT_EXT_IND packets, this would look
at the procedures that are enqueued, and not the procedure that was
being rejected. This meant that although a reject was received for the
encryption procedure, the handling for a different control procedure was
run.
This would result in the link being terminated as control procedure
timer would time out for the encryption procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Static variables and functions don't need #ifdefs if the code calling
them is using IS_ENABLED(). If IS_ENABLED() evaluates to false the
compiler will strip out all the static entities.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Static variables and functions don't need #ifdefs if the code calling
them is using IS_ENABLED(). If IS_ENABLED() evaluates to false the
compiler will strip out all the static entities.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Static variables and functions don't need #ifdefs if the code calling
them is using IS_ENABLED(). If IS_ENABLED() evaluates to false the
compiler will strip out all the static entities.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When aborting radio event, there is a possibility that the
packet timer would start the radio while the packet timer
is being reset. Hence, perform a second radio state disable
with packet timers uninitialised.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing radio status and configurations reset on radio
event abort. This caused under race conditions the radio
being put into active state after being aborted.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect ticker/mayfly user id used in scheduling the
abort of a radio event. Incorrect use of thread context as
the caller caused the abort function to be scheduled from
thread context while being called from ULL high context
level in reality. This could cause corruption of mayfly
scheduling.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When flash driver requests abort of radio event in unreserved
time space, resume radio events in the pipeline were not
flushed. These resumed events caused flash driver to assert
on the check whether radio was in use.
Fixed by flushing the pipeline of all radio events, resume
and also those events in pipeline with pre-empt timeout
being setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When multiple simultaneous peripheral connections are
supported, restarting connectable advertising by host on
peripheral connection establishment failed in controller.
This prevented establishing new connections while first
connection was active.
The failure was caused by a bug in the way controller was
using quota for Rx PDU buffers. As the quota count was
release before the connection complete event rx PDU buffer
being released, the Rx PDUs needed to reserve for
connection complete event for new connectable advertising
was not available. This caused the connectable advertising
enable to fail.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in ATT reset handling, not releasing queued notification
buffers when the connection is terminated.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use entropy driver directly in bt_rand instead of stitching together
calls to sys_rand32_get to improve efficiency. The use of
sys_rand32_get could also leak timestamps into keys.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Added support for vendor specific meta data in LLL node_rx_hdr. This
enables vendors to add "footer" data to the RX PDU, for supporting
specialized BLE features.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Immediate logging is not compatible with the software-based controller
due to the additional ISR latency that it introduces. Ensure that
deferred logging is in use whenever using the software-based LL.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Handle case where:
- Peripheral sends security request after master has sent pairing
request or started encryption procedure.
This packet can be ignored, as long as the slave has not already
responded with pairing response.
- Central wants to start security after peripheral initiated security
request, return error code busy in this case
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move initiating security functionality and LTK requesting into the SMP
module so that SMP can track when the connection is in the encryption
process
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move the bt_smp_keys_check function above all usage of the function
in order to avoid prototype declaration when making the function static.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix calling bt_hex and bt_addr_le_str multiple times in the same logging
call could result in string overwritten since log_strdup is not
guaranteed to duplicate the string buffer in all logging configurations.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Added to allow vendor specific increase of user operation capacity for
ULL_HIGH, to support queuing additional ticker operations.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Enabled use of ticker must_expire feature for ensuring ADV timing
randomization, even when ADV doesn't get air-time. This reduces ADV
collisions. Not active for nRF51 platform for now.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Added support for vendor specific meta data in LLL conn object. This
enables vendors to add state data to connection, for supporting
specialized BLE slave features.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix regression introduced in refactoring of use of SWI.
Reduced use of SWI cannot be used in combination with
CONFIG_BT_CTLR_LOW_LAT as additional SWI is required
to split ticker WORKER and JOB contexts in order to
disable JOB but keep WORKER enabled.
Regression introduced in commit 78b461ae3e ("Bluetooth:
controller: Refactor use of SWI").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Calling indicate or notify on a disconnected connection object would
result in the error code ENOMEM when failing to acquire buffers instead
of the expected return code ENOTCONN.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Stop linking interface libraries against zephyr_interface. This is
cargo cult code that in practice does nothing.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
The start timestamp was supposed to signify the starting point of the
clear procedure. The code was incorrectly initializing it to the *end*
point of the procedure.
Fixes#19263
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Some modules use snprintk to format the settings keys. Unfortunately
snprintk is tied with printk which is very large for some embedded
systems.
To be able to have settings enabled without also enabling printk
support, change creation of settings key strings to use bin2hex, strlen
and strcpy instead.
A utility function to make decimal presentation of a byte value is
added as u8_to_dec in lib/os/dec.c
Add new Kconfig setting BT_SETTINGS_USE_PRINTK
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
When not using ticker compatibility mode in legacy
controller, ticker job should not be disabled inside radio
events.
Ticker compatibility mode was introduced in
commit 3a9173afe1 ("bluetooth: controller: Revised ticker
for improved conflict resolution").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This file contains redundant definitions of a bunch of nRF IRQ numbers
(not all, however) that only generates confusion, as enumeration values
provided by MDK can be used instead.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Header files of nrfx HALs are not supposed to be included directly
but only with their names prepended with the hal/ directory (so that
an inclusion of an nrfx HAL header clearly differs from an inclusion
of an nrfx driver header).
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
The nRF52811 Radio is similar to nRF52840 and exhibits
similar Radio Timings constants. We align the LE Coded
PHY (S2) RX chain delay with that of nRF52840, which,
eventually fixes the TIFS for nRF52811. In nRF52840 we
correct the inline comment only.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
We have introduced option HAS_HW_NRF_RADIO_BLE_CODED, which
reflects that an nRF SoC has a Radio with LE Coded PHY
capabilities. We now modify all #ifdef expressions for
Coded PHY in the nRF controller port, removing SOC_NRF52840
and adding this new option instead. This allows to build
an nRF controller with Coded PHY support for SOCs other
than nRF52840.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Nordic nRF52811 SoC has a 2.4GHx Radio which supports
LE Coded PHY, so we add the option to build a BLE
Controller for nRF52811 platforms with LE Coded PHY
support.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Enable possibility to configure time a slave will wait until
start of connection parameters update procedure after BT connection
is established.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This moves check_perm code under GAT and make use of it to check if CCC
write permission can be attended by the connection security level or if
it needs to be increased.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support to set different permissions to CCCD so security can
be checked when enabling notification which conforms to:
BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G page 2360:
'3.3.3.3 Client Characteristic Configuration
Authentication and authorization may be required by the server to
write the configuration descriptor.'
In addition to that also ensure that notification are not re-enabled
until the proper security level is reached to conform to the following
statement:
'10.3.1.1 Handling of GATT indications and notifications
A client “requests” a server to send indications and notifications
by appropriately configuring the server via a Client Characteristic
Configuration Descriptor. Since the configuration is persistent
across a disconnection and reconnection, security requirements must
be checked against the configuration upon a reconnection before
sending indications or notifications. When a server reconnects to a
client to send an indication or notification for which security is
required, the server shall initiate or request encryption with the
client prior to sending an indication or notification. If the client
does not have an LTK indicating that the client has lost the bond,
enabling encryption will fail.'
Fixes#17983
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add GATT initializer macro for GATT CCC and allow the
BT_GATT_CCC_MANAGED to accept an already initialized CCC user data.
This allows the application to specify the storage location of the CCC
user data.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
CCC storaged is no longer declared separetly so check if ccc->cfg
matches with sc_ccc_cfg no longer works so instead use the cfg_changed
callback and match against sc_ccc_cfg_changed.
Fixes#19267
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
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>
In certain cases there could be no buffer available which may lead to
NULL being returned by bt_l2cap_create_pdu so instead use
bt_l2cap_create_pdu_timeout to wait with a specific timeout.
Note that this should also ensure the SMP will not be waiting for a
buffer when the remote might have timed out already.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds bt_conn_create_pdu_timeout function which can be used
to provide a timeout when allocating a buffer.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix reset of Encryption Procedure state on reception of
REJECT_IND and REJECT_EXT_IND.
This is a regression in commit 79cb615770 ("Bluetooth:
controller: split: Port Enc setup to be queueable")
Relates to #18578.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the controller implementation to handle data packet
enqueue being pause on Encryption Request be done early in
the ULL when enqueueing packets towards LLL.
Fixes#18645.
Signed-off-by: Vinayak Kariappa Chettimada <vinayak.chettimada@gmail.com>
Rename AUTHENTICATION, to AUTH, since this is a well established short
form of the word.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename bt_conn_security to bt_conn_set_security, this makes the API
naming more consistent.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename security level enum, using level and number instead of low,
medium, high and fips.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
A security vulnerability in the Bluetooth BR/EDR Bluetooth Core
specification versions 1.0 through 5.1 has been identified as
CVE-2019-9506. The Bluetooth BR/EDR encryption key negotiation
protocol is vulnerable to packet injection that could allow an
unauthenticated user to decrease the size of the entropy of the
encryption key, potentially causing information disclosure and/or
escalation of privileges via adjacent access. There is not currently
any knowledge of this being exploited.
From Core spec erratum 11838:
A device shall enforce an encryption key with at least 128-bit
equivalent strength for all services that require Security Mode 4,
Level 4. For all other services that require encryption, a device
should enforce an encryption key with at least 56-bit equivalent
strength, irrespective of whether the remote device supports Secure
Simple Pairing.
After encryption has been enabled, the Host should check the
encryption key size using either the HCI_Read_Encryption_Key_Size
command (see [Vol 2] Part E, Section 7.5.7) or a vendor-specific
method.
Fixes#18658
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In case sufficient security level wasn't reached the error propagation
was missing, which could lead to incorrect state transitions when
update_sec_level_br() returns. Return true/false and make sure to
abort any further operations in case the update fails.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The storage for the public key is pub_key in hci_core.c.
When the public key event is generated the public key is copied into
this buffer, but the pointer to the event storage of the key is given
in the public key ready callback (bt_smp_pkey_ready).
SMP expects that it is safe to assign a global pointer to this variable.
In smp_init bt_pub_key_get is used to get the pointer to the public key.
In both cases SMP assigns the le_sc_pub_key to the pointer given.
This creates an issue when bt_smp_pkey_ready callback occurs after
smp_init during pairing procedure, SMP will then have a pointer to an
event buffer that has been released and contains invalid data.
Fixes: #18580
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Give the security changed callback when the peripheral initiated
security request and peer attempted to encrypt the connection but no LTK
match was found.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Make sure that a new pairing procedure with an existing bond does not
result in a security with weaker security properties.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add option to force the host to initiate pairing procedure even if the
host has encryption keys for the peer.
This option can be used to pair with a bonded peer that has deleted its
bonding information without deleting the keys. If new pairing results
in weaker keys the pairing will be aborted.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add security error to security_changed callback. Call this callback when
security has failed and provide current security level and error.
Reason for failure can be.
- Pairing procedure failed, pairing aborted before link encryption.
- Link encrypt procedure failed
- Link key refresh procedure failed.
Fix missing bt_conn_unref on encryption key refresh with error status.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Stop the pairing procedure in the request phase if no storage is
available for the keys. This avoids the pairing procedure from failing
during the key distribution phase.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Proved the Authentication callback for pairing failed and pairing
complete when BR/EDR SSP is complete.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allow SMP debug keys to behave in the same way as normal keys, in order
to debug with encryption and Bluetooth sniffer the exact way it behaves
when not using debug keys.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix reset of Encryption Procedure state on reception of
REJECT_IND and REJECT_EXT_IND.
This is a regression in commit 79cb615770 ("Bluetooth:
controller: split: Port Enc setup to be queueable")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The period_start timestamp wasn't getting properly initialized in the
case that retransmission was not being used. In the case of
retransmission the timestamp was getting updated in the mod_publish()
delayed work callback. Add a send_start callback and do the
initialization there, since this covers both the retransmission as
well as the no-retransmission cases.
Fixes#17820
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Post Tx pool corruption fix, clean up code and add comments
explaining the use of Tx node next field used to indicate
the Tx node's allocation from Control or Data pool.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the Tx FIFO, queue and pool corruption due to missing
release of link object to Tx link pool and hence missing
reset of the per connection initially allocated Tx link
free pointer.
The bug caused Tx PDUs and associated memory to be lost
leading to missing L2CAP segment transmissions. With lost
control PDU buffers, ULL would stall processing Done events
also leading to controller asserts.
Fixes#18546.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This removes the necessity of registering the storage for CCC and make
it part of the declaration itself.
Fixes#18547
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support to provide an UUID to bt_gatt_indicate so API user
don't need to hardcode the attribute offset by hand.
Fixes#18572
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The code for checking space in the Friend queue was faulty in the case
that we receive a message with more segments than the configured Friend
Queue size. This is not an issue for the default configuration but
still a possible one. Move the check for exceeding Friend Queue Size
to the per-LPN function, so that bt_mesh_friend_queue_has_space()
iterates all LPNs before delivering its verdict. This allows us to
return success in case no LPN matched (which is how the code was
intended to work).
Fixes#18522
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
According to Mesh Profile Specification 1.0.1 Figure 5.17, the
unprovisioned device should send its confirmation value after the
provisioner sends theirs. Previously, the confirmation value would be
sent immediately after OOB input complete. Now it first waits for the
input data, then from confirmation from the provisioner before sending
the confirmation.
Fixes: #18178.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Qualification test case MESH/NODE/FRND/FN/BV-08-C requires that we do
not store more messages than the reported Friend Queue size. The
implementation was so far opportunistic and stored more if it could
(it would later discard if necessary to make sure all queues can store
the required amount). The spec also requires the queues to have new
messages overwrite old ones (in the style of a circular buffer), so we
have to keep track of which buffers are part of the same segmented
message (so we discard all buffers belonging to the same message).
To pass the test case, add APIs to check for space in the Friend
queue, and track the number of buffers for each incoming segmented
message.
Fixes#18090
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The bt_mesh_trans_resend() function had no users, and had in fact not
even a prototype in a header file. Just remove it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When sent solely to the Friend Queue the send callbacks were not
getting called for unsegmented messages.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This fixes the dead code when parsing Find Information response since
the index counter can never be zero, instead it checks there are any
attributes found and if there nothing don't proceed with discovering
which was the original intent of the now dead code.
Fixes#18384
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Due to conditional compile path ending in LL_ASSERT(0), the compiler
sees code following the assert as using uninitialized variables.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When the database changes and a client becomes change unware it should
also clear the out of sync flag as the following request should return
an error:
Core Spec 5.1 | Vol 3, Part G, 2.5.2.1 Robust Caching:
'The error response is sent only once after the client becomes
change-unaware, unless the client disconnects or the database changes
again before the client becomes change-aware in which case the error
response shall be sent again.'
Fixes: #18183
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes the following crash:
ASSERTION FAIL [0] @ ZEPHYR_BASE/subsys/logging/log_core.c:180
argument 2 in log message "%s: Stored CCCs for %s (%s)"
missing log_strdup().
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix issue unable to connect to bonded peer when host resolution is used
either because the controller does not support privacy, or the
controller resolving list was exceeded.
In this case we need to use the RPA from the advertising report
directly, there is a small chance of the peer cycling the RPA here, in
which case the connection might be unsuccessful.
Bug introduced here: 45da629b24Fixes: #18306
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Disable Advertising Extensions by default, since they are not really
operational and they take RAM.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
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.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When in Low Power mode an LPN may receive messages sent by nodes other
than its friend during its brief receive window. These messages get
rejected by the transport layer. At some point in the future the LPN
will receive these messages from its friend, however they will have
already been added to the network message cache earlier.
When the transport layer rejects a message due to it being received from
a non-friend node while in Low Power mode it must be removed from the
network message cache so that it can be correctly received from its
friend in the future.
Fixes#17809
Signed-off-by: Rich Barlow <rich@bennellick.com>
The commit 1c7b668804 tried to fix
resending segments to the GATT bearer, however it got the buffer
refernce counting wrong. The bt_mesh_net_resend() function doesn't
own a reference to the buffer, i.e. it's not responsible for unrefing
it. E.g. bt_mesh_adv_send() takes its own reference.
What was missing however was the handling of the callbacks. Use the
recently introduced send_cb_finalize() helper to make sure they're
called.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There are several places that require the send callbacks to be called
immediately. Reduce the code a bit by introducing a helper for this.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The RPA timer should always be running, even with privacy supported by
the controller. In order to select an IRK to generate the private
the controller is instructed by provided an identity address.
If we want to advertise privately without providing an identity address
the host has to set the private address.
Fixes: #18150
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Mesh Profile Specification states in section 3.10.5 IV Update
procedure: "The IV Update procedure is initiated by any node that is a
member of a primary subnet", meaning if we're not on the primary
subnet we should not try to initiate the procedure.
Additionally this fixes initiating IV Update in all cases where the
sequence is updated, by putting the code into bt_mesh_next_seq().
Fixes#17977
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This branch is inherited from old code that used to start the timer as
soon as a message was queued for transmission rather than when it was
actually transmitted (the case today). It'll also cause a race in case
the publication goes over the GATT layer since the "sent" callback
happens synchronously in that case.
Fixes#17821
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The GATT bearer is a reliable one so there should theoretically never
be a need to resend segments. If however for some strange reason the
proxy client doesn't immediately ack all segments we should do the
resending on the GATT bearer, rather than sending them over
advertising.
Fixes#17907
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code was incorrectly bailing out with "return 0" rather than
continue. Also, it was incorrectly making a reference to
tx->seg[seg_o] since when a PDU goes through the friend queue we don't
use the usual retransmission mechanism.
Fixes: #17932
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In case a queued buffer is canceled before sending we have to unref
it, since that's what adv_send() would do as well.
Fixes#17936Fixes#18013
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Mesh Profile 3.6.7.2 Publishing Heartbeat messages:
"
Triggered publishing of Heartbeat messages is enabled by
the Heartbeat Publication Features state (see Section 4.2.17.5):
...
- If the Low Power bit is set to 1, a Heartbeat message shall be
published when the node establishes or loses Friendship (see Section
3.6.6.1).
"
Fixes#18194
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When sending heartbeat messages triggered by feature changes the code
was trying to look up the configured publication subnet, in an
apparent attempt to figure out if publication is enabled or not. A
more appropriate way is to check for the heartbeat publication
destination address, and since we have a helper function this can be
done in a single place.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The heartbeat is a transport layer feature, so move it to transport.c.
This also opens the way to properly fix Friendship-established/lost
triggering for LPN role.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix missing interval min copy in bt_conn_set_param_le. Application is
unable to override BT_GAP_INIT_CONN_INT_MIN for interval_min.
Fixes: #17789
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.
Background from issue #17997:
Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.
Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.
See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Fix the pipeline prepare-resume implementation to correctly
handle multiple continuous events that request resume on
being pre-empted.
Symptoms of the bug being, when having continuous scanning,
and an active peripheral if a directed advertising is
started the peripheral event are not scheduled causing link
supervision timeout.
This is fixed by not having an enqueued resume event
prepared if there is an enqueued new non-resume event in the
pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase pipeline size to accommodate probable multiple
prepare for directed advertising events, with reserved time
which are shorter than prepare duration, being enqueued.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase the event start overhead time to accommodate for
processing time for dequeueing pipeline in Upper Link Layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reduce the maximum number of pending event done elements by
decoupling it from the maximum pipeline elements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is safer now that bt_conn_create_pdu can return NULL when using
syswq which can prevent things like signalling of L2CAP and ATT layers.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Since TX complete notification are dispatched with syswq blocking on it
can completely deadlock Bluetooth so this attempt to make it safe by
return -ENOMEM if that the current thread happens to be the syswq
thread.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add shell commands to add and remove devices from the shell.
Add commands and options to use whitelist for advertising, scanning,
and creating connections.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add whitelist support in the bluetooth host.
Supported features:
- Advertising with whitelist on scan requests, connect request ,or both
- Scanning with whitelist
- Creating connections using a whitelist (Auto connection procedure).
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allow Security level HIGH and FIPS to be initiated when we have received
OOB data for the remote device. The security property of MITM is allowed
if out of band authentication data is available.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update bluetooth help text to include FIPS level in help text.
Also validate input range for the different connection types
Bluetooth security level for LE is from 1-4, while BR/EDR is 0-3
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Authentication using OOB data uses the on-air device addresses used
during connection setup. So we need to check against the on-air
addresses in the info object to see if we have correct OOB data.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix issue with registering authentication callback handlers failing
without notifying the user of the shell.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use the src and dst naming to refer to the identity addresses of the
connection. Keep the device addresses used during connections but rename
them to local and remote instead.
Update documentation to be more descriptive.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
subsys/bluetooth/host/Kconfig.gatt is already sourced within an
'if BT_CONN' in subsys/bluetooth/host/Kconfig.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Fix the mandatory and optional parameter counts for the
directed adv shell command definition. Also, refactor the
command for consistency.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix assert in the RPA timeout when no resolving entry exists in the
resolving list, and the advertiser was requested to use a local IRK
to generate it's own address.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
If no callback for oob data request is registered, or the user decided
to abort authentication during OOB data request, we should return the
error code for no OOB data available to indicate that the user does not
have the correct OOB, or no OOB interface at all.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix kernel crash if bluetooth authentication handlers has not been
registered. The bt_auth object is then NULL, this dereference caused a
call to an invalid function pointer.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The code was already rejecting the key, however that rejection
happened only after we had already sent our public key as response,
which got interpreted as acceptance by the tester (PTS).
This fixes issue that d4fd267086a56c270a793114e7575afae9a9befa
supposed to fix. The problem is bt_dh_key_gen is async.
Local public key cannot be sent from the same context
the bt_dh_key_gen is called because we don't know yet
if remote key is valid.
Fixes MESH/NODE/PROV/BI-13-C.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fixed error 'The int symbol BT_DISCARDABLE_BUF_COUNT is being evaluated
in a logical context somewhere'.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
subsys/bluetooth/host/Kconfig.l2cap is already sourced within an
'if BT_CONN' in subsys/bluetooth/host/Kconfig, so BT_DEBUG_L2CAP does
not need a 'depends on BT_CONN'.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Find by type does only accept a UUID with the same length as the UUID
which is stored in the internal list. If a UUID is stored in the short
16 bit format then a request with 128 bit UUID will fail.
Add support for the missing formats.
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
Changed ticker behavior to resolve conflicts in ticker_worker instead of
in ticker_job. This allows better real-time slot allocation, as well as
allowing callbacks even if ticker node doesn't get air-time (for audio
stream housekeeping). A priority property now also allows prioritizing
one ticker node over others.
Compatibility mode enables lagacy ticker behavior if needed.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix an issue in the SMP identity distribution where the IRK for the
default identity was always distributed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix an issue with enhanced connection complete event raised by the
advertiser role. The advertiser reported that it has resolved the
the identity address of the peer, even when the peer is connecting
using it's identity address.
The host will not have the correct on-air address type i.e public.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix bug introduced by: 45da629b24
Mistakenly set the own address type to the destination address type.
Also this uses the RPA_OR_RANDOM in case local IRKs exists in the
controller.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The 'registered' flag was not cleared when 'gatt metrics off'
was called so that one was unable to register the service again.
Remove 'registered' variable that is actually not needed as there
is no tracking if service is already registered in similar
cmd_register_test_svc command. If the service is already registered,
the host will log an error.
Fixes: #17882
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The init addr should contain the on-air address used to establish the
connection. The dst address contains either the current RPA of the
unknown peer, or the identity address after identity information has
been exchanged.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Error codes are listed in header files and in the core spec as hex
values. Always print them in hex in debug for easier error code
checking.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix an issue where the generated identity was not permanently stored.
This resulted in being unable to reconnect after bonding when using
privacy, since a new local IRK was generated on reboot.
When settings is enabled the application is responsible for loading
identities and possible creating its own identities.
When settings_load is called and no identities has been created or found
in persistent storage a new identity will be created.
Since bt init has not been finalized bt_id_create will not make a call
to bt_settings_save_id. So we need to make sure that this identity will
be stored.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Logging module requires strings to be duplicated using log_strdup.
Enabling CONFIG_BT_DEBUG_KEYS caused runtime assertions in the logging
module.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Core 5.1, Vol 3, Part F, 3.3.1
"Multi-octet fields within the GATT profile shall be sent least
significant octet first (little-endian) with the exception of the
Characteristic Value field. The Characteristic Value and any fields
within it shall be little-endian unless otherwise defined in the
specification which defines the characteristic."
Fixes: GATT/SR/GAS/BV-02-C
Fixes: #17857
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Changes related to Bluetooth TSE 11068.
This is done because the current test suite does not issue
an LE Enable Address Resolution command anymore in RPA
generation tests. Makes sense now that the Bluetooth SIG has
agreed to completely decouple address resolution from
generation.
Fixes BT LL TS 5.1.0 test:
LL/SEC/ADV/BV-03-C [Privacy - Non-connectable Undirected
Advertising, Resolvable Private Address]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The call to bt_conn_security will send a SMP security request for
peripheral, and for central it will initiate LL encryption.
A call to bt_conn_security with no IO capabilities but authenticated
keys has been distributed, would succeed on central side, but fail on
peripheral side with error code -22.
The keys could have been either:
- Preprogrammed
- IO capabilities may have changed.
- OOB bonding may been used.
Fix so that Peripheral can send a security request if the bond
information is already established.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The original creates a pointer to a compiler-generated temporary that is
destroyed when the scope is exited. The pointer is stored in a structure
defined in an enclosing scope and is invalid by the point it's used.
The fix holds the structure in a variable with the same lifetime as
the pointer.
Signed-off-by: Findlay Feng <i@fengch.me>
Fix the pipeline prepare or resume dequeue loop from
overflow. Fixes premature exit of dequeue of done FIFO
which caused the pipeline to overflow due to previously
placed done is not dequeued correctly and next event not
being put back into the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This introduces a new flag (BT_GATT_SUBSCRIBE_WRITE_PENDING) which is
set when a write operation requires canceling before the parameters can
be reused.
Fixes#17534
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds a dummy cancel request which is used instead of NULL when
clearing and outstanding request thus prevent new request to take
place before a response is received while allowing the original request
to be reused.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Set advertisers state flags so that previous advertise params does not
affect the current advertiser state.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Enable use of settings system in controller and introduce settings for
company_id and subversion_number.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Make the Upper and Lower Link Layer split architecture
implementation of the controller as the default when
building Zephyr Bluetooth Low Energy controller support
in applications.
Noticeable missing feature (porting) in comparison to old
architecture implementation is, Advanced scheduling of
connection events.
The missing features will subsequently be submitted
upstream.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename the controller Kconfig option BT_LL_SW to
BT_LL_SW_LEGACY in preparation towards switch to new Link
Layer implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Conditional compile the use of Rx Pool used to dispatch ULL
context generated messages towards LL thread context, which
is presently only used in connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the conditional compile of Data Length Update event
generation on PHY Update Procedure when Data Length
Extensions are not supported.
The regression was introduced in
commit 70a89876d0 ("Bluetooth: controller: Fix missing
data length update event")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a fix to handle L2CAP start frame with payload length
of zero which otherwise sent zero length data start PDU on
air.
Relates to #17046.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed a bug related to missing reset of packet timing
restriction variable.
Fixes BT LL TS 5.1.0 test:
LL/CON/SLA/BV-55-C [Initiating PHY Update Procedure - Packet
Time Restrictions, LE Coded]
Related to #17097.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in Data Length Update procedure that caused the
connection to drop due to the implementation sending bigger
PDU before the peer has acknowledged the receipt of Length
Response PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable the Fast Encryption design and connection RSSI
measurement when CONFIG_BT_HCI_RAW is selected.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the controller implementation to perform connection
event length reservation based on the completed Data Length
Update and/or PHY Update Procedure.
This fix with avoid states/roles from stepping on each
others event length. Connection would have supervision timed
out or have stalled data transmissions due to insufficient
reserved air time.
Relates to #15171.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing generation of data length update HCI event when
effective tx and rx timings change due to PHY update
procedure.
Fixes BT LL TS 5.1.0 test:
LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI
Change]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Bluetooth address parsing has been duplicated across the different
sub-shell files. Also missing parsing of identity/resolved addresses.
Move parsing of string close to parsing to string for a symmetrical API
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move duplicate hex2bin and add bin2hex function so that application can
use the functions and avoid code duplication.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the implementation of initiator to use correct anchor
tick and remainder microseconds when sending out CONNECT_REQ
PDU and then to scheduling the first connection event. This
is a fix when initiator is in continuous scan.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The bt clear command accepts either 'all' or a bluetooth address.
If it is an LE address then type is also needed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix bug in the ported code of the connection update, when
the slave events are skipped due to other overlapping state
or role the connection update at the instant used wrong
latency calculations. This lead to connection disconnection.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Submit GATT database hash as a delayed work to prevent it being run
twice if we register dynamic services.
Signed-off-by: François Delawarde <fnde@oticon.com>
Having this option disabled, MITM flag state can be controlled by
bt_conn_security state. This option is enabled by default to not
change the current implementation behavior.
Related to SM/MAS/SCPK/BV-01-C.
Fixes#17463
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit moves the BLE GATT heart rate service from
samples/bluetooth/gatt to subsys/bluetooth/services and adds a Kconfig
entry to enable and configure the service.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit moves the BLE GATT Battery service
from /samples/bluetooth/gatt to /subsys/bluetooth/services and
adds a Kconfig entry to enable and configure the service;
when enabled, it will register itself automatically.
Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Handle optional argument UUID in bt_gatt_discover with type
DISCOVER_DESCRIPTOR, bt_uuid_cmp doesn't check for NULL pointer.
On system with MMU (nrf52_bsim) this can result in segfault.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix assert in controller checking ticker_id_prepare = 0 when
a scanner and connection are active, and the connection is
skipping events in order to resize Rx buffers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the reset of ticker_id_prepare variable to the early
return in event_connection_prepare function.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We've already got GATT services in subsys/bluetooth/services so
subsys/bluetooth/mesh is a more natural place. Aditionally this aims
to fix the Kconfig dependencies to be able to use mesh together with
BT_CUSTOM (i.e. a custom, potentially non-HCI, host stack).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Two sections are needed: bt_l2cap_fixed_chan and bt_l2cap_br_fixed_chan.
However the second one cannot be created using #define as the
preprocessor will expand it to the first before compilation happens,
sending bt_l2cap_br_fixed_chan instances in the wrong section.
This fixes commit 4e8ddfd640 ("Bluetooth: L2CAP: Make use of
Z_STRUCT_SECTION_ITERABLE").
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Port the implementation that does radio event abort due to
ISR latencies. The implementation measures if the ISR could
not meet the hard real time deadline and closes the event
early.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added interface to get Advertiser and Scanner instance
handle for use in Lower Link Layer module.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix an issue in the gatt_register routine where removing a service and
adding it again would cause the database to have non-ascending
orderdered handles numbers and lead to an incomplete service discovery.
Fix: Go through the database and look for a place where to insert
the new service.
Signed-off-by: Arthur Crepin-Leblond <arthur.crepin@proglove.de>
Renames the "Blueooth Controller Assertion Handler" to "Application
Defined Assertion Handler" to better fit the purpose of the Kconfig
option.
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
Introduce a separate buffer pool for events which the HCI driver
considers discardable. Examples of such events could be e.g.
Advertising Reports. The benefit of having such a pool means that the
if there is a heavy inflow of such events it will not cause the
allocation for other critical events to block and may even eliminate
deadlocks in some cases.
Also update all mesh samples not to specify explicit RX buffer counts
anymore. Instead, create appropriate defaults in Kconfig so that we
only need to override this in the app for cases like the bbc:microbit
with limited memory.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This event is a priority one, so it's not safe to have it use the RX
buffer pool which may be depleted due to non-priority events (e.g.
advertising events). Since the event is consumed synchronously it's
safe to have a single-buffer pool for it. Also introduce a new
bt_buf_get_evt() API for HCI drivers to simplify the driver-side code,
this effectively also deprecates bt_buf_get_cmd_complete() which now
has no in-tree HCI driver users anymore.
Fixes#16864
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
move misc/stack.h to debug/stack.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/slist.h to sys/slist.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/mempool_base.h to sys/mempool_base.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/dlist.h to sys/dlist.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/byteorder.h to sys/byteorder.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/__assert.h to sys/__assert.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move uart.h to drivers/uart.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move entropy.h to drivers/entropy.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move clock_control.h to drivers/clock_control.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move atomic.h to sys/atomic.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Log all send errors, but don't try to call e.g. prov_send_fail_msg()
since that'll almost certainly fail as well.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Mesh Profile Spec v1.0.1 | Section 5.4.2.3:
"The Provisioner and the device shall check whether the public key
provided by the peer device or obtained OOB is valid (see Section
5.4.3.1).
When the Provisioner receives an invalid public key, then provisioning
fails, and the Provisioner shall act as described in Section 5.4.4.
When the device receives an invalid public key, then provisioning
fails, and the device shall act as described in Section 5.4.4."
This is also in Erratum 10395 which is Mandatory for Mesh v1.0.
The code was already rejecting the key, however that rejection
happened only after we had already sent our public key as response,
which got interpreted as acceptance by the tester (PTS).
Fixes MESH/NODE/PROV/BI-13-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Mesh Profile Spec v1.0.1 Section 5.4.2.3: "If the public key was not
available using an OOB technology, then the public keys are exchanged
between the Provisioner and the unprovisioned device. For each
exchange, a new key pair shall be generated by the Provisioner and the
unprovisioned device."
This allows passing MESH/NODE/PROV/BV-12-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Clear the callback list once generation is complete and we've done
calling all callbacks. This lets us use bt_pub_key_gen() multiple
times, which before this patch could have resulted in a corrupt linked
list.
Also remove redundant callback dispatching from bt_pub_key_gen() since
the function checks for the PUB_KEY_BUSY flag in the beginning, i.e.
there cannot be other pending generation actions at this point in the
code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Update code to handle other users of the public key generation APIs
by fetching the current public key at the beginning of each SMP
session. This is particularly important if someone creates the (rather
odd) combination of Mesh and SMP where Mesh will regenerate a new
key pair after provisioning.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Mismatch in Public Key type will cause device to send Invalid Format
error, and treat any further PDU's as unexpected.
This affects MESH/NODE/PROV/BI-03-C test case.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Provisioning errors shouldn't cause device to close link. Upon error,
device will send Provisioning Failed PDU, and any further PDU's will
be considered as unexpected as per Mesh Profile section 5.4.4.
Also a timer is started every time device sends or receives a PDU.
This affects MESH/NODE/PROV/BV-10-C test case.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Added a fix handling L2CAP start frame with payload length
of zero which otherwise sent zero length data start PDU on
air.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated the bluetooth module to use static handlers. Removed the
old bt specific static registration.
The routine bt_settings_init() is still calling settings_init() which
IMO is not needed anymore.
Updates:
changed SETTINGS_REGISTER_STATIC() to SETTINGS_STATIC_HANDLER_DEFINE()
changed settings_handler_stat type to settings_handler_static type
removed NULL declarations
renamed bt_handler to bt_settingshandler, as bt_handler already exists.
renamed all bt_XXX_handler to bt_xxx_settingshandler to avoid any
overlap.
changed SETTINGS_STATIC_HANDLER_DEFINE() to create variable names from
_hname by just prepending them with settings_handler_.
updated all bt_xxx_settings_handler to just bt_xxx.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
The string returned by bt_uuid_str() is not in ROM so log_strdup()
must be used on it. This also eliminates the following kind of warning
messages: "<err> log: argument 3 in log message "%s: start_handle
0x%04x end_handle 0x%04x type %s" missing log_strdup()."
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use Device Tree,and in particular a new 'bt-c2h-uart' to select which
UART is being used to communicate with an external BLE Host when acting
as a Controller.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Although the Characteristic Value descriptor is required to be
immediately after the characteristic descriptor, the specification
allows for gaps in the corresponding Attribute handles. Use the value
handle from the characteristic descriptor for value reads.
See BLUETOOTH CORE SPECIFICATION Version 5.1 Vol 3, Part G section 2.5.1
(p. 2345), first paragraph.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Update the Replay Protection List handling for segmented messages to
be more in line with Figure 3.43 in Mesh Profile Specification 1.0.
This means that the RPL check and update need to be split into two
independent steps rather than always doing these together.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix iterating past the response which causes an invalid memory to be
accessed and passed over to the callback as if there were more
attributes found.
Fixes#16602
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Moved and renamed ull_entropy_get to lll_entropy_get, placed under
vendor specific ll_sw. This is needed for SW implemented entropy,
to allow vendor implementation of faster, less secure random number
generator for randomizing ADV timing.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
When advertising with different identities we need to flag any
programmed RPA as invalid if it was generated using a different
identity.
Fixes#16893
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This array was created because more than 4 bytes were needed, however
now the minimum is 8 bytes, so we can use the net_buf user data
directly.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This updates all client modules to const char processing of
setting names.
Update of peripheral_dis sample
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Reversed revised ticker implementation pending new design which resolves
the issues described in GH issues #16830.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix pending Tx control buffer leak on supervision timeout.
Queued tx buffers in LLL consists of both data and control
PDUs but only data buffers got correctly released.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This makes it safe to allocate buffer from the TX callback by freeing
the context before calling the callback which should wake up the TX
thread had it be pending on add_pending_tx.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This API had several issues:
- The parameter types and order were inconsistent with e.g.
bt_le_adv_start()
- There were no real users of num_params, which just caused increased
code size and memory consumption for no good reason.
- The error handling policy was arbitrary: if one of the
notifications would fail it would be impossible for the caller to
know if some notifications succeeded, i.e. at what point the
failure happened. Some callers might also want to make note of the
failure but continue trying to notify for the remaining parameters.
The first issue is easily fixable, but because of the other two I
think it's best we don't have this code as part of the stack, rather
require whoever needs it to do the for loop themselves. It's just a
few lines of code, so the benefit of having this in the stack was
anyway quite minimal.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Change code from using now deprecated DT_<COMPAT>_<INSTANCE>_<PROP>
defines to using DT_INST_<INSTANCE>_<COMPAT>_<PROP>.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
k_sem_give shall only be used if no callback has been set otherwise
k_sem_take was not called which can break the flow control.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Port the implementation that performed random backoff of
forced slave event scheduling.
When peer master implementation skips events, multiple
local overlapping slaves will randomize their forced
scheduling to break out of a round robin pattern increasing
the chance of synchronizing with their masters again.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
For the request:
DCID shall map to rx.cid:
'This field specifies the endpoint of the channel to be disconnected
on the device receiving this request.'
SCID shall map to tx.cid:
'This field specifies the endpoint of the channel to be disconnected
on the device sending this request.'
For the response when receiving the roles are inverted.
Fixes#16799
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Changed ticker behavior to resolve conflicts in ticker_worker instead of
in ticker_job. This allows better real-time slot allocation, as well as
allowing callbacks even if ticker node doesn't get air-time (for audio
stream housekeeping). A priority property now also allows prioritizing
one ticker node over others.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix scan requests being processed during directed advertisiments.
Directed advertise packets are not scannable
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This adds number of matches as optional parameter to gatt show-db:
> gatt show-db 2803 1
attr 0x005065f0 handle 0x0002 uuid 2803 perm 0x01
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Number of matches was not being properly handled causing the callback to
be called more than specified by the caller.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Since the bt_mesh_msg_ctx struct no longer has a size that is a
multiple of 2, the bitfields might as well be made to normal types
as this will minimize the code generated to access them.
Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
By moving the rssi value from the bt_mesh_net_rx struct to the
bt_mesh_msg_ctx struct, it will be available to applications via
the mesh op callbacks.
Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
The attribute handle used to read next attribute has to be incremented
to not loop reading the same attribute.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When trying to establish friendship the Friend must respond to the
initial Friend Poll with a Friend Update. If this initial Friend Update
response is not received the Friendship establishment process must start
again.
When starting a second Friendship establishment processes the `sent_req`
field of the `lpn` struct was left set to `TRANS_CTL_OP_FRIEND_POLL`.
This prevented the initial Friend Poll being sent out on the second
attempt. Since the Friend Poll was not sent, no timeout is set and
nothing happens ever again. No more Friendship Requests are sent.
This commit clears `sent_req` back to zero when no Friend Update
response has been received after the initial Friend Poll.
Fixes#16678
Signed-off-by: Rich Barlow <rich@bennellick.com>
Add some missing fatal asserts that need to be caught to
avoid unexpected failures in the implementation of the
architecture.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Although unlikely it is possible that a remote may attempt to send just
1 byte as the write request allows to do that:
BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part F
page 2320:
'If the attribute value has a fixed length and the Attribute Value
parameter length is less than or equal to the length of the attribute
value, the octets of the attribute value parameter length shall be
written; all other octets in this attribute value shall be
unchanged.'
Fixes#16734
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix the tx_ack mfifo count to accomodate both data and
control PDUs being acknowledged.
With out this fix, pending maximum number of data plus
control PDUs in LLL on supervision timeout asserted due to
tx_ack mfifo overflow.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Explicitly track the connection update related ticker stop
and start to avoid asserting due to ticker update being done
at the same time for compensating the master clock drift.
Relates to #11764.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added an internal ull_update_mark function to detect race
conditions while stopping ticker instances during slave
drift, disconnection and connection update.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This convenience macro wraps Z_DECL_ALIGN() and __in_section() to
simplify static definitions of structure instances gathered in dedicated
sections. Most of the time those go together, and the section name is
already closely related to the struct type, so abstracting things behind
a simpler interface reduces probability of mistakes and makes the code
clearer. A few input section names have been adjusted accordingly.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The alignment fix on struct device definitions should be done to all
such linker list tricks. Let's abstract the declaration plus alignment
with a macro and apply it to all concerned cases.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Per guidelines, all statements should have braces around them. We do not
have a CI check for this, so a few went in unnoticed.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
When reading attributes from static services their handles will not be
set and must be resolved at runtime.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Port the fix for the controller implementation to make start
encryption queueable if there is any control procedure in
progress.
Refer to #15335.
Relates to #15335, #15186, #15958 and #14636.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix disconnect command optional argument count to permit the
supply of Bluetooth Address so as to be able to cancel a
pending central initiated connection creation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix gatt indicate when conn is NULL and called with characteristic
declaration as the attribute argument. In this case the handle was not
advanced to the characteristic value. This is inconsistent with the rest
of the notify and indicate API
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Mesh Profile 1.0 Section 6.6:
"The timeout for the SAR transfer is 20 seconds. When the timeout
expires, the Proxy Server shall disconnect."
This will let qualification test case MESH/SR/PROX/BV-05-C pass
without requiring an explicit disconnect.
Fixes#16600
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This moves the processing packets of upper layers from RX thread to the
system workqueue so they have the same priority as the TX callbacks
which has the added benefit of making any protocol on top of L2CAP to
be executed using system wq stack.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Disable flow control with POSIX_ARCH since these boards tend to run
faster than normal defering the TX callback to system wq may not be
able to run before another packet is received.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes the transmission complete callbacks to run on system wq
context so they are not executed in TX thread which usually has a much
smaller, and non-configurable, stack size.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reworks bt_gatt_notify_cb to allow passing an UUID, in addition to
that it can now accept multiple notification at once as there could be
multiple instance of the same UUID the user can set multiple set of
parameters.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This make use of bt_gatt_foreach_attr_type in gatt show-db to match
attributes by UUID.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This make use of bt_gatt_foreach_attr_type to match the CCC UUID which
previously was not possible with bt_gatt_foreach_attr.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds bt_gatt_foreach_attr_type which can match attribute by UUID
and/or attribute user_data, in addition of that the user can also limit
the number of matches.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Implement HCI driver for STM32WB. It allows host to controller.
It is based on ST library allowing communication over RAM shared
bewteen chip's C-M4 and C-M0 cores.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
When removing a service using bt_gatt_service_unregister, its attributes
handles will keep their value which can cause a problem when adding the
service again to the GATT database.
When re-adding, the gatt_register routine is taking the last handle of
the GATT database to compare it with the handles of the service to be
added.
If a service has handles with a lower value than the last handle of
the database an error will occur.
If we add/remove/add the last service, no error will occur as its
handles are always greater than the last one of the database.
Instead of resetting the handles when unregistering a service and
reassign new ones we make sure that the handles of the services are
not in use in the GATT database in order to place the service back
where it used to be.
Signed-off-by: Arthur Crepin-Leblond <arthur.crepin@proglove.de>
Implements hooks to implement user protocols in ull.c
A user defined init function can now be called, this code is gated by
the CONFIG_BT_CTLR_USER_EXT define.
A user defined PDU length can now also be defined using the Kconfig
CONFIG_BT_RX_USER_PDU_LEN
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
This adds a new callback for L2CAP channels which notities whenever
status has changed so the channel user can can for example resume or
suspend sending depending on the status.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The Bluetooth menu has way too many option so this move the L2CAP
specific option to its own menu.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This prints to the output when a packet finishes transmitting:
uart:~$ l2cap send 2
Outgoing data channel 0x005166a0 transmitted
Outgoing data channel 0x005166a0 transmitted
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds a new callback to bt_l2cap_chan_ops which is called whenever a
SDU is completely sent.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This allows setting a custom pointer to be passed back to the complete
callback at expense of increasing the buffers in 4 bytes.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This changes the declaration of fixed channels to be statically defined
with use of BT_L2CAP_CHANNEL_DEFINE since fixed channels are never
unregistered.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix shell app regression due to stale tmp role implementation
not fully being removed in commit 4c77bf6194 ("Bluetooth:
controller: Remove redundant tmp role implementation").
The regression caused ticker indexes outside of allocations to
be accessed causing application faults and memory corruptions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added support for the LE SC pairing with the OOB data. The peripheral
side is only supported for now.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
The the footer structure and extra bytes (rssi, resolving index etc.)
were overlapping in memory, rx_ftr was moved into the header, but the
extra and footer are still being read from the same place, extra was
written to the end. So this avoided memory corruption, but reading extra
reads wrong information.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix compilation issues in central_hr or peripheral_hr sample when using
split LL and privacy is enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The node_rx buffer does not contain the data from the connect ind, so
copy it over.
Also back up the adv pdu chan_sel bit so that it can be used to properly
select the correct channel selection algorithm
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The node_rx buffer for the connect ind buffer is being reused to send
connection complete event, make sure all data is backed up before
reusing the buffer.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The privacy state variables rl_idx and rpa_gen was not initialized
properly, which results in connection failing to be established.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Code refactored to allow calling of a proprietary rx demux function.
This will enable implementation of proprietary protocols and
functionality that is not yet public, while keeping a common zephyr
code base.
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
A conditional block to save a directed advertising report flag was
present three times. Remove two of the blocks.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Add an event handler for HCI vendor-specific events with the
event code BT_HCI_EVT_VENDOR.
A vendor defined callback can be registered to be called when
vendor-Specific events are received in the stack. The callback can then
decode and handle the event; if not the stack will decode and handle
the event.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
When using the procedure Read By Type the response may contain multiple
instances so it needs to be parsed properly. When dealing with long
values only the beggining will be read, for the remaining bytes the
application should issue another bt_gatt_read with offset so Read Blob
procedure is used as recommended by the spec:
BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part F page 2312:
The Read Blob Request would be used to read the remaining octets of a
long attribute value.
Fixes#16107
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Port fix for #14044 from legacy LL to split LL.
The master is using unknown rsp to terminate slave side initiated
procedures that has collided with the encryption procedure initiated by
the master.
We need to handle an unknown response that is sent in unencrypted during
the encryption procedure, even though we have already set up to receive
encrypted packets.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove comment stating that UNKNOWN_RSP during encryption procedure
is a workaround.
The core spec mandates that connections should not be dropped if
receiving this control packet during encryption procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This is a pure refactoring of the k32src_wait function. It used the
following rules when refactoring:
Don't use the preprocessor when unprocessed C language suffices.
Don't undefine macro's.
Avoid global variables when possible.
Use consistent names for similiar things (hf_clock, lf_clock).
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
Fix broken master role RSSI measurement. Since the original
contribution clean up into Zephyr, the radio shorts that was
set for measuring the RSSI for master role has been broken,
as it was cleared by the radio switching code further in the
Tx ISR.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
The old footer was appended after PDU using pointer arithmetic. Now
the footer fields have been moved to the header struct, the
footer fields are now statically located in the data structure,
this is type safe and fields can be referred to by their actual
names rather than indirectly through reference to other members,
thus avoiding pointer arithmetic. Secondly, this change will pave
the way for adding other meta data in the future.
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
The 'Bluetooth' menu contains just 'config BT' and its indented
children.
Remove one menu level by removing the 'Bluetooth' menu and turning BT
into a 'menuconfig' symbol. Also change the prompt from "Bluetooth
support" to just "Bluetooth", to make it consistent with e.g. "Logging".
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This commit adds support for board: nrf52811_PCA10056.
The nRF52840 DK: PCA10056 is the recommend development kit, it emulates
the nRF52811, and can be used as a starting point for development
before moving over to a custom board.
Please note that this development kit does not support Bluetooth
Direction Finding. What is more it cannot be used with most of Arduino
shields because of PCA10056 PIN layout.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix an issue wherein local or remote initiated Connection
Parameter Request procedure would stall without generation
of LE Connection Update Complete HCI event because a local
or remote initiated PHY Update procedure has overwritten the
currently active Link Layer Control Procedure type.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
This is a workaround for IOP issue, where peer rejects LLCP Slave
Connection Parameter Request with LMP Error Transaction Collision
error code even if previous request is complete at the instant.
Relates to #15366.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the encryption setup queueing implementation to avoid
overlapping with local initiated Length Update Procedure.
Fixes#15733.
Relates to #15335, and #15186.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If the local node keeps getting bombarded with messages, it's possible
that the storage timer gets rescheduled over and over again and never
expires. Add the necessary code to only reschedule the timer if the
new deadline is earlier than an existing one.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The default values for the timeouts, as well as non-defaults in most
Mesh samples, use a higher value for the RPL than then generic mesh
storage timeout. This hasn't had any effect in practice since the code
only uses the RPL timeout if it is *smaller* than the generic one.
The original intention of the code was to use the RPL timeout,
regardless of what the generic one is, whenever the RPL is the only
thing that needs updating. Add some helper macros to track the various
groups of pending flags, and perform the appropriate checks to apply
the RPL timeout whenever it's smaller than the generic timeout, or if
there are no other items to store besides the RPL.
Fixes#15904
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This is a follow up to commit 0eaa5e53a36af498115b4e56b1ea68cc89fc29ee.
`HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE` is a base number for two PPI
channels, so two bits need to be marked in the used channel bit mask.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Fix calling bt_gatt_foreach_attr with start handle parameter set
to last static attribute handle.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Due to a protracted merge of:
5e38ed9320
the naming for the HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI changed
semnatics, now requiring use of
HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Mark the PPI channels and groups used by the Bluetooth controller
as occupied and thus unavailable for allocation through nrfx_ppi.
Add also a build time assertion that checks if these PPI channels
do not overlap with those assigned to the pwm_nrf5_sw driver
(to replace the comments in this driver that were supposed to warn
about this threat but had in fact little chance to be read by users).
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Updated the controller implementation to not feature
exchange if already done once either by local or remote peer
device in an active connection session.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
Disable the unsupported controller privacy feature in the
ULL/LLL split architecture implementation.
This feature will be enabled in the future when it has been
ported to support multiple vendor SoCs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable the support for Zephyr HCI Vendor-Specific Commands
and Event in the ULL/LLL split architecture implementation
of the controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrectly defined Rx and Tx buffer sizes. Wrong
calculation allocated more memory than necessary.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Kconfig default values for ULL and LLL execution
priorities that caused build warnings when ranges changes
based on other priority values being selected.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect data type used in calculation of slot_us
detected by compiler, and reported as possible integer
overflow.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect conditional compilation that caused compile
error when lll_scan structure did not contain connection
context included which is needed only for central role.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the missing reset of Encryption Procedure state when the
peripheral responded with error reason as pin or key missing
which otherwise caused connection disconnection on next
reception of data or control packet.
Relates to #15570, and #15727.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is a workaround for IOP issue, where peer rejects LLCP Slave
Connection Parameter Request with LMP Error Transaction Collision
error code even if previous request is complete at the instant.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
Increase the resolution of advertising random delay from
1 ms unit to 1 ticker unit.
Relates to #10289, #10391, and #10398.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added prompt to BT_CTLR_RX_PRIO_STACK_SIZE, allowing vendor specific
configuration of high priority Rx thread stack size for
!SOC_COMPATIBLE_NRF.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix XTAL advanced feature by adding the missing
implementation to calculate and, retain or release the XTAL
clock source after a Bluetooth state or role is stopped.
Fixes#15817.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to toggle GPIO Debug pins on HFCLK
request and release by the controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement a lower ISR latency ULL processing design. Instead
of looping use ISR/mayfly tail-chaining to process
successive ULL messages.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implemented ULL to yield from processing in an infinite loop
if current PDU being handled is deferred.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing BT_CTLR_FILTER conditional compilations that
cause compile errors when device whitelisting feature is
disabled in builds.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Renamed function vendor_cmd_handle to vendor_cmd_handle_common for
shared vendor commands. This allows vendor to implement
vendor_cmd_handle, containing both common and specific handling.
Signed-off-by: Morten Priess <mtpr@oticon.com>
* Rename the stack local 'done' to 'evdone' so as to disambiguate from
MFIFO_DEQUEUE_PEEK(done) which is actually 'mfifo_done'.
* add comment on ull_slave_done
* add comments to addr_us_get
* add comments to HCI_CLASS
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Fix the missing reset of Encryption Procedure state when the
peripheral responded with error reason as pin or key missing
which otherwise caused connection disconnection on next
reception of data or control packet.
Relates to #15570.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
settings_read_cb is defined to return ssize_t and not size_t. This
also eliminates several Coverity warnings.
Fixes#15765Fixes#15768Fixes#15771Fixes#15774Fixes#15778
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This makes use of BT_GATT_SERVICE_DEFINE to statically define services
for services that are not required to be dynamically registered.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reintroduces support for static service in the form of a new API,
BT_GATT_SERVICE_DEFINE, and changes the internal services (GAP/GATT)
to be defined as const as they are never register/unregistered.
Internal service needed to be renamed in order to keep the same order
as before since the section elements are sorted by name.
The result is the following (make ram_report):
before:
gatt.c 572 0.66%
cf_cfg 32 0.04%
db 8 0.01%
db_hash 16 0.02%
db_hash_work 32 0.04%
gap_attrs 180 0.21%
gap_svc 12 0.01%
gatt_attrs 160 0.18%
gatt_sc 80 0.09%
gatt_svc 12 0.01%
sc_ccc_cfg 32 0.04%
subscriptions 8 0.01%
after:
gatt.c 210 0.24%
cf_cfg 32 0.04%
db 8 0.01%
db_hash 16 0.02%
db_hash_work 32 0.04%
gatt_sc 80 0.09%
last_static_handle 2 0.00%
sc_ccc_cfg 32 0.04%
subscriptions 8 0.01%
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix the nRF52840 Coded PHY radio timings based on testing
with conformance tester.
Fixes the following conformance tests:
LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI Change]
LL/CON/MAS/BV-54-C [Slave Receiving Data, LE Coded, CI Change]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the regression in Coded PHY CI change implementation
introduced by reverting the commit 9d1ca9c390 ("Bluetooth:
controller: remove redundant PPI channel and TIMER CC").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Added Kconfig BT_MAYFLY_YIELD_AFTER_CALL to support vendor requirement
of invoking all outstanding mayflies for a given callee in
mayfly_run().
Signed-off-by: Morten Priess <mtpr@oticon.com>
In ull.c ll_rx_get, a configuration without CONFIG_BT_CONN would
sometimes return an uninitialized node_rx.
In ull_scan.c, the scanning channel was not initialized to 0 (37). This
would cause new scanning to start at random index (0,1,2).
Signed-off-by: Morten Priess <mtpr@oticon.com>
Add defines to support updated slot reservation calculation in advertise
Note: Numbers used in added defines are subject to HW specific tuning
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Added a new define (EVENT_IFS_US) to pdu.h - this is now used instead of
previous TIFS_US from vendor specific header
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Correct slot reservation time calc for legacy advertise
Add dependency on data lengths for advertise and scan response
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Fix regression by the addition of CONFIG_BT_CONN conditional
compilation that disabled the advanced clock (crystal)
oscillator management when only observer and/or advertiser
states supported in the controller build.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Major changes are:
- Expose settings backend API to enable custom backend support.
- Add a new CONFIG_SETTINGS_CUSTOM backend to allow registering a custom
backend.
- Change api of the handlers h_set() routines to allow for
backend-specific read callbacks.
- Provide a customizable settings_backend_init() routine for custom
backends.
- Move runtime settings support to be its own backend.
Signed-off-by: François Delawarde <fnde@oticon.com>
Aligned format specifiers for the Bluetooth Host. Now, the format
specifier matches the variable type.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
This patch adds support for Read Using Characteristic UUID which is one
of the procedure to read the characteristic value especially when the
client only knows the characteristic UUID and does not know the handle
of the characteristic.
Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
Added implementation to pause data PDU transmission during
PHY update procedure in order to comply to BT Spec. v5.1
Vol.6, Part B, Section 5.1.10.1 Packet transmit time
restrictions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor refactoring to move PKT_US into ULL internal header,
and rename ull_conn_allowed_check to ull_conn_llcp_req.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Ported implementation of Data Length Update Procedure to
ULL/LLL architecture of the Link Layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This introduces set command to GATT which can be used to write local
attributes:
uart:~$ gatt set 0x000b 62 6c 61 68
attr 0x004235a8 uuid 2a00 perm 0x09
00000000: 62 6C 61 68
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This introduces get command to GATT which can be used to read the
local attributes:
uart:~$ gatt get 0x000b
attr 0x004235a8 uuid 2a00 perm 0x09
00000000: 74 65 73 74 20 73 68 65 6C 6C
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This enables locating specific attribute in the database:
uart:~$ gatt show-db 0x2a00
attr 0x004235a8 handle 0x000b uuid 2a00 perm 0x09
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
General MIC fix for AAD lengths up to 14 bytes.
This case doesn't concern the mesh stack because it uses 16 bytes.
Signed-off-by: Reham Tarek <reham.tarek@si-vision.com>
This stores the database hash and check if it has changed on commit
skipping service changed if hash matches.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Custom handlers without any arguments don't since there is a check for
argc > 1, to fix this behavior removing the check.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If handle is over the range end return since handles are always placed
in ascending order.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reduces bt_gatt_foreach_attr complexity (O(n)) so it can skip
ahead when the start handle is not within its service handles.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
It may be very important information for the developer if scanning
fails to start or stop, so add proper logs. There's no need to log
EALREADY errors, since the mesh stack doesn't track the current scan
state and simply relies on the under lying GAP layer to return this
error if the desired state is already set.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
bt_gatt_connected should be only called, when there is no
connection error. Change fixes problem with receiving notifications
before connection.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
The commit 8d0ef1eb85 attempted to fix
test case MESH/SR/HM/CFS/BV-02-C, however inadvertently ended up
introducing a hidden bug. This bug was unearthed thanks to commit
686f5c79cf. We have to keep always track
of the FastPeriodDivisor state whether we're using it (faults > 0) or
not (faults == 0). Introduce a boolean field to the model publication
that's used to indicate whether the FastPeriodDivisor should be
applied or not, instead of zeroing the divisor when there are no
faults (this would cause wrong behavior when faults appear again).
Additionally, the PTS seems to require that we wait until the end of
the existing period before sending the next Health Current Status,
rather than sending it immediately when the fault count changes.
Fixes#15365
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix the controller implementation to make start encryption
queueable if there is any control procedure in progress.
The context related to encryption procedure is now shared so
that it will be used after the ongoing procedure completes.
The fix here maintains the old functionality of serializing
the queued data and LL Encryption Request PDU, so that data
queued before start encryption is acknowledged.
Fixes#15012.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement the Controller counterpart to CONFIG_BT_WAIT_NOP so that it
issues a NOP Command Complete event after booting up, to signal to the
Host that it is ready to receive HCI traffic.
Fixes#15333
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When a device is considered unpaired any configuration set in Client
Features shall also be removed.
Fixes#15329
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Send unknown rsp instead of asserting when encryption related control
PDUs are received in the wrong state.
This would allow an attacker to intentionally crash the device.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Stop the Length request procedure from initiating during the encryption
procedue. This would cause the peer to disconnect the link with error
code LMP_TRANSACTION_COLLISION
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the encryption procedure pending and start it as soon as
there are no other procedures running.
This allows the Host to enqueue the encryption procedure, and not
get disallowed command because a different LL procedure is active.
Fixes#15012
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When calling bt_unpair() the keys were removed from flash, however a
pointer was left to the invalidated keys in case there was an existing
connection. This would then lead to a bogus entry being stored in
flash for a zero-address peer device. Fix this issue by clearing the
conn->le.keys pointer in the bt_unpair() function.
Fixes#15325
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The bt_mesh_fault_update() API is meant for updating the publication
message and sending it out to the network, however it was missing the
necessary call to health_pub_update() which is responsible for
updating the publication message.
Fixes#15300
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixes:
.../zephyr/subsys/bluetooth/shell/bt.c:906:12:
warning: 'cmd_chan_map' defined but not used [-Wunused-function]
Signed-off-by: Jim Paris <jim@jtan.com>
Persistent storage is done. So are the configuration and health
clients. We're also not actively looking to optimize the provisioning
protocol & mesh networking memory usage anymore.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier. Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.
By default all files without license information are under the default
license of Zephyr, which is Apache version 2.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The fix done in #14938 introduced a later assert when raising an HCI
event for the procedure that was terminated during the procedure
collision handling. This assert happens because the unknown rsp
has information that is needed when raising the event.
Solve this by copying the scratch packet into the node buffer so that
we keep the data.
Fixes#15183
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename reserved function names in the subsys/ subdirectory except
for static _mod_pub_set and _mod_unbind functions in bluetooth mesh
cfg_srv.c which clash with the similarly named global functions.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
Rename reserved function names in drivers/ subdirectory. Update
function macros concatenatenating function names with '##'. As
there is a conflict between the existing gpio_sch_manage_callback()
and _gpio_sch_manage_callback() names, leave the latter unmodified.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
The spec allows to set to no specific value with use of 0xffff.
As this still enables entering values in the invalid range, 3200-65535
for min/max interval, this adds the necessary build checks to prevent
values within this range to be used and at same time check if min
interval is not bigger that max interval.
Fixes#15017
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In order to advertise directed to a privacy enabled central the
initiator field of the directed adv packet needs to set to an RPA.
To instruct the controller to use an RPA in the initiator field own
address type should be set to either 0x02 or 0x03.
Since it is not certain that a remote device supports address resolution
of the initiator address we add an option to turn this on and give the
application the responsibility to check if peer supports this.
Fixes#14743
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
In order to accept string of the same size entered in
CONFIG_BT_DEVICE_NAME_MAX an extra byte must be allocated to guarantee
it will always be NULL terminated.
Fixes#15067
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
There's no need to track this info in prov.c since hci_core.c is
already doing it. Just query hci_core.c always using the
bt_pub_key_get() API.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If PB-GATT is disabled while there are connected clients, those
clients must be disconnected. Add a 'disconnect` parameter to
bt_mesh_proxy_prov_disable() to handle scenarios when we don't want to
disconnect (e.g. right after successfully finishing provisioning) and
tose where we do want to disconnect (e.g. user requesting to disable
the provisioning bearer).
Also make sure that we always update advertising, so that a stale
advertising set isn't left in the controller.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If both PB-ADV and PB-GATT are supported, we need to properly
re-initialize variables such as link.rx.prev_id and (particularly
importantly) link.rx.buf. If we don't do this it may lead to the
following fault when trying to reprovision again:
***** USAGE FAULT *****
Illegal use of the EPSR
***** Hardware exception *****
Current thread ID = 0x20001f10
Faulting instruction address = 0x0
Fatal fault in thread 0x20001f10! Aborting.
Fixes#14928
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Remove unnecessary const keywords (the entire struct is const) and use
bool instead of u8_t for the require_link member.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Using settings_delete() makes it much easier to understand what the
code is doing, and actually also reduces the amount of code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add error checking, remove redundant code, and improve the logging for
settings related functionality.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The read() callback of attributes returns ssize_t and not size_t. Fix
this, which also fixes a Coverity warning.
Fixes Coverity CID 197457
Fixes#14958
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The convention in the code is to use the appropriate address copying
functions instead of direct assignments. Even when a specific copying
function doesn't exist the convention is to use memcpy.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The master is using unknown rsp to terminate slave side initiated
procedures that has collided with the encryption procedure initiated by
the master.
We need to handle an unknown response that is sent in unencrypted during
the encryption procedure, even though we have already set up to receive
encrypted packets.
Fixes#14044
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Updating the Resolvable Private Address when advertising and
active scanning in progress fails and clears the RPA_VALID
flag; making the next bt_le_scan_start while continuing to
advertise to fail.
This is fixed by keeping the RPA_VALID flag remain set.
Stopping and starting active scanning to update RPA can be
implemented in a separate commit.
Fixes#9463.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When building ticker.c from the shell, it requires include access to the
Nordic HAL, so add the relevant folder to the include path.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
With BT_HOST_CRYPTO, advertising stack size could be overflowed,
increase size to 1024 when BT_HOST_CRYPTO is enabled.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Command scan fixed in the way that it can take one mandatory parameter
and one optional. Previously it accepted only 2 mandatory parameters.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Removed automatic argument count checking in bt command. Now
it is possible to print a message that extra argument is not
recognized.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Several public APIs were not checking the BT_DEV_READY flag, which
could lead to hard-to-debug behavior, particularly when the stack
lacks an identity address. Add the appropriate checks to these APIs.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The treatment of the BT_DEV_READY flag was broken when used together
with BT_SETTINGS. The flag would get set even though the stack was
still in a partially initialized state. Even worse, for central role
the stack would potentially try to initiate passive scanning without
having an identity address.
Refactor the code that sets the BT_DEV_READY flag (among other
initialization) into a separate bt_finalize_init() helper function and
call it when the settings have been loaded. Also clarify the warning
message given to the user in case settings_load() needs to be called.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix a bug where the controller would use the length
field of the advertisement packet before checking
if the length field was valid.
It is possible that the controller has received a packet
that passes CRC check but has a length field that is invalid.
This would cause the scanner to overwrite the scan report
buffer
Fixes: #14741
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The code for clearing model bindings and subscriptions was flawed in
that proper "cleared" entries were never stored in settings. The code
must pass 0 and NULL to settings_save_one() in case the entry is
desired to be cleared.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code was storing a "cleared" entry in storage for every model,
regardless of them having any subscriptions or not. Update hte
mod_sub_list_clear() function to return a "cleared entries" count so
that the calling code can decide whether any action is needed or not.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Remove redundant "val (null)" logs and add a few missing BT_DBG()
calls to make the tracing of storage handling easier.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The le_conn_param_req() function was missing a return statement in
case of a failed connection lookup. This could lead to replying to the
connection parameter request twice as well as passing NULL to
bt_conn_unref(). The latter issue also triggered a Coverity warning.
Fixes CID 196638
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
BT_WARN() should only be used for log messages that may indicate a
problem. However, the controller HCI code was using it for messages
that were of a pure debugging/informational nature. Convert these to
BT_DBG() instead - this should hopefully also help avoid unnecessary
user questions of seemingly alarming log messages.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The 2M and Coded PHY bit should not be set when the
PHY update procedure is not supported.
Fixes#14658
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Peer side will disconnect if controller initiates
Encryption procedure before PHY update procedure
has finished.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix bug in LL encryption procedure, controller was
using the wrong pointer to connection state.
Function event_enc_prep is called from
slave_event_prepare, where _radio.curr_conn has not
been assigned yet.
The connection ended up sending LL_START_ENC_RSP
unencrypted, resulting in disconnect on the peer
side with reason MIC failure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix implementation to correctly return the configured
default Tx Power Level.
Also, fix the missing use of RADIO_TXP_DEFAULT in the new
ULL/LLL implementation of Advertiser and Observer states.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation in controller to use range delay
alongwith the active clock accuracy jitter.
Range has been hard coded to 1000 meters, suffices
modules out in the market.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Due to regression the option to enable PHY Update Procedure
on proprietary 2M PHY for nRF51 series was disable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Workaround from asserting when Rx PDU buffers from pool
needing resize is acquired by another connection. By
skipping the connection events to give some headroom for
the host to process the Rx packets and eventually make the
pool available for resize.
Fixes#11841.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There's a BT_DBG that will output the value of pub_addr before its ever
set to anything. Remove output of pub_addr from BT_DBG().
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This adds BT_GATT_DISCOVER_ATTRIBUTE which can be used to discover any
type of attribute in a given range.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Those are not considered Descriptors and shall be discovered with
use of BT_GATT_DISCOVER_CHARACTERISTIC.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When discovering descriptor Find Information procedure is used which
does not allow any filtering by the server so it will return all
attributes in the given range including services and characteristics.
Fixes#14265
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Maybe this is some "just in case" thing that got copied around. There's
no need to have a blank line at the beginning or end of Kconfig files.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Use reverse order for bitfields on big-endian architectures. Treat
all PDU data as little-endian and add conversions as needed. Treat
access address as 4-byte value instead of u32_t to avoid flipping
endianness.
Signed-off-by: Wolfgang Puffitsch <wopu@oticon.com>
By specifying the controller directly when selecting the default
BT_HCI_TX_STACK_SIZE, an external controller may rely on the final
default value when none of the in-tree controllers are used.
The value is increased to 1024 to accomodate the current worst-case
stack size.
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
This moves the vendor-specific HCI command/event configuration
definitions out of bluetooth/common into bluetooth. This allows
the controller itself to indicate its support for vendor-specific
commands/events.
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
Update reserved function names starting with one underscore, replacing
them as follows:
'_k_' with 'z_'
'_K_' with 'Z_'
'_handler_' with 'z_handl_'
'_Cstart' with 'z_cstart'
'_Swap' with 'z_swap'
This renaming is done on both global and those static function names
in kernel/include and include/. Other static function names in kernel/
are renamed by removing the leading underscore. Other function names
not starting with any prefix listed above are renamed starting with
a 'z_' or 'Z_' prefix.
Function names starting with two or three leading underscores are not
automatcally renamed since these names will collide with the variants
with two or three leading underscores.
Various generator scripts have also been updated as well as perf,
linker and usb files. These are
drivers/serial/uart_handlers.c
include/linker/kobject-text.ld
kernel/include/syscall_handler.h
scripts/gen_kobject_list.py
scripts/gen_syscall_header.py
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
subsys/bluetooth/common/Kconfig and subsys/bluetooth/host/Kconfig are
'source'd within 'if BT' and 'if BT_HCI', in subsys/bluetooth/Kconfig,
so there's no need to add those dependencies within them.
'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.
Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Check the return value of mayfly_enqueue() and assert if not successful.
Coverity ID: CID 190991
Fixes#13833.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Inside ll_test_end(), result of lll_clk_off() is not checked
which might result in releasing resources acquired for radio.
Coverity-CID: 190954
Fixes: #13861
Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
Due to regression the option to enable Data Length Update
Procedure for nRF51 series was disable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Some old peer central controllers respond with Unknown
Response PDU to our local Slave Initiated Feature Request
after the peer initiated the Encryption Setup Procedure.
The peer has voilated the Bluetooth Specification by sending
the Unknown Response during the Encryption Setup Procedure,
but as a workaround to IOP with such controller our local
implementation is updated to not disconnect the connection
but accept the voilating Unknown Response PDU.
Relates to #12362.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
CCC cfg value was not being cleared on disconnection of a non bonded
peer if another peer was connected, had non zero value and occurred
earlier in the ccc cfg array.
Signed-off-by: Nick Ward <nick.ward@setec.com.au>
Variable evt_prop could be used without being initialized. This problem
was spotted by coverity.
CID 190970
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This makes use of BT_GATT_CCC_MANAGED so instead of having a custom
attribute which is not managed by stack.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This consolidates code for finding a CCC config in a helper function
thus reducing the amount of duplicated code.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds another helper macro called BT_GATT_CCC_MANAGED which can be
used to set 2 new callbacks:
- cfg_write: Which application can set if it wants to manage writes to
CCC configuration.
- cfg_match: Which application can set if it wants to manage matching
CCC configuration when notifying/indicating.
BT_GATT_CCC_MANAGED retains the ability of saving peer configuration
on storage making it useful for clients which are only interrested in
managing the CCC configuration but not the storage itself.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Some more were added since the cleanup pass in June 2018. See e.g.
commit 2d50da70a1 ("drivers: ipm: Kconfig: Remove redundant 'default n'
properties") for a motivation. It also avoids people wondering whether
or not they need to put in 'default n'.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Same change as in commit 8cf8db3a73 ("Kconfig: Use a short, consistent
style for prompts"), fixing stuff that got introduced since then.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Prevent temporary strings from being printed incorrectly if they go out
of scope before being processed by logger.
Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
The bt_settings_encode_key() cannot know if the given path pointer is
on the stack or not, so the only safe way to pass it to the logger is
by using a log_strdup() call. Not doing this will likely cause
corrupted strings to show up in the log output.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
It is planned to deprecate SHELL_CREATE_STATIC_SUBCMD_SET macro
which is replaced by SHELL_STATIC_SUBCMD_SET_CREATE.
Additionally, removed irrelevant comments about alphabetical
ordering which is no longer needed.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
mem_pdu_rx is not runtime resized meaning PDU_RX_SIZE_MIN is no longer
relevant.
Dynamic resizing was a left-over from the old bt controller.
Its size field was only ever set to PDU_RX_SIZE_MIN.
PDU_RX_SIZE_MIN only accounted for advertise PDUs.
So we remove size field from mem_pdu_rx.
However, the rest of the BT controller expects to be able to pull
RX_CNT-number of valid nodes from the pool at init/reset (rx_alloc)
time. This will fail unless we inflate the capacity by one.
To avoid inflation-by-one, mem_* would have to be rewritten to avoid
always-one-extra pattern.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Refactor PDU_RX_POOL_SIZE into its constituents and name each term.
No functional change expected.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Fix a bug in Encryption Procedure feature conditional
compile which prevent any data transfer when the feature was
disabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Changed the order of Bluetooth callbacks. Now the connected callback is
received before CCC changed callbacks.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
In certain configurations, such as with MPU support enabled, the
consumption of the advertising thread has gone slightly up. In some
case it was seen to overflow by some 48 bytes. Let it always be 786,
like it was so far with CONFIG_BT_HOST_CRYPTO.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
* Slight tweaks to memq comments,
* Document most of mfifo through commentary.
No functional change expected.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
* Clarify certain functions and data structures in upper link layer.
* Disambiguate node rx event done, add commentary.
MFIFO_DEQUEUE macro does string concatenation.
Thus MFIFO_DEQUEUE(done) does not refer to done (the stack local), but
mfifo_done.
No functional change expected.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
ull_ref_inc already existed, but not ull_ref_dec.
No functional change expected.
Consistency is preferred due to code navigation.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.
This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.
All files that use these macros have been updated.
Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
Rename ull_tx_ack_put to ll_tx_ack_put as ack is enqueued
into LL thread context from ULL ISR context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move PKT_US definition from LLL header file to ULL header so
as to share it across vendors.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix compile error due to missing conditional compile of
connection related code when selecting only observer state
support.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Replace generating CONFIG_ symbols with DT_ symbols for chosen
properties like 'zephyr,console' or 'zephyr,bt-mon-uart'. We now use a
kconfigfunctions (dt_str_val) to extract the info from dts into Kconfig.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This adds BT_GATT_ENFORCE_CHANGE_UNAWARE option which when enable
returns -EAGAIN when notifying or indicating if the client is
change-unware to conform with following statement on the spec:
'BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G page 2350:
Except for the Handle Value indication, the server shall not send
notifications and indications to such a client until it becomes
change-aware.'
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G page 2405:
'For clients with a trusted relationship, the characteristic value
shall be persistent across connections. For clients without a
trusted relationship the characteristic value shall be set to the
default value at each connection.'
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This implement Robust Caching which is mandatory when Database Hash and
Service changed Characteristics are supported.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This implements the Database Hash characteristic which generates a hash
with the contents of certain attributes. The generation of hash is
usually offloaded to the systemwq using a delayed work so that when
application register multiple services only one hash needs to be
calculated.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The Client Supported Features characteristic is used by the client to
inform the server which features are supported by the client.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds BT_GATT_CACHING option which can be used to enable support
for Client Supported Features and Database Hash characteristics.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When optimizations are disabled more RAM is used and we get a stack
overflow on BT_HCI_TX_STACK_SIZE. To rectify this, increase the stack
size when CONFIG_NO_OPTIMIZATIONS.
This does not scale well, and will have to be replaced by a a more
general solution eventually, but in the mean time it follows the
existing best practice established by the GCOV infrastructure in
commit e908ea9aa5
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Translate HCI error codes to POSIX error codes in order to be able to
distinguish reason of connectable advertising start failure.
Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
Return meaninful HCI error when it's not possible to start advertising
because of maximum number of connections already in use.
Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
Remove the redundant proof of concept template temporary
role implementation from the repository.
Relates to #12860.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
During regression testing of PA/LNA feature it was noticed
that compilation failed due to missing port of the code
conditionally compiled for PA/LNA feature.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Convert the hci_spi sample to get the SPI and GPIO settings from Device
Tree instead of Kconfig.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
The Bluetooth 5.1 specification was recently released, and has a new
version identifier (10) assigned to it in the Bluetooth Assigned
Numbers.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Convert the remaining places of the host stack where
net_buf_pull_mem() makes more sense than net_buf_pull().
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Take advantage of the new net_buf_pull_mem() API, and refactor the
events from long switch statements into (const) handler tables. This
helps reduce code size and makes it cheap to add proper checks/asserts
for having sufficient data in the buffers coming from the controller.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
It's more natural to use net_buf_pull_mem() for the HCI command
parsing. Note that this also fixes a bug in hci_cmd_handle() where it
would previously check for sufficient parameter length with the
command header still included in the buffer (which it shouldn't have
been).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Sending a model publication message could fail e.g. if there are no
buffers available, however this doesn't mean that we should stop doing
periodic publishing indefinitely. When an error occurs, make sure to
call the publish_sent() function so that the periodic publishing timer
gets resubmitted if necessary.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In some cases the Friendship & Low Power Node features aren't
available or feasible, however power saving is nevertheless required.
This patch introduces two new APIs to suspend and resume the Mesh
network. Currently, what this impacts is the LE scanning, the
ability to allocate new outgoing buffers, as well as the model
publishing, beacon and heartbeat timers.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Tracking of the BT_MESH_VALID flag and the PB-GATT state was rather
fragile. Add proper error returns to the various GATT service enable &
disable handlers, and toggle the BT_MESH_VALID flag in a single file
(main.c). Use the newly added error returns to ensure that we don't
re-enable PB-GATT if it wasn't already enabled from before.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There's already a flags member in the bt_mesh context, so take
advantage of that for any boolean members that have so far been
bit-fields. This should produce more efficient code, also for the
sequence number that's now its own u32_t.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Build fails in smp.c:3942 if BT_SMP_SELFTEST is enabled,
sign_test uses smp_sign_buf which only available for BT_SIGNING.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Fix the control procedure context safety by adding checks in
thread mode control path to detect pre-emption by interrupt.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is a squash merge of commits introducing the new split
Upper Link Layer and Lower Link Layer architecture of the
Bluetooth Low Energy controller.
This introduces a new, improved Link Layer based on the
concept of split responsibilities; The Upper Link Layer
(ULL) is in charge of control procedures, inter-event
scheduling and overall role management. The code for the
ULL is shared among all hardware implementations. The
Lower Link Layer (LLL) is responsible for the intra-event
scheduling and vendor specific radio hardware access.
The communication between ULL and LLL is achieved through
a set of FIFOs that contain both control and data packets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Signed-off-by: Wolfgang Puffitsch <wopu@oticon.com>
Signed-off-by: Morten Priess <mtpr@oticon.com>
Preliminary work done towards Mesh extensions on the old LL
architecture implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Missing updates to old architecture implementation towards
introduction of new ULL LLL architecture.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactored the internal LL interfaces to have return value
to match the HCI error code u8_t data type.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This adds write-without-response-cb command which can be used to
confirm the transmission of the PDU using bt_gatt_write_without_rsp_cb.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds bt_gatt_write_response_cb works similarly to
bt_gatt_notify_cb which can take a callback to be called when the PDU
is considered transmitted over the air.
Note: This can also be used to disable the ATT flow control which would
blocks sending multiple commands without wainting their transmissions.
Fixes#11558
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit renames the nrf5_clock_control.h and
nrf5_clock_control.c files to nrf_clock_control.h and
nrf_clock_control.c, respectively, as they are used
in nRF9160 builds, as well.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit renames the CLOCK_CONTROL_NRF5 Kconfig symbol to
CLOCK_CONTROL_NRF. The change is required to aleviates confusion
when selecting the symbol in nRF9160 SOC definition.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
The current stack consumption with the H4 driver on qemu_x86 is as
follows with a change from 256 to 512:
usage 396 / 512 (77 %)
Increase the default for this configuration, as well as other similar
configurations. Set the fallback default to a higher value as well.
Fixes#12429
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The msg->prev_addr is already stored in frnd->clear.frnd, so there's
no need to have an extra stack variable for this (in the form of
prev_addr).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use fixed-width type instead of enum for field op in struct
ticker_user_op to avoid struct layout differences between
compilers. Also make check whether struct sizes match size definitions
build-time asserts.
Signed-off-by: Wolfgang Puffitsch <wopu@oticon.com>
Since `str` is the output buffer, `bt_hex_real` should limit its output
length according to the `str` size, not the `hex` size.
Signed-off-by: Jiahao Li <reg@ljh.me>
Currently, when handling a Friend Request message with `prev_addr` set,
we look up existing friend entry using `prev_addr` as the address.
However, `prev_addr` is the address of the requesting node's previous
friend, NOT the address of the requesting node itself. Therefore, we
should always look up existing friend entry using `rx->ctx.addr` as the
address.
Signed-off-by: Jiahao Li <reg@ljh.me>
Adds documentation-commentary to some infrastructure used by the LL.
It is a long-term effort to better document the LL.
Notably ticker and mayfly require more documentation; this will be
done later.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Changes to Bluetooth shell application related to the
controller split architecture preparation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Preparation to introduce the Upper Link Layer (ULL) and
Lower Link Layer (LLL) split architecture.
- Move SoC dependent HAL to vendor specific folder.
- Preparation to split data structures into ULL and LLL
types.
- Added more role and state conditional compilations.
- Added some work-in-progress implementation of advertising
extensions, will be used as inspiration in the new split
architecture work.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This fixes usage of an uninitialized variable (to_store) as introduced
by commit bfad2a0.
Fixes#12314
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When using bt_gatt_discover with BT_GATT_DISCOVER_CHARACTERISTIC the
read callback would be set to bt_gatt_attr_read_chrc which would attempt
to access the next attribute which in this case would not be set since
the value attribute is no fetched by the discovery, the spec actually
omit the value handle saying it should always be the first attribute to
appear after the characteristic thus we can assume it to be handle + 1.
Fixes#12159
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix an issue wherein local or remote initiated Connection
Parameter Request procedure would stall without generation
of LE Connection Update Complete HCI event because a local
or remote initiated PHY Update procedure has overwritten the
currently active Link Layer Control Procedure type.
Signed-off-by: Vinayak Kariappa Chettimada <vinayak.kariappa@gmail.com>
Changed number of valid arguments from two required to
one required and one optional.
Command can be called with required <type: off, on, scan, nconn>
and optional <mode: discov, non_discov>".
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Function name prefix is now configurable (by default only debug
messages are prefixed) and log macros can be simplified.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix in the do_ecb() function
In real HW this function busy waits for the ECB to be done.
In simulation with the POSIX arch a WFE was added to avoid that
infinite loop.
But this function is called with the ECB interrupts disabled.
In normal builds other interrupts will awake the CPU very soon
after entering into that WFE, and the problem was not discovered.
But, in controller only builds, during some conformance tests,
the loop will hang as no other interrupts are coming.
=> Replace the WFE() with a k_busy_wait (only for simulation)
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Fix channel map update procedure implementation's handling
of different transaction collision by not asserting but
disconnecting the connection due to invalid behavior by
peer implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Both "store" and "clear" are verbs, so putting them after each other
is just confusing. Use "clean" consistently when clearing settings
entries.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code need to be align after introduction of stream codec to
setting serialization subsystem.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The Code need to be align after introduction of stream codec to
setting serialization subsystem.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Added BT alisa for dumping binary data to the logg.
The macro will be useful for BT as reworked settings supports r/w of
raw data - which will be widely leveraged in bluetooth storage alignment
to reworked settings.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
1. Created new shell module: shell_help.
2. Simplified command handlers with new shell print macros.
3. Removed help functions from command handlers.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Removing help "options" from shell API.
Currently SHELL_OPT macro is not used by users. What is more
commit: a89690d10f ignores possible options created in
command handler by the user. As a result they are not printed
in help message.
Second, currntly implemented "options" in command handlers options are
implemented without SHELL_OPT macro.
And last but not least this change will allow to implement
help handler in a way that user will not need to think about calling
functions printing help in a command handler.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Explicitly track the connection update related ticker stop
and start to avoid asserting due to ticker update being done
at the same time for compensating the clock drift.
The compensation related ticker update failure in this case
can be safely ignored as new anchor point is used anyway
at the instant of the connection update.
Fixes#8796
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When we're acting as a Friend for an LPN, we need to consider all
elements of the LPN. The information of how many elements the LPN has
is provided in the Friend Request message, however until now the code
did not do anything with this information.
Fix the issue by tracking the number of elements for each LPN and
update the unicast address matching code to take this into account.
Fixes#11731
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit defines a default log level at bluetooth subsystem
level when module log level is not defined.
Prior to this change, the bluetooth subsystem would use
the firmware default log level.
Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
There is not an easy way to relate an application's user_data to a
connection. One way is to save a pointer to bt_conn in the
application's user_data array upon connection establishment.
Each connection related callback function will have to loop for all
user_data and compare the saved pointer to the passed bt_conn
pointer. This is inefficient if there are many callback activations
during the connection.
This change makes the internal bt_conn mapping function accessible to
applications in conn.h. The function name is changed to
bt_conn_index() to clearly indicate that the function returns an
index of an array.
Add an ASSERT to catch illegal parameter.
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
When removing a peer from a CCC, it also needs to be removed from
the attribute `cfg`.
Not removing it would create a shortage of `cfg` that could
prevent new host to pair to the BLE device.
Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
CCC settings was not removed when unpairing all keys.
It means CCC settings were still present in flash and were
loading at bluetooth initialization time.
Loading these orphan CCC settings would fill `bt_gatt_ccc_cfg`
configurations and would prevent to add new CCC when pairing
with a new device.
Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
Accourding to Bluetooth specification the Service Changed
Characteristic shall not have its handle changed once it has been
bonded, so this moves the GATT service to be the very first service
registered that way it is guaranteed that it won't change even if
device is flashed with a different configuration which end up changing
the handles after it.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
It is related to b904ad387f.
This fixes checking ECDH related events in event mask.
If ECDH support is disabled in host, there is no need to check
if those are supported in the controller.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Some backends may actually contain the same key multiple times so the
code needs to check if there is already a ccc_cfg for an address before
attempting to use one that is unallocated.
Fixes#11409
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If there are no CCC to be stored the value should be set to NULL so it
is properly cleared otherwise calling settings_str_from_bytes will leave
str uninitialized which may cause a crash when attempting to load the
value.
Fixes#11564
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds Kconfig option to disable HCI ECDH support.
It will compile out ECDH related code, especially HCI event handlers.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds common option to disable support for LE Data Length Update
procedure in controller and host.
This will reduce flash usage by compiling out le_data_len_change
event handler that will never be called if controller has been
compiled with BT_CTLR_DATA_LENGTH option disabled.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds common option to disable support for PHY Update
procedure in controller and host.
This will reduce flash usage by compiling out le_phy_update_complete
event handler that will never be called if controller has been
compiled with BT_CTLR_PHY option disabled.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Logging subsystem could take few extra bytes when enabled.
ECC thread stack has been unconditionally increased to
support it.
During my test, I noticed a usage of 1052 bytes when logging
subsystem is enabled.
Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
This makes it clear that only request need to set an opcode since they
require a error response in case it fails.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The comment was suggesting that write callback was reading and storing
buffer when in fact it should write to the attribute value.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Application may need to handle the write differently depending on the
write operation so this adds a flag called BT_GATT_WRITE_FLAG_CMD which
can then be checked by the callback, for instance one can respond with
BT_ATT_ERR_WRITE_REQ_REJECTED when that flag is not set which should
indicate to the client to use write command instead.
Fixes#11206
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Updated controller implementation to disallow disabling
initiator state using scan disable. But allow disabling an
already disabled scan state. Also, disallow enabling scan
state while in initiator state.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Consider invalid if the request pointer is NULL or the callback is NULL
or there is a request ongoing. This conditions would likely lead to a
crash and most likely there is some other bug involved like for example
the application queueing the same request multiple times.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Updated the controller implementation to not feature
exchange if already done once either by local or remote peer
device in an active connection session.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When issuing LE Set Data Length Command host should not assume that
LE Data Length Change Event will be generated. From Core Spec 5.0:
"If the command causes the maximum transmission packet size or maximum
packet transmission time to change, an LE Data Length Change Event
shall be generated."
Change-Id: I17723b58ed4f390aa465db3f69126ee229871123
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
If master or application decided to switch connection parameters to
ones that meet pending parameters don't bother sending request
after 5 seconds timeout.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Experiments have shown that the probability of missing advertising
packets is significantly lower with 30ms scan window compared to 10ms
scan window. This is especially the case with advertisers using a 20ms
advertising interval, which in turn is perhaps the most common one
since it's the smallest allowed by the Bluetooth 5.0 specification.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
By default, CCC value is only stored to persistent memory during
BT disconnection. This commit adds an optional storing of CCC right
after it has been updated. This results in better robustness of
peripheral but increases system workqueue stack usage.
Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
The channels assigned to the controller are reordered so that the ones
previously used and now available for other purposes have continuous
numbers. When the controller can take advantage of the pre-programmed
PPI channels (when TIMER0 is used as the event timer), the now free
channels are 0-4, when it cannot, it is the channel 0.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Several PPI channels in nRF5 family SoCs are pre-programmed with fixed
settings. A few of them can be used in the bluetooth controller instead
of the freely programmable ones that are used currently. This commit
makes such replacements where possible so that the universal channels
can be left available for other purposes.
This commit also removes macros used previously in calls to functions
enabling and disabling particular PPI channels (as it is sufficient
to use the BIT macro to set bits corresponding to the channel numbers)
to prevent such problems like the one introduces by commit
9d1ca9c390 (channel 18 changed to 17
but the related macro definition not updated).
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Couple of findings which were revealed after changing
LOG_MODULE_REGISTER macro:
- missing semicolons after LOG_MODULE_REGISTER()
- missing LOG_LEVEL defines
- other
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The endif comment block is for CONFIG_BT_FIXED_PASSKEY not
CONFIG_SMP_FIXED_PASSKEY. Fix the comment to match.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
BT_LE_ADV_CONN_DIR_LOW_DUTY declares a local variable so it cannot go
out of scope, so instead of assigning in the scope of the if statement
this rework the code to mantain the declaration in the same scope it is
used.
Fixes#10570
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes mesh shell to register commands with the new shell subsystem
and stop using the legacy shell.
Fixes#11056
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
With multiple devices on auto-connect list it is possible that while
having pending connection to device A, device B disconnects. In that
case host should not try to start scan (currently controller doesn't
support concurrent scanning and initiating).
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This commit moves the BLE GATT Device Information service
from /samples/bluetooth/gatt to /subsys/bluetooth/services and adds
a Kconfig entry to enable and configure the service;
when enabled, it will register itself automatically.
Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
Add support for exchanging both minimum and maximum
connection interval values in Connection Parameter Request
Procedure implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fallback to L2CAP Connection Parameters Update Request if LL Connection
Update Request was rejected by remote device that has this marked as
supported in features. This can happen if procedure is supported only
by remote controller, but not enabled by host. This is connection
parameters update with iOS devices.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
The code had somehow gotten corrupt (yet in a way that it compiles) so
that an intended if-branch was missing.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This will exclude GATT Client response handlers from compilation
if GATT Client support is disabled.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This is a pure refactoring of the k32src_wait function. It used the
following rules when refactoring:
Don't use the preprocessor when unprocessed C language suffices.
Don't undefine macro's.
Avoid global variables when possible.
Use consistent names for similiar things (hf_clock, lf_clock).
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
k_poll_signal was being used by both, struct and function. Besides
this being extremely error prone it is also a MISRA-C violation.
Changing the function to contain a verb, since it performs an action
and the struct will be a noun. This pattern must be formalized and
followed and across the project.
MISRA-C rules 5.7 and 5.9
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Fix misspellings in Kconfig files that show up in the configuration
documentation (and make menuconfig screens).
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Fix an integer overflow in the scheduling implementation
that calculates whether resources required for next radio
event be retained.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit optimizes access to RNG driver by taking advantage
of the data structures layout. As result, number of calls to RNG
driver is reduced.
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
The entropy_nrf_get_entropy_isr(), which is specific to this driver,
is in fact equivalent of generic entropy_get_entropy_isr(..., 0).
This commit removes the entropy_nrf_get_entropy_isr() function
and replaces its usage by call to generic entropy API.
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
In Bluetooth 5 the definition of LE security mode 1, has changed.
LE Security Mode 1 level 4 requires authenticated LE Secure Connections
pairing with encryption using a 128-bit strength encryption key.
This also changes the behaviour when a security request and response
would end up with a security level that is lower than the one requested.
Before pairing would complete, and the link would disconnect with error
authentication failure. Instead a SMP will abort pairing with error code
authentication requirement, or encryption key size.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This adds new API fuction to update running advertising data.
It will remove the need of advertising restarting.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The bluetooth controller has been using the flag '-Ofast' to keep
within a real-time limit. There are two problems with this; firstly,
when a project should be optimized for size it is standard to use -O2,
not -Ofast.
Secondly, optimization flags have been deemed to be non-portable, so
instead of directly using "-Ofast" we should use the intent-macro
OPTIMIZE_FOR_SPEED_FLAG to ensure toolchain portability.
Testing has shown that we are still within the real-time limit when
changing from -Ofast to -O2. -Ofast is about 1us and 1% faster, but
increases the code size by 13kB (5% of the available flash on a
nRF51).
Since the slowdown is comparatively small compared to the code size
increase we have decided to use -O2 in place of -Ofast.
Other optimization combinations were also measured and their results
can be seen below:
-Ofast in BLE Controller and in #pragma in entropy driver.
Memory region Used Size Region Size %age Used
FLASH: 138920 B 256 KB 52.99%
[bt] [INF] encode_control: l: 6, 6, 7; t: 75, 45, 132.
-O2 in BLE Controller and in #pragma in entropy driver.
Memory region Used Size Region Size %age Used
FLASH: 125840 B 256 KB 48.00%
[bt] [INF] encode_control: l: 6, 6, 7; t: 75, 51, 133
-O3 in BLE Controller and in #pragma in entropy driver.
Memory region Used Size Region Size %age Used
FLASH: 138920 B 256 KB 52.99%
[bt] [INF] encode_control: l: 6, 6, 7; t: 75, 50, 132.
No extra CFLAGS for BLE and entropy driver (pragmas removed), using
CONFIG_SIZE_OPTIMIZATIONS=y
Memory region Used Size Region Size %age Used
FLASH: 120124 B 256 KB 45.82%
[bt] [ERR] isr_rx_conn: assert: '!radio_is_ready()' failed
No extra CFLAGS for BLE and entropy driver (pragmas removed), using
CONFIG_SPEED_OPTIMIZATIONS=y
Memory region Used Size Region Size %age Used
FLASH: 138004 B 256 KB 52.64%
[bt] [INF] encode_control: l: 6, 6, 7; t: 61, 51, 130.
NB: RAM usage differences were insignificant.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Connection complete event with error code can be received only for
central role and can be compiled conditionally.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This adds a possibility to reject incomming LE Connection request
due to insufficient authorization or encryption key size.
This is needed for qualification purposes
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds support for returning various return codes from
the channel accept callback.
This is needed for implementation of incoming connection
authorization for certification purposes.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Rename connection response results to map those that are defined
for BR.
BR: BT_L2CAP_BR_*
LE: BT_L2CAP_LE_*
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Convert the monitor protocol to a proper logger backend. This also
means that our log.h headerfile gets greatly simplified.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that log processing happens in a separate thread, the
BT_STACK_EXTRA macro is not needed (since there's no significant
overhead), and therefore the BT_STACK macros become unnecessary as
well.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use irq_lock (same way as bt_hex does it) and increase the number of
static buffers to reduce the risk of reuse before a buffer gets
processed.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This shell command was tied to bluetooth and the bluetooth shell and
also had messages all related to nordic ICs.
Make it generic and put it under drivers/flash/ so it can be included by
anyone and independently of bluetooth.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Mkae sure that variable pointed by params is valid when passing it
as function argument.
Fixes#10587
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Improve the error feedback when calling bt_le_adv_start and inputting
too much data in the advertisement.
Error feedback before:
Bluetooth initialized
Advertising failed to start (err -22)
Error feedback after:
Bluetooth initialized
[bt] [ERR] set_ad: Advertising data does not fit in buffer
Advertising failed to start (err -22)
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Add option to disable legacy pairing and only use secure connection.
If legacy pairing was requested pairing will be denied with status
insufficient authenticated
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Added implementation to avoid retransmitting NACK-ed Tx PDU,
to save on current consumption in retrying to transmit in
case peer device has no free buffer to receive the PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
To allow the BLE stack to be used both in the real nRF platforms
and simulated ones, change the used macros in the code to the
COMPATIBLE ones.
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Fix broken master role RSSI measurement. Since the original
contribution clean up into Zephyr, the radio shorts that was
set for measuring the RSSI for master role has been broken,
as it was cleared by the radio switching code further in the
Tx ISR.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix connection failed to be established regression
introduced by the commit 350c569aba ("Bluetooth:
controller: Avoid offseting to lldata").
As the Rx-ed PDU buffer is re-used to construct the
connection complete message towards HCI, the fields in the
Rx-ed PDU need to be backup for future use in the control
path. Here the channel selection bit is backup now.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Connection Parameter Request Procedure implementation
to respond with sent interval_min and interval_max so that
certain peer devices dont reject the response as Invalid LL
Parameters.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit adds missed const modifier for addr pointer for
bt_le_set_auto_conn function
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
Refactored the fix in the commit 685da02354 ("Bluetooth:
controller: Fix advertising random delay resolution calc")
to apply modulo in tick units before adding a tick.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bluetooth config dependencies where the definitions depend on other
definitions.
BT_RX_PRIO is not always defined in a controller only build.
BT_CTLR_TX_BUFFER_SIZE does not depend on BT_CTLR, but BT_LL_SW.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Calling bt_recv in the Bluetooth host Tx thread by the
controller implementation caused deadlock in combined host
controller builds when HCI LE Create Connection Cancel
generated the HCI LE Connection Complete or HCI LE Enhanced
Connection Complete events.
Controller's HCI implementation has been updated to place
the generated event into Rx FIFO to avoid the deadlock.
Relates to commit a59f544fb4 ("bluetooth: controller:
Handle non-priority events correctly")
Relates to #10314.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
bt_conn_disconnect removes device from autoconnect list and thus
should not be called from le_conn_update when timeouting pending
connection. Also auto connect flag needs to be check on connection
failure to make sure scan is restarted.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
In commit d5836195d7 ("Bluetooth: controller: Increase advertising
random delay resolution"), the resolution of random_delay was
increased from 8-bit to 16-bit. Due to this switch the result
of HAL_TICKER_US_TO_TICKS() can now be a 0, which causes the following
crash:
***** Kernel OOPS! *****
Current thread ID = 0x200043f0
Faulting instruction address = 0x17914
Fatal fault in ISR! Spinning...
Let's make sure we don't pass a 0 to ticker_update() by increasing
the result of HAL_TICKER_US_TO_TICKS() by 1.
Signed-off-by: Michael Scott <mike@foundries.io>
Fix the default Tx buffers to 3. While the first Tx-ed
buffer generates the HCI Number of Completed Packets Event,
the controller needs to have 2 additional Tx buffers queued
so that the second Tx PDU has the More Data (MD) bit set so
as to have the connection event to continue to transmit any
additional Tx buffers that the Host will enqueue in the same
connection event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
1. Command handler can return command exectution status as int.
2. Existing command handlers rework.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This splits L2CAP commands under 'bt' to 'l2cap' removing 'l2cap-'
prefix from the commands:
l2cap - Bluetooth L2CAP shell commands
Options:
-h, --help :Show command help.
Subcommands:
connect :<psm>
disconnect :[none]
metrics :<value on, off>
recv :[delay (in miliseconds)
register :<psm> [sec_level]
send :<number of packets>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This splits BR/EDR command under 'bt' to 'br' to reduce the command
list and at same time cleaning the mix between different bearers.
In addition to that also remove "br-" prefix for the commands:
br - Bluetooth BR/EDR shell commands
Options:
-h, --help :Show command help.
Subcommands:
auth-pincode :<pincode>
connect :<address>
discovery :<value: on, off> [length: 1-48] [mode: limited]
iscan :<value: on, off>
l2cap-register :<psm>
oob :
pscan :value: on, off
sdp-find :<HFPAG>
rfcomm-register :<channel>
rfcomm-connect :<channel>
rfcomm-send :<number of packets>
rfcomm-disconnect :[none]
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Increase the resolution of advertising random delay from
1 ms unit to 1 us units. The controller scheduling will
floor it to nearest 32KHz clock unit on nRF5 series.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Auto connect code reuses bt_conn object and connection code was assuming
object was cleared which resulted in invalid code being provided to
application. Fix that by explicitly setting error code to 0 on
successful connection.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Depending on perhiperal advertising interval 3 seconds might not be
enough and would result in cancelling pending connection. Make this
Kconfig configurable and let application to decide.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Under GNU C, sizeof(void) = 1. This commit merely makes it explicit u8.
Pointer arithmetics over void types is:
* A GNU C extension
* Not supported by Clang
* Illegal across all ISO C standards
See also: https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Applications may require different scan windows and interval depending
on expected re-connection time or peer devices advertising parameters.
Default to GAP recommended slow values.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
In order to avoid the build system complications that come from
including a timestamp, remove it by default from the version string in
HCI Vendor Extensions. Users can still include a unique identifier, be
it timestamp or not, using the CONFIG_BT_CTLR_HCI_VS_BUILD_INFO Kconfig
option.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The Data Length Update implementation reused the flags used
by Encryption Procedure which caused invalid Encryption
Procedure sequence under conditions where Data Length Update
Procedure collide with Encryption Setup initiated by the
peer central device.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The address of the device is also set via HCI interface when passive
scanning is used. As a result, LL does not filter out directed
advertising packets that are targeted at this device.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
This allows to configure desired parameters for peripheral. When set
PPCP characteristic is also added to GAP service. If disabled it is
up to application to controll connection parameters and stack will
only enforce 5 seconds delay before update.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This fixes a few issues with the handling of Connection Parameter
update in the Host:
- starting conn param update timer as master
- ignoring 5 seconds slave timer when calling bt_conn_le_param_update
- starting conn param update timer on every PHY update
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
There is an unnamed choice for the BT link layer selection.
Giving the choice a name would allow multiple declarations of the
option and the ability to select out-of-tree LL's.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
So far the stack hasn't provided any way for the application to access
the existing bonds. This patch adds such an API.
Fixes#10122
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This uses net_buf_append_bytes to reassemble the SDU segments instead of
doing it manually.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If the remote stack is not able to fully utilize each segment it is
possible it would run out of credits before completing the SDU, these
changes detects if that would happen and attempt to restore enough
credits for the SDU to be received.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This simplify the logic of restoring the credits after each SDU instead
of using an arbitrary threshold which was not configurable per channel.
Because the credits are restored only when the full SDU has been
reassembled it means the channels needs to be set up with enough for
the configured MTU otherwise there is a risk of the channel to run out
of RX credits before the packet is fully reassembled, because of such
corner case the code will now warn if a channel is setup with not enough
init_credits.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds a int return to recv callback which can be used to notify the
stack about errors when receiving a packet. In addition to that the user
can return -EINPROGRESS to inform the stack the data will be processed
asynchronously which can be complete by calling
bt_l2cap_chan_recv_complete.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When activating SystemView internal kernel header files will be
included. This causes a name conflict with smp_init in smp.c
and smp_init in kernel_internal.h
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This fix ensures that the handle range used for next GATT discovery is
always inclusive. Previously, the discovery procedure could not be
started with equal value of start and end handle.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
This allows to provide public address for controller without using
VS HCI command from host. Useful for controller only builds or
combined builds that are not using VS HCI commands.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
The current method relies heavily on the linker/compiler to
do the correct operation. Which is to eliminate the code that will
never get called. This posses a problem if the build even changes
by a smallest fraction.
The current patch will enforce proper inclusion of the code at the
pre-processing stage. Thereby not relying on the compiler/linker to
do the right thing.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
New shell implementation is on the way. For now old one and all
references are kept to be gradually replaced by new shell.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add a new command in the shell which can be used to set the channel
map by specifying a 37 bit bitmask written as a five byte hex array.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add functionality for setting the host channel classification in
the controller using the HCI command.
This closes issue #9851
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When running combined build on nRF5 with disabled VS command it is
possible to simply read static random address from FICR in host.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This adds a shell command for qualification purposes to enable/disable
Bonding flag in Authentication Requirements.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds a function that will disable Bonding flag in
Authentication Requirements flag in SMP Pairing Request/Response.
This is needed for qualification purposes.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This will exclude testing Mesh related code from build if BT_MESH
option in Kconfig is not set.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This enables using these commands to perform discover all procedure:
> gatt-discover-primary
Discover pending
Service 1800 found: start handle 1, end_handle 5
Service 1801 found: start handle 6, end_handle 9
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes bt_gatt_discover perform discover all proceduce if no UUID
is given in the parameters.
Fixes#9713
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Long write procedure currently requires BT_GATT_PERM_PREPARE_WRITE to
be set otherwise the prepares would fail. This changes the behavior so
that BT_GATT_PERM_PREPARE_WRITE enables checking each prepare chunk
skipping it otherwise.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
None of the data for the CEP, CUD and CPF descriptors needs to be
modified by the stack at runtime. Make it possible to pass constant
data to the descriptor macros, and make sure the descriptor handlers
cast the data back to be a constant.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The req variable in smp_pairing_failed() does get used, so
ARG_UNUSED() is inappropriate for it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Just like we set the address for an identity without depending on the
BT_DEV_READY flag, we should do the same for the IRK. Otherwise we
risk getting an all-zeroes IRK. Remove the condition and always set
the IRK value whenever CONFIG_BT_PRIVACY is enabled.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code creating identities from the Read_Static_Addresses vendor
command was failing to create matching IRKs, resulting in an
all-zeroes IRK to be used. Fix this by using the existing id_create()
function which takes care of generaing an IRK when necessary.
Fixes#10003
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
A subsequent patch will make bt_setup_id_addr() depend on id_create()
which was so far lower down in the hci_core.c c-file. Move
bt_setup_id_addr() further down to avoid a forward declaration.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There are some cases where atomic_and/or don't need to be
checked. Actively acknowledge these cases.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.
The only directory excluded directory was ext/* since it contains
only imported code.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This changed added notification complete callback which
gives information if a given notification has been sent.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
Added a new command, which can be used to test the directed advertising
API. This command allows user to turn on directed advertising in two
modes: low and high duty. High duty mode is the default one.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Added implementation to the directed advertising API in the Connection
Management module. Introduced a new connection state for this type of
advertising. The new state is symmetric to the connection state used for
scanning.
Added a new advertising option that can be used to trigger low and high
duty directed advertising. Added macros for default values of
Advertising Parameters, which are used to trigger directed advertising.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
In the BLE controller, NRF radio HAL, for the PPI registers used
for the SW TIFS.
To allow easier testing, replace direct use of registers
from Nordic's nrfx MDK with accesses via its HAL inlined functions
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
This adds Central Address Resolution characteristic that is required
to check by peer if it's about to send directed advertisements where
initiator address is set to RPA.
Zephyr supports the Address Resolution, so the characteristic value
is hard-coded.
Please check Core 5.0 Vol 3 Part C 12.4 CENTRAL ADDRESS RESOLUTION
Related PTS test case: GAP/CONN/ACEP/BV-03-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This ensures the core services are always registered first and the
gatt_sc work is initialized.
Fixes#9785
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The test for IS_ENABLED(BT_SETTINGS) in mod_reset()
should be IS_ENABLED(CONFIG_BT_SETTINGS).
Signed-off-by: David Leach <david.leach@nxp.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The ordering of items in flash is not guaranteed, so it's possible we
get an App Key before the corresponding Net Key. Remove the check for
a Net Key, since the storing code should never store an App Key if
there is no corresponding Net Key.
Fixes#9670
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code in le_set_private_addr() was hardcoding identity 0, even
though it is given a specific identity as an input parameter.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Replase magic numbers with HCI Error Code definitions in the
LE controller implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated the implementation of Connection Update Procedure to
not assert when peer master violates the Bluetooth
Specification v5.0 Vol.6 Part B Section 5.3 Procedure
Collisions. Instead disconnect the link with reason
Different Transaction Collision (0x2A).
Certain phones in the market perform Connection Update
Procedure and do not correctly handle remote initiated
colliding PHY update procedures. They try to perform both
the transactions involving an instant simultaneously
violating the Bluetooth Specifications.
Implementation in Zephyr is updated to gracefully handle
the violating remote master device, and not fatally assert
in the local device.
Relates to commit 8b3fd6963c ("Bluetooth: controller: Fix
assert on different transaction collision")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If cfg_changed has not been set consider that the application don't
care and just skip it.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Updated the implementation of PHY update procedure to not
assert when peer master violates the Bluetooth Specification
v5.0 Vol.6 Part B Section 5.3 Procedure Collisions. Instead
disconnect the link with reason Different Transaction
Collision (0x2A).
Certain phones in the market perform Connection Update
Procedure and do not correctly handle remote initiated
colliding PHY update procedures. They try to perform both
the transactions involving an instant simultaneously
violating the Bluetooth Specifications.
Implementation in Zephyr is updated to gracefully handle
the violating remote master device, and not fatally assert
in the local device.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
PTS version 7.3.0 incorporates some errata which change the expected
behavior of the heartbeat subscription state. Update the code so that
the following tests pass successfully:
MESH/NODE/CFG/HBS/BV-01
MESH/NODE/CFG/HBS/BV-02
MESH/NODE/CFG/HBS/BV-03
MESH/NODE/CFG/HBS/BV-04
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Some things, such as UUID, URI or even the local name may be different
when bt_mesh_prov_enable() is called compared to when bt_mesh_init()
was called. Create the advertising data on-demand each time when
enabling PB-GATT.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In some cases the application might only initialize its UUID after
calling bt_mesh_init(), e.g. in the case of deriving the UUID from the
identity address. To avoid confusing logs, only print the UUID when
actually enabling one of the provisioing bearers.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This API makes it possible to delete an existing identity and to flag
its storage slot as unused.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Make sure the application doesn't pass existing identity addresses to
bt_id_create() and bt_id_reset(). Also make sure we don't accidentally
create a duplicate when generating random identity addresses.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add a new API which can be used to reclaim an identity slot for a new
identity. When called, any previous pairings, connections, or other
data will be cleared, and then a new identity will be generated in the
place of the old one.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
None of the callers of these APIs do anything with the return value,
so just remove it to produce more efficient code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This wasn't used anywhere and was typed incorrectly (the foreach
callback takes two parameters). There was also one user of this which
was triggering compiler warnings of mismatched callback type.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When doing bt_unpair() we need to pass the given identity when
disconnecting and clearing keys, in case all associated pairings were
requested to be cleared.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Update the storage handling to take into account multiple identities.
We can save a bit of code by using the new bt_id_create() API from
within settings.c.
Also make the treatment of addr & irk parameters to bt_id_create()
consistent, in that NULL is acceptable for both of them.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This flag was both redundant and creates confusion with potentially
multiple identity addresses (it was only referring to the first
identity address). We can simply just look at the type of the identity
address wanting to be used.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Make it possible to have multiple identity addresses as an LE
peripheral. For central role only the default identity is supported
for now. This also extends the flash storage in a backward compatible
way.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Up until now, Zephyr has patched Kconfig to use the last 'default' with
a satisfied condition, instead of the first one. I'm not sure why the
patch was added (it predates Kconfiglib), but I suspect it's related to
Kconfig.defconfig files.
There are at least three problems with the patch:
1. It's inconsistent with how Kconfig works in other projects, which
might confuse newcomers.
2. Due to oversights, earlier 'range' properties are still preferred,
as well as earlier 'default' properties on choices.
In addition to being inconsistent, this makes it impossible to
override 'range' properties and choice 'default' properties if the
base definition of the symbol/choice already has 'range'/'default'
properties.
I've seen errors caused by the inconsistency, and I suspect there
are more.
3. A fork of Kconfiglib that adds the patch needs to be maintained.
Get rid of the patch and go back to standard Kconfig behavior, as
follows:
1. Include the Kconfig.defconfig files first instead of last in
Kconfig.zephyr.
2. Include boards/Kconfig and arch/<arch>/Kconfig first instead of
last in arch/Kconfig.
3. Include arch/<arch>/soc/*/Kconfig first instead of last in
arch/<arch>/Kconfig.
4. Swap a few other 'source's to preserve behavior for some scattered
symbols with multiple definitions.
Swap 'source's in some no-op cases too, where it might match the
intent.
5. Reverse the defaults on symbol definitions that have more than one
default.
Skip defaults that are mutually exclusive, e.g. where each default
has an 'if <some board>' condition. They are already safe.
6. Remove the prefer-later-defaults patch from Kconfiglib.
Testing was done with a Python script that lists all Kconfig
symbols/choices with multiple defaults, along with a whitelist of fixed
symbols. The script also verifies that there are no "unreachable"
defaults hidden by defaults without conditions
As an additional test, zephyr/.config was generated before and after the
change for several samples and checked to be identical (after sorting).
This commit includes some default-related cleanups as well:
- Simplify some symbol definitions, e.g. where a default has 'if FOO'
when the symbol already has 'depends on FOO'.
- Remove some redundant 'default ""' for string symbols. This is the
implicit default.
Piggyback fixes for swapped ranges on BT_L2CAP_RX_MTU and
BT_L2CAP_TX_MTU (caused by confusing inconsistency).
Piggyback some fixes for style nits too, e.g. unindented help texts.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
After a dedicated header is allocated to the simulated SOC versions
there is no need anymore to have guards in these other files
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
To avoid issues with differences between the simulated and the real
SOC let's separate the simulated one into its own header
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Settings consider the character space the end of the value, so instead
encode the name using settings_str_from_bytes and restore it with
settings_bytes_from_str.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Normally App Keys are identified using the AppKey Index value (a 12
bit value in practice), whereas the stack-internal array index has
very little relevance.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When we receive a security request we need to make sure that any
existing keys contain an LTK to encrypt with. Otherwise there's a risk
of trying to encrypt with an all-zeroes LTK.
Fixes#3221
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Added implementation to check and wait for stable 32KHz
clock source before starting connectable/directed
advertising state and initiating state.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed the implementation to generate command status as per
Bluetooth v5.0 specification instead of the incorrect
command complete that was generated before.
Also, the unsupported features status will be generated
before the invalid parameters status.
Relates to commit 258c7ccff1 ("Bluetooth: controller: Fix
HCI LE Set PHY invalid behavior check")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a callback struct with only the pairing_confirm authentication
method. This is useful both for just-works testing as well as the
recently added fixed passkey support.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add a new bt_passkey_set() API that can be used to set a fixed passkey
to be used for pairing. The new API also requires a new Kconfig option
to be enabled first (CONFIG_BT_FIXED_PASSKEY).
Fixes#8350
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code was not doing the right thing when we as peripheral would
send a security request to the central. First of all, the SEQ_REQ flag
was getting cleared by the pairing request handler, resulting in
pairing_confirm() callbacks for no reason. Secondly, the behavior in
encrypt_change() was not utilizing the smp_reset() helper as it should
have done.
Fix the situation by calling smp_init() when sending a security
request, and detect that this has been done when receiving a pairing
request. Also do the appropriate cleanup if the result is an encrypt
change instead of a pairing request (in case we were already paired
with the peer).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The smp pointer is the return value of CONTAINER_OF() which is
guaranteed to always be non-NULL.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Provide proper documentation for all of the authentication callbacks,
and clarify the usage of the cancel callback. Previously the cancel
callback was always required, even though that doesn't necessarily
make sense now that the pairing_complete/failed callbacks exist.
Fixes#8385
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Whoever added Zephyr's prefer-later-defaults Kconfig patch originally
didn't do the same for 'range's. Earlier ranges are still preferred.
Swap the ranges on BT_RFCOMM_L2CAP_MTU to give the intended behavior.
Fixes the following warning for tests/bluetooth/shell/prj_br.conf:
warning: default value 200 on BT_RFCOMM_L2CAP_MTU (defined at
subsys/bluetooth/host/Kconfig:508) clamped to 264 due to being outside
the active range ([264, 32767])
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Essentially all products that support pairing or Mesh need to be able
to support ECC. This is particularly important for traditional
peripheral/central use cases where legacy pairing is considered
insecure. With split builds we don't know if the controller supports
ECC HCI commands or not, however with a combined build we know that
the current controller lacks any special ECC support, so enable
TINYCRYPT_ECC by default for such a configuration.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The SMP_FLAG_ENC_PENDING flag indicates that we've generated an STK
and are waiting for encryption to happen. In case the remote enables
encryption prematurely we should not try to encrypt with whatever is
stored in smp->tk, rather reject the pairing attempt.
Fixes#3222
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The recently added pairing_complete & pairing_failed callbacks
were missing a NULL-check for bt_auth, since it is possible that
there's no authentication callback structure registered at all.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
hci-cmd can be used to inject an arbritrary HCI command which can be
useful when testing vendor/new commands.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
commit 9b6ad4067b introduced some minor
coding style issues related to line splitting. Fix these.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Added two new callbacks for Bluetooth stack to notify
the application that pairing has been completed or failed.
fixes: #8390
Signed-off-by: Jun Li <jun.r.li@intel.com>
Update the RX SDU Kconfig value to something that reflects better
current use cases and doesn't waste memory needlessly. Also lower the
minimum to two segments, since while many samples need three for their
composition data (typically the biggest transferred payload), it's
possible to have a very simple node whose composition fits in two
segments.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Mesh specification doesn't support more than 32 transport layer
segments, the way the number was so far derived from the advertising
buffer count could result in a highre numbe than 32, thereby wasting
memory. Make the number of supported segments build-time configurable
through a new BT_MESH_TX_SEG_MAX configuration option.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Symbols without prompt cannot be configured from application
configuration file.
warning: BT_CTLR_LE_ENC (defined at subsys/bluetooth/controller/
Kconfig:198) was assigned the value 'n' but got the value 'y'.
This symbol has no prompt, meaning assignments in configuration files
have no effect on it. It can only be set indirectly, via Kconfig
defaults (e.g. in a Kconfig.defconfig file) or through being 'select'ed
or 'imply'd (note: try to avoid Kconfig 'select's except for trivial
promptless "helper" symbols without dependencies, as it ignores
dependencies and forces symbols on).
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
The controller already has a minimum of 1, and the host should mirror
that (in particular to avoid Kconfig warnings). A single buffer is
unsafe in some scenarios (such as with LE SC enabled) however there
are valid scenarios where a single buffer makes sense, so leave it up
to the developer to choose this.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
name command can be used to read or write the GAP Device Name which is
used by the advertise command.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This enables the user to provide a ScanData, as long as it contain
names, and set BT_LE_ADV_OPT_USE_NAME.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This introduces a new advertising flag BT_LE_ADV_OPT_USE_NAME which can
be used by applications to make the stack automatically include the
Bluetooth Device Name in the Scan Response.
The name is also updated in case there is already an advertising
instance using it.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes GAP name writable if CONFIG_BT_DEVICE_NAME_STORAGE is > 0
which means the name can be persisted.
Fixes#8357
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This uses bt_dev to store the name and allow changing it at runtime, in
addtion to that if CONFIG_BT_SETTINGS is defined make the name
persistent.
Fixes#8357
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If we use newlib the isdigit (and other similar functions) return an
error as char can possibly be viewed as signed:
usr/include/ctype.h:57:54: error: array subscript has type ‘char’ [-Werror=char-subscripts]
#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)])
Explicity cast to unsigned char so we deal with both this warning and
possible warning when -Wpointer-sign is enabled.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
If we use newlib the isdigit (and other similar functions) return an
error as char can possibly be viewed as signed:
usr/include/ctype.h:57:54: error: array subscript has type ‘char’ [-Werror=char-subscripts]
#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)])
Explicity cast to unsigned char so we deal with both this warning and
possible warning when -Wpointer-sign is enabled.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Bool symbols implicitly default to 'n'.
A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.
Remove some 'default ""' properties on string symbols too.
Also make definitions more consistent by converting some
config FOO
<type>
prompt "foo"
definitions to a shorter form:
config FOO
<type> "foo"
This shorthand works for int/hex/string symbols too, not just for bool
symbols.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Fixes issues caused in GPIO driver due to overlapping GPIOTE
channel use in nRF5 software PWM driver and in Bluetooth
controller for implementing PA/LNA feature.
The issue is solved by assigning the base and available
channel count for GPIOTE considering whether PWM and/or
PA/LNA feature is selected in the Kconfig.
Fixes#8815.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
An empty packet on 2M phy is one more byte compared to 1M phy because
of the preamble.
The empty packet is then 11 bytes, which takes 44 us to transmit.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit removes the inclusion of kernel_includes.h from
the nRF51 and nRF52 soc.h headers. This prevents from an
inclusion cycle formation on soc.h. In the wake of
kernel_includes.h removal, necessary header files have been
added in several source files to be able to compile Zephyr for
nRF5x SOCs.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Split meaning of BT_CTLR and BT_LL_SW, since they always are the same.
This way BT_CTLR means that there an controller implemented,
and BT_LL_SW refers to the specific implementation.
This allows alternative controller implementations.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Configuration Model specification states that all non-unicast
addresses given as the address of an element are Prohibited. The
correct action for Prohibited parameter values is to ignore the
message. As of writing this patch the PTS does not enforce this, but
it might in the future (as it does for many other Prohibited values).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Previously the code only checked if any of the models within an
element had the destination address in their subscription list. After
that check the specific model that the message was addressed to was
not verified to have that address in it's subscription list. This
patch fixes the problem.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The nRF52810 is a low-cost variant of the nRF52832, with a reduced set
of peripherals and memory. This commit adds Bluetooth controller support
for it.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When we're reading the initial state from flash, calling the various
internal functions was leading to scheduling a rewrite to flash. Add
an extra parameter to the appropriate functions so they know when
they're called due to active configuration by a configuration client,
and when they're called due to restoring the state from flash.
This was not only wasting flash space, but also causing erroneous
behavior with the FCB settings backend if there was an intermediate
node reset operation stored, followed by a reprovisioning. The node
reset entries would cause them to be re-appened after the second valid
provisioning, leading to an incomplete node state.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If the model publication is not enabled, we should return success,
however no other steps need to be done. This also helps avoid writing
redundant entries to flash when resetting a node that never had model
publication enabled.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There were several things broken with the initialization order during
node reset:
- The model->flags should not be touched since the writing to
persistent storage happends through delayed work, and the flags
need to be kept until that.
- The unprovision() function should only be called at the very end of
the reset procedure, since it calls model-specific init functions
which may clear things which the earlier reset routines depend on.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Provide flexibility in choosing to use the host defined crypto
functions or the ones provided by the controller
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This adds an Kconfig option to disable GATT Multiple Read support.
This GATT sub-procedure is optional and does not have to be supported.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This function does nothing actually if SMP is disabled.
This excludes att_signed_write_cmd handler from build if BT_SMP
is disabled or BT_SIGNING is disabled.
Note:
BT_SIGNING depends on BT_SMP
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This chunks should be excluded from build if the target application
does not support neither observer not central role.
This helps to reduce the application image size that implement
Peripheral or Broadcaster role.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds dependency upon BT_BROADCASTER and BT_OBSERVER roles.
Those are necessary to implement Mesh device.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Don't build the code that is related to central role if the target
does not support connection creation.
This helps to reduce the application image size that implement
either Observer, Peripheral or Broadcaster role.
Note:
BT_CENTRAL implies BT_CONN and BT_OBSERVER
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
It is quite easy to implement a buggy or security vulnerable
advertising data parser. Provide a helper for this purpose, which uses
the existing bt_data struct which is used for programming the local
advertising data.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This fixes a regression introduced in commit 6af5d1cd1f
("Bluetooth: Compress bt_keys struct").
Instead of passing a value zero as the random number, the
value at the RAM address zero was being used by the start
encryption function call. It is now fixed by consistently
using byte-array to store EDiv and Rand values.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In the BLE controller, radio HAL, for the PPI registers:
To enable for easier testing, replace direct use of registers
from Nordic's nrfx MDK with accesses via its HAL inlined functions
Cleaned up old test hooks.
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
In the BLE controller, radio HAL (TIMER registers):
To enable for easier testing, replace direct use of registers
from Nordic's nrfx MDK with accesses via its HAL inlined functions
Cleaned up old test hooks.
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
In the BLE controller radio HAL, for the CCM registers:
To enable for easier testing, replace direct use of registers
from Nordic's nrfx MDK with accesses via its HAL inlined functions
Cleaned up old test hooks.
(CCM part)
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
In the Radio HAL, for the RADIO and RTC registers:
To enable for easier testing, replace direct use of registers
from Nordic's nrfx MDK with accesses via its HAL inlined functions
Cleaned up old test hooks.
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
In the BLE controller radio HAL:
To avoid confusion, use SOC series macro instead of board macro.
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
In the BLE controller ECB HAL:
To avoid confusion, use SOC series macro instead of board macro.
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
In the BLE HAL for the ECB:
To enable for easier testing, replace direct use of registers
from Nordic's nrfx MDK with accesses via its HAL inlined functions
Cleaned up old test hooks.
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
In the ble hal for the RTC:
To enable for easier testing, replace direct use of registers
from Nordic's nrfx MDK with accesses via its HAL inlined functions
Cleaned up old test hooks.
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
This fixes invalid assert condition.
As stated in Bluetooth Core v5.0 Vol 3 Part F
3.4.4.1 Read By Type Request &&
3.4.4.9 Read by Group Type Request
"The starting handle shall be less than or equal to the
ending handle."
3.4.3.1 Find Information Request &&
3.4.3.3 Find By Type Value Request
"Only attributes with attribute handles between and
including the Starting Handle parameter and the Ending
Handle parameter that match the requested attribute type
and the attribute value that have sufficient permissions
to allow reading will be returned."
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Invalid configurations should be detected during configuration instead
of during compilation whenever possible.
This patch replaces a BUILD_ASSERT on CONFIG_SYSTEM_WORKQUEUE_PRIORITY
with what is intended to be an equivalent Kconfig restriction.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Remove include guards in internal files; it is an agreed
convention to not have include guards in internal header
files in Bluetooth subsystem.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Introduce a quirks field to the HCI driver struct, which can be used
to create exceptions in host behavior for non-standard or unusual
controller behavior. An initial quirk is added to prevent the host
from sending the HCI_Reset command (in which case the controller is
responsible for performing the reset).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This is the simplest & cleanest way to make these APIs available for
drivers. We already have a public hci.h header file, so using it seems
most natural.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Invalid configurations should be detected during configuration instead
of during compilation whenever possible.
This patch replaces a BUILD_ASSERT on CONFIG_NET_BUF_USER_DATA_SIZE
with what is intended to be an equivalent Kconfig restriction.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Recent commits which made the choice of attribute to pass to
bt_gatt_notify() more flexible contained some unfortunate bugs in
handling the attributes and their values. In particular, both calls to
gatt_notify() would in certain circumstances pass the wrong handle
value. This should now be fixed.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
According to the Bluetooth Specification v5.0, Direct Test
Mode shall use maximum Tx power.
Fixed by adding nRF5x Radio HAL interfaces to get supported
maximum Tx power for SoC selected, and DTM testing sets the
Radio peripheral to use maximum Tx power.
Fixes#7243
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Introduce a custom HCI driver for the native POSIX port, which opens a
HCI User Channel socket to the Linux kernel to gain access to a local
Bluetooth controller.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
With updates to bt_gatt_notify and bt_gatt_indicate it is now possible
to pass the Characteristic attribute instead of its value which makes
the code able to verify if attribute properties are set correctly.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Since BT_GATT_CHARACTERISTIC now expands to 2 attributes it may be
confusing to use bt_gatt_indicate as that expects the Value attribute to
be given which is no longer visible, so this enables the user to use
the Characteristic attribute in addition to its value.
Fixes#8231
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Since BT_GATT_CHARACTERISTIC now expands to 2 attributes it may be
confusing to use bt_gatt_notify as that expects the Value attribute to
be given which is no longer visible, so this enables the user to use
the Characteristic attribute in addition to its value.
Fixes#8231
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When att_disconnected is called a thread may be waiting for the tx_sem
but that is memset to 0, furthermore there exists a flag
ATT_DISCONNECTED to indicate the context is no longer valid so instead
move memset to bt_att_accept so it is cleared when it is about to be
reused.
Fixes#8083
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The adv_send() function was incorrectly decoding the 5-bit value (it
was using it directly as milliseconds), which effectively lead to the
code always picking the controller's minimum supported interval.
Fix this issue, but do it by simplifying the (re)transmission state
tracking so that the state is always stored in the original "packed"
8-bit value, where 5 bits are reserved for the interval, and 3 for the
count.
Fixes#7972
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We should check for valid lengths, not just because flash may have
become corrupted, but also because this fixes coverity errors, such as
CID 186030.
Fixes#7739
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In certain cases the response to a command can come in the form of a
non-priority event. This is the case of LE Create Connection Cancel,
which generates a Command Complete and then an LE (Enh) Connection
Complete. Take this case (and other future ones) into account by calling
the correct Host recv function.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Some versions of gcc do not seem to compile out the inaccessible code
in this case and instead give the following error:
subsys/bluetooth/host/mesh/transport.c:419: undefined reference to
`bt_mesh_lpn_poll'
This happens at least when building samples/bluetooth/mesh for
native_posix on Fedora 28.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Implement the new entropy_get_entropy_isr() function to allow the kernel
to collect entropy before the scheduler and kernel data structures are
ready. Switch to an nrf-specific version for high-performance
requirements in the BLE Link Layer.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Remove non-existent Kconfig symbol references. An additional (but
related) change is the removal of all persistent storage symbols from
the Arduino 101 Bluetooth shell app, since BT_STORAGE no longer
exists.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Bluetooth core specification splits the valid LE L2CAP PSM range
into two subranges:
- Standard, SIG-assigned fixed PSM values in the range 0x0001-0x007f
- Dynamic, allocated at runtime in the range 0x0080-0x00ff
Previously the bt_l2cap_server_register() API was assuming that the
app would always decide the PSM, which effectively made it impossible
to have collision-free dynamic PSMs. This patch extends the
implementation so that if server->psm is 0, then the stack will look
for a free PSM from the dynamic range and take it into use.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Instead of having an ivu_unknown variable to track when we can ignore
the 96-hour minimum duration requirement, simply set the duration to
the minimum (96 hours) in the places where ivu_unknown would have been
1.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When the IV Update state enters Normal operation or IV Update in
Progress, we need to keep track of how many hours has passed in the
state, since the specification requires us to remain in the state at
least for 96 hours (Update in Progress has an additional upper limit
of 144 hours).
In order to fulfil the above requirement, even if the node might be
powered off once in a while, we need to store persistently how many
hours the node has been in the state. This doesn't necessarily need to
happen every hour (thanks to the flexible duration range). The exact
cadence will depend a lot on the ways that the node will be used and
what kind of power source it has.
Since there is no single optimal answer, this patch adds a new
configuration option, which allows specifying a divider, i.e. how many
intervals the 96 hour minimum gets split into. After each interval the
duration that the node has been in the current state gets stored to
flash. E.g. the default value of 4 means that the state is saved every
24 hours (96 / 4).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
After introducing persistent storage, it's useful for an app to check
if the node has been provisioned or not.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This ensures the every characteristic has a value attribute declared
with the same UUID since the old macro did not declare the value the
application would normally have to declare one itself using a different
UUID which is not allowed.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The rx_prio_queue k_fifo object has not been used for anything for a
really long time. The use for it was originally removed by the following
commit:
commit ad475d863a
Author: Szymon Janc <ext.szymon.janc@tieto.com>
Date: Fri Apr 22 11:36:04 2016 +0200
Bluetooth: Remove RX priority fiber
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The sequence number was acting as a stop-gap for missing persistent
storage. Now that we have the settings support in place it's no longer
needed.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The logic for restoring the sequence number was flawed in that it
would not always cause an incremented sequence write upon the
transmission of the first packet. The reason the code didn't work is
that it assumed the stored value was a multiple of SEQ_STORE_RATE,
however since the sequence number is stored in a deferred fashion
that's not always true.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We can implicitly trust locally originated messages, so there's no
need to burden the RPL with them.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for storing the remaining configuration server model
states (all of which are one byte values). The states are stored under
a single settings key bt/mesh/Cfg.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for storing the heartbeat publication persistently. The
information is only stored as "publish indefinitely" or as "periodic
publishing disabled" since we can't know for how long the node is
powered off. The information is stored under the settings key
bt/mesh/HBPub.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for storing the model publication information
persistently. The addresses are stored under the settings key
bt/mesh/s/<mod id>/pub for SIG models and bt/mesh/v/<mod id>/pub for
vendor models.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for storing the subscribed group addresses for each model
persistently. The addresses are stored under the settings key
bt/mesh/s/<mod id>/sub for SIG models and bt/mesh/v/<mod id>/sub for
vendor models.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for storing the bound App Keys for each model
persistently. The bindings are stored under the settings key
bt/mesh/s/<mod id>/bind for SIG models and bt/mesh/v/<mod id>/bind for
vendor models.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Keeping the model struct same sized, change the element pointer to two
indexes, and add a flags member that will be used to track pending
storage actions.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In order not to have a Node Reset consume more stack than other
operations, also perform the related storage writes through the same
delayed work as all other storage updates.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Instead of having an RPL-specific storage timer, introduce a generic
one that'll eventually be used for all persistent storage.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To reduce stack consumption, and to avoid blocking the CPU during
network activity, prepare for a generic timer that can be used for
most (possibly all) mesh storage values.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There are valid use cases where the model layer must know the true
destination address. So far only the fact that it was one of the
addresses that the model subscribes to (its element's unicast
included) has been knowable.
Solve the issue by moving the destination address from the internal
net_rx context to the public bt_mesh_msg_ctx struct.
Fixes#7453
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There are certain use cases where the application needs to be able to
explicitly set a specific identity address. This was previously
possible using the bt_storage API, however now that it's gone another
solution is needed.
This patch adds a ne bt_set_id_addr() API which the application can
use to set a specific identity address before calling bt_enable().
Fixes#7434
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Instead of manually iterating all app keys and net keys, use the
bt_mesh_subnet_del() helper on all subnets. This will also clear any
app keys, and ensures that persistent storage is cleared as well.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Both the local sequence number as well as the Replay Protection List
(RPL) are states that may potentially change very often. In order not
to wear out the flash with these updates it makes sense to try to
avoid too frequent writes.
For the local sequence number a simple solution is not to write the
number on every increment. This patch introduces a new Kconfig option
to define after how many increments the sequence number gets written.
When the stack gets initialized it automatically adds the configured
number to the last stored one, thereby guaranteeing that the node
starts off with a number that's larger than the last used one.
The RPL is more problematic, since in principle it needs to be updated
every single time that we receive and process a message. Especially
security sentitive nodes will want this stored immediately to flash.
To give some use-case dependent flexibility, this patch introduces a
new Kconfig option to specify a timeout after which the RPL gets
written to flash.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
These are needed both for bt_mesh_provision() as well as persistent
storage-based network creation.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This variable is both redundant as well as problematic when it comes
to adding persistent-storage-based provisioning information, which
will not come through main.c or the bt_mesh_provision() API. Just
remove it and use bt_mesh.valid which serves the same purpose in
practice.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add APIs for storing core network values, such as Net and App Keys, IV
Index, Sequence number, RPL, etc.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add initial skeleton for doing settings-based persistent storage for
the mesh network state. This patch only includes restoring some core
network state such as IV Index, Sequence number, Net Keys, App Keys
and the Replay Protection list. The remaining state, and actually
storing the state, is left for follow-up patches.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The sequence number is incremented from several different places in
the stack. The way it was done was potentially race condition prone,
and was also problematic from the perspective of updating the
sequence number in persistent storage. Create a dedicated helper for
incrementing the sequence number (solves the race) which can in later
patches be used to add the persistent storage support.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This for loop runs inside an "if (!sub)" branch, so explicitly setting
sub to NULL in the loop is redundant.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
These app key and net key (subnet) helpers will soon be needed to be
called from the persistent storage code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Enable settings and increase the system workqueue size to deal with
the stack usage. This also makes it possible to test unpairing support
with the shell's 'clear' command.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There's a bit of unnecessary space in the bt_keys struct. Re-design
some fields for a more compact format, which is particularly helpful
now that the struct gets stored as-is to flash through the settings
API.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Integrate the bt_keys submodule with bt_settings. Add a new
bt_keys_store() API to write keys to flash, and extend the existing
bt_keys_clear() to remove the keys from flash.
Along with this, add some helpers for genrating settings key values
containing a bluetooth address, as well as for decoding them to get
the binary bt_addr_le_t.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add a new linker section for a list of submodule settings handlers,
and iterate the list from the various settings callbacks.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The same functionality is now supported by the settings-based
solution, so remove bt_storage out of the way. There were stubs in
bt_storage to handle per-peer information (e.g. pairing keys) but this
was never actually implemented in full. The next step is to add this
support to the settings-based solution.
Leave the code for generating temporary IRK and identity address in
case BT_SETTINGS is not enabled. Also leave the code for using vendor
HCI to read the identity address, in which case the settings
implementation will not touch it.
Introduce a new bt_unpair() API to replace the removed
bt_storage_clear(), since the latter was actually doing more than just
storage management: it was also handling runtime storage of pairing
information. Later, the bt_unpair() implementation will be extended to
clear settings-based pairing storage.
There is one feature that the bt shell module looses: the ability to
give a specific identity address to the "init" command as a parameter.
We might look later in the future if this is really needed, and add a
separate API for this.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Introduce a basic skeleton for peristent storage based on the settings
subsystem. Also enable support for this to the peripheral sample
application, so the new code gets exersized by CI. For now, the
implementation provides the same level support as the bt_storage API
ever did, i.e. for the identity address and the IRK.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code was updating net_rx->seq to make sure sdu_recv() gets the
right sequence number (seq_auth for segmented messages), however later
net_rx->seq was also used for enqueuing to the Friend Queue, causing
the queued messages to have the wrong value.
To fix this, don't update net_rx->seq, rather pass an explicit
sequence number value to sdu_recv(), which is just net_rx->seq for
unsegmented messages, and seq_auth for segmented messages.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The 'valid' member of struct bt_gatt_ccc_cfg was redundant, since
setting 'peer' to BT_ADDR_LE_ANY does the same job. What's worse, the
handling of 'valid' was also buggy in that some places looking for
valid CCC structs only matched the address, meaning it might yield a
positive match for invalid entries.
Fix these issues by removing the 'valid' struct member, and solely
using the 'peer' member to identify valid entries. Also simplify the
code by acknowledging that no CCC entry is essentially the same as the
value '0' written to CCC.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The bt_mesh_provision() call results in the provisioning link state
being cleared, so link.conn will become NULL. Add code to store the
information of whether PB-GATT was used and use this information after
the call instead of relying on link.conn anymore at this point.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The condition 'iv_index != bt_mesh.iv_index + 1' is already caught by
the earlier conditions in this branch.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If the network is in IV Update In Progress state when we get
provisioned we should set a timer so we eventually transition back to
Normal mode (otherwise we may end up in IVU In Progress indefinitely).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When we get provisioned we can't know how long the network has been in
the current IV Update state. Introduce a special value for
bt_mesh.last_update to indicate that we don't know the duration.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Introduce hal/ticker.h to abstract out SoC specific
implementations and move any conditional compilations to
include header files here.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The Node Identity advertising should only be automatically enabled
when provisioning happened over PB-GATT, but not when it happened over
PB-ADV. Move the enabling of Node Identity to the provisioning code,
where we know the bearer that was used (this information does not get
passed to the bt_mesh_provision function).
Fixes#6338
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There's a small but real chance of a race-condition when sending
messages to the local node (through the local network interface) that
expected parameters will be NULL in the message handles. Add
appropriate NULL checks for them.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This updates result values for LE Credit Based Connection
Response according to Table 4.20 from Core 5.0 Vol 3 Part A.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Selecting a choice symbol is always a no-op, and the latest version of
Kconfiglib prints a warning. This commit removes all selects of choice
symbols, which might make the Kconfig files a bit clearer and gets rid
of the warnings.
This is just a dumb removal. I did not try to guess the intent of each
select.
Fixes#6849
Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Fix missing device filter clearing for cases where whitelist
was used and then in subsequent adv/scan enable it was
unused.
This fixes an assert in ll_filter.c at line 248.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Cleaned up the use of conditional statements to use the max macro.
Fixes#6230.
Signed-off-by: David Maitland <hello@davidmaitland.me>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
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>
Having these in the beginning of a switch statement without any case
statement makes no sense.
Fixes#6135
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Redesign of the net_buf_simple and net_buf structs, where the data
payload portion is split to a separately allocated chunk of memory. In
practice this means that buf->__buf becomes a pointer from having just
been a marker (empty array) for where the payload begins right after
the meta-data.
Fixes#3283
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix conditional compilation in nRF5 radio interface so that
when Coded PHY feature is not selected then it does not use
the PPIs required for supporting the feature.
This will allow pwm_nrf5_sw driver to use PPI channels 14 to
19 and support 3 PWM channels. Without the Coded PHY feature
disabled, only PPI 14, 15, 18 and 19 are available for PWM.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed a missing ticks unit to microsecond unit conversion
potentially caused incorrect window offsets being used while
establishing connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
ticker timespace reservation can range up to 10.24 seconds,
needing 19-bits to represent in 32KHz clock units. Hence,
fix controller implementation to use u32_t to store ticks
slot values.
Without this fix, the controller is asserting in scan_adv
sample when using continuous scanning with 2 second interval
and window.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactored the high frequency clock preparation advanced
feature to improve radio utilization during continuous
scanning.
The inter-event timespace value now considers the reserved
timespace while determining if the high frequency clock
will be retained. This reduces the preparation time, hence
increased radio use inside scan window.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the invalid control PDU handling so as to reuse the
switch-case and hence, reduce code size and CPU time used.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In preparation towards a refactored controller, rename the
old radio_*_is_enabled() function to ll_*_is_enabled().
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the controller implementation to handle Control PDUs
with invalid lengths by responding with Unknown Response
PDU.
Fixes LL.TS.5.0.2 conformance tests:
LL/PAC/SLA/BI-01-C [Control PDUs with Invalid Length from
Master]
LL/PAC/MAS/BI-01-C [Control PDUs with Invalid Length from
Slave]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Cleanup the use of long radio_pdu_node_rx and
radio_pdu_node_tx variable to shorter node_rx and node_tx
names.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the pdu_data_llctrl_phy_req_rsp struct into
pdu_data_llctrl_phy_req and pdu_data_llctrl_phy_req structs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the pdu_data_llctrl_length_req_rsp struct into
pdu_data_llctrl_length_req and pdu_data_llctrl_length_req
structs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit implements a minor refactoring of the implementation
for enabling the Radio on TIFS expiration. It inlines a function
that is defined in the local radio_nrf5_ppi header file.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit contributes the implementation of the sw-switch for
tIFS in nRF5 Radio using the EVENT_TIMER instead of a dedicated
TIMER instance. A Kconfig configuration is added so the user can
select whether to use the EVENT_TIMER for the tIFS switch or use
a dedicated TIMER instance.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit implements minor refactoring of radio.c and ctrl.c,
to prepare for adding the implementation of sw-switch based on
the event timer.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit adds the option of conditionally reuse an existing
CC register of the event timer for timer sampling used in ISR
profiling, in case SW tIFS switching is implemented based on the
event timer.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit adds a symbolic name for the event timer
CC offset that is used to sample the event timer during
ISR profiling.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor radio_nrf5* header files to group together
definitions and have less #if-#else-#endif.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Until now the OOB info and URI fields in unprovisioned beacons were
generally ignored by the implementation. Add fields for these to
bt_mesh_prov and make sure to take them into account when encoding
advertising data, both for PB-ADV and PB-GATT. For PB-ADV the URI goes
out in a separate beacon, whereas for PB-GATT it is placed in the scan
response data.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix HCI LE Set PHY command for invalid behavior testing for
invalid parameters and unsupported features.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix generation of redundant length update event when no
change in effective octets or time.
Fixes LL.TS.5.0.2 conformance tests:
LL/CON/MAS/BV-73-C [Master Data Length Update - Responding
to Data Length Update Procedure; LE 1M PHY]
LL/CON/MAS/BV-74-C [Master Data Length Update - Initiating
Data Length Update Procedure; LE 1M PHY]
LL/CON/MAS/BV-76-C [Master Data Length Update - Responding
to Data Length Update Procedure; LE 2M PHY]
LL/CON/MAS/BV-77-C [Master Data Length Update - Initiating
Data Length Update Procedure; LE 2M PHY]
LL/CON/SLA/BV-77-C [Slave Data Length Update - Responding
to Data Length Update Procedure; LE 1M PHY]
LL/CON/SLA/BV-78-C [Slave Data Length Update - Initiating
Data Length Update Procedure; LE 1M PHY]
LL/CON/SLA/BV-80-C [Slave Data Length Update - Responding
to Data Length Update Procedure; LE 2M PHY]
LL/CON/SLA/BV-81-C [Slave Data Length Update - Initiating
Data Length Update Procedure; LE 2M PHY]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed implementation to use Connection Parameter Request
Procedure Preferred Periodicity value in calculating the new
connection interval used by the master role in Connection
Update Indication.
Fixes LL.TS.5.0.2 conformance tests:
LL/CON/MAS/BV-32-C [Accepting Connection Parameter Request –
Preferred_Periodicity]
LL/CON/MAS/BV-33-C [Accepting Connection Parameter Request –
Preferred_Periodicity and preferred anchor points]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The vendor variants of the model publication client messages were not
passing onward the CID, rather passing CID_NVAL which is clearly not
right.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix controller implementation to restrict HCI LE Set Random
Address command when advertising and/or active scanning
and/or initiator state is enable.
Fixes LL.TS.5.0.2 conformance tests:
LL/CON/INI/BV-01-C [Connection Initiation]
LL/SEC/ADV/BV-01-C [Advertising With Static Address]
LL/SEC/SCN/BV-01-C [Random Address Scanning]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to support Connection Parameter Request
Procedure initiation with and without use of Feature
Exchange Procedure being performed in a connection.
Fixes LL.TS.5.0.2 conformance tests:
LL/CON/MAS/BV-81-C [Initiating Connection Parameter Request
- Unsupported Without Feature Exchange]
LL/CON/MAS/BV-82-C [Initiating Connection Parameter Request
- Unsupported With Feature Exchange]
LL/CON/SLA/BV-85-C [Initiating Connection Parameter Request
- Unsupported Without Feature Exchange]
LL/CON/SLA/BV-86-C [Initiating Connection Parameter Request
- Unsupported With Feature Exchange]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
A few lines earlier the code bails out in case len is 0. Checking for
buf->len < 1 is the same as checking for buf->len == 0. Since len is
guaranteed to be > 0 here the check len > buf->len implicitly checks
for buf->len == 0, i.e. the second test can be removed.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The timeout was hard-coded to 400ms, but the spec actually states:
"This timer shall be set to a minimum of 200 + 50 * TTL milliseconds."
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The caculation was wrong since the value may be BT_MESH_TTL_DEFAULT,
i.e. 0xff, leading to much too large values.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Replay protection is not enforced at the Lower Transport Layer, so it
is possible to get an old replayed segment here. In such a case
cleanly discard it instead of causing a valid existing transaction
from being discarded.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix controller implementation to only restrict HCI LE Set
Random Address command when advertising and/or active
scanning is enable.
Continues to pass the following LL.TS.5.0.2 conformance
test:
LL/SEC/SCN/BV-01-C [Random Address Scanning]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed implementation to disallow setting Bluetooth device
address under active advertising or scanning states.
Fixes LL.TS.5.0.2 conformance tests:
LL/CON/INI/BV-01-C [Connection Initiation]
LL/SEC/ADV/BV-01-C [Advertising With Static Address]
LL/SEC/SCN/BV-01-C [Random Address Scanning]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Conditionally compiled changes to the NRF52 HAL so it can
run on simulated HW on the native port.
(HW models are not included in this commit)
All changes are under ifdefs and therefore will not have any
effect on normal builds
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Refactor mayfly based execution context solution out into
the HAL folder. This opens up the possibility to use
tasklets (if and when kernel gets the support) style
execution contexts.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixes a bug where in Connection Parameter Request was
initiated by slave role while Encryption Setup had been
started by the peer master.
Fixes: #5823
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We want to move to use a common FLASH_DEV_NAME across the various flash
drivers. So samples, tests, or other code can be a bit more generic. So
replace CONFIG_SOC_FLASH_NRF5_DEV_NAME with FLASH_DEV_NAME.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Rename some legacy upstream and downstream interfaces in
radio_* namespace to ll_* namespace for consistency.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor Kconfig and CMakelists.txt to be able to
conditionally compile in BT_LL_SW variant in the controller
subsystem. This is done to support future controller with
vendor specific variant implementations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add conditional compilation and move code to support
building a non-connectable Bluetooth shell application.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove redundant code that clears NRF_RADIO->EVENT_*
registers that are only used in PPI context. Only EVENT_*
registers that are read back need to be cleared.
Relates to: #5753
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit implements the SW-based radio switch for TIFS for LE
Coded PHY S2 in nRF52840 with a single PPI channel and a single
TIMER CC register.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit moves the radio enable on-tick functionality in
function hal_radio_enable_on_tick_ppi_config_and_enable() in
radio_nrf5_ppi.h.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Help text for BT_CTLR_DEBUG_PINS incorrectly mentioned
specific GPIO pins being reserved for this feature, but in
reality the pins reserved vary on the SoC selected, hence
any specific mention of pin details is removed from help
text.
Fixes: #5499
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix a missing !CONFIG_BT_CTLR_TIFS_HW conditional
compilation when nRF52840 is configured to use hardware
Trx switching, that caused compile error.
Fixes: #5779Fixes: #5761
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This check is needed to not schedule the delayed work if current
message to be sent is the last heartbeat message.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The timer should be reset before sending to ensure correct
publication period.
This patch allows to pass MESH/NODE/CFG/HBP/BV-02-C.
This patch is ported from mynewt:
Commit: d4b84638df47e7ea21629e6919f547f5dcd47285
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit refactors the nRF5 radio driver of Bluetooth controller
to use symbolic names for PPIs. It also revisits the Radio hardware
timing constants to align with experimental measurements.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Virtual address labels array entries were not updated on va deletion,
so that STATUS_INSUFF_RESOURCES error was returned after few
subsequent Config Model Subscription Virtual Address Add, Delete,
Overwrite commands, even if there shall be free space available.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes missing bt_mesh_lpn_group_del call in mod_sub_va_del.
If Config Model Subscription Virtual Address Delete was received
and successfully proceeded, subscription address shall be also
deleted from LPN Subscribe Groups.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Features received in Config Heartbeat Publication Set message can have
Feature bits set to RFU values.
This patch fixes setting this RFU bits in Heartbeat Publication
Features, so that those are not indicated in Config Heartbeat
Publication Status message.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This reverts commit ada5771d7c.
MESH/NODE/FRND/LPN/BI-02-C in Mesh Test Specification 1.0.1
has been fixed according to TSE #9774.
IUT shall ignore the message with an RFU Transport Control Opcode
but another Friend Poll message shall be sent with an alternating
FSN value.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
According to Mesh Specification v1.0 4.3.2.48 Config Model App Status:
"The Status Code shall be Success if the received request was redundant
(bind request of existing binding, or unbind of a non-existing binding),
with no further action taken."
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds commands to manage Friend node Subscription List.
Those will be used to add or remove and group/virtual address
from subscription list.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This command will be used to test if model can properly send
segmented and unsegmented messages to a given destination address.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add implementation to consider differing Rx chain delays for
S2 and S8 Coded PHY PDU reception. These changes are
required to meet tIFS timings for transmission after a
reception on S8 coding.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixes many instances of errors similar to below:
zephyr/subsys/bluetooth/controller/ll_sw/ctrl.c:5927:22:
error: declaration of ‘s_link’ shadows a previous
local [-Werror=shadow]
static memq_link_t s_link;
^~~~~~
zephyr/subsys/bluetooth/controller/ll_sw/ctrl.c:5905:21:
note: shadowed declaration is here
static memq_link_t s_link;
^~~~~~
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This introduces Bluetooth internal API intended to be used for
qualification purposes. Application may register callbacks to get
data that is not exposed by public API.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When the controller is connecting to multiple connectable
advertisers, the events are scheduled consecutively avoiding
overlapping events. Calculation of the window offset did not
consider the preparation time before the event, causing the
new master role connection event to overlap with previous
event. This is now fixed by including the preparation time
in the used window offset from the end of connect_ind PDU
transmitted.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed the check related to initiating connection parameter
request procedure. This will avoid sending invalid repeated
dispatch of connection parameter request PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When connection parameter request procedure was responded
by master role with Unsupported Link Layer Parameter Value,
a missing reset of the connection parameter request
procedure state caused next connection parameter request to
be incorrectly responded with same procedure collision
extended reject ind PDU. This caused an eventual connection
disconnection with reason LMP response timeout. This is now
fixed by reseting the state correctly.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If we have the maximum number of supported connections, then it
doesn't make sense to try to do connectable advertising.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Create a slightly smarter algorithm for choosing how long to advertise
each subnet. This is particularly important for the mesh_shell app,
since it uses a 10 second NODE_ID_TIMEOUT, meaning starting Node ID
advertising through user interaction would only succeed in advertising
one subnet (due to this being configured to 10 seconds).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Mesh Profile Specification 1.0 section 7.2.2.2.3:
"When the server starts advertising as a result of user interaction,
the server shall interleave the advertising of each subnet it is a
member of"
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Node ID advertising is short lived, so it's important to make sure
that subnets that get it enabled are first in queue to start
advertising.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We'll soon extend the start functionality with a bit more stuff
(prioritizing the started subnet), so in order to avoid excessive code
duplication, create helpers for these actions.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Until now the proxy server code would only advertise with the first
subnet. Introduce tracking of what the last advertised subnet was, and
give each subnet 10 seconds of advertising at a time.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add configuration client model support for NetKey Add message, as well
as a mesh shell command for calling the new API.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The logic for choosing to relay from the GATT bearer to the
advertising bearer was still buggy. This patch refactors the logic to
a separate helper function to make it clearer.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The command handler already has support for decoding from hex, however
it was not using the decoded value when calling the client API.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If relaying is not supported, or disabled, the Relay Transmit state
will normally be 0, which is not what we want to use when proxying out
packets from GATT clients. The bt_mesh_net_relay() function is also
used for sending out locally originated packets, in which case the
Relay Retransmit state is also the wrong one to use (the Network
Transmit state should be used instead).
This patch makes sure we only use the Relay Retransmit state for
packets originating from the advertising bearer, and for all other
packets use the Network Transmit state.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The bt_mesh_net_relay() function was missing several important checks
for whether a PDU should be relayed or not. In particular, it would
relay a packet from adv to adv even if the Relay state was set to
disabled, as long as GATT Proxy was set to enabled. The code would
also relay packets to the GATT Proxy bearer if the Relay state was set
to enabled but GATT Proxy was set to disabled. This patch addresses
both of these issues.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If the Relay state is set to Not Supported (0x02) the Config Relay Set
message should not change the state, rather just return its current
value.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The beacon cache handling was severely broken in the way that the
cache_add() function was incorrectly mapping net_idx to array index,
which could have lead to array overflows.
To fix this, while also cleaning things up, move the cache to the
actual bt_mesh_subnet struct. This e.g. lets us avoid having to track
the net_idx twice.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
https://www.bluetooth.org/errata/errata_view.cfm?errata_id=9807
"If the computed Beacon Interval is less than 10 seconds, it should be
set to 10 seconds. If the computed Beacon Interval is greater than 600
seconds, it should be set to 600 seconds."
The lower limit is already covered by how frequently the delayed work
callback gets called, so we just need enforce the 600 second maximum.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Whenever there's a security change (Key Refresh or IV Update) we
should immediately send beacons to any Friend Queues or connected GATT
clients. Introduce a helper function to do this, and make sure it's
called from all places that change the Key Refresh or IV Update
states.
This fixes test case MESH/SR/PROX/PB-12-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This makes it clear why 18 is a valid minimum network PDU length to
enforce. This is particularly important since as of writing this patch
there's at least one PTS test case which sends too small PDUs, which
could potentially lead to people thinking the implementation is at
fault (it's not).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Some Transport Layer tests (MESH/NODE/TNPT/BV-13-C in particular)
require manual clearing of the RPL. Introduce an API for it as well as
a command to the mesh shell to call the API.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If we the stored RPL entry was for an old IV Index, and the received
PDU is for a new IV Index we should not be comparing the sequence
number (as it's by definition always greater than the old one).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Section 4.2.11 of the Mesh Profile Specification 1.0 states:
"Upon transition from GATT Proxy state 0x01 to GATT Proxy state 0x00
the GATT Bearer Server shall disconnect all GATT Bearer Clients."
This also makes test case MESH/SR/MPXS/BV-08-C pass.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The bt_mesh_proxy_identity_enable() function was missing a line to
properly initialize the start time for Node Identity advertising.
Without it this public function wouldn't work as intended.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Test case MESH/SR/MPXS/BV-04-C requires the Proxy Service CCC to have
read permissions in order to pass.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Section 4.2.11.1 of the Mesh Profile specification 1.0 states:
"When the GATT Proxy state is set to 0x00, the Node Identity state for
all subnets shall be set to 0x00 and shall not be changed."
When the proxy state has been changed we also need to wake up the
advertising module to make sure we do the right kind of advertising.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Section 3.4.5.2 in the Mesh Profile Specification (1.0) states:
"The output filter of the interface connected to advertising or GATT
bearers shall drop all messages with TTL value set to 1."
Also: https://www.bluetooth.org/errata/errata_view.cfm?errata_id=9811
Note that this is specifically 1 and not 0, since e.g. Friend PDUs
always go out with TTL 0.
Another noteworthy thing is that the way this has to be implemented is
slightly contrary to how it's presented in the specification (both in
the text as well as the Message processing flow diagram in section
3.11. If this was implemented following the spec to its word, then any
PDU received over GATT or Advertising with TTL 2 would never be
relayed (since the TTL would be 1 when the PDU gets rerouted back to
the bearer). This would be both counterintuitive to the intended
purpose of the TTL, and would also be contrary to the test
specification (see Test Procedure step 1 in MESH/NODE/RLY/BV-01-C).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Most places in bt_mesh_friend_req() used rx->sub (which is already
quite short in itself), so just remove the only remaining user and the
helper variable itself.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There were several issues with the code:
- queue_size wasn't properly kept up to date, leading to erroneous
buffer discarding logic.
- Poll timeout when there were buffers in the Friend Queue didn't
work because we didn't track if there'd been a preceding request
for messages or not (hence the added pending_req variable).
- We would overwrite the recv_delay timer if there was another
request while the previous one was still sending (a likely scenario
if we send out multiple advertising events per packet).
- We weren't canceling the sending of a buffer if the Friendship was
suddenly cleared.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When receiving Friend Offers we should also consider unestablished
contexts, and simply start from the beginning if that happens.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Pass the subnet to some friend_cred_* APIs since it contains all
necessary information for choosing the right keys to generate them
from. Also shorten the API names to avoid awkward line splitting -
these are internal APIs so it's an acceptable compromise. One bug that
this fixes as part of the cleanup is using the right NetKey Index when
clearing Friendship: previously the code was always using the index of
the first subnet, regardless of which subnet the Friendship was based
on.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Key Refresh Phase 2 is analogous to the Key Refresh flag being set.
This means that the flag can directly be used as the index to the
new/old key two-element array.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Since the stack supports runtime reset and reprovisioning, we need to
clear the network message cache whenever creating a new mesh network.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Remove inconsistent and sometimes unreliable tracking of what
advertising parameters should be used and when the Node Identity
advertising started. The main change that facilitates this is to have
the Node ID start timestamp as part of the mesh subnet context.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Some PTS test cases only work when we're advertising using Network
Identity. Using the default timeout of 60 seconds for Node Identity
will cause this test cases to fail (i.e. the PTS gives up before
Zephyr transitions to advertising from Node Identity to Network
Identity).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The shell was being inconsistent in its parsing of boolean parameters.
Some commands were documented as accepting "on" but were actually
parsing the parameter with strtoul() which would result in 0.
Introduce a new helper to convert a string to a u8_t which still
accepts "on" or "enable". This gives us full flexibility of having a
simple interface to the user, but still allowing non-boolean values to
be tested (since on-air the value is a full octet).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Instead of having a hard-coded UUID, introduce a command to change it.
This is particularly useful if there are many unprovisioned nodes
around.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Having the Static OOB value set up-front can be confusing to the user
since they will not know what the value is. Start off by having it
unset, but introduce a new command using which the user can either set
or clear it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixes the following compile error when building
tests/bluetooth/shell application:
In file included from subsys/bluetooth/shell/ticker.c:16:0:
subsys/bluetooth/shell/../controller/util/mayfly.h:21:2:
error: unknown type name 'memq_link_t'
memq_link_t *_link;
^~~~~~~~~~~
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We need to send out a Health Fault Current Status (the Health Model's
publication message) when all faults are cleared. The logic for
calculating number of faults was also wrong after the updated model
publication API.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Health Current Fault message size was being set too small to fit
any faults. Use a macro to make sure the size gets applied in both
places where appropriate.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixes error encountered during connecting BLE endpoint.
[bt] [ERR] le_remote_feat_complete: Unable to lookup conn for handle 32
This is to work around a buggy controller that states support for
enhanced privacy, but misbehaves when it's enabled. This change
makes it possible to ensure the host doesn't try to enable the enhanced
event by simply disabling the privacy feature in Kconfig.
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
If we get a different key value in Phase 1 we should return the same
"Cannot Update" error as in phases 2 and 3. This fixes test case
MESH/NODE/KR/BI-02-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This makes it possible to pass all IV Update tests without having to
build a custom configuration for some of the tests. We also disable
the feature in all sample configurations, but leave it on in the
tests.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There was a chance that initial beacons for subnets would be sent with
uninitialized data. Make sure we initialize the beacon data each time
when we create a new subnet.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use NULL instead of "", fix typos, and indicate app-key-add last
parameter as optional (to match the command implementation).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for sending messages that add, delete or overwrite Label
UUIDs, and add commands for these to the shell. With the help of these
commands it's possible to pass Transport Layer PTS tests (in
particular TNPT/BV-05-C) by manually adding a Label UUID through
module subscription, since the test case itself does not do this.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code would unconditionally clear sent_req in update_timeout(),
which would e.g. cause us to switch to Friend Polls if the Friend
didn't respond to a Subscription List Add/Remove on the first attempt.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The purpose of using something less than the configured poll timeout
was to cover the case where the LPN establishes Friendship before the
provisioner has completely configured it. However, there's the "more
data" flag in the initial Friend Response, and we now also have a
public API to request for more messages. Both of these features
diminish the value of having a reduced initial timeout. Also, some LPN
test cases do not expect us to send frequent polls initially, causing
failures with the PTS.
Therefore, introduce a Kconfig option to set the initial timeout, and
make it default to the actual poll timeout.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Many apps, the mesh shell included (due to PTS test requirements)
benefit from exposing LPN state and polling outside of the stack.
Introduce new APIs for these, and add code to the mesh shell module to
take advantage of them.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Health Fault Test & Test Unacknowledged messages are supposed to
be sent for more than the Node Composition Data Company ID. It's true
that some PTS tests require the message to be ignored for
non-composition data ID, however that's something that should be
covered by the application that's used for testing, and not the
generic Health Server Code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for sending Health Attention messages, as well as commands
to use these new APIs from the shell.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There was a lot of code duplicated in the Foundation Client Models for
waiting on a specific status message. Refactor this into helper
functions (one per client model).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for sending Health Period messages, as well as commands to
use these new APIs from the shell.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Company ID 0xffff is treated as invalid in some contexts, so use a
valid one. Also, the Health tests require the Health Fault Company ID
to match that found in the Composition Data.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add a callback to the Health Client Model context, so that the
application is able to receive Health Current Status messages that
some Health Server Model publishes.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add the needed Health Client API for sending Health Fault Get, and add
a command to the shell to utilize it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixes the following compile error when CONFIG_BT_CTLR_LE_ENC
is disabled:
subsys/bluetooth/controller/ll_sw/ctrl.c: In function
'isr_rx_conn_pkt_ctrl':
subsys/bluetooth/controller/ll_sw/ctrl.c:2613:29: error:
'LLCP_ENCRYPTION' undeclared (first use in this function)
(conn->llcp_type != LLCP_ENCRYPTION)) ||
^~~~~~~~~~~~~~~
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixes:
subsys/bluetooth/host/hci_core.c: In function ‘set_static_addr’:
subsys/bluetooth/host/hci_core.c:4043:1: error: label ‘generate’ defined
but not used [-Werror=unused-label]
generate:
^~~~~~~~
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
PA/LNA feature being not default enabled, keeping the PPI
indices used for this feature at the higher indices would
allow use of these PPI indices by other drivers, for
instance the nRF5 software PWM driver.
Software PWM driver provides 3 PWM pins/channels using upto
6 PPI channels. If BLE controler where to use 0-13, then
14-19 PPI indices can be used by the PWM driver.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Replace use if void * declaration related to memq links with
more readable memq_link_t.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The Poll Timeout needs to be at least 24 bits, so u16_t doesn't
suffice and will potentially result in truncation. Use u32_t, thereby
also fixing a coverity warning.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The bt_mesh_model_publish() is supposed to return a "not supported"
error if the publish context doesn't exist. Fixing the premature
dereferencing also fixes coverity warnings.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The separate checking for "now < reftime" is unnecessary, since the
integer over/under-flow for unsigned 32-bit values resulting from
subtraction will give the right delta even if 'now' is less than the
reference.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
After the Publish Retransmit state was introduced the Publish Period
measurement would begin once the previous Publish message has finished
transmitting. This will however cause inaccurate periods, which is
particularly an issue with the PTS that expects accuracy of less than
0.5 seconds (apparently).
Since the publication timer is also used for the retransmissions we
can't simultaneously use if for the period as well. Therefore, we
introduce a new variable called period_start which makes a note of
when the period was supposed to start, and then once all
retransmissoins are done initializes the timer with the send duration
taken into account.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The only generally available model supporting publication that's
convenient to be used for testing is the Health Server Model.
Unfortunately since this model supports period publication, the
non-periodic side got less attention and had some bugs.
The first thing that needs to be done is to verify that the period
returned by bt_mesh_model_pub_period_get() is positive. If it's zero
then no periodic publication should take place.
Another thing that this patch cleans up is the naming of the callback
used for periodic publishing. There's no need do require the callback
to call bt_mesh_model_publish() since this must happen no matter what,
so instead rename the callback from 'func' to 'update' and have the
access layer call bt_mesh_model_publish() if the callback was
successful.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When a small amount of supported connections is configured (especially
the default number of 1), connectable advertising may fail. This is
perfectly fine since as soon as a disconnection event happens the
advertising will be successfully restarted. To avoid causing
unnecessary user worries, downgrade the resulting errors to warnings.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There were some things that were working only when receiving a Node
Reset message from someone else, but not when the app called
bt_mesh_reset() directly. There was also some state cleanup missing
for the transport layer. This patch addresses all of these issues.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Configuration Client is such a generally useful feature for the
shell that it makes sense to have it as a mandatory dependency (the
shell wasn't anyway compiling at the moment without it).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Optimised the parameter passing order of memq interface such
that the compiled code uses less space and execution time.
Having a parameter that gets returned as the first parameter
passed to a function avoids instructions required to have
the result in the return register.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The Del and Overwrite operations have the exact same parameters and
expected status response as the Add operation, so we can reuse most of
the code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Even though we have LPN enabled, we might still receive messages
through other network interfaces than the advertising one (e.g. the
local network interface).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Using the start callback, especially with multi-segment messages, may
not be super useful for applications, but we should support if if they
do provide it. One application could e.g. be to calculate the duration
it takes for a multi-segment message to be completely received by the
remote end.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Model publication was broken in a couple of ways:
- The Publish Retransmit State was not taken into account at all
- Health Server used a single publish state for all elements
To implement Publish Retransmit properly, one has to use a callback to
track when the message has been sent. The problem with the transport
layer sending APIs was that giving a callback would cause the
transport layer to assume that segmentation (with acks) is desired,
which is not the case for Model Publication (unless the message itself
is too large, of course). Because of this, the message sending context
receives a new send_rel ("Send Reliable") boolean member that an app
can use to force reliable sending.
Another challenge with the Publish Retransmit state is that a buffer
is needed for storing the AppKey-encrypted SDU once it has been sent
out for the first time.To solve this, a new new net_buf_simple member
is added to the model publication context. The separate 'msg' input
parameter of the bt_mesh_model_publish() API is removed, since the
application is now expected to pre-fill pub->msg instead.
To help with the publishing API change, the Health Server model gets a
new helper macro for initializing the publishing context with a
right-sized publishing message.
The API for creating Health Server instances is also redesigned since
it was so far using a single model publishing state, which would
result in erratic behavior in case of multiple elements with the
Health Server Model. Now, the application needs to provide a unique
publishing context for each Health Server instance.
The changes are heavily intertwined, so it's not easily possible to
split them into multiple patches, hence the large(ish) patch.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Model Publish Retransmit Interval is in units of 50ms and not 10ms
like the other transmit/retransmit states. Create dedicated macros for
the Publish Retransmit State and use them where appropriate.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There's no need for callback exposed in the public API to be something
different than what's used internally. In fact this would just
complicate things. This patch exposes the internal callback under a
bt_mesh_adv_cb name and uses it throughout the mesh stack.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In case an outgoing message gets only delivered to the proxy interface
we should not forget to notify the send callbacks of this.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Some places of the code are interested in when the first advertising
event goes out. Others, on the other hand, are interested when the
last advertising event goes out. Some are even interested in both of
these. Instead of providing a single callback, provide a struct with
two possible callbacks for sending advertising PDUs.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This simplifies the callback implementations since they no-longer need
to do their own look-ups of the needed context.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We've so far been trying to keep the per-buffer mesh meta-data to
a maximum of 8 bytes in anticipation of upcoming net_buf refactoring
that'll have all net_bufs in the system with the same sized user data.
It's however slowly becoming unfeasible to do this - e.g. simply
adding user data to the sending callback would already fill up the
full 8 bytes.
To solve this issue, treat the net_buf user data as just a pointer to
the actual user data, and keep the actual user data in a separate
array. We still keep taking advantage of net_buf_id() however, so
buffers can cheaply be mapped to their meta-data.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When testing memq implementation used by controller, a
missing check on NULL pointer return could lead to NULL
pointer deferencing.
Current implementation of controller and mayfly do not
by design lead to NULL pointer dereferencing, this fix
is only for correct-ness and complete-ness.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When resetting there is no point trying to start clearing the
Friendship since there will not be any security material left to send
out PDUs.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The common interpretation (among other implementations) seems to be
that Model Publication for a given AppKey Index implies a binding for
that AppKey. This isn't currently explicitly stated in the spec, but
in order to improve interoperability go with this interpretation as
well.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The variable for tracking that a buffer from the Friend Queue hasn't
been sent yet was not being properly set.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This simplifies the API since there is no-longer a need to pass a huge
number of function arguments around.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This simplifies the API since there is no-longer a need to pass a huge
number of function arguments around.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add a command for getting and setting the model publication. We also
have to adjust the app's configuration, since both the Model
Publication Set and Status messages are segmented messages, meaning we
need two TX and RX segment contexts.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The value 0xffff is reserved, so we can use that to indicate whether
there's a vendor model in question or not. Simplifies things over the
previously used separate boolean value.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There were some needed changes missing after the update to have manual
control of PB-ADV & PB-GATT provisioning bearers. E.g. the test for
CONFIG_BT_MESH_LOW_POWER in net.c was no-longer indicative of scanning
being on or not.
Do the scan enabling selection within the LPN module if LPN is
supported, or otherwise enable scanning unconditionally in
bt_mesh_provision().
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
10 seconds is quite long for configuration messages, and way too much
currently since we only talk through the local networking interface.
Set the default timeout to 2 seconds, and provide APIs through which
the timeout may be changed at run-time (mainly useful for the shell).
Note: The timeout_set() API is normally assumed to be called just once
for an application, based on the expected size of the network (hops &
latency). Trying to change it e.g. in a multi-threaded environment for
every message may not yield the expected results.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Convert the hb-ub-set command to a more generic hb-sub that can be
used both for getting and setting the Heartrate Subscription State.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Convert the hb-pub-set command to a more generic hb-pub that can be
used both for getting and setting the Heartrate Publication State.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Avoid having to go do "init" for the bt module before issuing "init"
for the mesh module. Instead perform Bluetooth init implicitly. The
bt_enable() API will cleanly fail with -EALREADY if it was previously
called.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If the app does direct provisioning, it may still want to do common
handling through its provisioning complete callback (if it has one
registered). This also means that we always require a non-NULL
provisioning context provided to bt_enable(), and that it needs to
fail if NULL was given.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
It may be useful for the app to know what the initial NetKeyIndex that
it was given during provisioning is.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This is in anticipation of soon adding health client support, which
could then cause confusion due to the ambiguous API names.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that there's support for configuration client as well, rename cfg
to cfg_srv to avoid any confusion.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add the ability to track the provisioning bearer through an extra
parameter to link_open/close. Also introduce new public functions to
enable/disable specific provisioning bearers. This also means that one
now needs to explicitly enable provisioning bearers after calling
bt_mesh_init().
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add commands for 1-byte states such as Default TTL, Friend and GATT
Proxy, as well as the 2-byte Relay state.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support to the Configuration Client Model for getting and setting
1-byte states (which can be nicely generalized in code) as well as the
2-byte Relay state.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This patch adds read permission for client characteristic configuration
descriptor. This is required by MESH/NODE/MPS/BV-06-C,
MESH/NODE/MPS/BV-07-C PTS tests.
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@codecoup.pl>
Add a basic shell skeleton for Mesh, containing basic command for
initialization, provisioning and reset.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The restoring of the buffer parsing state was only correct for the
friend queue (which needs the app-layer data). Relaying on the other
hand requires the network layer data, i.e. it needs a different state
to be restored.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We never access the local network interface queue in a blocking
fashing, so it's unnecessary to have all the infrastructure that
k_fifo provides. Use the simpler sys_slist_t instead.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
It may be useful for the app to know when the provisioning link is
active and when it has been closed. This can be used e.g. to signal
the user the state of the device. Some PTS tests also require
verifying the link state.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code was missing the sending of the Input Complete PDU, and was
also setting the link.auth value too late.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The parameter structs for advertising and scanning contain many
members that may not get explicitly set when enabling these states. Do
a memset to zero on them to make sure we don't operate on
uninitialized memory.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
A value of 20ms means it's possible the LPN will end up doing
simultaneous advertising & scanning, which increases the risk of lost
packets. Use a default of 100ms to keep these separate.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Handling Friend Clear messages and sending the Friend Clear
Confirmation responses wasn't so far properly implemented. One of the
requirements is to keep sending the reponses even though we no-longer
have a friendship. This means that we need to keep the net_idx, frnd
and lpn_counter values valid, which in turn requires the introduction
of a separate "valid" boolean value.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The PTS tests for the Friend node expect a minimum of 16 queued
messages and the ability to have two LPNs. Set these as defaults.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When sending PDUs from Friend to LPN we should adhere to the
configured network transmit count & interval to get better
reliability for the PDUs to be received by the LPN.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When a Friend Node receives a Friend Request with a unicast
PreviousAddress that's not an element on the Friend Node, it needs to
start the Friend Clear procedure. This procedure involves sending
periodic Friend Clear messages to the old Friend of the LPN.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The only messages that should be encrypted using the friendship
credentials are those coming through the Friend Queue on the Friend
node, most request-response pairs between LPN & Friend (exceptions are
Friend Request - Friend Offer, and Friend Clear - Friend Clear
Confirm), as well as Model Publication messages when the Friendship
Credentials Flag has been enabled in the model publication.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When the node is in LPN node, the LPN-Friend messages has its own
retries, so doing this on the advertising level (i.e. following the
network transmit state) is sub-optimal.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This makes it possible (in a subsequent patch) to fine-tune some
special cases, like the LPN poll messages.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Update the advertising callback to include the exact duration that we
will be sending out the packet. This is useful since sometimes we want
to use the end point of the advertising as the reference time to count
when some other action should take place.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Lower the attempts and make sure we track the old Friend address for
subsequent Friend Requests, in case we never receive a Clear
Confirmation.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add some automated policies for starting LPN establishment and make it
possible to perform the establishment in a "low power" way, i.e.
switching to low duty-cycle already when starting to send Friend
Requests.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
According to the Mesh Spec value 0x00 of ReceiveWindow parameter is
prohibited. This is needed to pass MESH/NODE/FRND/LPN/BI-03-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The intention of the code was to access client->conn and not
clients->conn (which would always access the first client struct).
Fixes#4738
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The function return type was declared incorrectly. Also, the magic
checking for i after exiting the loop could cause some false positive
compiler warnings. Instead, return directly from the loop (with the
downside of duplicating a few lines of code).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
It's in practice impossible for the time between two beacons to be
more than 50 hours (the approximate wrap-around time for a 32-bit
millisecond timer), so we can use a 32-bit timestamp instead of a
64-bit one for the beacon tracking.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The LE scanning and advertising implementations were allocating and
holding buffers (the scan & advertising parameters respectively) while
at the same time potentially sending other commands (such as setting
the local private address). If these APIs would end up being called
simultaneously from different contexts, this could lead to a deadlock
in trying to allocate HCI command buffers, especially considering that
the default HCI command buffer count is 2.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.
Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.
This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.
For users that just want to continue their work with minimal
disruption the following should suffice:
Install CMake 3.8.2+
Port any out-of-tree Makefiles to CMake.
Learn the absolute minimum about the new command line interface:
$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..
$ cd build
$ make
PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
If we are a Friend node with multiple LPNs, we need to iterate through
all available Friendship credentials to find the right keys.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Mesh spec expects us to fall back to master credentials if
friendship ones are not available. Also remove an unnecessary branch
with the help of a new 'idx' variable.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The friend_cred and new_key information is common for all segments of
a segmented transaction, so it makes sense to store them as part of
struct seg_tx instead of each buffer's user data.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The friend_cred hint needs to be set already at the point of
segmenting, i.e. doing it in bt_mesh_net_send() is too late. Move the
setting to bt_mesh_trans_send() and bt_mesh_ctl_send().
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
MESH/NODE/FRND/LPN/BI-02-C requires us to ignore unknown Transport
OpCodes instead of treating them as valid responses to a Friend Poll.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Mesh Specification recommends retrying up to 6 times the Friend
Poll when establishing Friendship as LPN.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We should not have any valid key material in key slot 0 if the KR flag
is set, since then the new key/old key information will be incorrect
when network PDUs get decrypted.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
According to the Mesh Profile Specification: "The acknowledgment timer
shall be set to a minimum of 150 + 50 * TTL milliseconds".
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Mesh Profile Specification states that replay protection must be
done for all control and access messages. Furthermore, the replay
protection list must be updated with the sequence from the last
segment of a segmented message (the code was only updating based on
SeqZero).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that Friend support is complete we can create a full
implementation of the LPN PollTimeout Get message.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Even with the privacy feature disabled, the stack has so far defaulted
to using an NRPA for active scanning, in order to protect privacy.
This is mainly because it is not always clear that scanning for other
devices may risk revealing the local identity.
There may however be use cases where such revealing is actively
desired, so introduce a new option for this (which defaults to
disabled).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for loading IRKs into the controller as well as the LE
Enhanced Connection Complete HCI event. To simplify things, the old LE
Connection Complete handler translates its event into the new enhanced
one which is then the single place of processing new connection
events.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
MESH/NODE/CFG/HBS/BV-02-C expects it to be possible to do a Set with
the existing src & dst addresses but with a zero period in order to
"cancel" the current subscription. In such a case the addresses should
remain set but the period be set to zero, similar to what would happen
if the period would expire.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The heartbeat subscription Count, MinHops & MaxHops should only be
reset when enabling heartbeat subscription. Any other actions should
keep it unchanged.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The heartbeat should only be sent in case the relay state actually
changes. This fixes MESH/NODE/CFG/HBP/BV-03-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
"4.1.2 Log field transformation
In order to compress two-octet values into one-octet fields, the
following logarithmic transformation is used: any two-octet value is
mapped onto a one-octet field value representing the largest integer
n, where 2^(n-1) is less than or equal to the two-octet value."
Log field transformation table:
Log Field Value 2-octet Value
0x01 0x0001
0x02 0x0002 through 0x0003
0x03 0x0004 through 0x0007
0x04 0x0008 through 0x000F
0x05 0x0010 through 0x001F
0x06 0x0020 through 0x003F
0x07 0x0040 through 0x007F
0x08 0x0080 through 0x00FF
0x09 0x0100 through 0x01FF
0x0A 0x0200 through 0x03FF
0x0B 0x0400 through 0x07FF
0x0C 0x0800 through 0x0FFF
0x0D 0x1000 through 0x1FFF
0x0E 0x2000 through 0x3FFF
0x0F 0x4000 through 0x7FFF
0x10 0x8000 through 0xFFFF
"4.2.17.2 Heartbeat Publication Count Log
The Heartbeat Publication Count Log value between 0x01 and 0x11 shall
represent that smallest integer n where 2^(n-1) is greater than or
equal to the Heartbeat Publication Count value. For example, if the
Heartbeat Publication Count value is 0x0579, then the Heartbeat
Publication Count Log value would be 0x0C."
According to this definition 2^(n-1) is an upper bound for n log
value.
Proposed Publication Count Log transformation table:
Pub Count Log Value 2-octet Value
0x01 0x0001
0x02 0x0002
0x03 0x0003 through 0x0004
0x04 0x0005 through 0x0008
0x05 0x0009 through 0x0010
0x06 0x0011 through 0x0020
0x07 0x0021 through 0x0040
0x08 0x0041 through 0x0080
0x09 0x0081 through 0x0100
0x0A 0x0101 through 0x0200
0x0B 0x0201 through 0x0400
0x0C 0x0401 through 0x0800
0x0D 0x0801 through 0x1000
0x0E 0x1001 through 0x2000
0x0F 0x2001 through 0x4000
0x10 0x4001 through 0x8000
0x11 0x8001 through 0x10000
According to Log field transformation table 0x0579 would be
transformed to 0x0B and should be to transformed to 0x0C.
This is required to pass MESH/NODE/CFG/HBP/BV-01-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Section 4.2.18.2 in the Mesh Profile Specification states:
"The Heartbeat Subscription Destination shall be the unassigned address,
the primary unicast address of the node, or a group address, all other
values are Prohibited."
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This patch fixes issue when receiving iv index greater than current
index + 42 in update mode. According to Specification when node is in
update state it should only accept iv index equal to the current iv
index. When node is in normal mode it should ignore index that is
greater than current index + 42.
This allows to pass MESH/NODE/IVU/BI-02-C.
Also this patch cleans up the iv update procedure, to make it easier
to read.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The lower transport layer is responsible e.g. for the Friend Queue, so
we need to have the buffer in its original parsing state there.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fail on Mesh initialization if provisioning is enabled and keys were
not generated. This make it simpler to debug misconfigured devices.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
On targets where non-Zephyr controllers are likely, such as qemu, it
may be harmful to try to issue any of the vendor HCI commands, since
non-Zephyr controllers may interpret them in completely different
ways.
Introduce a Kconfig option that, when enabled, uses some simple
heuristics (HCI version & lack of public address) to try to guess in
advance whether the Zephyr HCI vendor extensions are supported or not.
The new option is available for any host-only configuration and is
enabled by default for the qemu targets.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixes the following conformance test regression failure
introduced in commit 7dd5fbee26 ("Bluetooth: controller:
Fix MIC error due to parallel Enc Proc")
TP/CON/MAS/BV-28-C [Initiating Connection Parameter Request
different procedure collision encryption]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix to disallow initiating LE Start Encryption while another
procedure is in progress. Similarly, disallow initiating
another procedure while Encryption procedure is in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the controller Kconfig to enable use of fast radio ramp
up by default, hence enabling support for Asym PHY updates
by default on nRF52 Series SoCs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Replace all controller asserts in control procedure responses
that checked for buffer availability with an implementation
that nacks request PDUs if there are no buffer to prepare
response PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The implementation of the Network Message Cache has so far been
suboptimal, since it has treated the same packet with different TTL
values as different packets. Since one of the purposes of this cache
is to prevent unnecessary relaying, it's important that we don't let
the TTL value influence the "hash" that's used for matching messages.
This patch changes the hash to consist of most of the IV Index (three
least significant bytes of it), the sequence number and the source
address, which should give fairly optimal matching behavior.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The main purpose of recv_thread is to process incoming events from the
radio and also any buffered items waiting to be dispatched to the Host
and that are pending because of lack of Host buffers.
When an iteration of the recv_thread obtains a element from the radio it
needs to process it immediately, either sending it straight away to the
Host or appending it to the queue. This was not the case before this
patch, where the concurrency of a buffered packet with one coming from
the radio would cause the latter to be "dropped", causing missing
packets.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
There was a missing net_buf_unref() for the response to reading the
controller static addresses.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add skeleton for HCI vendor extenstions and convert the nRF5x-specific
static address setting to use the HCI VS commands instead.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When a connection is disconnected with outstanding unacked packets, the
Host has no way to signal or acknowledge their processing to the
Controller, since it is illegal to send a Host Number of Completed
Packets command when the connection is not up. Instead, consider the
outstanding packets as acked in order not to affect the correct flow
control.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The feature bits for Proxy and Friend were missing in the composition
data and heart beat messages.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Both count and period must be non-zero for message publication
Stop publication when count becomes zero
Add count to debug message in hb_publish
Signed-off-by: Steve Brown <sbrown@cortland.com>
There have been situations where the remote stacks cannot responds
within a second, so increases it to 2 seconds. The timeout has to be
relatively short as the channel cannot be reused while disconnecting.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
MPS shall never be bigger than MTU + 2 as the remaining bytes cannot
be used since the SDU is limited to length + MTU.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add implementation to support Coded PHY update procedure
with packet transmit time restrictions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use S8 coding Rx chain delay timings to calculate the PA
pin assertions when in Coded PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Always use S8 Rx Chain Delay instead of the actual Rx-ed
packet coding. I believe, as the packet always start with
S8, hence S8 timings when used the tIFS is near correct
value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When calculating and setting up the header compelte timeout
use S8 coding Rx chain delay.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In the commit dd52b8ea02 ("Bluetooth: controller: Fix
first connection interval timing"), instead of using just a
tick unit as workaround, microseconds corresponding to a
tick unit was used while calculating the window offset to be
used at the connection update instant. This introduced an
error in scheduling the first event with new connection
parameters, causing supervision timeout of connection update
procedure.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Mesh Profile Specification v1.0, 4.4.1.2.8:
"When an element receives a Config Model Subscription Add message
or a Config Model Subscription Virtual Address Add message that
is not successfully processed (i.e., it results in an error condition
listed in Table 4.113), it shall respond with the Config Model
Subscription Status message, setting its fields to the values
of the corresponding fields (i.e., the identically named fields)
of the incoming message and setting the Status field to a status code
(defined in Table 4.113), and setting all other fields to 0."
The same applies to other Model Subscription messages.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
It's possible that tx_notify still contains items when a Disconnect
Complete happens. Since the normal path for processing tx_notify is
not taken when the connection is not in CONNECTED state, we must make
sure to process the list latest in conn_cleanup() that's called as one
last thing before the connection object is freed up.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixed a missing reset of FC feature on HCI reset. This
feature provided a simple connection handle based event
exclusions, but this is no longer needed with the
support for controller to host flow control. This feature
should be removed in the future.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
A connection might have gotten disconnected by the time that an ACL
buffer is free up, in which case there is no need to send a HCI
command for it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When a peer master performed a PHY update procedure with no
change, the state machine was not released. This blocked
any future local initiation of the procedure and also
leading to termination of connection with reason LMP
response timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed the usage of NRF_AAR peripheral for controller privacy
to clear events on configure and on every radio ISR entry.
Without this fix, there was spurious AAR matches leading to
controller asserts.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
PHY Update procedure timeout was started without transition
to the state that waits for the procedure to complete. This
prevented the timeout from being reset on successful
completion of the procedure and eventually leading to a
connection termination with reason LMP Response Timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Connection Parameter Request Procedure's Connection
Update Procedure initiation to calculate the offset rather
than selecting offsets from an out-of-bound memory area.
The symptoms of the bug was noticed as a supervision timeout
due to use of incorrect offset communicated to peer and a
wrong offset used in scheduling the connection events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When the peer slave rejects a Connection Parameter Request
Procedure, the controller proceeds to perform a Connection
Update Procedure without clearing the procedure timer that
causes the connection to terminate eventually. This is
fixed by clearing the procedure timeout when the Connection
Update Procedure completes.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If a peer master role has support for Connection Parameter
Request Procedure set in its supported features but would
send an Extended Reject Ind as response to the procedure
then the controller incorrectly initiated a Connection
Update Procedure which is not permitted in a slave role.
This would lead to connection timeout after the used instant
in the invalid Connection Update Procedure.
This is fixed by initiating a Connection Update Procedure
only if in a master role.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Since the Zephyr HCI VS extensions apply to both the Host (using them
for additional functionality) and the Controller (implement the commands
and events), it make sense to make this a common setting in order for it
to be configurable in a way that applies to both.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The PA/LNA feature is not functional on nRF51x series due to added
interrupt latency. Disable this feature unconditionally for those ICs to
avoid unexpected behavior.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Issuing HCI reset command while having connections sometimes
hung the controller.
ll_reset supplied invalid stop ticker id to role_disable
when trying to stop all connections. Connection role does
not utilize stop ticker. The invalid ticker id supplied
referenced memory outside the pool of tickers and based on
what the content is in RAM there, the controller would hang
trying to stop connections.
Fixed by not calling the ticker_stop interface with invalid
ticker ids.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Proxy configuration messages are allowed (in fact required) to use
unassigned addresses, so they should be exempt from this check.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The test failure may be e.g. because of an unknown company id, and in
that case the spec expects us to ignore the message.
With this patch it should be possible to pass MESH/SR/HM/RFS/BI-01-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
A previous patch which moved dispatching the health publish callback
to a later moment introduced a regression where the period divider
does not get updated when it should. In fact, having the divider as
part of the Health Server context is redundant, since the same
information is already stored generically in the model publication
context. Switching to using the model publication context makes things
simpler and ensures that the value is always up-to-date.
With this patch it is possible to pass MESH/SR/HM/CFS/BV-02-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We should ignore invalid addresses (helps pass
MESH/NODE/CFG/LPNPT/BI-01-C). Also fix a copy-paste issue in an error
log.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The values all need to be zeroed when heartbeat subscription is
disabled. This makes it possible to pass MESH/NODE/CFG/HBS/BV-01-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Implement the Read Build Information VS command. This returns a UTF-8
encoded string, which is extendable by the user via a new Kconfig
option.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Implement the Zephyr VS command that allows a Host to write a public
Bluetooth Address to the Controller in order to allow Hosts to provide
their own public Bluetooth addresses.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
From section 3.4.5.3 in the Mesh Profile Specification 1.0:
"A node shall implement a Local Network Interface."
Removing the Kconfig option also helps clean up quite a lot of code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The bt_mesh_net_relay() function needs to allow TTL <= 1 for the local
network interface since that's the code path that locally originated
outgoing packets take.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Mesh Profile Specification v1.0, 5.3.3:
"On the PB-ADV bearer, when the receiver has received all segments of
a transaction, the receiver shall calculate the FCS for the received
Provisioning PDU, and if it matches the FCS field in the Transaction
Start PDU, it shall send a Transaction Acknowledgment PDU after
a random delay between 20 and 50 milliseconds."
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Mesh specification recommends defaulting to the company ID in the
composition data when no other ID is relevant (e.g. in error cases or
if the app has not provided a callback).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Encrypting and sending a message takes a considerable amount of time
which makes the publication period longer than expected.
With this patch it is possible to pass MESH/SR/HM/CFS/BV-02-C test.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The branch for handling the case when the app has not provided a
callback for health faults was encoding the payload in a wrong way.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To avoid signedness issues with some compilers, like icx, use 'char *'
instead of 'unsigned char *' for the at_client buffer.
Fixes#3600
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code was passing the wrong first parameter to the sdu_len_is_ok()
function.
Fixes#3985Fixes#3984
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
It makes no sense to respond with Pairing Failed PDU to another
Pairing Failed PDU.
Jira: ZEP-2620
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Move the use of tIFS software switching PPI index set up by
one position to make place for use of PA/LNA implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Earlier design captured AA twice in the first Rx in a slave
connection event and retained one of the capture until end
of event to calculate drift.
Design updated to use single capture of AA and save the
first AA capture in a slave connection event in RAM instead.
This frees up a PPI channel in the controller design.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Document internal the purposes of various Tx/Rx PDU end
capture setup.
Also, removed any redundant capture of packet end.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor refactor of radio_tmr_start to reduced duplicate
assignments common in if-then-else control path.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated debug pin mapping so that the outputs are on P3 pin
head on all nRF5x Development Kits.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed the configuration of NRF_CCM for 2M PHY connections.
Now faster 2M data rate mode will be used when a connection
is in 2M PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use correct NRF_AAR enable macro defines from Nordic MDK.
Old code funtionally worked fine even though not setting
the correct enable value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed a bug in the implementation of Connection Parameter
Request Procedure when initiated in master role caused the
connection to terminate with reason LL response timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The status in the Command Complete event was uninitialized, leading to
incorrect contents of the event parsed by the Host. Correctly initialize
the status to success.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
During testing it was discovered that directed advertising
timeout is missing implementation to handle the timeout
happening while next event is already in preparation.
The consequence was that after the event ticker expired,
the counter is shutdown, stalling the setup PPI from
starting the erroneous advertising, leaving the controller
in an invalid hung state.
This has been fixed by correctly handling the cases, stop
between prepare and event, and stop inside radio advertising
event. The fix takes care of putting the radio active
callback and HF clock in the correct states.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Whenever the HCI ACL flow control is violated by the Host, a Data Buffer
Overflow event is now issued by the Controller (if enabled) to notify
the Host of the buffer overrun.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Added missing asserts to catch high CPU use in radio ISR and
latencies, without which if radio packet pointer is not set
correctly, would cause spurious transmissions and invalid
behavior.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Optimised the get() function in nRF5 hal rand implementation
to reduce number of probable branching operations.
This is needed to reduce nRF51 platform's CPU use in radio
ISR when using the fast encryption setup implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the code to acquire the RSSI sample after critical
control path that processes PDUs.
This is needed to reduce the time taken to assign the next
packet ptr inside radio ISR.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
To meet CPU time usage restricts inside radio ISR on nRF51
SoCs, use ccflags -Ofast when using fast encryption setup
implementation in the controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Default to n the support for Data Length Update and
PHY update procedures on nRF51 SoCs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed an assert when peer responded with unknown rsp to
slave feature request when an existing another control
procedure was in progress.
This assert happened with a BT v4.0 peer implementation that
was performing a channel map update and local controller
initiated a slave feature request, receiving an unknown
response.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Without this fix there is an issue when doing PB-ADV provisioning
with PTS. We keep retransmitting Public Key which is ACKed by PTS and
this leads to transaction timeout as PTS does not send confirm probably
because it keep receiving PK from us.
This patch also makes sure that transaction id is between 0x80 - 0xFF
Signed-off-by: Łukasz Rymanowski <lukasz.rymanowski@codecoup.pl>
Needed for following PTS test cases:
MESH/NODE/PROV/UPD/BV-10-C
MESH/NODE/PROV/BI-02-C
Signed-off-by: Łukasz Rymanowski <lukasz.rymanowski@codecoup.pl>
Fix the control and data packet management implementation
discovered during conformance testing.
This fixes:
TP/SEC/MAS/BV-12 [Master Start Encryption: Overlapping
Procedure]
TP/SEC/MAS/BV-13 [Master Start Encryption: Overlapping
Procedure with LL_SLAVE_FEATURES_REQ]
conformance tests in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Privacy on nRF51 is not passing the conformance and qualification tests
due to the time it takes to execute the privacy code while in ISR. Until
we come up with a way of optimizing and/or deferring the work, do not
allow privacy on nRF51 targets.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Use the macros generated during the build and located in version.h to
fill in the version information in the Read Version Information VS
command. Additionally reply with the correct hardware identifiers when
running on Nordic hardware.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Seems due to incorrect rebase in commit 07270e52ba
("Bluetooth: controller: Coding style and refactoring"),
commit 95d55a2bfc ("Bluetooth: controller: Do not skip
one-shot tickers with slot"), and
commit 4ba2bb0d1c ("Bluetooth: controller: Be fair when
pre-empting a ticker"), a pointless expression was
introduced, fixed it.
Coverity-CID: 171563
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The code was setting the wrong bit of the Static OOB Type when a
static value has been provided.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixes an assert during connection establishment when the
initiator overflows the initiator window in time while
sending the CONNECT_IND PDU. The actual window is one low
frequency tick less, hence corrected the check that permits
the transmission of CONNECT_IND PDU inside the initiator
window.
Symptom was, stopping of the scanner's ticker succeeds on
connection establishment, but next interval prepare was
already run when continuous scanning was used, breaking the
design, hence there was an assert.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement the Zephyr Read Key Hierarchy Roots command, returning the IR
and ER present in nRF5x ICs when compiling for those.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Implement the first Vendor-Specific Command of the Zephyr specification
other than the 3 mandatory ones already present in the codebase, along
with a Kconfig option to enable and disable the presence of the VS
commands.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This is necessary in order for k_queue_get to work properly since that
is used with buffer pools which might be used by multiple threads asking
for buffers.
Jira: ZEP-2553
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Refactor the Connection Parameter Request Procedure to be
separate from and not overlap the variables of the
Connection Update Procedure.
Also, added missing implementations to pass all Connection
Parameter Request Procedure related Conformance Tests.
Jira: ZEP-1918
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement the LE Read Channel Map HCI command, along with making the
reading of the multi-byte channel map value from the connection pointer
thread-safe in case the ISR triggers while we are reading the value.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Although the current BLE controller only supports a single TX power (0
dBm), the qualification tests require the 2 Read TX Power to be
present and supported in the controller, so implement them while
returning always 0 dBm.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When the CONFIG_BT_CTLR_CONN_RSSI option is set, the connection RSSI is
available in the controller, and can be reported to the Host via the
Read RSSI command. Implement the command, which is required for
qualification.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
There are 2 possible interpretations regarding the address to return in
response to the Read Peer RPA HCI Command:
1) The RPA that the local controller generates to be used in certain
packets it sends
2) The RPA generated and used by the peer device in its packets
We used to return 1) but our interpretation turned out to be incorrect
when reading the HCI test specification, so this commit switches to
returning 2).
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In the ll_rl_pdu_adv_update() function, the check to verify if we are
dealing with an item from the resolving list or else with a simple
standard non-privacy enabled device was left over from the previous
iteration, which used negative values. Replace that check with the
proper current one, using the size of the rl array as an indicator of
whether the index is valid.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Due to varying remainder value, first interval will need to
consider the remainder value used in microsecond timing from
the start of the initiator window.
Also the tx chain delay and ready delay must be substract
after the window offset is calculated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The Read Remote Version Information command is supported on the BLE
controller, enable the bit in Read Local Supported Commands to reflect
this.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix controller assert due to a bug introduced in commit
07270e52ba ("Bluetooth: controller: Coding style and
refactoring").
This reverts implementation to original way it was and the
calculation of the ticker expiry will now not overflow the
range of the RTC peripheral, which is a 24 bit counter.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix checks for BT_HCI_RAW and move default range after the other range
options, required by Kconfig to avoid overwriting other options.
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
The RSSI value is an 8-bit signed integer. Since the Link Layer works
only with positive unsigned integers, translate into a negative number
at the HCI layer.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Older value of 256 was introduced in 1.7 times. Testing on
BOARD=96b_carbon with 2 weeks old codebase however showed that TX
thread stack however can grow to 324 bytes. Finally, with the
latest master, following stacks are reported on BLE disconnect
(with CONFIG_INIT_STACKS enabled):
rx stack (real size 1024): unused 452 usage 572 / 1024 (55 %)
tx stack (real size 384): unused 16 usage 368 / 384 (95 %)
Two outcomes:
1. TX stack needs increase.
2. Over time, the stack usage grows, plus variations in SPI
drivers should also be taken into account.
So, increase the stack size to 416 bytes, to leave some headroom
beyond the immediate values seen on 96b_carbon.
Jira: ZEP-2510
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Add a sample application that allows a Zephyr-based Bluetooth
controller to interface with an HCI driver via SPI. This sample
implements the same BT SPI protocol already as Zephyr's HCI SPI
driver.
Currently, the sample only supports the legacy SPI API.
Provide a single configuration file, avoiding board-specific
files. Some board-specific configuration information must be provided
via other means:
- CONFIG_BT_CONTROLLER_TO_HOST_SPI_DEV_NAME
- CONFIG_BT_CONTROLLER_TO_HOST_SPI_IRQ_DEV_NAME
- CONFIG_BT_CONTROLLER_TO_HOST_SPI_IRQ_PIN
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Since Extended Scanner Filter Policies is an independent feature from
Controller-based Privacy, split it out so it can be built independently
and included without it.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Unless offset was specified, it should default to 0, whereas
previously, value from the last command was used.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Whenever privacy is enabled, we support the Extended Scan Filter
Policies functionality, and therefore we must show it in the bitfield of
LE supported features for the controller.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Rename the BT_CONTROLLER prefix used in all of the Kconfig variables
related to the Bluetooth controller to BT_CTLR.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Avoiding segmentation in the GATT-based Mesh Proxy protocol requires
having an RX buffer length of at least 77. We could round it up to 80
since there's otherwise wasted space, however there's also
BT_HCI_RESERVE to consider, so to avoid pushing over the 4-byte
boundary for certain HCI drivers just leave the size at 77.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Implement the 4.2 event LE Directed Advertising Report, used for
scanners in a privacy-enabled controller to report directed advertising
events whose TargetA cannot be resolved by the local controller.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add implementation to support PHY update procedure with
packet transmit time restrictions.
This fixes:
TP/CON/SLA/BV-49-C [Initiating PHY Update Procedure Packet
Time Restrictions]
TP/CON/SLA/BV-50-C [Responding to PHY Update Procedure
Packet Time Restrictions]
TP/CON/SLA/BV-52-C [Initiating PHY Update Procedure Packet
Time Restrictions, No Change]
TP/CON/SLA/BV-53-C [Responding to PHY Update Procedure
Packet Time Restrictions, No Change]
TP/CON/MAS/BV-49-C [Initiating PHY Update Procedure Packet
Time Restrictions]
TP/CON/MAS/BV-50-C [Responding to PHY Update Procedure
Packet Time Restrictions]
conformance tests in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The CONFIG_BT_WAIT_NOP define is used only by
zephyr/subsys/bluetooth/host/hci_core.c.
It is also the only config in drivers/bluetooth that is in use when
BT_CONTROLLER is enabled. Moving it into the bluetooth subsystem
allows us to restructure the drivers/kconfig code such that the entire
Bluetooth driver menu option is omitted when the BT_CONTROLLER is
enabled.
Moving it will also mean that all configs in drivers/bluetooth will
now be related to configuring the source code in drivers/bluetooth.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.
Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There are two kinds of HCI implementations. Bluetooth drivers in
drivers/bluetooth that implement HCI by using a wired serial
transport layer to talk to an external controller chip. And a
bluetooth controller in subsys/bluetooth/controller that directly
talks to an internal on-chip controller node.
Currently, when the the subsys/bluetooth/controller is used there
still exists exposed to the user a bluetooth driver configuration
menu, even though no external bluetooth driver is in use. This is due
to a dependency on certain configs in driver/bluetooth that are needed
even though no external controller is used.
This patch moves one of these configs, BLUETOOTH_HCI_RESERVE, from
drivers/bluetooth/hci/Kconfig to subsys/bluetooth/host/Kconfig such
that eventually we can omit the entire Bluetooth driver menu option.
This re-organization does not change when the config can be enabled.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Fix incorrect return data type, which causes controller to
hang generating random numbers.
Fixes bug introduced in commit d90095b556 ("Bluetooth:
controller: Use random numbers in adv and enc setup")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The specification requires the scanner to verify that the AdvA present
in a scan response matches the AdvA that was sent in the original scan
request.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Added implementation to get random numbers in ISR. And fixed
implementation to use random numbers in advertisement random
delay and encryption setup procedure.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The existing check for the TargetA address in directed advertising
events was incorrect. In fact the specification states:
"An initiator that has been instructed by the Host to use
Resolvable Private Addresses shall not respond to directed connectable
advertising events that contain Public or Static addresses for the
target’s address (TargetA field)."
Hence, reject TargetA values that have not been successfully resolved
when the controller is generating its own RPAs.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix compiler warnings resulting from passing C string literals to
functions expecting an unsigned char pointer.
Jira: 2443
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To be able to get a hit on the AAR whenever a Scan Response is received,
enable it in the state transition.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add missing checks for the logic that discriminates between whitelisting
and non-whitelisting filtering, so that we do not fall into an
unsuspected false positive.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Rework the ctrl_lrpa_get() function so that it doesn't require an
assignment to be present inside the if statement, yielding smaller and
safer code.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Advertising reports generated by a scanner require the controller to
look up the resolving list to supply the host with an ID address instead
of the RPA that has been sent over the air.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Use the actual scanner address to copy the generated RPA into, instead
of mistakenly copying it into the advertiser's address.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Whenever trying to generate a local RPA to send a scan request or a conn
ind, verify that it can be generated (i.e. no NULL IRK provided by the
Host) and fall back to using the public/random address if required.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since the hardware expects big-endian IRKs but the common generation
function expects it in little-endian, copy and reverse the peer IRK
before generating RPAs.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Implement the LE Enhanced Connection Complete HCI event, but include it
only when controller-based privacy is enabled, since it is only relevant
with it.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since a connection attempt can fail and will still generate an LE
Connection Complete event, check the status from the LL control module
before incrementing the HCI connection count used for flow control.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The Test ID was incorrectly being added as 4 bytes (size of a pointer)
instead of the intended 1 byte.
This fixes Coverity CID 173643.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The current 960 is at least too small under qemu_x86:
ecc stack (real size 1024): unused 36 usage 988 / 1024 (96 %)
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The nRF5 AAR requires the packet pointer to be placed exactly 3 bytes
before the beginning of the address. Since we don't use the S1 extra
length byte, substract one from the address of the radio packet pointer.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The currently supported hardware in the LL requires big-endian IRK
values to properly function. Reverse the order of the IRK bytes coming
from HCI to address this issue.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The nRF5's AAR was being improperly configured, leading to a NULL
scratch pointer which made it not function at all.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In order to make sure that the ISR never gets an incomplete or partial
local RPA, use pointers to share the local RPA between thread mode and
ISRs. Pointer updates are guaranteed to be atomic at least on ARM
Cortex-M.
Additionally add support for using local RPAs when initiating a
connection or sending a scan request.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since the hardware is only able to resolve the first address in the
packet, use the existing functionality to resolve a potential TargetA
RPA in software to verify if it matches the local device.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit introduces controller-based privacy for both the scanner and
the initiator roles. All the features in the specification are
implemented except:
* RPA resolution for directed advertising (TargetA address)
* RPA generation for scan requests and conn ind packets
Follow-up patches will cover the 2 items of functionality still missing
from the basic implementation. Hosts not using controller-based privacy
should not be affected by this change.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
If peer has previously configure to received service changes indications
any changes to the database during the time it has been disconnected
shall be indicated once it reconnects:
[bt] [DBG] sc_process: (0x004065b4) start 0x000a end 0x0014
[bt] [DBG] sc_save: (0x004065b4) peer b8:8a:60:d8:17:d7 (public)
start 0x000a end 0x0014
[bt] [DBG] bt_gatt_connected: (0x00405240) conn 0x00405aa0
[bt] [DBG] gatt_ccc_changed: (0x00405240) ccc 0x00400b30 value 0x0002
[bt] [DBG] sc_ccc_cfg_changed: (0x00405240) value 0x0002
[bt] [DBG] sc_restore: (0x00405240) peer b8:8a:60:d8:17:d7 (public)
start 0x000a end 0x0014
[bt] [DBG] sc_process: (0x004065b4) start 0x000a end 0x0014
[bt] [DBG] gatt_indicate: (0x004065b4) conn 0x00405aa0 handle 0x0008
[bt] [DBG] sc_indicate_rsp: (0x00405240) err 0x00
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
bt_gatt_indicate return 0 in case of success, not true, so
SC_INDICATE_PENDING was flag was not set when it should.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Control and Data packet Tx queue management updated to be
optimal and defer control packet responses when Tx is paused
during encryption setup.
This fixes:
TP/SEC/MAS/BV-12 [Master Start Encryption: Overlapping
Procedure]
TP/SEC/MAS/BV-13 [Master Start Encryption: Overlapping
Procedure with LL_SLAVE_FEATURES_REQ]
conformance tests in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix handling of different procedure collision when receiving
a PHY update request and handling of reject extended
indication.
This fixes:
TP/CON/MAS/BV-47-C [Handling Protocol Collision – Different
Procedure – Channel Map],
TP/CON/SLA/BV-46-C [Handling Protocol Collision – Different
Procedure – Channel Map] and
TP/CON/SLA/BV-48-C [Handling Protocol Collision – Different
Procedure – Connection Update]
conformance test in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing PHY update event generation on same procedure
collision,
This fixes TP/CON/SLA/BV-44-C [Handling Protocol Collision –
Same Procedure] conformance test in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix PHY update procedure intiation to use correct No Change
value in MtoS and StoM when there is no change to respective
PHYs. Also, added missing HCI event generation under this
case.
This fixes TP/CON/MAS/BV-41-C [Initiating PHY Update
Procedure] conformance test in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As ticker can only drift in 32kHz units, the slave Rx
window should consider a +/- one 32kHz unit in addition to
+/- 16us jitter of the master. Hence, for the current
implementation the slave Rx window jitter is +/- 48us.
Future improvement can be done by using remainder of 32kHz
unit drift to reduce this jitter to +/- 16us.
With this fix 20ppm clock accuracy passes conformance TIM
tests (else 251-500ppm had to be used).
Problem was not seen in real life as master do not have a
+/- 16us jitter.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix terminate procedure timeout when supervision timeout
equals connection interval. In this case, avoid timing out
in the first event of procedure initiation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix slave implementation to initiate reject_ext_ind if peer
supports reject_ext_ind.
This fixes:
TP/SEC/SLA/BV-11-C [Slave Sending Reject_Ind_Ext]
conformance test in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix handling invalid control PDUs by generating
LL_UNKNOWN_RSP PDU.
This fixes:
TP/PAC/SLA/BV-01-C [Unknown Packet from Master]
TP/PAC/MAS/BV-01-C [Unknown Packet from Slave]
conformance tests in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix access address generation to correctly have two
transitions in the six MS bits and add other missing checks.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor cleanup of Encryption Restart Procedure; No need to
pause rx for slave role on reception of PAUSE_ENC_RSP PDU as
its already paused.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The buf variable may have been unrefed by net_buf_frag_del thus it shall
not be used to store the sent data nor it should be in the
chan->tx_queue.
Jira: ZEP-2395
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix assert in the controller on master connection creation
due to the CONNECT_IND PDU being transmitted beyond the
calculated scan window.
This is related to commit 80a796b493 ("Bluetooth:
controller: Fix scanner to use correct slot ticks")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix an assert in next role event preparation when a
connection terminated during the connection event being
aborted/pre-empted out by the next role event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Since we generate BLUETOOTH_MONITOR_ON_DEV_NAME based on dts we need a
!HAS_DTS check around it. Otherwise we can get into odd build errors.
Its also possibly that we don't specify "zephyr,bt-mon-uart" and in that
case we default to CONFIG_UART_CONSOLE_ON_DEV_NAME (ie 'zephyr,console'
on DTS platforms).
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add an initial implementation for the Bluetooth Mesh Profile
Specification. The main code resides in subsys/bluetooth/host/mesh and
the public API can be found in include/bluetooth/mesh.h. There are a
couple of samples provided as well under samples/bluetooth and
tests/bluetooth.
The implementation covers all layers of the Bluetooth Mesh stack and
most optional features as well. The following is a list of some of
these features and the c-files where the implementation can be found:
- GATT & Advertising bearers (proxy.c & adv.c)
- Network Layer (net.c)
- Lower and Upper Transport Layers (transport.c)
- Access Layer (access.c)
- Foundation Models, Server role (health.c & cfg.c)
- Both PB-ADV and PB-GATT based provisioning (prov.c)
- Low Power Node support (lpn.c)
- Relay support (net.c)
- GATT Proxy (proxy.c)
Notable features that are *not* part of the implementation:
- Friend support (initial bits are in place in friend.c)
- Provisioner support (low-value for typical Zephyr devices)
- GATT Client (low-value for typical Zephyr devices)
Jira: ZEP-2360
Change-Id: Ic773113dbfd84878ff8cee7fe2bb948f0ace19ed
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When populating the hardware filter, add only slots that are marked as
taken to avoid the hardware being confused by all-0 addresses. This
solves an EBQ issue with whitelist filtering.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
To avoid warnings (seen on some machines) that a function reaches its
end without returning a value, conditionally compile the function in a
way that this cannot happen.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix master terminate procedure so that if slave responded to
the ack from master for the LL_TERMINATE_IND then the master
correctly disconnected.
This fixes TP/CON/MAS/BV-09-C [Master Accepting Termination]
in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Tested-by: Ulrich Myhre <ulmy@nordicsemi.no>
Fix implementation to maintain a connection in the slave
role not taking slave latency into use before receiving an
acknowledgement from the master.
This fixes TP/CON/ADV/BV-03-C [Master Missing Slave Packets]
in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Tested-by: Ulrich Myhre <ulmy@nordicsemi.no>
When the controller is configured to have its worker and job
be run at different interrupt priority, check for mayfly
priority being equal was incorrect.
Fixed by conditionally compiling the correct check of mayfly
priority level.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed a defect wherein anchor for first scanner event was in
the past (when looking for a free timeslice to avoid
overlapping with master role events) when actually there
were no master roles active. This defect caused the scanner
role to assert, when started with other roles active (eg.
advertiser), when trying to catch-up to current tick.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This reverts commit 3c23c6f53d ("Bluetooth: controller:
Fix assert due to stale tick count") as this leads to
connection events to be skipped, failing conformance tests.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This reverts commit b5235207d3 ("Bluetooth: controller:
Fix for scanner Rx window hang") as this leads to
connection events to be skipped, failing conformance tests.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix calculation of T_Terminate and other procedure timers by
using ceil on calculated connection interval units.
This fixes TP/CON/MAS/BI-02-C [Master T_Terminate Timer] and
TP/CON/SLA/BI-02-C [Slave T_Terminate Timer] in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Ulrich Solli Myhre <ulmy@nordicsemi.no>
Fix implementation so that both slave and master behave same
during connection setup and generate disconnection complete
with reason 0x3e (connection failed to be established).
This fixes TP/CON/ADV/BV-02-C [Accepting Connections
Timeout] in LL.TS.5.0.0.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Ulrich Solli Myhre <ulmy@nordicsemi.no>
Whenever not using the whitelist the resolving list is traversed to
verify that the device is allowed depending on its current privacy mode.
In the case where the device is not found by address in the resolving
list, allow the request to go through, since we are then dealing with an
unknown devices and the resolving list restrictions do not apply.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This causes num of packets command handling to dead lock since it
is done on RX buffer destroy if used on TX it may not be destroyed
on time causing.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The specification states that the AdvA in a Scan Request packet should
be identical to the one sent in the original advertising packet, so
check this when processing a Scan Request.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When the initiator is using an RPA and we match it using the filtering,
we should return early and allow the device packet through instead of
going through the whole resolving list.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The specification states that filter policies shall be ignored for
directed advertising, so reflect this behaviour in the code.
Additionally when the local device is using RPAs but the peer uses an
identity address, the resolving list index needs to be updated when
traversing the RL to reflect that there has indeed been a device match
even though the IRK match did not happen.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The AdvA in the CONN_IND packet must match the AdvA in the advertising
packet that triggered it regardless of the advertising type.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Added BUILD_ASSERT check for Tx and Rx thread priorities.
The Tx thread priority shall be higher than Rx thread
priority in order to correctly detect transaction violations
in ATT and SMP protocols. The Number of Completed Packets
for a connection shall be processed before any new data is
received and processed for that connection.
The Controller's priority receive thread priority shall be
higher than the Host's Tx and the Controller's Rx thread
priority.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This adds a second vendor service testing if service changed indications
works with more than one change in a row and as a bonus it implements
echo attribute which notifies any data that is written to it:
> ACL Data TX: Handle 3585 flags 0x00 dlen 9
ATT: Write Command (0x52) len 4
Handle: 0x0013
Data: 0000
< ACL Data RX: Handle 3585 flags 0x02 dlen 9
ATT: Handle Value Notification (0x1b) len 4
Handle: 0x0013
Data: 0000
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
With introduction of bt_gatt_service_unregister it is now possible to
unregister service at runtime.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
There could be situations where many services are changed in a row which
would cause k_sem_take to block on the second change, but if the calling
thread is actually the RX thread then this will deadlock since the RX
thread is the one processing the confirmations of indications and it is
blocked k_sem_give is never called.
To solve this the services changes are now offloaded to the system wq
and the code will attempt to consolidate the range being changed so only
one indication is send. If for some reason another changes is caused
while confirmation is pending we just reschedule it to run later to
avoid blocking the system wq in the same way.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
For consistency with the Resolving List, rename the whitelist filter to
match its type and the privacy-enabled version to align it with the
short name used in the RL.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
To correctly handle the allocation and deallocation of resolving list
items, the ll_rl_find and wl_pees_find functions have been modified to
return an invalid index instead of a negative value in case of error.
This is to avoid the ambiguity when mixing indices and negative numbers,
which does not play well with the first index 0.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Upcoming memory protection features will be placing some additional
constraints on kernel objects:
- They need to reside in memory owned by the kernel and not the
application
- Certain kernel object validation schemes will require some run-time
initialization of all kernel objects before they can be used.
Per Ben these initializer macros were never intended to be public. It is
not forbidden to use them, but doing so requires care: the memory being
initialized must reside in kernel space, and extra runtime
initialization steps may need to be peformed before they are fully
usable as kernel objects. In particular, kernel subsystems or drivers
whose objects are already in kernel memory may still need to use these
macros if they define kernel objects as members of a larger data
structure.
It is intended that application developers instead use the
K_<object>_DEFINE macros, which will automatically put the object in the
right memory and add them to a section which can be iterated over at
boot to complete initiailization.
There was no K_WORK_DEFINE() macro for creating struct k_work objects,
this is now added.
k_poll_event and k_poll_signal are intended to be instatiated from
application memory and have not been changed.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The following error and warning is received when connecting
to certain central devices:
[bt] [ERR] hci_num_completed_packets: packets count mismatch
[bt] [WRN] bt_att_recv: Ignoring unexpected request
This could happen if Tx-ed packet is not added to pending
list before a num of completed packets event and/or new Rx
packet is received.
This is fixed by reducing the Rx thread priorities in the
Host and the Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The code in send_frag() depends on being able to allocate a new
pending tx contexts with 100% certainty. We must therefore notify
*all* connections instead of the current one in order to ensure that
there are free contexts available in free_tx.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The num_handles parameter of the Number Of Completed Packets event is
8-bits and not 16-bits, so no helper variable or byte order conversion
is needed.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In case both conn->tx_notify and conn->tx_queue have data in them we
should first process the notify queue and only then new outgoing
packets.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Due to the missing remainder support in the ticker_start
function for first interval, fix implementation so as to
round the first interval/offset during master connection
setup and connection update to within +/-16us.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The worst-case maximum number of CCC entries we need is actually
MAX_CONN + MAX_PAIRED. Provide a helper define for it and use it
whenever appropriate.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The HCI Read Remote Version Information Complete event structure was
incorrect, leading to qualification test failures. This patch fixes the
structure and also the storing of the data in an endianness-agnostic
manner.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
To avoid manipulation of the irkmatch_ok and irkmatch_id, rely instead
on Resolving List indices for all checks in the advertising ISR.
Although we do incur in a small overhead to look it up initially, the
overall gains are worth the change.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The Controller reserved more than required time for
advertisement event length. Due to this, directed
advertisements did not meet the required <= 3.75ms
interval. It is now fixed by having event lengths based
on the advertisement PDU types.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Correct the default value (0x0) for the Event Mask Page 2 and add the
command to set it to the list of supported commands.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Correctly filter out the Authenticated Payload Timeout Expired event
based on the bit present on page 2 of the Event Mask.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In order to be able to filter events present in Page 2 of the Event
Mask, this command allows the Host to set the Page 2 of the bitmask
through the corresponding command.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Reset and initialize filters correctly based on whether privacy is
enabled in the controller. Particularly relevant in the case of the
whitelist, which is handled in a completely different way if privacy is
enabled. Additionally reset the peer IRK list in the resolving list
whenever the list itself is cleared.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When flashing in synchronous mode with BLE roles active,
ticker function calls will be deferred to avoid radio ISR
latencies. Increase the total operations supported by 1, to
accommodate flash driver's use of ticker operations.
It has been observed, without this increase, either the
flash driver returned -ECANCEL or the BLE Controller
asserted on data transmit as a slave (trying to force data
transmit on earliest connection event interval).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Locking interrupts for a long duration is in general bad design, and
is particularly bad for the controller which depends on low latency
interrupts. Instead of using interrupt locking introduce a new flag to
track the shared buffer usage and simply drop characters if the flag
is set.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Implement privacy-enabled filtering in the advertiser role. This
includes all required checks when running address generation and
resolution so that the advertiser complies with the relevant
specification sections.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix missing re-initialization of ret_cb to
TICKER_STATUS_BUSY before every new call to ticker interface
functions' with operation's callback.
One issue was undirected advertisement disable to return
failure status in the scan_adv sample.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
With the fix in commit 3c23c6f53d ("Bluetooth: controller:
Fix assert due to stale tick count") it is required that a
skipping event shall abort the previous role in order to
enable the ticker_job to resume and reschedule next ticker
expiry.
In the scan_adv sample, with continuous scanning, an
advertiser would pre-empt it, but if the advertiser skipped
its event without aborting the scanner, the scanner is hung
with its rx window without a timeout, and HCI command to
stop the advertiser will wait forever to complete.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The scanner was reserving a little less slot ticks which
caused other roles to overlap before scan window could
close.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This doesn't make much practical difference, however it should resolve
Coverity CIDs 170740 and 170748.
Jira: ZEP-2343
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
With the ticker for flash driver added, the Controller was
corrupting memory outside its allocations by incorrectly
using the flash ticker instance to be a BLE role and
corrupting memory. This is now fixed by checking for the
ticker ids to be within the Controller's use before using
them.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In some cases applications may want better control of advertising
instead of the stack doing automated re-enablement. Introduce a new
option that can be used to do more "manual" advertising control.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The BT_DEV_ADVERTISING flag already does a suffient job with tracking
the actual advertising state, so there's no need for bt_le_adv_stop()
to return an error if KEEP_ADVERTISING is set. We still need to clear
KEEP_ADVERTISING, but it should not be considered an error if it was
not set.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixed uninitialised auto variables, that had caused compile
errors under CONFIG_DEBUG=y.
Jira: Zep-2334
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Temporarily, disable scan request notification reports when
LE Advertising Extensions feature is enabled; as support for
enabling scan request notification is not yet added to the
Controller's Link Layer interface functions, yet.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Intention is to test flash driver along with BLE radio.
Added flash shell module with commands for erase, write-check, read and
co-operation with radio stress test.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Extend radio ticker nodes for support in-timeslice execution
Added interface for abort the radio
Added interface for check whether the radio is idle
Added interface for get ticker IDs for timeslice ticker node
Added interface for check whether radio ticker is running
Added interface for check whether radio ticker is initialized
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
In order to associate a hit on the hardware IRK filtering with an entry
of the resolving list, add an array of correspondance between the IRKs
and the resolving list entries.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In order for some of the required checks in the ISR to be performed, we
need to keep track of which of the items in the resolving list are in
the whitelist as well. Track them using a single bit in the resolving
list entries.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In order to obtain the ID (index) of the device matched in a hardware
filter, a new API call has been added along with the required
implementation for nRF5x devices.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When force scheduling a ticker use the number of times the
tickers have already skipped their intervals to decide if
the forced ticker can pre-empt the colliding ticker. This
introduces a fairness amongst tickers contesting for the
overlapping time slice.
Flashing in co-operation with Radio needs to be fair in
order to avoid connection supervision timeouts.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In preparation towards mesh advertise implementation, avoid
one-shot tickers with slots, that have been scheduled to
expire, from being removed by a forced start or update
operation on another ticker.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the PRNG initialization after reading local supported commands,
so that we don't send HCI_LE_Rand if the controller doesn't support it
(we still need to fail the init however). The patch also removes a few
unnecessary #ifdefs related to crypto.h.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To avoid iterating twice through the list, have ll_rl_find() return the
first free empty slot on the list.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add handling of the LE Set Privacy Mode HCI Command along with the logic
required to take it into account when populating the hardware filters.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In order for privacy to work correctly with and without peer IRKs, an
additional hardware filter is required to help match the peer device in
the case address resolution is not possible for a peer since the Host
has not provided a peer IRK for it.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When removing a device from the resolving list, if it contained a peer
IRK then it is necessary to update the indices that point to the peer
IRK list, since the list itself is contiguous in memory.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When using privacy, an additional cache of the actual privacy peers is
required to avoid additional processing in the ISR (since some of the
peers in the whitelist will be disabled by the corresponding privacy
settings). Add the cache and populate the actual whitelist just before
advertising, scanning or initiating a connection.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Properly use the role and feature Kconfig variables to populate both the
supported commands and the supported states in the controller.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since the peripheral role depends on the broadcaster one, and the
central role depends on the observer one, select them automatically
instead of using defaults.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
It's possible that the controller will emit the number of completed
packets event before bt_send() returns, or possibly preempt
send_frag() before it manages to call add_pending_tx(). We have to
therefore add the pending TX entry before calling bt_send().
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixed assert due to stale tick count in role event
preparation. This happens when ticker timeout expiry is
delayed from the requested realtime anchor, due to thread
mode processing overheads and occurring interrupts therein,
if any, that added a delay between requested anchor tick
and actual scheduling for the requested ticker timeout.
The assert is reproduced in bt shell by starting advertising
and following it with continuous scanning (interval 2.5ms,
window 2.5ms), on nRF51x. If the overheads and/or a
advertiser event delayed the scheduling of scanner by over
2.5ms, then the preparation of scanner asserted.
The assert has been fixed by checking for stale tick count
at expiry in role event preparation and skip the event
gracefully.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
For whitelist and resolving list handling, avoid trying to start the
advertiser and scanner roles when they are already running.
Additionally, and since simultaneous scanning and initiating is not
supported, correctly report this to the host both in the supported
states and in the HCI command via an error code, instead of silently
disabling scanning.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
We have conflicting types between the decleration and implementation of
several radio functions. We should be using u32_t everywhere. This
shows up when we try and build with newlib enabled.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Added HAL Radio abstractions to use SoC specific Radio Timings
as documented in SoC's electrical characteristics.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
An OCF is a 10-bit value as defined by HCI, and therefore requires a
16-bit integer to store it.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fixed assert due to incorrect implementation of stopping of
advertiser role under directed advertisement timeout, and
also, fixed assert due to adv stop ticker not being stopped
on advertisement disable from thread mode.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added checks for advertiser and initiator/target addresses
received in CONNECT_IND when performing directed
advertising.
This is required to pass TP/CON/ADV/BV-04-C [Directed
Advertising Connection].
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When directed advertisements timed out, connection context
associated was not being released. Subsequent connectable
advertising or connection creation failed.
This is now fixed by releasing the connection context on
directed advertisement timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor whitelist handling into generic filter management in
preparation for future resolving list ID address filters.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Rename bt_gatt_unregister_service to bt_gatt_service_unregister to be
consistent with other APIs such as bt_gatt_service_register.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This initial commit adds the following:
* Handling of privacy HCI commands
* New Link Layer filter module for both whitelist and resolving list
* Advertising RPA generation with timeouts
Follow-up commits will expand the functionality.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Enforce the logical dependency between SMP, RPA generation and privacy
in the Kconfig files for the Bluetooth subsysem.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
For consistency with the return value and to conform with other naming
schemes, rename mem_is_zero() to mem_nz().
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Use globally available find_lsb_set in Zephyr instead of a
custom find first set function.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Moving the net_buf_pool objects to a dedicated area lets us access
them by array offset into this area instead of directly by pointer.
This helps reduce the size of net_buf objects by 4 bytes.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
gatt-unregister-service can be used to remove the test service at
runtime causing service changed to be indicated:
00:1b:dc:07:31:88 (public)> gatt-unregister-service
[bt] [DBG] gatt_indicate: (0x0011e100) conn 0x0011d880 handle 0x0008
[bt] [DBG] bt_att_req_send: (0x0011e100) conn 0x0011d880 req 0x0011db00
[bt] [DBG] att_send_req: (0x0011e100) req 0x0011db00
Unregistering test vendor service
< ACL Data TX: Handle 3585 flags 0x00 dlen 11
ATT: Handle Value Indication (0x1d) len 6
Handle: 0x0008
Data: 0a001000
> ACL Data RX: Handle 3585 flags 0x02 dlen 5
ATT: Handle Value Confirmation (0x1e) len 0
Jira: ZEP-2225
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
With the introduction of Service Changed support it is now possible to
unregister services at runtime.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds bt_gatt_register_service using bt_gatt_service which contains
the attribute array that is then added to the database saving a pointer
in each and every attribute declared.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
GATT is mandatory service and now that the db can only be build
dynamically there is no reason to keep the applications registering it.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
GAP is mandatory service and now that the db can only be build
dynamically there is no reason to keep the applications registering it.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes applications able to select the value used for the
GAP appearance attribute.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Removes CONFIG_BLUETOOTH_GATT_DYNAMIC_DB in preparation to the
introduction of bt_gatt_unregister.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In certain cases a response may happen even before number of complete
packets is generated by the controller:
[bt] [DBG] att_req_destroy: (0x0011cfe0) req 0x0011daa0
[bt] [DBG] att_process: (0x0011cfe0)
[bt] [DBG] att_req_sent: (0x0011d780) conn 0x0011d820 att 0x0011d9a0
att->req 0x00000000
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In preparation towards Privacy 1.2, move implementation that
swapped scan response PDU double buffer to same place as
where adv data PDU double buffer is swapped. So that, change
in AdvA in adv data PDU can be reflected in scan response
PDU buffer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added fix to avoid adv data set function call from
corrupting a ADV_EXT_IND PDU under LE Extended Advertising.
Also, avoid redundant code execution under directed
advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Only ADV_IND, ADV_DIRECT_IND, and CONNECT_IND PDUs can have
ChSel bit set in Advertising channel.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The Bluetooth subsystem assumes execution of its system threads in
cooperative priority, including the system workqueue and the thread
that interact with the controller (i.e. calling bt_send). This commit
adds a compile-time check for the system workqueue priority and
documentation for the bt_send API call.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fixed compile error due to the missing header file
dependency on bluetooth/hci.h, for bt_addr_le_t, in the
Link Layer header file.
Merge of PR #475 introduced the new dependency that broke
compilation after merge of #474.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a callback function ll_adv_scan_state_cb from the
Controller that gets called on either an advertiser or a
scanner getting started as the Controller's first enabled
state. The callback is also called on the Controller's
last disabled advertising or scanning state.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing implementation to reset the advertiser state
when directed advertisements stop without a connection being
established.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add Bluetooth Link Layer LE Advertising Extensions commands
for manual testing the feature during development. First one
being advx command to start non-connectable non-scannable
extended advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In order to reuse code, the reset() function is used both to handle the
reset HCI command but also to initialize the internal HCI variables when
bringing up the system. In the latter case, avoid setting the reset bit
in the state atomic and signalling the polling API, since that is not
required during initialization.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
As a preparation for advanced filtering (Controller-based privacy) this
commit refactors whitelisting so that it becomes its own module and
actually correctly performs state tracking to avoid modifying the
whitelist when it's in use.
Additionally it also removes the duplicate separate entries for
advertising and scanning, since the specification only allows one single
global whitelist singleton.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add internal functions to read advertiser and scanner filter
policy if the roles are enabled. This is required to
restrict updates to whitelist and resolving lists when
filter policy are being used by the roles.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Under invalid host behavior, trying to start advertising
while already active would corrupt the advertiser context.
This is fixed by having an explicit flag to check whether
advertiser is already running.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Under invalid host behavior, trying to start scanning while
already active would corrupt the scanner context. This is
fixed by having an explicit flag to check whether scanner is
already running.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Restrict encryption support on nRF51 series SoC to Bluetooth
LE 1M PHY and max. 27 bytes PDU. If 251 bytes PDU using Data
Length Update procedure is desired, then LE Encryption
procedure will not be supported (until a software CCM is
implemented in future).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add Kconfig option to be able to conditional compile the
Bluetooth v4.0 LE Encryption procedure.
This is needed in order to be able to not support encryption
on nRF51 series when using Data Length Update procedure with
upto 251 byte payloads until a software-based CCM support is
implemented.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a repeat param to gatt-write-without-response so that
it covers what gatt-write-without-response-repeated was
doing. gatt-write-without-response was removed in the
commit 26eae70da.
gatt-write-signed too will have repeat param with this
change.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
At the moment all bluetooth logs are prefixed with [bt] making it
difficult to understand where the logs belong to.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
It's mandatory to set chan->ops so explicit checks for it are
redundant. What's worse, inconsistent checking for this triggers
static code analyzer warnings. This patch fixes Coverity CID 151984.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
buf->len should be validated before accessing it since remote can
send invalid frame_len which can result in out of bound memory
access.
This also fix the len check wrt cstate, since current check is
not considering the cstate length size and frame_len size.
Jira: ZEP-2110
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Added shell module for the Bluetooth Controller's ticker
interfaces.
For now, info command enumerates active tickers' details.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This makes gatt-write-signed to reuse cmd_gatt_write_without_rsp since
it is quite similar and that adds the ability to send multiple octecs
instead of just a single byte.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This removes gatt-write-without-response-repeated and makes
gatt-write-without-response similar to gatt-write which was the
intention of gatt-write-without-response-repeated.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
All the files under shell subdir shall only be build if
CONFIG_BLUETOOTH_SHELL is selected.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In order to properly queue request there need to be a bt_att_req
storage but none of the calls to gatt_write_ccc were using the params
causing gatt_send to use bt_att_send and not bt_att_req_send.
To fix this now all the callers of gatt_write_ccc do set the params
properly but this means that bt_gatt_unsubscribe has to wait for it
to be completed before the application can reuse the
bt_gatt_subscribe_params.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
While returning 32-bit values from radio status interfaces,
explicitly compare radio h/w event registers to be non-zero,
dont just return the direct 32-bit h/w register content.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added extra assert checks to detect controller failure if
a role event preparation function was not followed by the
role event start function.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
For some write requests, such as CCC, the code doesn't use an ATT
request context but we still need to clear the request timeout when
the response comes. Move the k_delayed_work_cancel() call to the right
place and add some debug logs that helped pinpoint this issue.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Both scan on and scan passive performed passive scanning,
fixed scan on command to use active scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In commit c41d3edda when implementing the alternative
encryption setup implementation, the original fast
encryption setup implementation was broken. When host is
slow in responding to LTK request, the controller asserted
when fast encryption implementation is selected. This is
now fixed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the assert in the controller during connection setup
when peer does not support CSA#2 feature and free Rx buffer
queue does not have enough buffers to generate CSA event.
The assert was reproduced by turning on advertisement
indication and scan request notification features in the
controllers advanced features, and a peer that does not
support CSA#2 initiated a connection.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Since role support is fundamental to both the Host and the Controller,
move the role configuration options to the top-level file and rename
them to fit the GAP specification, avoiding confusion between GAP and LL
names.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Only include connection-related options when CONFIG_BLUETOOTH_CONN is
selected, since otherwise this can lead to inconsistencies between
features and supported commands.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This replaces the use of shell_register_prompt_handler with
SHELL_REGISTER_WITH_PROMPT which doesn't overwrite other modules
prompt.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If CONFIG_BLUETOOTH_GATT_CLIENT is not defined disable command that
would depend on it.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Due to several changes in the way stacks are calculated, 320 bytes is no
longer enough for the controller-only build. After measuring usages of
up to 320 bytes (locally) and 376 (reported by Ricardo Salveti), the
stack size is increased by 128 bytes, up to 448 bytes.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The msgtype value is created using 'hdr & 3' which means that the
resulting value can never be greater than 3. This fixes Coverity CID
166771.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Added implementation to auto-update LE Data Length to max.
Tx octets supported by the local and peer controllers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to handle an incoming Reject Ext Ind PDU in
response to a sent Length Req PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When initiating Data Length Change at the same instant the
crossover condition was not handled correctly causing the
controller to assert.
This fix will allow crossover of Data Length Update
procedure, and this collison is harmless as per Bluetooth
specification, and gracefully handled by the controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Return error codes for HCI Tx buffer overflow conditions are
missing which would lead to silent dropping of Tx packets if
host implementations do not follow number of completed packets
or use correct buffer counts as returned by HCI Read Buffer
Size command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Since the PHY update complete event can be generated due to the
procedure being initiated by the peer, use a flag to
differentiate between local auto update initiated on connection
complete versus peer initiated anytime in the connection. This
is necessary to avoid repeated initiation of auto-update
procedures intended only to be issued on connection complete.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
With the support for 2M PHY added, the controller can now Rx/Tx
upto 18/19 minimum sized L2CAP packets per 7.5ms connection
intervals.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
To better debug the flow of events into the Host, log the subevent code
whenever processing an LE Meta Event.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When required Rx MTU is less than configured Rx MPS, the
resultant initial credits was 0 which prevented any L2CAP
packet to be received.
Fixed by ceiling the initial credits count in the credits
calculation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
To be consistent with other subsystem menu, use menu for
Bluetooth support in Kconfig instead of menuconfig which
showed up as checkbox.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
To allow for hci_uart builds that do not include the controller code,
move the UART Kconfig option used by the sample up one level so that it
is shared by all configurations using Bluetooth:
Jira: ZEP-2132
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since more and more code is going to be reused by both the Host and the
Controller, this commit introduces a common/ folder that will contain
everything that is not tied to one of the two components but shared by
them.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This reverts commit 698de88916 ("Bluetooth: controller:
Cleanup redundant ticker busy loop")
Scan enable asserted in ctrl.c line 3756 due to the fact that a
role event was active and ticker job has hence been disabled.
Add back the busy loop so that scan enable can wait until the
active role event completes gracefully.
The ticker busy loop is mandatory in all ticker interface calls
if a blocking behavior is desired.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The calculation in packet_rx_reserve_get() was already handled by
packet_rx_acquired_count_get(). So, let's use that code instead
and remove the duplication.
Change-Id: Ic76f70f1e78bebc74f5bef36cd92a3c332e489e9
Signed-off-by: Michael Scott <michael.scott@linaro.org>
This calculation can be used in packet_rx_reserve_get() where currently
the code is duplicated from packet_rx_acquired_count_get().
Let's allow use of packet_rx_acquired_count_get() regardless of whether
CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH is enabled.
Change-Id: I613bde0a407f3caccabb22f369098575965e98ad
Signed-off-by: Michael Scott <michael.scott@linaro.org>
During testing, lr->max_rx_octets and lr->max_tx_octets were
at times set to 0. If we use these 0 values, we end up with
very erratic behavior. Best, to check for a sane value and
if invalid, default to the value in _radio.conn_curr->max_*x_octets.
Change-Id: I57c0e3790d988f0de17993cebe5c5c2ab0fc07a6
Signed-off-by: Michael Scott <michael.scott@linaro.org>
When Controller to Host flow control is enabled, output informational
messages for certain operations to help tune and debug the feature.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since the HCI driver debug option applies to both files in
drivers/bluetooth and subsys/bluetooth, the configuration option itself
now lives in the top-level Kconfig file for consistency.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Added implementation to auto-update Bluetooth PHY to 2Mbps
if the local Controller supports it.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added support for Bluetooth v5.0 PHY Update Procedure in the
Controller.
Asymmetric PHY connections do not work for now due to the
Radio mode not being setup in time in the ISR during tIFS
period and the Radio already ramping up in the cached
previous Radio mode to meet tIFS deadline.
Subsequent commits will add this feature, by either double
buffering the mode in software or using fast radio ramp up
which gives enough time in the ISR to change the mode.
Jira: ZEP-2086
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Scale the ctrl pkt enqueue implementation to allow multiple
ctrl packets to be enqueued. This will aid in the graceful
implementation of parallel control procedure collisions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added HCI macros to check LE Features. Also, added test
macros for 2M and Coded PHY support in HCI Controller.
Earlier a common test macro was used between BR/EDR and LE,
but since LE features do not use pages for feature, an
explicit macro for testing LE feature is added now.
Also, features field in LE device structure is now a single
dimension array of 8 octets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The APIs for allocating RX buffers were modified recently and hci_raw
had not reflected those changes properly.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The event mask population used to let the Controller know which events
are relevant to the Host needs to take into account the features
supported by the Controller itself, in order to only enable those that
are indeed valid.
Jira: ZEP-2050
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Implement the framework for LE Scan Request Received Event.
The feature is available under the Controller's advanced
features and will be selected implcitly when Bluetooth v5.0
LE Advertising Extensions feature is implemented.
Jira: ZEP-2073
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove unreferenced function hci_evt_is_discardable after
introduction of hci_get_class function.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In preparation for refactoring the Controller implementation
into seperate state and role based source files, add Kconfig
options for states and roles in the Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
To guarantee code that is endianness-independent, the sys_le* macros
must be used everywhere when accessing multi-byte values from the
command parameters.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In HCI, the response buffer to a command is the same as the one for the
command itself, requiring command parameters to be processed before the
response is formed on the same memory area.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since Controller to Host flow control is a feature that affects both
sides equally, move it to the top-level Kconfig file and consolidate its
use in both Controller and Host.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This feature was removed some time ago, but turns out it's important
to have it available for split host-controller setups.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Enable the bits corresponding to the new 3 commands supported when
enabling Controller to Host Flow Control, in order for the Host to be
able to enable the feature.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In order to achieve proper sharing of configuration options, everything
that is common to both the Host and the Controller should now be placed
in the top-level Kconfig file, and Controller-only options are in the
controller/ Kconfig one.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Introduce alternative TRX switching using dedicated timers
and peripheral interconnect. This will enable the
possibility to independently configure the Tx and Rx
settings between the tIFS.
Note, this will also provide the opportunity to design a
soft realtime Radio ISR.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The Bluetooth Specification allows for optional Controller to Host flow
control based on the same credit-based mechanism as the Host to
Controller one. This is particularly useful in 2-chip solutions where
the Host and the Controller are connected via a physical link (UART, SPI
or similar) where the Host is sometimes required to ask the Controller
to throttle its data traffic while still making sure that relevant
events get through the line.
This implementation is based on a simple queue of pending events and
data that is populated whenever the Controller detects that the Host is
out of buffers and then emptied whenever the Host notifies the
Controller that is ready to receive data again. Events relevant to the
connections are also queued to preserve the order of arrival.
At this point the Controller ignores the connection handle sent by the
Host and treats all connections equally, and it also queues events even
for connections that have no data pending in the queue. Both this items
can be improved if necessity arises.
Note that Number of Completed Packets will still flow freely from the
Controller to the Host regardless of the pending ACL data packets, which
might lead to inconsistencies in the sequential order of certain
operations that include bi-directional data transfer.
Jira: ZEP-1735
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This ensures that an unknown request won't cause ATT to timeout since
no response is currently generated.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Rename ll_address_* to ll_addr_*. Also, update ll_addr_get
to return reference to stored public or random address.
Change-id: I22cb0135d2223f679c4d9321f4724f8b7de0aede
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Fix the attr->handler reference to attr->handle.
Change-Id: I4a6ccee7860abf800f51df404979eac18eb26e8e
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Rename occurences of bt_hci_ev_* to more widely used
bt_hci_evt_* namespace.
Change-id: I742fb86f8f835a0f6072638e1e997ad08891d43d
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
In the Controller's radio hal, explicitly differentiate
between Advertisement and Data channel packet
configuration.
Also, remove nRF5x specific extra overhead in Advertisement
PDU structure.
Change-id: I942b88a160af78f8900d7e49fb5f36c8aa493b97
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
L2CAP Dynamic Channel feature uses the global connection Tx
pool for segmentation either when there is no free buffers
in the original application pool or when the original data
buffer has no headroom to add L2CAP headers.
This eliminates the need for a dedicated fallback pool for
Dynamic Channel segmentation.
Change-id: Ia5452c814169d17ef261ecef425a8fcf2e7e1e84
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
This function already has an 'i' variable on the top-level, so no need
to declare a second one that'd just shadow the original.
Change-Id: I5dfa4df2c4793be220a40ac642b19bf440e80220
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The segment allocation function can't fail (it eventually waits with
K_FOREVER for a buffer to become available), so there's no point in
checking its return value for NULL. Also, the connection state check
is because of this particular waiting and not the semaphore waiting
(which is done with K_NO_WAIT).
Change-Id: I9698760541de810869cffc1c60cf97c5f8f7df8d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
L2CAP Tx segmentation used BT_L2CAP_RX_MTU value which is
the value used by fixed channel protocols. Decoupling the
buffer size provides the opportunity to reduce RAM used per
connection.
Change-id: Id064f9b2e3f02073402815d09c3ea13a35df2a6c
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Remove BT_ prefix from BT_L2CAP_MAX_LE_MPS and
BT_L2CAP_MAX_LE_MTU as they are internal to l2cap.c file.
Change-id: I6abec0a1f07b8aef49940ab7abeaacbd19947e0b
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
The switch from C99 integer types to u16_t, etc. caused misalignment
in structs and function definitions with multi-line parameter lists.
Change-Id: I1448b159ab1afe50ff88b7a6bd1b254c44858d4c
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This information should be part of the main BR/EDR context struct,
rather than there being a separate member in struct bt_dev. If/when
the needed ESCO information grows we can consider having a separate
struct, but even then it should be part of the main BR/EDR struct
instead of sitting directly in bt_dev.
Change-Id: I3edf120606ea6c6974f515bba90de2b25fc6fac6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The switch from C99 integer types to u16_t, etc. caused misalignment
in structs and function definitions with multi-line parameter lists.
Change-Id: Ic0e33dc199f834ad7772417bca4c0b2d2f779d15
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.
Jira: ZEP-2051
Change-Id: I8f57a17f78e674aca5400f005db8975c9f9e150e
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
If there are many connections there may be some delay before an ATT
PDU really gets transmitted over the air. Use the TX callback to
start the response timer so that it doesn't expire too soon.
Change-Id: Ibdd5bc1029ae4034caf329bf03892ac2093a0c67
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In order to not overload the TX buffer pool and potentially run out of
them, enforce flow control for outgoing ATT packets so that the send
functions block until the PDU has actually been transmitted over the
air.
Change-Id: Ic065bb88aec8c2d0ac2def8ef62131a427f7051f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This CONTAINER_OF() worked by chance, but was actually wrong, since it
makes it look like bt_l2cap_le_chan is the parent container of bt_att.
Instead bt_l2cap_le_chan is simply a member of bt_att, i.e. we can
dereference it directly.
Change-Id: I7307517bae823e54b45db31f75462655ce6eb50d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There is no command that should take more than a couple of seconds. If
it does there's something severely wrong with the system. Catch such
situations with a clear assert rather than silently blocking the
sending thread.
Change-Id: Ie981fddcc27059df3e4df586e86ceac2e348f509
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
According to the SMP specification the pairing is only to be
considered complete once the last SMP PDU has been transmitted over
the air. Take advantage of the new TX callback to notify completion
only once the packet has really been transmitted.
Change-Id: Ic87e598cd0e040d99f38344b98e476f67e4d9762
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
It's not valid for a peer to send another request before getting the
response to a previous one, or to send another indication without
getting the confirmation to a previous one. Take advantage of the
recently introduced TX callback to track when it's ok to accept these
ATT PDUs again.
The HCI USB transport has a potential issue here since a race
condition can occur between the ACL data and HCI event endpoints,
leading to dropping data when in fact both peers were behaving
correctly. To avoid hitting this issue, disable the flow enforcement
by default on the qemu targets that commonly use a USB-based
controller on the host OS.
Change-Id: I2791aaec6f6c0f8fd78a9a809a25e3ce129106c7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Protocols/profiles may want to know when exactly their PDU has been
transmitted over the air. To make this possible, introduce support for
a callback that will get called when the controller reports that a
packet has been transmitted (through the Number of Completed Packets
HCI event).
Change-Id: Ia3a19b93c5b2111f144bfabe5861187c41525f30
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When the ECC code was last time refactored hci_raw.c was forgotten
about. This fixes the issue so that ECC works again with hci_raw.
Change-Id: I1b1df66f1b2a311db611b9936ec074c88caf4143
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This reduces the pressure on TX pool which may constantly block in case
of heavy traffic causing the RX thread to block as well.
Change-Id: Icfdde32031715e882085b7fa371191f157954156
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes the code attempt to allocate from the original buffer pool
before relying on le_data_pool which shall only be used as last resort
as it is configure with minimal possible buffers (1 per connection).
Change-Id: I85b581627f5c3b1bf1ee7c5fa69099c5aca13d4a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Added support in the Controller for increased feature set
bit fields in Bluetooth 5.0. Cached feature set in the
connection context is increased to a uint32_t value to
accommodate 17 feature bits.
Change-id: I9ae15d6d90fa7a3de186905d3c68088ee22d2911
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
With the introduction of event mask implementation in the
Controller, it is discovered that peer centrals
initiating LE connection parameter requests timed out as
the Host did not get/enable the HCI LE connection parameter
request event in the set LE event mask command.
Fix by adding the LE connection parameter request event bit
mask while creating set LE event mask command.
Jira: ZEP-2027
Change-id: Ida7750f375addc8a91036fffc47325518a3d2ec0
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
To avoid having to define a BIT64() macro in a public namespace, use
instead masks directly instead of bits, and also refactor the host code
so that it uses those instead of the earlier byte array with hardcoded
indices and masks.
Change-id: Ief03db616a96df65349d24289b62566a268ffdd0
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Rename symbol names with channel/chnl to chan.
Change-id: I196ffea79e7e10b0253363949051fdf82be62cb4
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Since the type of int, uint32_t, etc change with newlib we get the
following error:
subsys/bluetooth/host/at.c: In function ‘cme_handle’:
subsys/bluetooth/host/at.c:272:25: error: passing argument 2 of ‘at_get_number’ from incompatible pointer type [-Werror=incompatible-pointer-types]
if (!at_get_number(at, &val) && val <= CME_ERROR_NETWORK_NOT_ALLOWED) {
^
subsys/bluetooth/host/at.c:46:5: note: expected ‘uint32_t * {aka long unsigned int *}’ but argument is of type ‘int *’
int at_get_number(struct at_client *at, uint32_t *val)
^~~~~~~~~~~~~
We we can easily address by making val a uint32_t.
Change-Id: Ie6988368bd862afd4075baede7cb0a66c1628c18
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
If we use newlib the isdigit (and other similar functions) return an
error as char can possibly be viewed as signed:
usr/include/ctype.h:57:54: error: array subscript has type ‘char’ [-Werror=char-subscripts]
#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)])
Being explicit about the char being unsigned char deals with this.
Change-Id: I348189e1df11a1fcc58e5810b010b602fd2df33e
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
For consistency, "chan" and "param" are used wherever "channel" and
"parameters" are the words in the specification.
Change-Id: I778a8501ae6af991618c14cc6e395d765a9ae102
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix doxygen comment typos used to generate API docs
Change-Id: I3efff6f5fa26f87d1e658d6336fef01ce45f5bb0
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
This fixes regression introduced by
87f2f7afec.
Change-Id: I4a1177ad42c7bb20fe66f8927cd00a30236152af
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If the connection process fails the user may still need to do
bt_conn_get_info() in its connected callback, so this needs to give a
meaningful value for the remote address. Start off with the one that
was given to bt_conn_create_le().
Jira: ZEP-2005
Change-Id: I4e9a033dec7c55fa549f5b6746c3bd81c0ccade5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This replaces custom made list manipulation with sys_slist_t which makes
the code more readable.
Change-Id: I9ee024ad83da3e28f2ecab74b001bf0e795fe489
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Use #if defined(...) constructs while using conditional
compilations of advanced event preparation and advanced
scheduling implementations.
Change-id: I728c76d0e7dbbfa378e8978b726ec404d9e55a72
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Move the scan duplicate filter length option and group it along
with rx/tx buffer size Kconfig options.
Change-id: I3df07e667029c7d2571270db442ecb7241a417c2
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
The bt_conn_set_state() function will not notify the connected
callback of the connection error if conn->err isn't properly set.
Jira: ZEP-2005
Change-Id: Idc30e736f4d8ba00156bf5c0e37dcccdb151742f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Conditionally declare the iterator variable to avoid a warning when
compiling the controller without any duplicate filter entries.
Change-Id: I69e23d4c594db18172dc57d45e7925243fe2da69
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The main issue is that after the latest update to TinyCrypt the
ecc_make_key() API expects a twice as big random number. Fix this, but
also move the variables to the static context since we're limiting one
HCI command at a time. Also place the variables in a union based on
their temporal dependencies. Thanks to this, we can now further reduce
the ECC stack size by 40 bytes (on ARM this then reports 12 bytes of
unused stack after key-pair generation and DHKey calculation).
Change-Id: I1036e0ca15f7c08063cba9e568d7df99e65c9156
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
HCI event masking allows the host to choose which events are reported to
it to avoid interruption and excessive traffic. This patch implements
masking to drop any non-enabled events as specified by the host.
Jira: ZEP-1769
Change-Id: If09d4aa22b0da8f743fc42a3b0db3f369daaff96
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Implement the controller's ability to drop duplicate advertising reports
when instructed by the Host.
Jira: ZEP-1246
Change-Id: I2d1b7abf1ed950dde705e5df30a858c595f3834c
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add Controller advanced Kconfig options to select IRQ
priorities of the Radio, Ticker's Worker and JOB IRQs.
This will provide an opportunity to have peripheral IRQ's
of higher level than Bluetooth Controller.
Change-id: Iaa128c1cd64a309a77d42d485fdefe68f31e4895
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Move the nRF5 specific GPIO debug pin macro definitions to
hal/nrf5/debug.h.
The Controller's hal folder contains prototypes and
hal/<soc> shall contain SoC specific implementation to
realize a software-based Link Layer.
Change-id: Ic7bf283f926bbc3069e7d15c047fe93a6daa894f
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Cleanup redundant ticker busy loop that could hang if the
worker and job IRQ priority levels are misconfigured, and
job gets disabled before all users/mayfly functions using
job complete.
Change-id: I053ad75a4328c51cfe651b820a2fa961e42ae48f
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
In a host plus controller combined build, if no connection
is required, deselect CONFIG_BLUETOOTH_MAX_CONN. This will
reduce RAM and ROM usage in the controller.
Also, make BLUETOOTH_PERIPHERAL, BLUETOOTH_CENTRAL and
BLUETOOTH_CONN switches accessible by the controller kconfig
to select the right roles to enable.
Change-id: I164cf696ab2a6f4859086d2cb18f6d3f2b1399d3
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
BR/EDR sources that was compiled under BLUETOOTH_CONN
if-clause is moved out as independent conditional
compilation based on selected BR/EDR feature support.
Change-id: Iedfafc6056132654a9150ed235b245f8be62b4b1
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
If during hfp_hf_send response callback is not filled with NULL
and you receive unsolicited callback. which will not be taken care.
This patch fixes this issue.
Change-Id: I04007059d62273b9cdddf29e2d4a9086b07a01e5
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
A initiation to send AT commands is given in the application
with prefered AT command as the argument.
This patch supports to send the command within the profile stack.
Change-Id: Id5caa3ce64070fc17e60f4ea61a8c83a961099ba
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
This cause packets that are up to 2 bytes off segment maximum length
to be considered transmitted when in fact that could be some bytes left
to be transmitted which cause any subsequent packet to trigger invalid
SDU on the remote end:
[ 3612.376068] l2cap_le_data_rcv:6757: SDU fragment. chan->sdu->len 66 skb->len 68 chan->sdu_len 67
[ 3612.376073] Bluetooth: Too much LE L2CAP data received
Change-Id: Id2f3469ce1c0b27bb87c4d5bc18e6ede9d93dbde
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Move the Kconfig option BLUETOOTH_MAX_SCO_CONN to BR/EDR if
clause.
Change-id: Iead2bc5a70a9499125f9edf22e85ade4dda8f5ac
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Move the BLUETOOTH_UART_TO_HOST_DEV_NAME options to after
BLUETOOTH_HCI_RAW option to group it together in the
Kconfig while using menuconfig.
Change-id: I21da080a5ffa30a08b1a1aa148ce8116e63a3c18
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Group the stack size related options together to represent a
better order when using menuconfig.
Change-id: Id2968607e5054e30029c42987b3e70cb8cbfc74d
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Move the Kconfig BLUETOOTH_CONTROLLER switch from top-level
Bluetooth Kconfig to Bluetooth Controller Kconfig.
Change-id: Iead760c22a0fbbda11e4558c4943b3366ecc8769
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
This makes the code consistent with respect of errors, so instead of
checking directly on bt_gatt_write_without_response let this up to
bt_smp_sign.
Change-Id: Iea8d0bd2020df427b7542e2878ce8d9fd8b94170
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When there's no support for connections there's also no need to track
the controller side buffers.
Change-Id: I7eac3af486f139f1ab32efda8ccfa188ed8359eb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Checking both if signing has been requested _and_ conn->encrypt can
bypass signing leading to the caller to assume that a proper signature
was send in when fact it was not.
To fix now the code explicitly checks if SMP is enabled and in case it
is and signing was requested fails.
Change-Id: Ie17df4a4c2191f2da0172c687db7999395839a97
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In case the controller is receiving PDUs very rapidly, prevent it from
spamming the logs by limiting its stack analysis to at most once every
5 seconds.
Change-Id: I31c70d28e8af62b27172a4a77bf6e614ea3e20eb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Move company id and subversion number Kconfig to the
Controller configuration section from the features section.
Change-id: Ic4deb8b24d84d9b1817ba542705eebd612f0e020
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Added a explicit Kconfig option to show the Controller's
advanced feature configurations. These feature
configurations need specific in-depth Controller
implementation knowledge and should not overwhelm normal
users of the Controller.
Change-id: Iae764f2b266b199cf180936c51c7a4ea089ee510
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Add Kconfig option to enable advanced scheduling in the
controller.
Enable non-overlapping placement of observer, initiator and
master roles in timespace. Uses window offset in connection
updates and uses connection parameter request in slave role
to negotiate non-overlapping placement with active master
roles to avoid slave roles drifting into active master
roles in the local controller.
This feature maximizes the average data transmission amongst
active concurrent master and slave connections while other
observer, initiator, master or slave roles are active in the
local controller.
Disabling this feature will lead to overlapping role in
timespace leading to skipped events amongst active roles.
Change-id: I16e4e6c3ca99f93987ab86924af0cb9d76bdbc7e
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
HCI drivers are obliged to send HCI Command Status/Complete events
from a separate context than all other data, however the ECC wrapper
was violating this rule (sending everything from the same ECC thread).
This could lead to a deadlock if e.g. the ECC API user decides to
generate a DHKey from the same callback that it got notified of local
key-pair generation.
The obvious solution is to emit the Command Status directly from the
send function, before passing the command to be processed by the ECC
therad (through a k_fifo). However, this is not quite so simple since
bt_buf_get_cmd_complete() reuses the original command buffer, meaning
we'd loose the original parameters after sending a Command Status.
To work around this limitation with bt_buf_get_cmd_complete() we stop
passing the command buffer to the thread and instead store the
parameters in static variables and do the thread communication using
flags and a semaphore. One side effect is that only one command can be
pending at a time, however that works out fine for all of the users of
ECC.
A nice side effect of moving some things to static variables is that
we end up reducing call stack usage in the ECC thread, allowing it to
be shrunk by 180 bytes (verified to be sufficient for both ARM and
x86 boards).
Change-Id: Ic41f0316d3fe4d14b64fd3d0a549b221d168411a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Added Kconfig option to enable advanced event preparation
feature.
Enables advanced event preparation offset ahead of radio
tx/rx, taking into account predictive processing time
requirements in preparation to the event, like control
procedure handling and CPU execution speeds. Crystal
oscillator is retained between closely spaced consecutive
radio events to reduce the overall number of crystal
settling current consumptions.
This feature maximizes radio utilization in an average role
event timeslice when they are closely spaced by using a
reduced offset between preparation and radio event.
By disabling this feature, the controller will use a
constant offset between the preparation and radio event. The
controller will toggle crystal oscillator between two
closely spaced radio events leading to higher average
current due to increased number of crystal settling current
consumptions.
Change-id: I19e640f7395ac7938873ef4bfac38acf8d6f7e0e
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
The monitor protocol provides support for logging packet drops with
the help of the extended monitor header. Implement support for this.
Change-Id: I7ef7894816cb8d1bd876842d0253ef0980471e69
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The IRQ lock should never be held for long periods of time. Instead of
using the IRQ lock to prevent monitor protocol corruption simply drop
the data. Follow-up patches will add additional drop count tracking so
that these get reported properly over the protocol.
Change-Id: If498125b29f1b58bed676c78ad2062e2aa206318
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Using lookup table to search for unsolicted command and its
handler function.
Change-Id: Id677dad3918d7187e0065ada2985ec12a97f8ed9
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
Same volatile status variable as return and being updated
in ISR would modify the variable in two context which
caused the variable to be set to a stale value.
This commit uses two different variables, one for return
value and the other to be updated by ISR.
Jira: ZEP-1941
Change-id: I19e3bdc85e15bda7891395f3f1f64c2ddbeee0c6
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
role_disable initiated through HCI commands are initiated
in thread context and controller code was using the job
mayfly caller id instead of using the correct app caller
id.
Also the XTAL retain calls being called from two different
call context used the same worker caller id and same mayfly
instead of using the correct caller ids and independent
mayfly for each caller.
This potentially could cause mayfly enqueued list to be
corrupted and enqueued mayfly could be lost.
Change-id: Ia356419462d1fb4e38f4a20c720974143f12fdb6
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
This avoid having duplicated code for list manipulation in both LE and
BR channels.
Change-Id: I734635e8e51d4b826a3d45cda8551e1e509bd913
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes an issue found on automated testing. If IUT had no credits
to send data, the TX request was not queued, because -EAGAIN error was
not returned to bt_l2cap_chan_send (which was responsible for queueing).
Scenario:
1. IUT was out of credits
2. Tester requested to send some data
3. Credits was given
4. No data was sent
Fixes: ZEP-1896
Change-Id: Ie9d0945d1e6b628cd978ede8105b37b838a61f1a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
Cleanup controller's root makefile and add folder level
makefile to have better control over dependencies.
Also explicitly include folder paths in c files to clearly
depict the dependencies.
Change-id: Iac7b3a86eff11082111049ba48559c74f6c4d3fb
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Move the PDU related size definitions out of radio.h and
place it in pdu.h. This will remove hci's dependency on
radio.h.
Change-id: Idf9d7cdf7c60d74816ef2b093c4ae457df16e9a9
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Mark each PDU type explicitly instead of using BT_ATT_OP_CMD_FLAG for
this. For simple "error response or not" selection the command flag is
sufficient, but to prepare for support for enforcing both request and
indication flow control it's useful to easily look up the type of the
PDU.
Additionally, refactor the handler lookup to make the flow a bit more
streamlined.
Change-Id: I575848356934b6d636dcda8d10b7e7fde1095355
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Move the uint8_t members together to save 4 bytes for each struct.
Change-Id: I522be86397c57fd062018e409b65835912c6e7bc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
bt_conn_le_param_update returns -EBUSY when used in central
role if peer did not support LE connection parameter
request.
This commit allows a central role to use either LE
connection parameter request, if local controller supports
it, else use LE connection update.
Jira: ZEP-1773
Change-id: I72b9c77440459672fd50216a74ffcbd59c5f38f6
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Added checks for latency and timeout changes requested in
bt_conn_le_param_update, to decide if connection parameter
update is needed.
Change-id: I9de9f566158c5ade808ed356cb90b27186aa0243
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
There's no need to be opaque about this. Use the right type and let
the compiler catch errors for incorrect assignments.
Change-Id: If745354f514cbecfe6c0d845ebeaf3b93208b9b8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Only 1 TX buffer is sub-optimal for performance since the controller
would always have to wait for the host TX thread to give it another
buffer. Increase the value to 2 so the controller can keep
transmitting data without waiting for the host.
Change-Id: I4841a6c5010f294996d6fe0fe63260b848a6a437
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Updated controller code to use NULL keyword instead of
using 0 for pointers.
Change-id: I5ebff53dfeeba670fb7afe4740596b2662eb0334
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
There may be use cases where input and output is in big-endian rather
than little-endian. Introduce a native big-endian API to avoid
excessive byte order reversals in these cases.
Change-Id: Ia7b3e01bb0a07c4560b23f60c2f615ec614eb431
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There are some use cases where all parameters are in big-endian. To
avoid excessive byte order reversals introduce a native big-endian
API.
Change-Id: I58fe9156c8819a3a43d715e70b6ba358bd2f844b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Do this in preparation of a purely big-endian API (all three
parameters as big-endian).
Change-Id: I815f74549caffd5ac387b5bb84e5851aa96639b9
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
1. Reset the state when error occurs
2. This patch avoids checking for the AT_STATE_UNSOLICITED_CMD state
as the loop exits with possix error. So check for at->state
AT_STATE_START is sufficient for loop termination.
3. Fix different sign warning.
Change-Id: I80a1ca582112f1783690ac8a4125036bb706705f
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
This patch adds support to initiate audio connection from the stack.
< HCI Command: Setup Synchronous... (0x01|0x0028) plen 17 [hci0]
Handle: 256
Transmit bandwidth: 8000
Receive bandwidth: 8000
Max latency: 7
Setting: 0x0060
Input Coding: Linear
Input Data Format: 2's complement
Input Sample Size: 16-bit
# of bits padding at MSB: 0
Air Coding Format: CVSD
Retransmission effort: Optimize for power consumption (0x01)
Packet type: 0x003e
HV2 may be used
HV3 may be used
EV3 may be used
EV4 may be used
EV5 may be used
Change-Id: I4f4c0788760c9bdaf75651825511ff6bcd06df59
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
This patch handles the SCO disconnection part also unref the connected
corresponding ACL conn.
Change-Id: Ic2de68560cfd7d847e6011578c4424e24800d2ac
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
This patch renames the 'conn' variable to 'acl' which is reference
to ACL connection for SCO connection.
Change-Id: I5f0a60bc5d80de08fa5b963cf545c71552909401
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
Expose LE Encrypt helpers to applications. If software-
based controller is compiled-in, then controller's AES
hardware will be used by the exposed helper interface.
Change-id: I2bac9dfa5ccb3dd50447079affb52d920ae5bd81
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>.
Now that we have all the requested attributes of the service, form
the response packet and send it.
This also renames create_attrib_resp() to create_attrib_list() since
it is basically creating the list of attributes based on the filter.
> ACL Data RX: Handle 256 flags 0x02 dlen 21
Channel: 64 len 17 [PSM 1 mode 0] {chan 0}
SDP: Service Attribute Request (0x04) tid 28258 len 12
Record handle: 0x10000
Max attribute bytes: 4096
Attribute list: [len 5]
Sequence (6) with 3 bytes [8 extra bits] len 5
Unsigned Integer (1) with 2 bytes [0 extra bits] len 3
0x0004
Continuation state: 0
< ACL Data TX: Handle 256 flags 0x00 dlen 32
Channel: 64 len 28 [PSM 1 mode 0] {chan 0}
SDP: Service Attribute Response (0x05) tid 28258 len 23
Attribute bytes: 20
Attribute list: [len 17] {position 0}
Attribute: Protocol Descriptor List (0x0004) [len 2]
Sequence (6) with 3 bytes [8 extra bits] len 5
UUID (3) with 2 bytes [0 extra bits] len 3
L2CAP (0x0100)
Sequence (6) with 5 bytes [8 extra bits] len 7
UUID (3) with 2 bytes [0 extra bits] len 3
RFCOMM (0x0003)
Unsigned Integer (1) with 1 byte [0 extra bits] len 2
0x05
Continuation state: 0
Change-Id: I54ba00f7700cbb72182dce745d61f5281f83437a
Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Move crypto related interface provided by the
software-based Controller bt_rand into separate file,
crypto.c.
Change-id: I9998a43fe45799b479969ca195f324199418b8c2
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Use explicit path while including internal header files.
Change-id: Ide80eb23007574a7362850173ac227943bda21d5
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
The current hci_driver.c contained all the software Link Layer
initialization code. To decouple HCI from the actual LL, most of the
functionality that is actually part of the LL has been moved to the
ll_sw folder, opening the possibility for future hardware-based LL
implementations.
Change-Id: I1b54d655568a4ec02409da2f1a0addb4d64beed0
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since this presents a risk of public Bluetooth address duplication in
the wild by compiling once with a particular address and then flashing
the same image to multiple devices, a decision has been taken to remove
that config option and replace it later with another mechanism.
Change-Id: I068db25b2996c2409630554b1819b6adc48226cd
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
To present a common interface to both software and hardware Link Layers
the API in ll.h now lives in its own separate include/ folder.
Change-Id: I2b0ab0d11b47b9c35a5759bcc30f347e6c616648
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Declaring these as const lets the linker generate more optimal code.
Some extra care is needed with hci_ecc.c since it was overwriting the
send callback. Now the choice of send() call is done directly in the
bt_send() function
Change-Id: Iac74f5ee9bee097bbb34c11bd13d1d886700f5cc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Retrieves the record specified by the record handle, go over each
attribute in the record and check whether the attribute is there
in the list provided in the request.
Change-Id: I8f09e0fbb7811a20bb25dc0029cd7c79a9345c88
Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
In preparation for future hardware implementations of the BLE
Link Layer, this patch introduces the BLUETOOTH_LL_SW
configuration option to specify that the default software
LL is to be built.
Change-Id: I8b9d5b5e0d2926d18f9e8c8f042a74326895bf95
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Handles the ServiceAttributeRequest, populates the attributes to be
searched in the record specified by the record handle.
Change-Id: I3b702eaf05615f795d32aa30dbfaf91f5b2ce560
Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
Rename all LL downstream API calls from radio_ to ll_ so that they
reflect the layer they are actually targeting. Additionally they have
been moved to ll.h so as to expose a proper interface.
Change-Id: I4fb3946597920c9fafaacb6d87d34d83d75e8f27
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Remove the H:4 packet type macros that were unused in this file.
Change-Id: If161ddbf2d3adb2871cadd76de0e6c3bb50a16db
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Report as Bluetooth 5.0 compliant controller as there are
no mandatory features.
Rename PDU types as per the changes in Bluetooth 5.0
Specification.
Change-id: I1363e054eafd37c2bdca0f69b2638c7edb785787
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Bluetooth device address is 48-bit, added Kconfig range
field to restrict input to 48-bit hexadecimal value.
Change-id: I650343eab5809535137e164e783c9dd4f3e2a6f2
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Add Kconfig option to set the Controller's company id and
subversion number.
Change-id: I3508aba18bf0b79fd423c7b4142b6fc57eaf55d7
Signed-off-by: Matthias Ringwald <matthias@bluekitchen-gmbh.com>
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Add a Controller event that indicates everytime
advertisement event has been transmitted on air.
Change-id: I4722488bbfeca987e66983faf5b26467407a89c9
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Add ARG_UNUSED on rssi_ready local variable when the RSSI
feature is compiled out.
Change-id: I04f8f11cbc3530f7b85ffa72f27373e213b6e35e
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Now that we have all the records which has the uuids in the
service serach pattern, take the handle of each of those records,
prepare and send the service search response.
> ACL data: handle 256 flags 0x02 dlen 17
L2CAP(d): cid 0x0040 len 13 [psm 1]
SDP SS Req: tid 0x6b6f len 0x8
pat uuid-16 0x0100 (L2CAP)
max 256
cont 00
< ACL data: handle 256 flags 0x00 dlen 26
L2CAP(d): cid 0x0040 len 22 [psm 1]
SDP SS Rsp: tid 0x6b6f len 0x11
count 3
handles 0x10000 0x10001 0x10002
cont 00
Change-Id: I85ec8ee384d0bf8090265577ec3ef805e75d4766
Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
From the response of read_local_supported_feaatures check if local
device supports eSCO packet type and update it to bt_dev.
Also added sco field in bt_dev
Change-Id: If85b3d24d327a6243318fad89a07375a8253f89b
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
This patch includes handling AG network error i.e +CME ERROR and
report the error number.
Change-Id: I19a3158e44568ad0ad21fb0dd790ac2f554c0625
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
If mayfly enable is called before mayfly could be disabled,
then enable shall supercede disabling, the mayfly will
remain enabled. Any new mayfly enqueued by the caller that
tried to disable mayfly will be chain for deferred
executon under this condition.
The BLE Controller's connection update procedure broke when
mayfly implementation was updated to defer disabling until
all queued mayfly where completed. Mayfly is disabled
between ticker_stop and ticker_start calls to chain them
so that ticker does not power off counter h/w if the ticker
being stopped is last one.
This commit fixes the connection update procedure which
used the mayfly enable before mayfly disable could
complete.
Jira: ZEP-1839
Change-id: I07d34c90d193b5eca9762acd8b7272e8d7a78474
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Call to ticker_stop/update can fail under the condition
where in a role is being stopped but at the same time it is
preempted by the role event that also uses ticker_stop/
update.
Also if a role closes graceful while it is being stopped,
the radio ISR will process the stop state with no active
role at that instance in time. In this case just reset the
state to none, the role has already been gracefully closed
before this ISR execution. The above applies to aborting a
role event too.
This commit adds code to detect these conditions and
deterministically recover from it.
This commit fixes the assert observed while stopping
advertiser in the Bluetooth sample scan_adv.
Jira: ZEP-1852
Change-id: I51c8d6e212ef43e3526a199cf7b666a79729c732
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Added Kconfig option to be able set public address. Seems
conformance testers look for valid public address.
Change-Id: I2c4f702117f99a42c9eef0133b46556a1c6d1496
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
This allows to queue buffer to sent later in case it runs out of
credits so it no longer blocks the caller thread.
Jira: ZEP-1776
Change-Id: Ifa9b412f98889b50c0b889655d910520d11a4718
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This moves necessary functions that will be needed for queuing packets
while waiting for more credits.
Jira: ZEP-1776
Change-Id: I030c696d432ec5be1b8e6b649e953da145929777
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Controller asserted in preparation of a role event due to
the previous (same or another) role event preparation being
not complete.
Mayfly callee was disabled in the previous event due to the
preparation time being short and previous start running
(higher natural priority) before all previous preparation
mayfly completed. The previous start disabled mayfly to
avoid Radio ISR latencies.
The current role event that asserted, preempted the
previous role (observer role with continuous scanning
window) which runs until preemption to maximise the Radio
h/w use (observer scanning until next interval). The
previous preparation mayfly is still disabled when the
current role preparation tries to use same mayfly instance
which should be free for a new enqueue.
This commit updates mayfly implementation so that mayfly
callee is disabled only after all enqueued mayfly instances
are run to completion.
Jira: ZEP-1839
Change-id: I3e0d31422db8e47b819189110b11ebd07dd09a7c
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
The 100ms limit is only valid for controllers before version 5.0. For
a 5.0 controller the minimum is 20ms (0x00a0) which is already checked
for later in the valid_adv_param() function.
Change-Id: I0566a38ff855800d2e46e1d2c0a5c7bc9bc610cd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Since there are no mandatory features in 5.0 when compared to a 4.2
compliant controller, report 5.0 as the current specification
implemented by the controller, to allow for features such as short
advertising intervals (< 100ms) which are already supported.
Change-Id: I1b138a86290a0422760a5e265cdd7b72d68f0048
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add support for detecting version 5.0, i.e. 0x09.
Change-Id: Ia2da513b65c420142fe97a4fa173bfa8045e9d75
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Filters the service records by going through all the records and
removes the one which does not have the uuid. So finally, only
the records which has all the uuids in the service search pattern
will be present in matching recs.
Change-Id: I1daa7c1b645efae2af66962999cc4c541891eff7
Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
bt_gatt_get_mtu can be useful when GATT is used to transport another
protocol on top.
Change-Id: I328ef49138ccc4ce642b0019d08060f6022d5aa7
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Handles the service search request from peer, parses the service
search pattern (which is a data elem seq of uuids to be searched)
and populate the uuids.
This also populates the registered records which will be filtered
based on the uuids in the pattern (which will be done in the subsequent
patch).
Change-Id: I9a232a7cfdd159325214ed13e98cc20be39a2e3b
Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
This is mainly done to avoid VLAs for looking up the service to handle
service search requests so that we can make sure that RX stack size
is sufficient for the defined no of services.
Change-Id: Ia99072615d9094a35bd7605ed2901e8018c0ecb2
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Instead of returning -EINVAL at runtime assert in case of invalid
parameters.
Change-Id: I40505f06a4c12445bfb1f1846ace1b592b6bc342
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Separate out data element structure header into type and size fields
Change-Id: I869ee1ea82db1f6d669bb905055135b7d63f3fa2
Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
L2CAP TX and RX MTUs will be exchanged during configuration req/rsp.
It should not be modified after connection.
Change-Id: I1e291c9e093561f349bcdcbb75cd7ff22b4163a5
Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
A new Kconfig debug option now controls the usage of pin toggling to
debug the BLE controller.
Change-Id: I24c5c13ca71e3395e10f14e27ad4bca9f2e94687
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Use macros to identify the different debug pins used to monitor the
runtime behavior of the controller, for easier identification of the
lines.
Change-Id: Ia76d6298985b1d367b7ad193d8261f5403446371
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Added an API to allow addition of stream end points by the application.
Change-Id: I91b95fc5dc3b9b2950e8d55b5846e460e55f2453
Signed-off-by: Piyush Itankar <piyush.t.itankar@intel.com>
It was observed that due to possible CRC errors, one
connection interval was not sufficient by the peer to
respond to LE Ping PDU which caused the Controller to
generate the Authenticated Payload Timeout event to host.
This fix advanced the dispatch of LE Ping PDU by 6
connection intervals that the peer would listen to before
the 30s timeout.
Change-id: I6c292c623047a05b4e771e70093d87228db62cce
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
The new hard real-time (direct) interrupt support is used
only for Radio IRQ. Only Radio ISR has hard real-time
requirement of completing its execution inside the tIFS of
150us.
This commit reverts back RTC0 and SWI4 ISR to using the
normal IRQ_CONNECT.
Observed on nRF51, Radio ISR (open text, notifications):
Latencies: min. of 5us and max. of 10us.
CPU utilized: min. of 44us and max. of 77us.
Observed on nRF51, Radio ISR (LESC, fast encrypted,
notifications):
Latencies: min. of 5us and max. of 10us.
CPU utilized: min. of 39us and max. of 112us.
Jira: ZEP-1038
Change-id: Id3d09df7bdbdfea090f21f6f58aaded8c5f1e10d
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
The new hard real-time (direct) interrupt support in the kernel allows
ISRs to be run directly with no significant latency overhead.
Use this new mechanism to improve the latency of the 3 critical
interrupts in the controller: radio, RTC0 and SWI4.
Jira: ZEP-1038
Change-Id: Ief9dacbea4c4c2e8a1c77893a0d6175a91819ffb
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This fix not removing subscription if it was first element on the list.
In that case prev was NULL resulting in passing garbage node to
sys_slist_remove.
Change-Id: I9452af08409692f9a331afd514fbac8cc727d289
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This fix legacy pairing with passkey entry model when passkey
is fisr entered on local side. Replying with error in that case
is bogus as we should just wait for remote confirm.
Change-Id: I75480802928fd29d21617aa9250f90df647eb9a2
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
List container changes apparently were merged in the wrong order causing
leaving it with a compilation error.
Change-Id: Ib9d9502ddb39330c262e495a33592d0340713d83
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If the TX thread is not in k_poll() when conn->state gets set to
DISCONNECTED and a dummy buffer is pushed to conn->tx_queue the
bt_conn_prepare_events() function would have failed to add the
connection to the poll list for cleanup. To ensure the cleanup always
happens introduce a new flag that indicates that a cleanup must
happen. The extra benefit of the flag is that we no-longer need a
dummy buffer, but can simply use the conn_change signal to wake up the
TX thread.
Change-Id: I369584d305261ab3666b931c786daff9d131d228
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
From k_poll_signal_init() documentation:
The poll signal contains a 'signaled' field that, when set by
k_poll_signal(), stays set until the user sets it back to 0. It thus
has to be reset by the user before being passed again to k_poll() or
k_poll() will consider it being signaled, and will return immediately.
Change-Id: I55daac92dd6293ac653fd7fa0f907b0b7fd99d65
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
When iterating to the subscriptions to be removed the code has to keep
a reference to the previous node but it case the subscription matches but
doesn't need to be removed it doesn't update the prev node which may
corrupt the list in case the next node end up being removed.
Change-Id: Ic5448f01bf78d293f93b9a7078a0147385ea1d23
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If subcription was found within the subscription list,
we have check if remains identical subscription
from the next node.
Otherwise none unsubscription is realized.
Change-Id: I38132d7c80575801885b8057902f3d4666b08aea
Signed-off-by: Jonathan Gelie <jonathanx.gelie@intel.com>
If the buffer given to hci_cmd_done() is not from the command buffer
then using the cmd(buf) macro is not valid. Simply bail out from
hci_cmd_done() if this is an event that didn't have a matching command
buffer.
Change-Id: Id8357a23a307f4ef3a9214a4e1f7d853a18cb907
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The controller code should not use BT_ASSERT directly.
Change-Id: If0b7d8e21d2ab4569a564bd03e36e4eb9204c595
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
It is not used outside of sdp.c and has no declaration.
Change-Id: I420a6b98d1b46fedffa29d042267b9c606d04c46
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
'buf' variable of type struct net_buf was one of the arguments for
finish callback in response to each AT command sent. 'buf' variable
not used in that function. So removed 'buf' variables from the argument
list.
Change-Id: I7d6aa6082f524012ae13a04426915076130ddf69
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
Subscribe value is set to zero before calling notify callback,
to distinguish a subscription failure from an unsubscription
on disconnection (when flag BT_GATT_SUBSCRIBE_FLAG_VOLATILE is set).
Change-Id: Ia91220492d82041b2c385bf88a15180387e7a483
Signed-off-by: Jonathan Gelie <jonathanx.gelie@intel.com>
If found error during service level connection disconnect rfcomm.
Change-Id: Ida425375975b8d60ab1024d07a8ffe7745ae0b54
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
Some application protocol required non-persistente subscription
across connection even in bonded case.
Flag BT_GATT_SUBSCRIBE_FLAG_VOLATILE specify if subscription
must be remove during disonnection.
Change-Id: I1bc2bbbb4bc86f58905e44a7eb267ca0871f2fdb
Signed-off-by: Jonathan Gelie <jonathanx.gelie@intel.com>
The subscriptions callback may free or reuse the subscription so all
instances that where this could happen need to safely fetch the next
element which is why this changes switch to use sys_list_t as it has
SYS_SLIST_FOR_EACH_NODE_SAFE.
Change-Id: I37d51f27116ea0c057b560924a9416676477597b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Once the service level connection is done call the connected
callback.
Change-Id: I7541e221d4c03c939682ec70f1d9c093f87ceb09
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
We can go further with taking advantage of k_poll and merge the
connection TX thread together with the HCI command thread, thereby
saving even more memory.
Change-Id: I1792056fd4621d62c7cd05929094033acca45c74
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that the k_poll API is available we can use it to have single
connection TX thread instead of multiple ones, which helps reduce the
per-connection memory overhead by a substantial amount.
Change-Id: Icb5d4da87cf0d660bba8da43186d1e76f41c825a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Removing the module specific buffer pool. If future, use common acl_tx_pool.
Change-Id: Ie1452f981ef43642715be395315845cc2d9bb285
Signed-off-by: Arun Jagadish <arun.jagadish@intel.com>
Detaching the timeout from the tx_thread lets us prepare for merging
all TX threads into a single one with the help of k_poll(). There's no
need to define a new delayed work object since the existing connection
parameter update object and connection timeout will never need to run
in parallel. Additionally, but some CONFIG_BLUETOOTH_CENTRAL guards to
void pulling in unnecessary code when Central role is not enabled.
Change-Id: Ia1f222aa052edcecd484a924f2d9a63a3b8fd11f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Reduce the pressure on the common RX buffer pool by reusing HCI
command buffers also for the Command Status or Command Complete
response to them. This also implies removing the existing Kconfig
variable for the command buffer sizes since the size is also dependent
on maximum Command Complete event sizes. Instead, reuse the RX buffer
size also for HCI Command buffers.
Change-Id: I006b287d64a0c9ca40de741aa9a424a49a927385
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
With an upcoming patch the HCI command buffers will be reused for the
Command Complete/Status HCI events. The controller HCI code needs some
refactoring to postpone the event buffer allocation so that the
parsing state of the HCI command buffer isn't touched.
Change-Id: I1f614fb9f02ed1886ca84198fbc8c64abc29e44f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
A subsequent patch will start reusing HCI command buffers for
receiving the response, so the distinction of received vs sent data
headroom would just make the code unnecessarily complex. Instead, just
merge these two variable into a single one.
Change-Id: I31d846331939f1a2270df7ed0c75112825e16493
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The C pre-processor doesn't allow using sizeof() in comparisons such
as "#if FOO < sizeof(bar)". To make it possible to use such
comparisons where the sizes of headers are involved, introduce helper
macros for the headers instead of always having to hard-code magic
numbers into the code.
Change-Id: Iaf654cb4aaa49e83360901f5b01225ba4b952854
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If the driver send() fails we need to free up bt_dev.sent_cmd.
Change-Id: I41b6293dfe09f1d94d7f85663ddbebed40cf6e90
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Adds API to allow user get SupportedFeatures attribute ID.
Jira: ZEP-1112
Change-Id: I91a1bf548d99c5c7cc75682aed19e89390350533
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Adds API to get available specific information included in protocols UUID
tree during parsing Protocol Descriptor List attribute. Usually it's to
be remote Server Channel/PSM number operating on applicable protocol.
There're a few helper functions added to be able parse and retrieve such
information from raw record data.
Jira: ZEP-1112
Change-Id: I736a780b95ba54821d36e6011b739f5ff37cd64f
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Both all-zeroes and all-ones addresses are invalid. Fix the check for
this so that we fall back to a static random identity address when
needed.
Change-Id: I17cf903e0f3ed321311d86d09bed19343c2c801a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This will reduce memory consumption by 23 bytes per session.
Change-Id: I1831b59881eaefb68f93c30e298b8f97d63c7428
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Session idle timer should not be started in dlc destroy if
session is already disconnected (which can happen in scenarios
like acl disconnection where in dlc is detached from session and
destroy will be called from tx thread) otherwise timer function will
get invoked for a disconnected session.
This patch moves starting of idle timer from dlc destroy to
the point dlc disconnect is recieved from remote since idle
timer is to handle only that scenario.
Change-Id: I94501515a182ff0e2348ba4e2df63100f2f52209
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
The nRF5x come preprogrammed from manufacturing with either a public or
random static BLE address in the FICR register. Use the random static
one when present instead of generating one during Bluetooth
initialization.
Change-id: Ic733cb926e0414e56d6f8be65b033692e914b72a
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The hci_raw version of bt_buf_get_rx was expecting an int for timeout.
Let us int32_t instead so we match both the hci_core version and the
type that net_buf_alloc expects.
This addresses a possible build issue if/when int32_t differs from our
default (ie, newlib).
Change-Id: I69374c48da8f2b96fa2bd418ff505fbaacda11f0
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Change BREDR_NAME to DEVICE_NAME so it can also be used as the LE
device name.
Change-Id: I9ef55d9dff098372d47d9d5754ad7a7163a65bc0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Added structure definition for stream end points
and the a2dp stream.
Change-Id: I6d0cc08611f5179397bea6200eb9244d7c1cc8d6
Signed-off-by: Piyush Itankar <piyush.t.itankar@intel.com>
Fixed channels don't really use channels state as they don't need
connection setup.
Change-Id: Ie8b1327db0269a45e9ccb6049f8dda87aa445fb5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Adds state callback handler to allocate memory to AVDTP on an incoming
connection. Also, abstracts searching of free session as a function call.
Change-Id: Idee6b7a0507b0b75c0007717e351ca12de0cb5be
Signed-off-by: Piyush Itankar <piyush.t.itankar@intel.com>
This is mainly for backward compatibility with 1.0b devices and for
spec compliance. CFC is mandatory post 1.0b spec where in MSC FC
shall not be used.
FC bit in MSC is used to manage the flow control. If FC is 1 then
the device is unable to accept frames.
Implementation is done by reusing "tx_credit" as a binary semaphore
wherein it will be blocked if MSC is recieved with FC bit 1 and
unblocked if FC bit is 0. Once tx thread is scheduled then semaphore
should be always available until all the buf in queue is sent.
Change-Id: I91181668ec0f46ff0b02905dd97e4503fc1fa7a7
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
v24_signal in MSC response should be the copy of it received
in the command.
Change-Id: I9723ba182bf5911025c7a57220cd70687ca785f3
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
This implemnts the feature to handle the unsolicited response
received from the AG. In the hfp_hf.c file the unsolicited_cb function
process it.
Change-Id: I3ca6c8d4a1522d02f7160e2fe4ae1598cd93ce7e
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
Convert driver to use the CMSIS NVIC APIs rather than the internal
ones so we can remove them in the future.
Change-Id: Ib9fe696e8d5e55f60865d3fd958a035135ce517a
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.
Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.
Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file. Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.
Jira: ZEP-1457
Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
For combined builds with Controller+Host the Controller's HW RNG is
used instead of TinyCrypts PRNG.
Change-Id: I4dbe85e547c057cf57ae0934b10866f2bb9f610d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In case the channel provides its own MTU and allocator it should be
able to store as much data as set in the MTU, based on that the code
can give enough credits to fill the entire channel MTU.
Change-Id: I291cf1bb643f200bde191914e814f681f4f65c3e
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Added pointer to store the callback function
from the application in the Request structure.
Added userdata param, to be used to fill AVDTP resp.
Change-Id: I8f3289545fdbbd91e4ed7f9983f4f4331d9b59a6
Signed-off-by: Arun Jagadish <arun.jagadish@intel.com>
This makes l2cap_chan_add updates the state to CONNECT so it doesn't
have to be done manually for both incoming and outgoing code paths.
Change-Id: I7331e49c675c83c6c1b184eeecc49c75c446a1ff
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Try to use IS_ENABLED instead of #ifdefs whenever possible.
Change-Id: I330769204914286bb98583dd89a3d849d4fcc128
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Try to use IS_ENABLED instead of #ifdefs whenever possible.
Change-Id: I77d2e53f7aa7f2832513f235a63ad2cf14e73cb1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Try to use IS_ENABLED instead of #ifdefs whenever possible.
Change-Id: I78a3ccc6fcb84b431198f1a6c46aa6d50e9e9cd1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Try to use IS_ENABLED instead of #ifdefs whenever possible.
Change-Id: I4da93076a27a33b15a9b9119cfe5a1ff68acba0b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The new IS_ENABLED macro allows exposing conditionally enabled code
always to the compiler, even though it may not ultimately end up being
built. This is in particular useful for letting the compiler catch any
logging format string errors. Introduce a new BT_DBG_ENABLED macro
that c-files need to define before including <bluetooth/log.h> in
order to choose whether BT_DBG() logs are enabled or not.
When no Bluetooth logs are enabled the patch also modifies the log
macros to have the format strings checked with the help of the
__printf_like annotation and empty static inline functions.
Change-Id: Ie6bc8e10727b5b306f3ed0f94089a07a22583d9b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Introduce a new callback to bt_conn_cb that allows the application to
decide whether the accept or reject an incoming connection parameter
request. If the request is accepted the callback allows the
application to also adjust the values to what it thinks are more
appropriate.
The Zephyr Bluetooth API allows multiple registered connection
callbacks, so in principle there may be multiple le_param_req()
callbacks. It's recommended for an app to just use one (for clarity),
but if there are multiple the app is responsible for managing
potentially different requirements. In the case of multiple callbacks
each callback will receive the modified parameters in case a previous
callback modified them.
Jira: ZEP-1474
Change-Id: I098db5791aac521f1edfa9fefdf847db0a27e3a5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The BT_L2CAP_RX_MTU is counted starting with the BLUETOOTH_RX_BUF_LEN
variable, which doesn't include the BLUETOOTH_HCI_RECV_RESERVE
contribution (this would only be valid if we started subtracting from
BT_BUF_RX_SIZE).
Change-Id: I1ab3eaf8907946c56c2a9fe16b2074f3a3027a0f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
BT_BUF_RX_SIZE is used for the RX buffer pool which is used for both
ACL data and HCI events. It should therefore not contain any
ACL-specific details. This patch removes the ACL header size from the
macro and instead makes taking it into account the responsibility to
the Kconfig option. Since buffer sizes are anyway rounded up to the
nearest multiple of 4 the default goes up from 70 to 76.
Change-Id: I41274d9131e7529d41c16bd66de95637fb150a29
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
CONFIG_BLUETOOTH_RX_BUF_LEN shall not be used as RX MTU since it doesn't
account for ACL and L2CAP headers.
Change-Id: Ic3ebb4bd13d86a39174840f0ab625b66e863018a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is mainly for backward compatibility with 1.0b devices and for
ICS & spec compliance. CFC is mandatory post 1.0b spec where in
Aggregate FC shall not be used.
Aggregate FC is managed using FCOFF and FCON messages. This is for
the entire session which means that all the dlcs in that session
will be affected.
Implementation is done using binary semaphore wherein it will be
blocked when FCOFF is recieved and unblocked in FCON.
Once tx thread is scheduled then semaphore should be always available
until all the buf in queue is sent.
Change-Id: Ibfd2c4d033cef64c238ead83474f9e171572de1e
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Bluetooth Core Specification v5.0, Vol 2, Part E, 7.8.12:
"The Supervision_Timeout parameter defines the link supervision timeout
for the connection. The Supervision_Timeout in milliseconds shall be larger
than (1 + Conn_Latency) * Conn_Interval_Max * 2, where Conn_Interval_Max is
given in milliseconds."
Let's remember that:
conn_interval is given in units N * 1.25 ms
sup_timeout is given in units N * 10 ms
sup_timeout_ms > (1 + latency) * (conn_interval_ms * 2)
yields:
sup_timeout_n * 10 > (1 + latency) * (conn_interval_n * 1.25 * 2)
yields:
sup_timeout_n * 10 > (1 + latency) * (conn_interval_n * 2.5)
yields:
sup_timeout_n * 4 > (1 + latency) * (conn_interval_n)
Change-id: I30ac1d375a1baaa3e61f4c29b1165110599e1f7c
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This reduces stack pressure a little bit, and also paves the way for
introducing an application callback for accepting an incoming
connection parameter update request.
Change-Id: Ib02c14e27cbe34f85d663f36abd0597683ae1dc1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When receiving notifications we should be properly matching against
the remote address of subscribed peers.
Change-Id: Ibcba1101aac418fd02f9068667f84e8294aade07
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There are no users of this API and no (currently) envisioned use cases
for it. Remove it for now - it can always be brought back later if
there's a need for it.
Change-Id: I6530e096e3671c844a3f7dea8856147ffc716d71
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Rename the elements of 'enum at_cmd_type' in order to follow the
name spacing. Which should have prefix of 'AT_' for each elements.
This patch also involves the renaming, corresponding handler
function of 'enum at_cmd_type' with prefix 'at_' i.e 'cmd_start' as
'at_cmd_start'.
Change-Id: I722a25954163c06e131b94042c6a18e1e3458f6e
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
Rename hci_le_rand to bt_rand and make its parameter types compatible.
This also includes updating rand_get() to use size_t instead of
uint32_t & uint8_t.
Change-Id: I4d434dfbbaf339b1bc7b451d358d07a291dd0375
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The controller bt_rand() ties into the hardware which uses less memory
and is more power-efficient than using the TinyCrypt PRNG.
Change-Id: I7570d18f3e84dae3d5c2d3322b5d37cd3e8f3b6b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Having TX buffers split into numerous pools has the downside of
increased memory consumption. This patch takes the initial step to
consolidate these pools into a single one, saving about 248 bytes of
RAM for a basic configuration.
Change-Id: I449ba18b44a9a6af68e9a2c44f19a9286eb88b14
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Uses sys_slist_get function to get node and automatically, if valid,
remove one from the list.
Change-Id: I4cee6fbb064bf9644efdb7e6771e702b1f08678a
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Fixes not supported now format specifier.
Change-Id: Ia01ea3fd18acfeed6f4a3899334911dac1b76643
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
It's possible for the Public Key to be available by the time that the
bt_hci_cmd_send_sync() returns, so we need to make sure the flags have
the right values no matter what.
Change-Id: I053093b6611af360f52b14ddca50d409388f9475
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
As per the spec, the station which disconnects the last dlc
should disconnect session also. In case if remote does not
do it we need to disconnect otherwise rfcomm will be connected
without any dlc. So this starts an idle timer to handle the
above scenario.
This also starts a disconnect timer to handle in case remote
does not respond to session disconnect request.
Change-Id: I3b45aa5bf4c35fd81dc10974f2b0b6d4cfe4ea7d
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Rename cind_status_handle_values to ag_inidcator_handle_values.
Because the same function will be reused internally for +CIEV
Callbacks.
Change-Id: I875064de17700d72ea89dbbe0f5cb6554c813a5e
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
Reset AT and COMMAND state to process unsolicited response received
after processing result recieved for AT command sent to AG.
Change-Id: Id2a5827ce5b098336291696157027699479478cf
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
Confirmation callbacks needed not be registered with AVDTP
during A2DP initialization
Change-Id: I2cdf8c5a283775e49fa6e7e9404024e26d05a767
Signed-off-by: Piyush Itankar <piyush.t.itankar@intel.com>
This basically implements timer for connection and disconnection.
Conn timer will be started when dlc is initialized and stopped
when it is connected. Authentication if any, will be also included
in this timer.
Disc timer will be started during disconnect initiation.
Change-Id: Ia4b74e478fefa42db21aef528e623a24c72ddf7f
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Moves rfcomm_send_disc() and rfcomm_session_disconnect() to call it
while doing timer implementation.
Change-Id: I5805d31fb45181193385f055716c8518d68cc4a1
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Adds more descriptive comment to the code responsible for handling no
resolved UUID case.
Jira: ZEP-1112
Change-Id: I1af07949e19246d51bab9df05504a90f5fb22bb2
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
User may want to know when getting called user UUID callback handler
on what UUID the result data was retrieved from server.
Jira: ZEP-1112
Change-Id: Iabb2dbdf0f3cfdb24244e052f094c7549164b199
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
In order that host can continue a connection event by
enqueuing packets, the number of completed packets event
needs to be generated as soon it arrives on air. Hence, the
Controller now calls the radio_event_callback on every radio
Rx complete ISR.
The callback executes at the Radio ISR priority, take care
to only do as little as necessary in the callback, say, just
a semaphore give to wake up the hci_driver's thread.
Change-id: If48afd0f1390d450bc1e7ec66f1c9fd45208d9a4
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
For the host to be able to block on the recv_thread while waiting for a
number of completed packets HCI event, those are pulled from the radio
in a new, higher priority thread that also schedules the execution of
the lower priority event/ACL data recv_thread.
Change-id: I9d356bd297d0504cb16a032fb5fe5530693546e2
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
net_buf shall not be used with k_fifo since net_buf_unref will assume
unused bytes in the beginning are actually fragments causing it to
unref them as well.
Jira: ZEP-1489
Change-Id: I5ce420de73b245dc20eb15ea4d8d0b6ba346e513
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Since callers of bt_recv() have so far anyway been required to know in
which context to call it (based on e.g. bt_hci_evt_is_prio) it's
cleaner to have two separate APIs: bt_recv and bt_recv_prio.
Change-Id: Icd0d9aed9c51ffd2def31432c4ffcc16a9f13ccd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The recent redesign of the H:4 HCI driver means that the smallest
safest RX buffer count goes down to 2. Default is left at 3 however to
get a bit better performance.
Change-Id: I879c7bd3a769f973dfb9bd179d196ab91f9d2abe
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Advertising reports are the only HCI events which we can drop if we
are low on buffers. Allocate them therefore with K_NO_WAIT rather than
K_FOREVER.
Change-Id: I0b7c92647f9be54b8746da837037725f8161a452
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Since the controller already uses a thread for receiving data it makes
sense to enable the BLUETOOTH_RECV_IS_RX_THREAD option.
Change-Id: I927b20c1a0afaea8d000df28cc220a69ae817d59
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The controller uses K_FOREVER for the allocations so there's no
benefit in trying to use specialized pools (which exist to try to
guarantee availability of buffers for critical data).
Change-Id: I130f2c44a2f28af1284290e6a0b17dcba438862f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Allocate the event buffers after the ECDH operations rather than
before them. This way we don't hold on to the buffer for potentially
multiple seconds while the buffer could be used for other things.
Change-Id: I0fcc34ec4bea2265b7df3c1de3587c2a850c974e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There's no need to use the type-specific helpers since those anyway
map to the same pool.
Change-Id: I74750f545c989bb921abca58166fe591ed325856
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Give more sensible values when RECV_IS_RX_THREAD is configured.
Change-Id: I40b5bd88213d224cc29f63fccef6cecee5868f77
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The separate ACL & event pools will soon be removed, and it's already
now convenient to have a generic API when the exact type of the
incoming packet is not yet known.
Change-Id: I84cb65d17ea69ebeaeb21532fbf76689e4fb59a0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The controller doesn't support this feature and the only driver that
was needing it (h4.c) will be converted not to rely on it in the next
patch.
Change-Id: Ia514b79b6d05aa128768c2355353b7797e8b8977
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for using the context bt_recv() is called in as the RX
thread, rather than having a separate host-side RX thread.
Change-Id: I256bfe5dece5272c816f2292e58747553189963d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Refactor the bt_recv() logic to make it easier to insert #ifdefs to
remove the RX queue and thread when the context calling bt_recv()
itself is sufficient enough.
Change-Id: Ie8c5a4dfe9533a4464a2e4909c94d3e1b185b55b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If the controller doesn't need ACL host flow control it may want to
optimize and use a single pool for incoming data.
Change-Id: Iec2a69bd2d7a127c7329d0423ab5ce6b73cb9904
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This option has not been used so far and will only contribute
unnecessary complexity in subsequent patches that introduce a concept
of combined RX buffers.
Change-Id: I53e0ce5155eebc352b84ba41b30ecb9d9958699f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
After getting whole UUID response for SSA PDU request the user can be
informed about discovery results. Result data feeding the user is
splitted to logical record chunks if more than one record was found.
Every such portion represent unparsed SDP record prestripped from record
length. Each response record data passed to user starts from first raw
attributes data and the record response buffer's length tells exactly
about each record length. User UUID callback handler's return result
can drive delivery (dis)continuation of every such portion to the user.
Jira: ZEP-1112
Change-Id: Icec518ca7bab3c8dfef4a966d98e9d9004894bcc
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This analyzes the dlc stack using stack_analyze() which is coming
as 188 with BLUETOOTH_DEBUG_LOG off.
dlc stack (real size 320): unused 68 usage 188 / 256 (73 %)
So increase the stack size to 256.
Change-Id: Ie5d5f267f4f618747551f0bfd0e05ffb47e0bb91
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
When getting very first SSA PDU response for given UUID we can extract
from it the counter telling us how much data will be delivered by server
to collect all complete response for given UUID. Let's use that
information to check if the room allocated by app is big enough for
collecting resolved data.
Jira: ZEP-1112
Change-Id: I91515da668d89e05755d64e427dee0936bf20323
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
skip_whitespace() API name is changed to skip_space(). Where the
skip_space function is to skip only SPACE(ASCII Dec: 32).
Change-Id: Ib28ffa45295912505bc27a986803ed0ae2b0002c
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
Rename the API's with 'list' which uses the term 'stream'.
For example 'at_open_stream' is renamed to 'at_open_list' and
the same applies for other API's which uses 'stream' in it.
Change-Id: I62bed70de3d85cd4890b10e04eba27ae2de1907c
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
The private_key parameter to generate_keys is supposed to be 32 bytes
in size, i.e. an array of 8 uint32_t variables.
Change-Id: Ia891fd68bfd8662983b898084e5a8524b7a9b8e2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Adds driven by user params buffer location to be populated by UUID
resolved data. Corresponding handlers responsible for connected and
disconnected states of L2CAP transport channel used by SDP PSM traffic
automatically allocates and unrefs such memory. Data receiving handler
performs buffer fill up.
Jira: ZEP-1112
Change-Id: I8aa97e6e69344dca0f241a4e9097acac75e14a7c
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Adds two extra checks against invalid length of attribute payload
frame.
Jira: ZEP-1112
Change-Id: I089442a5b9631471f9f394860681f1483e021c43
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Iterates all UUID params list delivered by user. When iteration finish
release SDP client L2CAP transport channel.
Jira: ZEP-1112
Change-Id: I0602e32a5296a05719ad1385b4aff537350b3e7d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit introduces a very light-weight and lock-less
scheduling of the Controller's deferred function calls
called the Mayfly.
Earlier work implementation used in the Controller had an
O(n) to schedule a function in a linked list that used IRQ
lock during modification of the linked list in the
Controller's ISR executions.
Mayfly is a compile time configurable matrix of queues
where an execution context-safe queue exists between two
execution context, one being the caller and the second
being the callee. Callee(s) are run in a software interrupt
but can also be run in an OS thread.
There are minor clean ups too in this commit related to
folder structure.
Change-id: I5ff44dcee6679d2f5ce9e8437d98d6c868782f3d
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Enable connection encryption setup in 3 connection
intervals. Peripheral will respond to Encryption Request
with Encryption Response in the same connection interval,
and also, will respond with Start Encryption Response PDU in
the 3rd connection interval, hence completing encryption
setup in 3 connection intervals. Encrypted data would be
transmitted as fast as in 3rd connection interval from the
connection establishment. Maximum CPU time in Radio ISR will
increase if this feature is selected.
Change-id: I16f2863fc2aaed624826505739519d4de1ac44c5
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Add Kconfig configuration to select Tx buffer size, this
value will be returned in the HCI LE Read Buffer Size
command response.
This configuration will allow lower Tx RAM usage when
larger PDU sizes are desired in Rx direction only.
Change-Id: I5106a448d78a0754c4b0f6fa61fd5dcacd87a67c
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Add Kconfig configuration and conditional compilation of
RSSI measurement during a connection.
Change-id: I5a2f23f76a7cbbd9569d53d31899a472bf39d3ee
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Add Kconfig configuration to conditionally enable Data
Length Update procedure support in the Controller.
This will save CPU time, flash and RAM, if this feature is
not desired.
Change-id: I4515c0c7cf9aeb333a289397ae3c9bac04a08e4e
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Add additional conditional compilation of code not needed
when LE Ping is disabled in Kconfig.
Change-id: Idab40b1371488e06a6f2009fb553f7655b7b86f3
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Adds initial handling of SDP Service Search Attribute response PDU.
Currently attributes data are not collected. Main focus was done on
proper handling PDU continuation state to be able receive whole
requested SDP record(s) if found for given UUID.
< ACL Data TX: Handle 74 flags 0x00 dlen 24
Channel: 64 len 20 [PSM 1 mode 0] {chan 3}
SDP: Service Search Attribute Request (0x06) tid 1 len 15
Search pattern: [len 5]
Sequence (6) with 3 bytes [8 extra bits] len 5
UUID (3) with 2 bytes [0 extra bits] len 3
OBEX Object Push (0x1105)
Max record count: 65535
Attribute list: [len 7]
Sequence (6) with 5 bytes [8 extra bits] len 7
Unsigned Integer (1) with 4 bytes [0 extra bits] len 5
0x0000ffff
Continuation state: 0
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 74
Count: 1
> ACL Data RX: Handle 74 flags 0x02 dlen 68
Channel: 64 len 64 [PSM 1 mode 0] {chan 3}
SDP: Service Search Attribute Response (0x07) tid 1 len 59
Attribute bytes: 48
Continuation state: 8
cd 91 5a 58 30 00 00 00 ..ZX0...
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5
Num handles: 1
Handle: 74
Count: 1
< ACL Data TX: Handle 74 flags 0x00 dlen 32
Channel: 64 len 28 [PSM 1 mode 0] {chan 3}
SDP: Service Search Attribute Request (0x06) tid 2 len 23
Search pattern: [len 5]
Sequence (6) with 3 bytes [8 extra bits] len 5
UUID (3) with 2 bytes [0 extra bits] len 3
OBEX Object Push (0x1105)
Max record count: 65535
Attribute list: [len 7]
Sequence (6) with 5 bytes [8 extra bits] len 7
Unsigned Integer (1) with 4 bytes [0 extra bits] len 5
0x0000ffff
Continuation state: 8
cd 91 5a 58 30 00 00 00 ..ZX0...
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 74
Count: 1
> ACL Data RX: Handle 74 flags 0x02 dlen 68
Channel: 64 len 64 [PSM 1 mode 0] {chan 3}
SDP: Service Search Attribute Response (0x07) tid 2 len 59
Attribute bytes: 48
Continuation state: 8
cd 91 5a 58 60 00 00 00 ..ZX`...
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5
Num handles: 1
Handle: 74
Count: 1
< ACL Data TX: Handle 74 flags 0x00 dlen 32
Channel: 64 len 28 [PSM 1 mode 0] {chan 3}
SDP: Service Search Attribute Request (0x06) tid 3 len 23
Search pattern: [len 5]
Sequence (6) with 3 bytes [8 extra bits] len 5
UUID (3) with 2 bytes [0 extra bits] len 3
OBEX Object Push (0x1105)
Max record count: 65535
Attribute list: [len 7]
Sequence (6) with 5 bytes [8 extra bits] len 7
Unsigned Integer (1) with 4 bytes [0 extra bits] len 5
0x0000ffff
Continuation state: 8
cd 91 5a 58 60 00 00 00 ..ZX`...
> HCI Event: Number of Completed Packets (0x13) plen 5
Num handles: 1
Handle: 74
Count: 1
> ACL Data RX: Handle 74 flags 0x02 dlen 19
Channel: 64 len 15 [PSM 1 mode 0] {chan 3}
SDP: Service Search Attribute Response (0x07) tid 3 len 10
Attribute bytes: 7
Continuation state: 0
Combined attribute bytes: 103
Attribute list: [len 99] {position 0}
Attribute: Service Record Handle (0x0000) [len 2]
0x00010001
Attribute: Service Class ID List (0x0001) [len 2]
UUID (3) with 2 bytes [0 extra bits] len 3
OBEX Object Push (0x1105)
Attribute: Protocol Descriptor List (0x0004) [len 2]
Sequence (6) with 3 bytes [8 extra bits] len 5
UUID (3) with 2 bytes [0 extra bits] len 3
L2CAP (0x0100)
Sequence (6) with 5 bytes [8 extra bits] len 7
UUID (3) with 2 bytes [0 extra bits] len 3
RFCOMM (0x0003)
Unsigned Integer (1) with 1 byte [0 extra bits] len 2
0x09
Sequence (6) with 3 bytes [8 extra bits] len 5
UUID (3) with 2 bytes [0 extra bits] len 3
OBEX (0x0008)
Attribute: Browse Group List (0x0005) [len 2]
UUID (3) with 2 bytes [0 extra bits] len 3
Public Browse Root (0x1002)
Attribute: Bluetooth Profile Descriptor List (0x0009) [len 2]
Sequence (6) with 6 bytes [8 extra bits] len 8
UUID (3) with 2 bytes [0 extra bits] len 3
OBEX Object Push (0x1105)
Unsigned Integer (1) with 2 bytes [0 extra bits] len 3
0x0100
Attribute: Unknown (0x0100) [len 2]
OBEX Object Push [len 16]
Attribute: Unknown (0x0303) [len 2]
Unsigned Integer (1) with 1 byte [0 extra bits] len 2
0x01
Unsigned Integer (1) with 1 byte [0 extra bits] len 2
0x02
Unsigned Integer (1) with 1 byte [0 extra bits] len 2
0x03
Unsigned Integer (1) with 1 byte [0 extra bits] len 2
0x04
Unsigned Integer (1) with 1 byte [0 extra bits] len 2
0x05
Unsigned Integer (1) with 1 byte [0 extra bits] len 2
0x06
Unsigned Integer (1) with 1 byte [0 extra bits] len 2
0xff
Jira: ZEP-1112
Change-Id: Ie282782fba6ef06c6826b3e624f83c8f4c94ebbe
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
The following readings were obtained after running the peripheral and
central_hr apps in qemu combined with the controller (hci_uart) on nRF51
and nRF52:
Main Stack 380
Idle Stack: 68
ISR stack: 532
Controller RX Stack: 388
HCI TX Stack: 516
The numbers set in this change provide a safety margin from the ones
measured empirically.
Change-id: Ice7ad7f081502e0ea1accf856a7937c0bf0783b2
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
reserve parameter of bt_l2cap_create_pdu() is incorrectly passed
as timeout.
Change-Id: Ieed293f52c2e98f16f1e43c498140178703236db
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
For consistency with RX_STACK_SIZE and the rest of stack sizes, rename
to use the normal naming scheme.
Change-id: Ib8d484482466fa8d629e6329e07b927abdd6f598
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add Kconfig configuration to conditionally enable LE Ping
feature in the Controller.
This will save CPU time, flash and RAM, if this feature is
not desired.
Change-id: I5fbbdbe8f45ac01c9b0d7b11e002a0d1db4d272e
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
The data pointer and length was not updated before invoking the
write_rsp function therefore providing pointer to the handle.
Change-Id: I5c27ab7a793979dffb8f1f2c68def027c45f2376
Signed-off-by: Louis Caron <louis.caron@intel.com>
This should also have been net_buf_add_mem(). Otherwise the buffer
gets corrupted.
Change-Id: I4687584777f446d398182c3e8c2cde5946987da4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Move code that can be executed after radio tx/rx packet ptr
has been assigned in the radio h/w.
Change-id: I9c5a34ee6bb74c1265d7871bcdf93894e3e7b190
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Added code to profile radio ISR execution time and generate
an event, which can be used to populate a vendor HCI event.
This event and associated code is disabled, subsequent
patch will add kconfig to enable it.
Change-id: Ic3fa3e0f4e36829a22a25ffee039949eaae561a7
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Use BT_WARN instead of BT_ASSERT to display unknown rsp in
HCI layer.
Change-id: I63c792468d9c4768f69df73395ee026a03521704
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Peer controllers not supporting LE Ping feature will
respond with unknown response PDU, handle it internally in
the controller rather than exposing it to HCI layer.
Discovered that controller was passing the unknown rsp PDU
to HCI layer when LE Ping was send to Nexus 5.
Unknown response for slave feature request was forwarded to
HCI layer, during that implementation unknown rsp for LE
ping too was getting forwarded to HCI layer.
Change-id: I4396c482e5546d78239cf41d88728de996e48d7d
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
This call was supposed to be net_buf_add_mem().
Change-Id: I5e4a718474905c433533fd1c1d7e8e0b7ff35739
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This helps simplify code that was previously combining net_buf_add()
with memcpy().
Change-Id: If44cf9cd651aba5e544e36567869f147468663eb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Stops handle data if server responds with SDP Error PDU
Jira: ZEP-1112
Change-Id: Iaddb740f71fa86384753ab32956fc69b89faeea0
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Adds handler responsible for receiving SDP data on SDP client request.
For now simple validation are done on SDP response header data.
Jira: ZEP-1112
Change-Id: Ic6009030db34e26dfdbd57fa1b0a22f6e27b6a11
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
cid is uint16_t and L2CAP_BR_CID_DYN_END is 0xffff so doing
"cid < L2CAP_BR_CID_DYN_END" comparisong is always true resulting
in for loop not being terminated as expected. Check against cid
overflow instead. Code comment is also added for clarity.
Change-Id: I15d6d838ed8b731824e602d089d765614c96c6c1
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Resets SDP client session data on related L2CAP transport channel
disconnection state. Leave the channel itself reset to L2CAP layer.
Jira: ZEP-1112
Change-Id: I4d8a8f10908f5e599ba6506470b98508869cb21b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Makes possible to append user UUID to context to be able later iterate
it on subsequent resolving process.
Jira: ZEP-1112
Change-Id: I193ff1cee199045c9686dc4ca200adf19db377e4
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Renames and refactors helper get_client_session to sdp_client_get_session
to follow existing naming convention and adds second helper creating
new SDP client session. Then simplifies using them the API implementation.
Jira: ZEP-1112
Change-Id: I6b919f521e6665a7117fa06208b3fa2ae5f77fda
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Peer sends Remote Port Negotiation command to set port
communication settings. Currently we accept all the settings
sent by remote.
If there is only one value byte in the request then current
port settings has to be returned for which we returns the
default settings defined in ETSI.
Note that RPN may be sent even before a dlc is opened.
> ACL Data RX: Handle 256 flags 0x02 dlen 18
Channel: 64 len 14 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x03 cr 1 dlci 0x00
Control: 0xef poll/final 0
Length: 10
FCS: 0x70
MCC Message type: Remote Port Negotiation Command CMD (0x24)
Length: 8
dlci 10
br 3 db 2 sb 0 p 0 pt 0 xi 0 xo 0
rtri 0 rtro 0 rtci 0 rtco 0 xon 17 xoff 19
pm 0x3f7f
< ACL Data TX: Handle 256 flags 0x00 dlen 18
Channel: 64 len 14 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x01 cr 0 dlci 0x00
Control: 0xef poll/final 0
Length: 10
FCS: 0xaa
MCC Message type: Remote Port Negotiation Command RSP (0x24)
Length: 8
dlci 10
br 3 db 2 sb 0 p 0 pt 0 xi 0 xo 0
rtri 0 rtro 0 rtci 0 rtco 0 xon 17 xoff 19
pm 0x3f7f
Change-Id: I73b7d8577e7e2bc3e436f4db86a91e12db440f1f
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
rfcomm_make_uih_msg() only needs session to get the role while creating
msg. This is mainly done since some commands like Test and RPN may come
even before dlc is created.
Change-Id: Ifd5a2ceaf17c20db3f00604cd2b4f1759155123e
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
l2cap_br_conn_req_reply expects valid bt_l2cap_chan pointer but this
is achieved only on accept() callback. Use l2cap_br_send_conn_rsp
instead for rejecting cases where no channel was accepted. This also
makes success path being 'primary' function path ie erros all always
handled inside if() statements.
Jira: ZEP-1405
Change-Id: I890b4fcf029afce65eba4f2ebae0b1094feb007f
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Not all users are in an ISR context where we can't block, so give the
callers the freedom to choose if they want to block or not.
Jira: ZEP-1481
Change-Id: I19bd7e2df94c4eeb60886a17a78f872bd7bea887
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Adds validation check when 'sdp discovery' API is to be called
by client, to reuse existing connection if valid or initiate new one
if posssible to set SDP L2CAP link to remote.
Change-Id: I47ce33cb5e95cf2616f9b23712641b912ce40f37
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Added a Pending Request structure, this will keep
a track of the last sent AVDTP Singnalling Message.
This will be used to verify the response from the remote device
Memory will be allocated by the application.
Change-Id: Ic31df154b52ce9013e5039ab195a9651d1811a7a
Signed-off-by: Arun Jagadish <arun.jagadish@intel.com>
Adds for now stubs of handlers responsible for taking a connected and
disconnected state of SDP L2CAP channel.
Change-Id: I21b76b755168fb63f6cade5f6b0c0bab93d0a01f
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Adds basic functionality to be able to trigger establishing outgoing
L2CAP channel to remote using as PSM SDP channel. The number of such
outgoing connections is limited by configured pool of connections.
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Change-Id: Ie5428e5b1b5f5c57f473ee0adfd4621cd9fe6e3e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This patch contains API's which is used to parse range of values
eg. (0,3). This patch also parses the string, reads, process and
move the buffer accordingly.
Change-Id: I8dba5b7d630f65b87967c101557c5c7ffd297dd1
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
If more inquiry results were received during discovery than fits in
storage results with lowest RSSI will be skipped. This is to improve
API usefulness in busy environments where results with low RSSI (likely
more far away than high RSSI) could consume provided result space,
Change-Id: I1e9ca901b693f608d58575916809e8bd8bfe710f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
at_get_number which converts the string into number now operates on
at_client to get the string buffer. This patch also improves API()
skip_whitespace to be operated on at_client. Also the the API's
get_cmd_value, get_response_string are updated to work with buf
increment.
Also in this patch the return type of the function str_has_prefix
is changed from 'int' to 'bool'.
Change-Id: Ia626e0d13212b84413cce0444349975f4abe1cf6
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
The execution time of k_sem_give() increased slightly recently, and
since it was being called from the radio ISR this had an impact in the
deadlines not being met.
This change moves the actual call to k_sem_give() to a lower-priority
job and thus out of the ISR to avoid its execution time affecting the
ISR's timing.
Change-id: I76c82df895c6daaffef52786b0c900ee15acb0aa
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The ECC emulation synthesizes its own HCI events so we may need up to
two available priority buffers at any point in time.
Change-Id: I88b37c7e9e9f64483d80cde9243470a7f0477321
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In preparation for the new Nordic MDK and nRF52840 IC support we switch
to using the SERIES config instead of the old "NRF52" macro that will be
deprecated in the new MDK.
JIRA: ZEP-1418
Change-Id: I563f025c9db9b7497116c5af23814d95c720f836
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
There are static initializer macros available for most kernel objects
which we should use whenever possible.
Change-Id: I496f4d05d26801eddd21fae53bdd4fcdc3246fe3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This adds H7 function implementation and test based on sample data
from Core Specification 5.0 Vol 3. Part H. Appendix D.8.
Jira: ZEP-1431
Change-Id: I49d44ee7a352d1092f6379829d747c7e0ec5e83c
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Reduce the time limit for active clock startup and increase
the CPU usage time limit before hard real-time radio
transmit/receive.
Due to isr_wrapper overhead in ARM architectures, more time
was used before hard real-time radio transmission or
reception which was detected by controller implementation
and the controller aborted the radio transactions.
This commit permits more CPU utilization by the controller
before hard real-time radio transactions start.
Change-Id: Id976add80c70cabc753c43dfac6f6603588458d9
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
On CPUs like nRF51 which run at 16MHz, certain BLE control
procedure PDU processing take more CPU time than permitted
inside tIFS (150us). Current implementation of Data Length
Update procedure does not span over multiple connection
interval (unlike Encryption Setup, which is another control
procedure processing that would consume more CPU time)
hence taking more CPU time inside tIFS on nRF51.
During the radio ISR, the active clock and packet timer are
active and it is used to profile the CPU time taken which
is used to decide on whether there is sufficient time in
the current radio event to process the control packet.
This commit also fixes a potential bug that would cause
disconnection due to MIC failure on encrypted connections
that performed Data Length Update. Controller used to NACK
the request/response PDU if it was not in a state to resize
the receive buffers but did not reset the CCM counter. This
is now fixed by the change done to NACK control PDU based
on available CPU time in radio ISR.
Change-id: Id58322ad76a0dbc284738cdd9a7c0437c9e8c423
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
"next" is more relevant since its used to save next pointer
Change-Id: Ic0a8d543944681ba4291c5aa06125f565ab6115c
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
The function is not particularly small, and is used from several
places, so remove the inline declaration. This also prepares the way
for the possibility of having an application callback for letting the
application choose whether it's fine with the proposed parameters, and
thereby influence the response we send to the remote device.
Change-Id: I5848b179318b6fb6ee37fcbd479a919204f559f1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that all logging methods use printk as a backend the respective
Kconfig options should declare the right dependencies.
Change-Id: I65c759db0ec7ba6333b76d8d20aea0e374fd4947
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Since the user data size is now stored in the pool there's very little
value in storing it as well per-buffer.
Change-Id: I17a99123b232423c52a2179b4eccd813728d51b1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In order to keep the initialization process light-weight, remove
net_buf_pool_init() and instead perform the initialization of the pool
and buffers in a "lazy" manner. This means storing more information
in the pool, and removing any 'const' members from net_buf. Since
there are no more const members in net_buf the buffer array can be
declared with __noinit, which further reduces initialization overhead.
Change-Id: Ia126af101c2727c130651b697dcba99d159a1c76
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This is only for use with custom destroy callbacks, so that the
application gets isolated away from the details of how exactly the
buffers are managed. This opens up the possibility of switching away
from k_fifo to potentially better solutions, such as k_lifo.
Change-Id: I0d8322fdec3500d8ae060ae471b9448aeaa4572a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Until now it has been necessary to separately define a k_fifo and
an array of buffers when creating net_buf pools. This has been a bit
of an inconvenience as well as blurred the line of what exactly
constitutes the "pool".
This patch removes the NET_BUF_POOL() macro and replaces it with a
NET_BUF_POOL_DEFINE() macro that internally expands into the buffer
array and new net_buf_pool struct with a given name:
NET_BUF_POOL_DEFINE(pool_name, ...);
Having a dedicated context struct for the pool has the added benefit
that we can start moving there net_buf members that have the same
value for all buffers from the same pool. The first such member that
gets moved is the destroy callback, thus shrinking net_buf by four
bytes. Another potential candidate is the user_data_size, however
right not that's left out since it would just leave 2 bytes of padding
in net_buf (i.e. not influence its size). Another common value is
buf->size, however that one is also used by net_buf_simple and can
therefore not be moved.
This patch also splits getting buffers from a FIFO and allocating a
new buffer from a pool into two separate APIs: net_buf_get and
net_buf_alloc, thus simplifying the APIs and their usage. There is no
separate 'reserve_head' parameter anymore when allocating, rather the
user is expected to call net_buf_reserve() afterwards if something
else than 0 headroom is desired.
Change-Id: Id91b1e5c2be2deb1274dde47f5edebfe29af383a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Bluetooth thread stack sizes are optimized based on the assumption
that printk is used for logging and not printf. Using _prf() (the
printf backend) risks overflowing the stack, so use the recently
exposed _vprintk instead.
Change-Id: Ibcbe0af2994c83114d12aa27a8bc29c77bb8c4c8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now printk family from <misc/printk.h> already included should handle
BT_DBG() like expansion.
Change-Id: I5e03f786530e4bbbdb94a13a4cd77db580268c11
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Replace precision formatter (.) in printk with padding flag like %04x
since for now precision is not handled properly in printk family.
Change-Id: Ib63198e407ef584c5650d6452518b1767047630f
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
These should have been converted to using printk instead.
Change-Id: I62323704dad4fc51cc14ee4734acb6b325dcda14
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This will be used by the user to disconnect or cancel connect dlc.
This also defines an internal close function which will take
appropriate action based on the dlc state.
In case of user initiated disconnection if some pending packets are
there in queue then it has to be sent before sending DISC packet.
< ACL Data TX: Handle 256 flags 0x00 dlen 8
Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Disconnect (DISC) (0x43)
Address: 0x2b cr 1 dlci 0x0a
Control: 0x53 poll/final 1
Length: 0
FCS: 0x6d
> ACL Data RX: Handle 256 flags 0x02 dlen 8
Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Ack (UA) (0x63)
Address: 0x29 cr 0 dlci 0x0a
Control: 0x73 poll/final 1
Length: 0
FCS: 0x26
Change-Id: Ie4fa3bd8f6b279fee6fb56ddce198d82c5047849
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
When PSM server doesn't have BR/EDR L2CAP resources to assign and handle
incoming request properly, local channel pointer may stay uninitialized.
This fixes such scenario. The fix refactors main connection request
reply handler to additional helper which can be used to send response
unconditionally for situation when local channel is not allocated
to setup L2CAP link between.
Jira: ZEP-1405
Change-Id: I5caedd63a59ad0d1704ac87fa51616a0770320bf
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Instead of %4.4x we need to use %04x which printk supports.
Change-Id: I0564be5531bb266b328f77231f5d00f43eabe1ed
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If connection destination address has been changed update the addresses
stored by the time it disconnects since in case of RPA it is no longer
mapping to the same device after it has been disconnected.
Change-Id: I0ce966928f605a885125179eaa7b9093989825ab
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The connection destination address may change if the identity address
is resolved.
Change-Id: Id6f7b6494c24ff118043ba5f4ff54e254376eddf
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
bt_conn_lookup shall work both with identity address or initial
destination address as bt_conn may change the destination address with
the identity address.
Change-Id: Ibdd19ec453c3307eb6db188196b7e57a2260b526
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
There's now snprintk available that's more light-weight on the stack
than snprintf.
Change-Id: I6b3e4409703ca92fe6b8f4146ff47c490ab826cb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Applications may want finer control of the NRPA used for
non-connectable beacons, and provide it up-front rather than letting
the stack generate one.
Change-Id: I84d459372cc85ed09a8f9cde16dbb9b98dec2a43
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Expose helpers in hci.h for setting and getting the LE random address
type.
Change-Id: I7c6437051f0b2d1f5f79e19b2616bb643ae6300b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix compilation issues that show up if SYS_LOG is mapped to printk
instead of printf. Unlike printf, printk is annotated so that the
compiler catches incorrect format specifiers passed to it.
Change-Id: I4d6f635a0ed61de698727028ea8767dc0ef28bb1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Instead of having custom logic for determining the minimum of two
values, use the existing min() helper from misc/util.h.
Change-Id: I9809883d4a31126329373f293897dd49eb91e9ad
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
rfcomm_dlc_drop() can be used from many places to unlink dlc
from session and destroy it. So it is better to send DM
explicitly from relevant places.
Change-Id: I9b6a31ce5bb65b90510aa483539d4a201ba12b60
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
When the Controller is configured to support less than 251
as the supported maximum data length, missing check caused
the Controller to incorrectly re-initialize its rx buffers
causing assert during the DLE procedure. This commit fixes
the procedure to correctly use the supported maximum length
if the peer requests a transmit length that exceeds the
supported receive length.
Change-id: I6ad7196e3db44b303ddf2ec06e0ae579bf2eb774
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This allows to fine tune TX stacks size depending on selected HCI
driver. If needed it can be used to tune for monitor too or other
logging mechanism used.
Change-Id: Ib501921da0b786e151083760d85ec58fe3c08b60
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
If debugs are disabled scid and dcid variables were never read.
This also fix mixed values of scid and dcid in le_disconn_req.
Change-Id: I3b435dd0640c5c65ab5fe68e33dd25e3c9e0026e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
subsys/bluetooth/host/hci_ecc.c: At top level:
subsys/bluetooth/host/hci_ecc.c:277:6: warning: no previous prototype
for 'bt_hci_ecc_init' [-Wmissing-prototypes]
void bt_hci_ecc_init(void)
^
CC subsys/bluetooth/host/conn.o
Change-Id: I920d8b6b66c82be932c579461310505c6d402c08
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Even one-line branches should have {}, and the last two return
statements can be simplified into a single one.
Change-Id: I0f65aeaba867240255eae8e1c461386700444ae6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
With k_sem API it is possible to specify maximum sempahore value
so we no longer need to track semaphore count.
Change-Id: I86744ba63bd3207051ca3466d4f81b816d24f5ad
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Applications expect service end handle as attribute value in userdata
on discovery response callback.
Jira: ZEP-1354
Change-Id: I664da4a7e054a531ad1c2c8cbc74367cb679ff03
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Security needs to be elevated based on dlc required sec_level
before creating dlc. If L2CAP connection is not created then
setting dlc required sec_level to chan would do the job.
Change-Id: I21debd3559c9ccfb79011160d676932bc2a54604
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Correct the local LE supported features bitmap to actually "or"
together all the bits that correspond to the set of features that
are implemented at this time.
Change-Id: I0c62ec566c775514250fcf062aeef6c9656719e3
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
If the original buffer cannot be reused, either by no having enough
space for user data or if is fragmented, it can in fact be smaller than
both the segment buffer and MPS.
Change-Id: I59a537aff59c5d56b2883e9bd51f3a1a3932d348
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The segments need to be limited by the minimun of the segment buffer
tailroom and tx MPS not the original buf length.
Change-Id: I580a3bb61aa190ac0cdd3717bc06fd6e6e668304
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Implement the 2 HCI commands that provide ECC public key
and shared secret generation:
- LE Read Local P-256 Public Key
- LE Generate DHKey
Jira: ZEP-1246
Change-Id: I79388bfdb9f2e28b9377b4bb6ee2caca25f33f3e
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Handle the scenarios like ignoring a response in non existing dlc,
correctly handle if received a command with invalid mtu etc.
Change-Id: Ib0bce9134bac3a0dead03798f859af54873a70c1
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
k_sem_take return differ from nano_sem_take since it return 0 for
successful case instead of 1.
Change-Id: Ia39cd624d56dbc1c8e7f3558244bebf765da191d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is no longer needed after switch to unified kernel.
Change-Id: Ie1f8dadb3f2e43ae6ccfbfaf1f754196f3237471
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
After switch to unified kernel this is no longer needed.
Change-Id: If9877d3fa038dd873011fb780c7e767e150647ae
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This fixes defect found by coverity: 152027 Pointer to local outside
scope.
Change-Id: I50f196a04363ffa6e6654b71a9a1d89034580413
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Implement the 3 missing HCI commands required to support
Data Length Extensions:
- LE Read Suggested Default Data Length
- LE Write Suggested Default Data Length
- LE Read Maximum Data Length
Note: Only octets are actually used at this time, not time.
Jira: ZEP-1246
Change-Id: Id76d8fedb5ecaf0001c8429cf22f9a3e2c910a44
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix Coverity, sizeof not portable, defect; by explicitly
using sizeof(void *).
suspicious_sizeof:
Passing argument mem_head of type void ** and argument 4U
/* sizeof (mem_head) */ to function memcpy is suspicious.
In this case, sizeof (void **) is equal to sizeof
(void *), but this is not a portable assumption.
Change-id: I4b4776466e16020876500feba0141985b8581017
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
External interrupts are indexed from value 16, wherein
0 to 15 are ARM cortex M exceptions. Fixed code in
_irq_is_priority_equal to fetch correct external
interrupt line ISR priority.
Change-id: I9cfd411480e78dfc9635e72d14df9d667a9d8400
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Coverity analysis discovered NULL pointer being
dereferenced when passing a auto variable. The variable is
now correctly assigned with address of a valid default
value variable. As per design, the dereferencing will not
happen as the master role does not use the passed parameter
only slave role uses it to prepare the connection parameter
request PDU.
Change-id: I3f8519b23a83cb8c50c7fba81810eff7737ff74a
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Coverity analysis discovered that observer filter policy
field was 1 bit, whereas valid range for extended scanner
filter policy feature implemented in controller is 0 to 3.
Increase the bit field size from 1 to 2.
Change-Id: Id4b2e354961dfb3b45f72fa4e0ab18de7425bbb5
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
This fix using incorrect address type for passive scanning with
privacy enabled. Controller was not reporting directed advertising
to RPA address due to public type being used for passive scan.
This was affecting TC_CONN_GCEP_BV_01_C, TC_CONN_ACEP_BV_01_C and
TC_CONN_DCEP_BV_01_C qualification test cases.
Jira: ZEP-1200
Change-Id: Icc316441fcac1a72d75f9ade27a99030efc846b9
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This might create confusions when debugging as usually the prefix is
associated with the file or layer.
Change-Id: Ibf45578c1f54a4bec896acd6042589c815216e1f
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
BR/EDR code should have minimal impact on LE code so to keep it simple
just require peripheral and central to be enabled when selecting BR/EDR
support.
Fix following Kconfig warning:
warning: (NETWORKING_WITH_BT && BLUETOOTH_BREDR) selects
BLUETOOTH_L2CAP_DYNAMIC_CHANNEL which has unmet direct dependencies
(BLUETOOTH && BLUETOOTH_HCI && BLUETOOTH_HCI_HOST && BLUETOOTH_CONN
&& BLUETOOTH_SMP)
Change-Id: I7f7cb8794def0df6daaa4abfe4596df460f1a2b2
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Fix following warning:
CC subsys/bluetooth/host/monitor.o
In file included from zephyr/include/drivers/loapic.h:58:0,
from zephyr/include/drivers/ioapic.h:22,
from zephyr/include/drivers/sysapic.h:20,
from zephyr/include/arch/x86/irq_controller.h:33,
from zephyr/include/arch/x86/arch.h:28,
from zephyr/include/arch/cpu.h:23,
from zephyr/include/kernel.h:2458,
from zephyr/include/zephyr.h:20,
from zephyr/subsys/bluetooth/host/monitor.c:24:
zephyr/subsys/bluetooth/host/monitor.c: In function
'_deprecation_check_sys_init_bt_monitor_init0':
zephyr/include/device.h:130:16: warning: '_INIT_LEVEL_PRIMARY' is
deprecated [-Wdeprecated-declarations]
static struct device_config _CONCAT(__config_, dev_name) __used \
^
zephyr/include/device.h:245:2: note: in expansion of macro
'DEVICE_AND_API_INIT'
DEVICE_AND_API_INIT(dev_name, drv_name, init_fn, data, cfg_info, \
^
zephyr/include/init.h:69:2: note: in expansion of macro 'DEVICE_INIT'
DEVICE_INIT(_SYS_NAME(init_fn), "", init_fn, NULL, NULL, level, prio)
^
zephyr/subsys/bluetooth/host/monitor.c:193:1: note: in expansion of
macro 'SYS_INIT'
SYS_INIT(bt_monitor_init, PRIMARY, MONITOR_INIT_PRIORITY);
^
zephyr/include/device.h:48:31: note: declared here
static __deprecated const int _INIT_LEVEL_PRIMARY = 1;
Change-Id: Ie903e3a075f6614b26018be5769be3651f0963be
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Added implementation for HCI Reset Command. Implementation
gracefully disables any running advertiser, observer, and/
or connection roles, and it resets controller context members.
The HCI Reset Command is implemented in such a way that
driver instances shared with other sub-systems and
application is not disturbed and instance/references used
by Bluetooth Controller are gracefully returned back.
Jira: ZEP-1282
Change-id: Ifb9ae6807736b5ec2d9f346cf2a590322056bcee
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This fixes issue that L2CAP Connection Parameters Update Request was
not sent. There was check that used LE features of host controller
to determine if L2CAP procedure or LL shall be used. It was failing
with 4.2 controller. The check shall test if remote supports
LL Connection Parameters Request Procedure. If it's not supported,
then L2CAP Connection Parameters Update Procedure will be used.
Closes ZEP-1220
1/4 L2CAP TC_LE_CPU_BV_01_C PASS
2/4 GAP TC_CONN_CPUP_BV_01_C PASS
3/4 GAP TC_CONN_CPUP_BV_02_C PASS
4/4 GAP TC_CONN_CPUP_BV_03_C PASS
Change-Id: I61ad544d9568ca6306a845e05c1a2e28d1693ab4
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
Using the K_* macros makes it easier to read what exactly the various
timeouts are.
Change-Id: Ia405d3760b8e600af7e33a7221ef6ec717708973
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Switch left-over usage of TICKS_NONE and TICKS_UNLIMITED to the new
unified kernel counterparts K_NO_WAIT and K_FOREVER.
Change-Id: I2f2a16360e816f9f8791eb216deb3c70b8cc87df
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
During the initial integration of controller to Zephyr OS,
radio hardware access was abstracted out into hal/radio.c
file. Bug introduced in hal/radio.c has been fixed so that
whitelist feature works again.
Change-id: Ie5faf80b1a008ef326613548a5a28a4ba52e7ef7
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
The conditional defaults must come last in order to be properly
processed.
Change-Id: Id7a152ca1a1584935029e212d0dd8f37494d1cf4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add implementation in HCI and Controller to support
HCI_LE_Remove_Device_From_White_List, as it is listed as
mandatory under BT Spec. v4.2, Part E, Section 3.19 LE
Controller Requirements.
Change-id: Icef88dffc85746f3cc7adb7fb692ae5578274ed2
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Rename left-over mentions in code comments of "fiber" to "thread".
Change-Id: I1af1baf99652434e90eb491c10238b94d26d341d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Switch from fiber_start() to k_thread_spawn() and from NANOKERNEL to
POST_KERNEL init level.
Change-Id: I34fb11cbe20216c8646ebacb07be304a67e3cd0a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use k_thread_spawn() instead of the deprecated fiber_start() API.
Change-Id: I42e798ef3a4276863659c8d97c85224a652be1fd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The bt_recv() function had protections for being called from a
preemptible task context, however nothing was protecting preemption by
ISR. A fairly simple fix is to protect the couple of critical regions
that can be reached from bt_recv() with the help of irq_lock().
Change-Id: Ifc29fd31205eb5425e1b7c862347d9420688df4e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Switch to using the unified kernel k_thread_spawn() API instead of
nano_fiber_start().
Change-Id: I325cf467ae2a52c6aec8fc166397c323929e3013
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use the unified kernel API k_yield() instead of fiber_yield().
Change-Id: I8f52031f52f7ac8783033a51751dc22decdfa59a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Switch to using k_uptime_get() instead of the deprecated
sys_tick_get_32() API.
Change-Id: I737ef0153eff9d283bae840ff5177f8132396e1b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use defines from k_fifo intead of legacy API.
Change-Id: Ib8cf0d88240ef145da550b8cf83d2580e7140521
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Those are lefovers from nano_delayed_work usage.
Change-Id: I3f17c7b89b1fa946495e160732457500e2f74f25
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This fixes warnings related to the use of nano_work and
nano_delayed_work in HCI layer.
Note that k_delayed_work takes a timeout in miliseconds rather than in
ticks thus the timeout values have been changed.
Change-Id: I953a82a6aa613bb1072a8ad4b01e0f94e5cd64bd
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes warnings related to the use of nano_work and
nano_delayed_work in bt_conn layer.
Note that k_delayed_work takes a timeout in miliseconds rather than in
ticks thus the timeout values have been changed.
Change-Id: Ia8f34b475051515fd74000cce745ad226aa18aa5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes warnings related to the use of nano_work and
nano_delayed_work in SMP layer.
Note that k_delayed_work takes a timeout in miliseconds rather than in
ticks thus the timeout values have been changed.
Change-Id: Ida58ff0f609dc2a8fd415692bc2cec91eb56a294
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes warnings related to the use of nano_work and
nano_delayed_work in ATT layer.
Note that k_delayed_work takes a timeout in miliseconds rather than in
ticks thus the timeouts values changes.
Change-Id: I14d8438c1537febcb7768ef2934042ce38682739
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes warnings related to the use of nano_work and
nano_delayed_work in L2CAP layer.
Note that k_delayed_work takes a timeout in miliseconds rather than in
ticks thus the timeouts values changes.
Change-Id: I1e3bd7857248865e34a313dd42862af5f4e3805b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Currently the ideal buffer counts for a controller-only build are 6 RX
buffers and 7 TX buffers: ATT_MTU of 158 bytes can be sent in one
connection interval of 6 tx/rx -es wherein connection interval is
7.5ms
Change-Id: I64b4620c5e8e7db8d7ed72fa1db82e266e121f27
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This patch introduces the Connect API which initiates session
connection first. If session is already there with the peer
then it has to reuse it and initiate DLC (which will be done
in the subsequent patch) since there can be only one session
per device.
< ACL Data TX: Handle 256 flags 0x00 dlen 8
Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Set Async Balance Mode (SABM) (0x2f)
Address: 0x03 cr 1 dlci 0x00
Control: 0x3f poll/final 1
Length: 0
FCS: 0x1c
> ACL Data RX: Handle 256 flags 0x02 dlen 8
Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Ack (UA) (0x63)
Address: 0x03 cr 1 dlci 0x00
Control: 0x73 poll/final 1
Length: 0
FCS: 0xd7
Change-Id: I9828e0f3b3ea43bb17df95f0536e15df86f1b4be
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
In some SMP + GATT scenarios it's possible we get up to 6 incoming ACL
packets. To handle these efficiently, and more importantly, to not
have to drop data if the controller lacks host flow control (as is the
case currently with Zephyr-based controllers), increase the default
from 5 to 6.
For a controller-build it makes sense to just match up with the
controller-side configured RX buffers.
Change-Id: Id44fa724597b88a51f9085dac009e8d84a439bfc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
All boolean options default to 'n' without the need to explicitly
state this. It's only the cases where we want 'default y' where we
need to state this.
Change-Id: I47dbda62462ea437a2423b8508ea2cc640a22e41
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Restructure the Bluetooth options more logically.
- Both host and controller are now behind the same high level
CONFIG_BLUETOOTH.
- Selecting controller support disables other HCI driver selection, so
the controller isn't in the same list as HCI drivers any more.
- Under the top-level there's a "Custom stack" option, which when
enabled opens up the option of choosing CONFIG_NBLE.
There are various other cleanups and simplifications in this patch as
well, since splitting these up would have been fairly tricky while
making sure all test cases still build.
Change-Id: I5bb715cb9d20201cb8b72fbd149c8a09a4b2d7d2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This should be particularly useful with the recently added controller
assert functionality that causes vendor events with debug information.
Change-Id: Ied0df2ff414e08c11a73cca0afba4dc04b0b8625
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When building Zephyr in the controller-only configuration,
assertions that happen in the Link Layer code are not visible
to the Host which is running on another HCI and connected via
UART or USB to it. This patch allows the Controller code
to output the assertion line number when in such a configuration,
allowing the Host to view the event to help debugging.
The event format used is temporary and will be replaced by a
standardized Vendor Specific specification to come at a later
time.
Change-Id: I013ca6783a3fdedc47b171132919dd4798c66285
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The right convention for help text is tab + 2 spaces.
Change-Id: I2722a8b33f5f74be110dc43fbcecc12841f0db84
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When retrying the request due to a security error that can fail but since
the original buffer was freed in the process the code can no longer verify
if the opcode matches thus it always fails BT_ATT_ERR_UNLIKELY instead of
using the response error, so this not longer cares about the opcode and
just use the response error always.
JIRA: ZEP-1195
Change-Id: I1149b993b97733ab5bb00f347e4f973647e0fdd4
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This consolidate code around LE signalling header handling which has been
duplicated in many places.
Change-Id: I0c2cd48c155b751e1bbbd26070965d075cdc2cc5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When a peer controller does not recognize one of the LL control
PDUs received, it will issue an LL_UNKNOWN_RSP PDU to let the
peer know that it does not recognize the request.
The controller now handles this incoming PDU and completes the
procedure by issuing the appropriate HCI event in the case of
an LL_FEATURE_REQ and _RSP pair.
Jira: ZEP-1220
Change-Id: I7c04a346441f04deee41198daa6309c11ae1b571
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
'private' is a C++ reserved word and will lead to compilation errors:
C++ ble.o
In file included from ble.cpp:7:0:
include/bluetooth/bluetooth.h:284:10: error: expected unqualified-id before 'private'
uint8_t private[4];
Change-Id: I36aef5a84af4fc66e1c810bd0c56e5ab5f803294
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In function at_get_number check for the value if gets computed.
If not return error. Also change the end state handling.
Change-Id: I193b04fa2880dfb44e7727b30b67c1ec2e051cc7
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
Add an implementation for the bt_storage_clear() API.
Jira: ZEP-181
Change-Id: Iae01c571c161317ea0cc44513d108301c7b5a069
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add basic implementation of an internal storage handler that uses the
local file system. The root directory for all Bluetooth related data
is /bt. Each remote device has its own subdirectory and each key its
own file. This helps keep the implementation very simple, but does
come with the meta-data overhead for each file.
As an example, the value of a key 0x0001 for a device with a static
random address cc:11:22:33:44:55 would be stored in the following
file: /bt/cc11223344551/0001. Local values such as the identity
address are stored directly under /bt with a file name that matches
the key the same way as remote-device files.
For full functionality the implementation requires a file system that
can support file/directory names of up to 13 characters in length. If
the file system supports less than that (as is the case with FAT12)
then only local values can be stored (in /bt/abcd). Local values
include the identity address as well as the local IRK.
Jira: ZEP-181
Change-Id: I7dc696af6353a154cb00dcd01a5f4ac3d7127e6b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This is not needed for Zephyr controller build and should already
be fixed in Mynewt.
Change-Id: I39e81dc3e9b5fd5a3f5f823465527248625caf26
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Patch 8c118f8673 causes the wrong semaphore
to checked so receiving credits are never restored which caused the
channel to get stuck after all the credits are consumed.
JIRA: ZEP-1199
Change-Id: I9cd5474b3bcaafcb19d15613939ce30d07befe0a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Remove hardcoded use of crystal as 32KHz clock source and
20 ppm accuracy; and use the values from config for sleep
clock source and sleep clock accuracy value in Bluetooth
Controller.
Change-id: I1c0d53ecf8ad158153d5186a6680b5eb03d1641b
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Making a reference to the common work queue code should not necessarily
drag in the system workqueue, since it is possible to use a workqueue
that is not the system workqueue. This is done by moving the system
workqueue into its own code module.
Moving the system workqueue to its own code module allows removing the
NANO_WORKQUEUE and SYSTEM_WORKQUEUE kconfig options, and compiling the
common workqueue code and system workqueue all the time. They are only
linked in the final image if a reference to them exist, same as the
other kernel modules.
Change-Id: I6f48d2542bda24f4702e7c2e317818dd082b3c11
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
Provide more detailed information about the controller address and
version upon init when debug is enabled.
Change-Id: I5fe9c7c91f95928cb3cc64b801137bb1466e4115
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
During implementation of alternate encryption procedure
usable in nRF51, commited in
c41d3edda8, re-encryption
procedure was broken. This commit fixes the issue, and
now re-encryption should work on both nRF51 and nRF52.
Change-id: Ia41200f42b1d46e1f3f35ff44b582d4ffcc5f4fa
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
So that application could check data pointer to see if any
data have been received and if read operation is complete.
Change-Id: I36c3ff81baefbc535374d937e5297938445eafa6
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This makes use of the same code used by LE to print the state transitions.
Change-Id: I90a04f3c3f426fde1e0987acb572f7371c483c1c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds a common function to log state transitions including the caller
function and line in case something goes wrong:
[bt] [DBG] bt_l2cap_chan_disconnect: (0x0011b14c) chan 0x001199c0 scid 0x0040 dcid 0x0040
[bt] [DBG] bt_l2cap_chan_set_state_debug: (0x0011b14c) chan 0x001199c0 psm 0x0080 connect -> disconnect
[bt] [WRN] bt_l2cap_chan_set_state_debug: bt_l2cap_chan_disconnect()1562: invalid transition
Change-Id: I246a9004a04d93a38b8c7f7633705f6c191698b2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Channel state shall be updated properly otherwise it may cause unexpected
errors.
Change-Id: Ifd54d6bd3c5b44a40c315fd8a2946b30168aa65f
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This defines and clarifies PF bit macro for both UIH and
non UIH packets.
Change-Id: Ide7736c0fc8607708824766adbfccf1bd7bc48e9
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Security will be elevated based on the DLC required level
during connection.
Change-Id: I0b63885582f34a5689f7bc8081c1f9f011b2325f
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Initialize the variable to zero before computing.
Change-Id: Iccdf77a085667728dbb68779f001c8d940a7a89d
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
This is necessary in order to properly handle security errors which are
part of the testing specification thus can influence qualification.
Change-Id: If444e753be9196f3d5bb36cea00e332a33aa249f
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is to avoid code duplication while implementing outgoing
connection.
Change-Id: I52f882b7be9180f29def59c8ac3ef0a4798b719d
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
This is to avoid code duplication while implementing outgoing
connection.
This also moves setting initiator flag while allocating, than
doing it when SABM is received.
Change-Id: I8e811c995bf0eaa0bd24715e2e96d8a578a79c5d
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
This replaces initiator flag of session and dlc to enum which has
two values INITIATOR and ACCEPTOR.
Also this defines macros for CRs in header. Basically there are
three types fo CRs. Frame header CR has different meaning for
UIH and non UIH packets. Also this renames the existing msg hdr
CR to make it consistent.
These changes are basically done to make it more readable
Change-Id: Ic15e93465b0afbd19d8805f27d7a43f34ef38689
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Move controller code from drivers/controller to
subsys/bluetooth/controller.
Change-Id: I73f675188485aa3267507bad7647796e593a3da0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Move the Bluetooth host stack from net/bluetooth to
subsys/bluetooth/host. This is preparation for having both host and
controller under the same root, i.e. subsys/bluetooth/.
Change-Id: I3bc796f7e331fca0c485f3890d62b9c03e027b96
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>