Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
cdb.h File Reference
#include <inttypes.h>
#include <sys/atomic.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. More...
 

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. More...
 
void bt_mesh_cdb_clear (void)
 Clear the Mesh Configuration Database. More...
 
void bt_mesh_cdb_iv_update (uint32_t iv_index, bool iv_update)
 Set and store the IV Index and IV Update flag. More...
 
struct bt_mesh_cdb_nodebt_mesh_cdb_node_alloc (const uint8_t uuid[16], uint16_t addr, uint8_t num_elem, uint16_t net_idx)
 Allocate a node. More...
 
void bt_mesh_cdb_node_del (struct bt_mesh_cdb_node *node, bool store)
 Delete a node. More...
 
struct bt_mesh_cdb_nodebt_mesh_cdb_node_get (uint16_t addr)
 Get a node by address. More...
 
void bt_mesh_cdb_node_store (const struct bt_mesh_cdb_node *node)
 Store node to persistent storage. More...
 
void bt_mesh_cdb_node_foreach (bt_mesh_cdb_node_func_t func, void *user_data)
 Node iterator. More...
 
struct bt_mesh_cdb_subnetbt_mesh_cdb_subnet_alloc (uint16_t net_idx)
 Allocate a subnet. More...
 
void bt_mesh_cdb_subnet_del (struct bt_mesh_cdb_subnet *sub, bool store)
 Delete a subnet. More...
 
struct bt_mesh_cdb_subnetbt_mesh_cdb_subnet_get (uint16_t net_idx)
 Get a subnet by NetIdx. More...
 
void bt_mesh_cdb_subnet_store (const struct bt_mesh_cdb_subnet *sub)
 Store subnet to persistent storage. More...
 
uint8_t bt_mesh_cdb_subnet_flags (const struct bt_mesh_cdb_subnet *sub)
 Get the flags for a subnet. More...
 
struct bt_mesh_cdb_app_keybt_mesh_cdb_app_key_alloc (uint16_t net_idx, uint16_t app_idx)
 Allocate an application key. More...
 
void bt_mesh_cdb_app_key_del (struct bt_mesh_cdb_app_key *key, bool store)
 Delete an application key. More...
 
struct bt_mesh_cdb_app_keybt_mesh_cdb_app_key_get (uint16_t app_idx)
 Get an application key by AppIdx. More...
 
void bt_mesh_cdb_app_key_store (const struct bt_mesh_cdb_app_key *key)
 Store application key to persistent storage. More...
 

Variables

struct bt_mesh_cdb bt_mesh_cdb
 

Macro Definition Documentation

◆ APP_KEY_COUNT

#define APP_KEY_COUNT   0

◆ NODE_COUNT

#define NODE_COUNT   0

◆ SUBNET_COUNT

#define SUBNET_COUNT   0

Typedef Documentation

◆ bt_mesh_cdb_node_func_t

bt_mesh_cdb_node_func_t

Node iterator callback.

Parameters
nodeNode found.
user_dataData given.
Returns
BT_MESH_CDB_ITER_CONTINUE to continue to iterate through the nodes or BT_MESH_CDB_ITER_STOP to stop.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
BT_MESH_CDB_NODE_CONFIGURED 
BT_MESH_CDB_NODE_FLAG_COUNT 

◆ anonymous enum

anonymous enum
Enumerator
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 

◆ anonymous enum

anonymous enum
Enumerator
BT_MESH_CDB_ITER_STOP 
BT_MESH_CDB_ITER_CONTINUE 

Function Documentation

◆ bt_mesh_cdb_app_key_alloc()

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.

Parameters
net_idxNetIdx of NetKey that the application key is bound to.
app_idxAppIdx of the application key.
Returns
The new application key or NULL if it cannot be allocated.

◆ bt_mesh_cdb_app_key_del()

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.

Parameters
keyThe application key to be deleted.
storeIf true, the key will be cleared from persistent storage.

◆ bt_mesh_cdb_app_key_get()

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.

Parameters
app_idxAppIdx of the application key to look for.
Returns
The application key with the specified AppIdx or NULL if no such key exists.

◆ bt_mesh_cdb_app_key_store()

void bt_mesh_cdb_app_key_store ( const struct bt_mesh_cdb_app_key key)

Store application key to persistent storage.

Parameters
keyApplication key to be stored.

◆ bt_mesh_cdb_clear()

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.

◆ bt_mesh_cdb_create()

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.

Parameters
keyThe NetKey to be used for the primary subnet.
Returns
0 on success or negative error code on failure.

◆ bt_mesh_cdb_iv_update()

void bt_mesh_cdb_iv_update ( uint32_t  iv_index,
bool  iv_update 
)

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.

Parameters
iv_indexThe new IV Index to use.
iv_updateTrue if there is an ongoing IV Update procedure.

◆ bt_mesh_cdb_node_alloc()

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.

Parameters
uuidUUID of the node.
addrAddress of the node's primary element. If 0, the lowest possible address available will be assigned to the node.
num_elemNumber of elements that the node has.
net_idxNetIdx that the node was provisioned to.
Returns
The new node or NULL if it cannot be allocated.

◆ bt_mesh_cdb_node_del()

void bt_mesh_cdb_node_del ( struct bt_mesh_cdb_node node,
bool  store 
)

Delete a node.

Delete a node from the CDB.

Parameters
nodeThe node to be deleted.
storeIf true, the node will be cleared from persistent storage.

◆ bt_mesh_cdb_node_foreach()

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.

Parameters
funcCallback function.
user_dataData to pass to the callback.

◆ bt_mesh_cdb_node_get()

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.

Parameters
addrAddress of the element to look for.
Returns
The node that has an element with address addr or NULL if no such node exists.

◆ bt_mesh_cdb_node_store()

void bt_mesh_cdb_node_store ( const struct bt_mesh_cdb_node node)

Store node to persistent storage.

Parameters
nodeNode to be stored.

◆ bt_mesh_cdb_subnet_alloc()

struct bt_mesh_cdb_subnet * bt_mesh_cdb_subnet_alloc ( uint16_t  net_idx)

Allocate a subnet.

Allocate a new subnet in the CDB.

Parameters
net_idxNetIdx of the subnet.
Returns
The new subnet or NULL if it cannot be allocated.

◆ bt_mesh_cdb_subnet_del()

void bt_mesh_cdb_subnet_del ( struct bt_mesh_cdb_subnet sub,
bool  store 
)

Delete a subnet.

Delete a subnet from the CDB.

Parameters
subThe subnet to be deleted.
storeIf true, the subnet will be cleared from persistent storage.

◆ bt_mesh_cdb_subnet_flags()

uint8_t bt_mesh_cdb_subnet_flags ( const struct bt_mesh_cdb_subnet sub)

Get the flags for a subnet.

Parameters
subThe subnet to get flags for.
Returns
The flags for the subnet.

◆ bt_mesh_cdb_subnet_get()

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.

Parameters
net_idxNetIdx of the subnet to look for.
Returns
The subnet with the specified NetIdx or NULL if no such subnet exists.

◆ bt_mesh_cdb_subnet_store()

void bt_mesh_cdb_subnet_store ( const struct bt_mesh_cdb_subnet sub)

Store subnet to persistent storage.

Parameters
subSubnet to be stored.

Variable Documentation

◆ bt_mesh_cdb

struct bt_mesh_cdb bt_mesh_cdb
extern