123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- #ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_CDB_H_
- #define ZEPHYR_INCLUDE_BLUETOOTH_MESH_CDB_H_
- #include <inttypes.h>
- #include <sys/atomic.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #if defined(CONFIG_BT_MESH_CDB)
- #define NODE_COUNT CONFIG_BT_MESH_CDB_NODE_COUNT
- #define SUBNET_COUNT CONFIG_BT_MESH_CDB_SUBNET_COUNT
- #define APP_KEY_COUNT CONFIG_BT_MESH_CDB_APP_KEY_COUNT
- #else
- #define NODE_COUNT 0
- #define SUBNET_COUNT 0
- #define APP_KEY_COUNT 0
- #endif
- enum {
- BT_MESH_CDB_NODE_CONFIGURED,
- BT_MESH_CDB_NODE_FLAG_COUNT
- };
- struct bt_mesh_cdb_node {
- uint8_t uuid[16];
- uint16_t addr;
- uint16_t net_idx;
- uint8_t num_elem;
- uint8_t dev_key[16];
- ATOMIC_DEFINE(flags, BT_MESH_CDB_NODE_FLAG_COUNT);
- };
- struct bt_mesh_cdb_subnet {
- uint16_t net_idx;
- uint8_t kr_phase;
- struct {
- uint8_t net_key[16];
- } keys[2];
- };
- struct bt_mesh_cdb_app_key {
- uint16_t net_idx;
- uint16_t app_idx;
- struct {
- uint8_t app_key[16];
- } keys[2];
- };
- 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,
- };
- struct bt_mesh_cdb {
- uint32_t iv_index;
- ATOMIC_DEFINE(flags, BT_MESH_CDB_FLAG_COUNT);
- struct bt_mesh_cdb_node nodes[NODE_COUNT];
- struct bt_mesh_cdb_subnet subnets[SUBNET_COUNT];
- struct bt_mesh_cdb_app_key app_keys[APP_KEY_COUNT];
- };
- extern struct bt_mesh_cdb bt_mesh_cdb;
- int bt_mesh_cdb_create(const uint8_t key[16]);
- void bt_mesh_cdb_clear(void);
- void bt_mesh_cdb_iv_update(uint32_t iv_index, bool iv_update);
- 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);
- void bt_mesh_cdb_node_del(struct bt_mesh_cdb_node *node, bool store);
- struct bt_mesh_cdb_node *bt_mesh_cdb_node_get(uint16_t addr);
- void bt_mesh_cdb_node_store(const struct bt_mesh_cdb_node *node);
- enum {
- BT_MESH_CDB_ITER_STOP = 0,
- BT_MESH_CDB_ITER_CONTINUE,
- };
- typedef uint8_t (*bt_mesh_cdb_node_func_t)(struct bt_mesh_cdb_node *node,
- void *user_data);
- void bt_mesh_cdb_node_foreach(bt_mesh_cdb_node_func_t func, void *user_data);
- struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_alloc(uint16_t net_idx);
- void bt_mesh_cdb_subnet_del(struct bt_mesh_cdb_subnet *sub, bool store);
- struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_get(uint16_t net_idx);
- void bt_mesh_cdb_subnet_store(const struct bt_mesh_cdb_subnet *sub);
- uint8_t bt_mesh_cdb_subnet_flags(const struct bt_mesh_cdb_subnet *sub);
- struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_alloc(uint16_t net_idx,
- uint16_t app_idx);
- void bt_mesh_cdb_app_key_del(struct bt_mesh_cdb_app_key *key, bool store);
- struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_get(uint16_t app_idx);
- void bt_mesh_cdb_app_key_store(const struct bt_mesh_cdb_app_key *key);
- #ifdef __cplusplus
- }
- #endif
- #endif
|