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 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>
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>
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>
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>
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>
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.
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 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>
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>
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>
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>
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>
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>
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>
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>
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 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>
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 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>
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>
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>
The change changes the type of the attribute count in the
bt_gatt_service struct to size_t.
The background for the change is that with this variable being a
u16_t, we assign something that has been cast to an unsigned long
(from "ARRAY_SIZE") to an u16_t variable, and that Lint complains
about a loss of information (27 bits to 16 bits in the case I found).
(The issue seems to be not only about the cast, but about what is
casted. I suspect that Lint may be confused by the magic of
ZERO_OR_COMPILE_ERROR.)
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
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>
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>
This adds BT_GATT_ATTRIBUTE which replaces BT_GATT_DESCRIPTOR as the
most basic way to declare an attribute since using descriptor may be
confusing when declaring things like a characteristic value since the
Bluetooth has their procedures completely separated.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@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>
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>
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>
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>
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>
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 #ifdef protections are not needed, and in fact prevent helpers
such as IS_ENABLED() from being used when calling APIs which are
optional.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
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>