Bluetooth: Mesh: Add support for provisioner role over PB-ADV

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>
This commit is contained in:
Tobias Svehagen 2019-07-12 15:57:58 +02:00 committed by Johan Hedberg
commit 80669decce
20 changed files with 965 additions and 100 deletions

View file

@ -3269,8 +3269,11 @@ static int cfg_srv_init(struct bt_mesh_model *model)
return -EINVAL;
}
/* Configuration Model security is device-key based */
model->keys[0] = BT_MESH_KEY_DEV;
/*
* Configuration Model security is device-key based and only the local
* device-key is allowed to access this model.
*/
model->keys[0] = BT_MESH_KEY_DEV_LOCAL;
if (!IS_ENABLED(CONFIG_BT_MESH_RELAY)) {
cfg->relay = BT_MESH_RELAY_NOT_SUPPORTED;