Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
|
#include <stdbool.h>
#include <stdint.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/bluetooth/mesh.h>
Go to the source code of this file.
Data Structures | |
struct | bt_mesh_cdb_node |
struct | bt_mesh_cdb_subnet |
struct | bt_mesh_cdb_app_key |
struct | bt_mesh_cdb |
Macros | |
#define | NODE_COUNT 0 |
#define | SUBNET_COUNT 0 |
#define | APP_KEY_COUNT 0 |
Typedefs | |
typedef uint8_t(* | bt_mesh_cdb_node_func_t) (struct bt_mesh_cdb_node *node, void *user_data) |
Node iterator callback. | |
Enumerations | |
enum | { BT_MESH_CDB_NODE_CONFIGURED , BT_MESH_CDB_NODE_FLAG_COUNT } |
enum | { BT_MESH_CDB_VALID , BT_MESH_CDB_SUBNET_PENDING , BT_MESH_CDB_KEYS_PENDING , BT_MESH_CDB_NODES_PENDING , BT_MESH_CDB_IVU_IN_PROGRESS , BT_MESH_CDB_FLAG_COUNT } |
enum | { BT_MESH_CDB_ITER_STOP = 0 , BT_MESH_CDB_ITER_CONTINUE } |
Functions | |
int | bt_mesh_cdb_create (const uint8_t key[16]) |
Create the Mesh Configuration Database. | |
void | bt_mesh_cdb_clear (void) |
Clear the Mesh Configuration Database. | |
void | bt_mesh_cdb_iv_update (uint32_t iv_index, bool iv_update) |
Set and store the IV Index and IV Update flag. | |
struct bt_mesh_cdb_node * | bt_mesh_cdb_node_alloc (const uint8_t uuid[16], uint16_t addr, uint8_t num_elem, uint16_t net_idx) |
Allocate a node. | |
uint16_t | bt_mesh_cdb_free_addr_get (uint8_t num_elem) |
Get the first available address for the given element count. | |
void | bt_mesh_cdb_node_del (struct bt_mesh_cdb_node *node, bool store) |
Delete a node. | |
void | bt_mesh_cdb_node_update (struct bt_mesh_cdb_node *node, uint16_t addr, uint8_t num_elem) |
Update a node. | |
struct bt_mesh_cdb_node * | bt_mesh_cdb_node_get (uint16_t addr) |
Get a node by address. | |
void | bt_mesh_cdb_node_store (const struct bt_mesh_cdb_node *node) |
Store node to persistent storage. | |
int | bt_mesh_cdb_node_key_import (struct bt_mesh_cdb_node *node, const uint8_t in[16]) |
Import device key for selected node. | |
int | bt_mesh_cdb_node_key_export (const struct bt_mesh_cdb_node *node, uint8_t out[16]) |
Export device key from selected node. | |
void | bt_mesh_cdb_node_foreach (bt_mesh_cdb_node_func_t func, void *user_data) |
Node iterator. | |
struct bt_mesh_cdb_subnet * | bt_mesh_cdb_subnet_alloc (uint16_t net_idx) |
Allocate a subnet. | |
void | bt_mesh_cdb_subnet_del (struct bt_mesh_cdb_subnet *sub, bool store) |
Delete a subnet. | |
struct bt_mesh_cdb_subnet * | bt_mesh_cdb_subnet_get (uint16_t net_idx) |
Get a subnet by NetIdx. | |
void | bt_mesh_cdb_subnet_store (const struct bt_mesh_cdb_subnet *sub) |
Store subnet to persistent storage. | |
uint8_t | bt_mesh_cdb_subnet_flags (const struct bt_mesh_cdb_subnet *sub) |
Get the flags for a subnet. | |
int | bt_mesh_cdb_subnet_key_import (struct bt_mesh_cdb_subnet *sub, int key_idx, const uint8_t in[16]) |
Import network key for selected subnetwork. | |
int | bt_mesh_cdb_subnet_key_export (const struct bt_mesh_cdb_subnet *sub, int key_idx, uint8_t out[16]) |
Export network key from selected subnetwork. | |
struct bt_mesh_cdb_app_key * | bt_mesh_cdb_app_key_alloc (uint16_t net_idx, uint16_t app_idx) |
Allocate an application key. | |
void | bt_mesh_cdb_app_key_del (struct bt_mesh_cdb_app_key *key, bool store) |
Delete an application key. | |
struct bt_mesh_cdb_app_key * | bt_mesh_cdb_app_key_get (uint16_t app_idx) |
Get an application key by AppIdx. | |
void | bt_mesh_cdb_app_key_store (const struct bt_mesh_cdb_app_key *key) |
Store application key to persistent storage. | |
int | bt_mesh_cdb_app_key_import (struct bt_mesh_cdb_app_key *key, int key_idx, const uint8_t in[16]) |
Import application key. | |
int | bt_mesh_cdb_app_key_export (const struct bt_mesh_cdb_app_key *key, int key_idx, uint8_t out[16]) |
Export application key. | |
Variables | |
struct bt_mesh_cdb | bt_mesh_cdb |
#define APP_KEY_COUNT 0 |
#define NODE_COUNT 0 |
#define SUBNET_COUNT 0 |
typedef uint8_t(* bt_mesh_cdb_node_func_t) (struct bt_mesh_cdb_node *node, void *user_data) |
Node iterator callback.
node | Node found. |
user_data | Data given. |
anonymous enum |
struct bt_mesh_cdb_app_key * bt_mesh_cdb_app_key_alloc | ( | uint16_t | net_idx, |
uint16_t | app_idx ) |
Allocate an application key.
Allocate a new application key in the CDB.
net_idx | NetIdx of NetKey that the application key is bound to. |
app_idx | AppIdx of the application key. |
void bt_mesh_cdb_app_key_del | ( | struct bt_mesh_cdb_app_key * | key, |
bool | store ) |
Delete an application key.
Delete an application key from the CDB.
key | The application key to be deleted. |
store | If true, the key will be cleared from persistent storage. |
int bt_mesh_cdb_app_key_export | ( | const struct bt_mesh_cdb_app_key * | key, |
int | key_idx, | ||
uint8_t | out[16] ) |
Export application key.
Using security library with PSA implementation access to the key by pointer will not give a valid value since the key is hidden in the library. The application has to export the key.
key | cdb application key structure. |
key_idx | 0 or 1. If Key Refresh procedure is in progress then two keys are available. The old key has an index 0 and the new one has an index 1. Otherwise, the only key with index 0 exists. |
out | key value. |
struct bt_mesh_cdb_app_key * bt_mesh_cdb_app_key_get | ( | uint16_t | app_idx | ) |
Get an application key by AppIdx.
Try to find the application key with the specified AppIdx.
app_idx | AppIdx of the application key to look for. |
int bt_mesh_cdb_app_key_import | ( | struct bt_mesh_cdb_app_key * | key, |
int | key_idx, | ||
const uint8_t | in[16] ) |
Import application key.
Using security library with PSA implementation access to the key by pointer will not give a valid value since the key is hidden in the library. The application has to import the key.
key | cdb application key structure. |
key_idx | 0 or 1. If Key Refresh procedure is in progress then two keys are available. The old key has an index 0 and the new one has an index 1. Otherwise, the only key with index 0 exists. |
in | key value. |
void bt_mesh_cdb_app_key_store | ( | const struct bt_mesh_cdb_app_key * | key | ) |
Store application key to persistent storage.
key | Application key to be stored. |
void bt_mesh_cdb_clear | ( | void | ) |
Clear the Mesh Configuration Database.
Remove all nodes, subnets and app-keys stored in the database and mark the database as invalid. The data will be cleared from persistent storage if CONFIG_BT_SETTINGS is enabled.
int bt_mesh_cdb_create | ( | const uint8_t | key[16] | ) |
Create the Mesh Configuration Database.
Create and initialize the Mesh Configuration Database. A primary subnet, ie one with NetIdx 0, will be added and the provided key will be used as NetKey for that subnet.
key | The NetKey to be used for the primary subnet. |
Get the first available address for the given element count.
num_elem | Number of elements to accommodate. |
Set and store the IV Index and IV Update flag.
The IV Index stored in the CDB will be the one used during provisioning of new nodes. This function is generally only used from inside the stack.
This function will store the data to persistent storage if CONFIG_BT_SETTINGS is enabled.
iv_index | The new IV Index to use. |
iv_update | True if there is an ongoing IV Update procedure. |
struct bt_mesh_cdb_node * bt_mesh_cdb_node_alloc | ( | const uint8_t | uuid[16], |
uint16_t | addr, | ||
uint8_t | num_elem, | ||
uint16_t | net_idx ) |
Allocate a node.
Allocate a new node in the CDB.
If addr
is 0, bt_mesh_cdb_free_addr_get will be used to allocate a free address.
uuid | UUID of the node. |
addr | Address of the node's primary element. If 0, the lowest possible address available will be assigned to the node. |
num_elem | Number of elements that the node has. |
net_idx | NetIdx that the node was provisioned to. |
CONFIG_BT_MESH_CDB_NODE_COUNT
nodes, or reached the end of the unicast address range, or if addr
is non-zero and less than the lowest available address or collide with the allocated addresses. void bt_mesh_cdb_node_del | ( | struct bt_mesh_cdb_node * | node, |
bool | store ) |
Delete a node.
Delete a node from the CDB. When deleting the node and the address of the last element of the deleted node is greater than the lowest available address, CDB will update the lowest available address. The lowest available address is reset and the deleted addresses can be reused only after IV Index update.
node | The node to be deleted. |
store | If true, the node will be cleared from persistent storage. |
void bt_mesh_cdb_node_foreach | ( | bt_mesh_cdb_node_func_t | func, |
void * | user_data ) |
Node iterator.
Iterate nodes in the Mesh Configuration Database. The callback function will only be called for valid, ie allocated, nodes.
func | Callback function. |
user_data | Data to pass to the callback. |
struct bt_mesh_cdb_node * bt_mesh_cdb_node_get | ( | uint16_t | addr | ) |
Get a node by address.
Try to find the node that has the provided address assigned to one of its elements.
addr | Address of the element to look for. |
int bt_mesh_cdb_node_key_export | ( | const struct bt_mesh_cdb_node * | node, |
uint8_t | out[16] ) |
Export device key from selected node.
Using security library with PSA implementation access to the key by pointer will not give a valid value since the key is hidden in the library. The application has to export the key.
node | Selected node. |
out | key value. |
int bt_mesh_cdb_node_key_import | ( | struct bt_mesh_cdb_node * | node, |
const uint8_t | in[16] ) |
Import device key for selected node.
Using security library with PSA implementation access to the key by pointer will not give a valid value since the key is hidden in the library. The application has to import the key.
node | Selected node. |
in | key value. |
void bt_mesh_cdb_node_store | ( | const struct bt_mesh_cdb_node * | node | ) |
Store node to persistent storage.
node | Node to be stored. |
void bt_mesh_cdb_node_update | ( | struct bt_mesh_cdb_node * | node, |
uint16_t | addr, | ||
uint8_t | num_elem ) |
Update a node.
Assigns the node a new address and clears the previous persistent storage entry.
node | The node to be deleted. |
addr | New unicast address for the node. |
num_elem | Updated number of elements in the node. |
struct bt_mesh_cdb_subnet * bt_mesh_cdb_subnet_alloc | ( | uint16_t | net_idx | ) |
Allocate a subnet.
Allocate a new subnet in the CDB.
net_idx | NetIdx of the subnet. |
void bt_mesh_cdb_subnet_del | ( | struct bt_mesh_cdb_subnet * | sub, |
bool | store ) |
Delete a subnet.
Delete a subnet from the CDB.
sub | The subnet to be deleted. |
store | If true, the subnet will be cleared from persistent storage. |
uint8_t bt_mesh_cdb_subnet_flags | ( | const struct bt_mesh_cdb_subnet * | sub | ) |
Get the flags for a subnet.
sub | The subnet to get flags for. |
struct bt_mesh_cdb_subnet * bt_mesh_cdb_subnet_get | ( | uint16_t | net_idx | ) |
Get a subnet by NetIdx.
Try to find the subnet with the specified NetIdx.
net_idx | NetIdx of the subnet to look for. |
int bt_mesh_cdb_subnet_key_export | ( | const struct bt_mesh_cdb_subnet * | sub, |
int | key_idx, | ||
uint8_t | out[16] ) |
Export network key from selected subnetwork.
Using security library with PSA implementation access to the key by pointer will not give a valid value since the key is hidden in the library. The application has to export the key.
sub | Selected subnetwork. |
key_idx | 0 or 1. If Key Refresh procedure is in progress then two keys are available. The old key has an index 0 and the new one has an index 1. Otherwise, the only key with index 0 exists. |
out | key value. |
int bt_mesh_cdb_subnet_key_import | ( | struct bt_mesh_cdb_subnet * | sub, |
int | key_idx, | ||
const uint8_t | in[16] ) |
Import network key for selected subnetwork.
Using security library with PSA implementation access to the key by pointer will not give a valid value since the key is hidden in the library. The application has to import the key.
sub | Selected subnetwork. |
key_idx | 0 or 1. If Key Refresh procedure is in progress then two keys are available. The old key has an index 0 and the new one has an index 1. Otherwise, the only key with index 0 exists. |
in | key value. |
void bt_mesh_cdb_subnet_store | ( | const struct bt_mesh_cdb_subnet * | sub | ) |
Store subnet to persistent storage.
sub | Subnet to be stored. |
|
extern |