-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
Introduction
The following is taken from the Bluetooth Mesh Profile specification, 3.10.1 Mesh Network Creation procedure
To create a mesh network, a Provisioner is required. A Provisioner shall generate a network key, provide an IV Index, and allocate a unicast address.
...
The Provisioner can then find unprovisioned devices by scanning for Unprovisioned Device beacons using active or passive scanning. The Provisioner can then provision these devices to become nodes within the mesh network. Once these nodes have been provisioned, the Configuration Client can then configure the nodes by providing them application keys and setting publish and subscribe addresses so that the nodes can communicate with each other.
As I can't find any term in the Mesh specification for the node that uses the Configuration Client, I will refer to it as the Configurator.
Problem description
- There is no good separation of the local node's data and the data that is related to the network as a whole, ie network management.
- There is a public API for the Configuration Client but no API to actually receive the keys etc. that should be used for the Configuration Client API.
- There is no API to get info about the nodes that are part of the network.
Proposed change
Add a network management component that can be used by the Provisioner and Configurator. This component will be responsible for adding and providing access to all information that is needed to manage the network.
This management component should have no need for the local device to be provisioned and it should have no special handling for the local node.
Detailed RFC
The way that network information is stored today is in struct bt_mesh_net and related structures in net.c. The way I see it is that the information stored in there are used for the local node, ie when the local device has been provisioned to a network.
Since we would like to keep the local node data separate from the management data I suggest adding a mgmt.c and mgmt.h. The interface and data structures will probably be quite similar to the ones in net.h.
I also suggest adding a public API that can be used by an application to get all the information needed to manage the network.
Proposed change (Detailed)
So this is just a very rough idea just to get the ball rolling.
struct bt_mesh_mgmt_node {
u16_t addr;
u16_t net_idx;
u8_t dev_key[16];
u8_t num_elem;
};
struct bt_mesh_mgmt_subnet {
u16_t net_idx;
bool kr_flag;
u8_t kr_phase;
struct {
u8_t net_key[16];
} keys[2];
};
struct bt_mesh_mgmt_app_key {
u16_t net_idx;
u16_t app_idx;
struct {
u8_t id;
u8_t key[16];
} keys[2];
};
struct bt_mesh_mgmt_net {
u32_t iv_index;
struct bt_mesh_mgmt_node nodes[CONFIG_BT_MESH_MGMT_NODES_COUNT];
struct bt_mesh_mgmt_subnet subnets[CONFIG_BT_MESH_MGMT_SUBNET_COUNT];
struct bt_mesh_mgmt_app_key app_keys[CONFIG_BT_MESH_MGMT_APP_KEY_COUNT];
};
extern struct bt_mesh_mgmt_net bt_mesh_mgmt[CONFIG_BT_MESH_MGMT_NET_COUNT];
-
The management API would need to include functions like add/remove/find/list for nodes, subnets and app keys.
-
The
struct bt_mesh_nodearray instruct bt_mesh_netshould be removed and this interface should be used instead. -
The
struct bt_mesh_mgmt_nodecould be extended to actually contain "all" the information about the node composition, e.g. all its models, subscriptions etc.
Dependencies
-
Being a Provisioner or a Configurator would depend on having the network management code.
-
The provisioning code (
prov.c) and some access code (access.c) would probably need to be changed to use this new management API to store/ get nodes and keys.
Concerns and Unresolved Questions
- Is it okay to implement this as a shared resource between the Provisioner and the Configurator?
- What are the needs that a public API would have to provide?
Alternatives
One alternative would be to have on module that the Provisioner uses and one that the Configurator uses. The reason why I think that it might be a good idea to share is that it seems that the Configurator actually needs almost everything that the Provisioner needs.
- The Provisioner will need to know the address and number of elements of each node to be able allocate an address for new nodes. It also needs to know the network index, network key and IV index to use.
- The Configurator will need to know at least the Primary Element of each node but it also needs to have access to the device keys and all other keys that are in use in the network.