Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
cdb.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Tobias Svehagen
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_CDB_H_
7#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_CDB_H_
8
9#include <stdbool.h>
10#include <stdint.h>
11
12#include <zephyr/sys/atomic.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#if defined(CONFIG_BT_MESH_CDB)
20#define NODE_COUNT CONFIG_BT_MESH_CDB_NODE_COUNT
21#define SUBNET_COUNT CONFIG_BT_MESH_CDB_SUBNET_COUNT
22#define APP_KEY_COUNT CONFIG_BT_MESH_CDB_APP_KEY_COUNT
23#else
24#define NODE_COUNT 0
25#define SUBNET_COUNT 0
26#define APP_KEY_COUNT 0
27#endif
28
29enum {
31
33};
34
44
47
49
50 struct {
51 struct bt_mesh_key net_key;
52 } keys[2];
53};
54
58
59 struct {
60 struct bt_mesh_key app_key;
61 } keys[2];
62};
63
64enum {
70
72};
73
84
85extern struct bt_mesh_cdb bt_mesh_cdb;
86
98
106
119
140
149
161void bt_mesh_cdb_node_del(struct bt_mesh_cdb_node *node, bool store);
162
174
186
192
205
217int bt_mesh_cdb_node_key_export(const struct bt_mesh_cdb_node *node, uint8_t out[16]);
218
219enum {
222};
223
234 void *user_data);
235
245
256
264void bt_mesh_cdb_subnet_del(struct bt_mesh_cdb_subnet *sub, bool store);
265
276
282
290
306 const uint8_t in[16]);
307
322int bt_mesh_cdb_subnet_key_export(const struct bt_mesh_cdb_subnet *sub, int key_idx,
323 uint8_t out[16]);
324
337
346
357
363
378int bt_mesh_cdb_app_key_import(struct bt_mesh_cdb_app_key *key, int key_idx, const uint8_t in[16]);
379
394int bt_mesh_cdb_app_key_export(const struct bt_mesh_cdb_app_key *key, int key_idx, uint8_t out[16]);
395
396#ifdef __cplusplus
397}
398#endif
399
400#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_CDB_H_ */
int bt_mesh_cdb_create(const uint8_t key[16])
Create the Mesh Configuration Database.
uint8_t bt_mesh_cdb_subnet_flags(const struct bt_mesh_cdb_subnet *sub)
Get the flags for a subnet.
int bt_mesh_cdb_node_key_import(struct bt_mesh_cdb_node *node, const uint8_t in[16])
Import device key for selected node.
@ BT_MESH_CDB_ITER_CONTINUE
Definition cdb.h:221
@ BT_MESH_CDB_ITER_STOP
Definition cdb.h:220
struct bt_mesh_cdb_subnet * bt_mesh_cdb_subnet_get(uint16_t net_idx)
Get a subnet by NetIdx.
struct bt_mesh_cdb_node * bt_mesh_cdb_node_get(uint16_t addr)
Get a node by address.
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_clear(void)
Clear the Mesh Configuration Database.
void bt_mesh_cdb_app_key_store(const struct bt_mesh_cdb_app_key *key)
Store application key to persistent storage.
void bt_mesh_cdb_subnet_store(const struct bt_mesh_cdb_subnet *sub)
Store subnet to persistent storage.
#define SUBNET_COUNT
Definition cdb.h:25
void bt_mesh_cdb_subnet_del(struct bt_mesh_cdb_subnet *sub, bool store)
Delete a subnet.
void bt_mesh_cdb_app_key_del(struct bt_mesh_cdb_app_key *key, bool store)
Delete an application key.
void bt_mesh_cdb_node_del(struct bt_mesh_cdb_node *node, bool store)
Delete a node.
@ BT_MESH_CDB_IVU_IN_PROGRESS
Definition cdb.h:69
@ BT_MESH_CDB_NODES_PENDING
Definition cdb.h:68
@ BT_MESH_CDB_SUBNET_PENDING
Definition cdb.h:66
@ BT_MESH_CDB_KEYS_PENDING
Definition cdb.h:67
@ BT_MESH_CDB_FLAG_COUNT
Definition cdb.h:71
@ BT_MESH_CDB_VALID
Definition cdb.h:65
@ BT_MESH_CDB_NODE_FLAG_COUNT
Definition cdb.h:32
@ BT_MESH_CDB_NODE_CONFIGURED
Definition cdb.h:30
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.
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.
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_iv_update(uint32_t iv_index, bool iv_update)
Set and store the IV Index and IV Update flag.
#define APP_KEY_COUNT
Definition cdb.h:26
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.
struct bt_mesh_cdb_app_key * bt_mesh_cdb_app_key_get(uint16_t app_idx)
Get an application key by AppIdx.
struct bt_mesh_cdb_app_key * bt_mesh_cdb_app_key_alloc(uint16_t net_idx, uint16_t app_idx)
Allocate an application key.
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.
void bt_mesh_cdb_node_store(const struct bt_mesh_cdb_node *node)
Store node to persistent storage.
void bt_mesh_cdb_node_update(struct bt_mesh_cdb_node *node, uint16_t addr, uint8_t num_elem)
Update a node.
uint8_t(* bt_mesh_cdb_node_func_t)(struct bt_mesh_cdb_node *node, void *user_data)
Node iterator callback.
Definition cdb.h:233
#define NODE_COUNT
Definition cdb.h:24
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.
#define ATOMIC_DEFINE(name, num_bits)
Define an array of atomic variables.
Definition atomic.h:111
Bluetooth Mesh Profile APIs.
flags
Definition parser.h:96
static k_spinlock_key_t key
Definition spinlock_error_case.c:15
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Definition cdb.h:55
struct bt_mesh_key app_key
Definition cdb.h:60
uint16_t app_idx
Definition cdb.h:57
struct bt_mesh_cdb_app_key::@101 keys[2]
uint16_t net_idx
Definition cdb.h:56
Definition cdb.h:35
uint8_t num_elem
Definition cdb.h:39
struct bt_mesh_key dev_key
Definition cdb.h:40
uint8_t uuid[16]
Definition cdb.h:36
uint16_t addr
Definition cdb.h:37
uint16_t net_idx
Definition cdb.h:38
Definition cdb.h:45
uint8_t kr_phase
Definition cdb.h:48
uint16_t net_idx
Definition cdb.h:46
struct bt_mesh_key net_key
Definition cdb.h:51
struct bt_mesh_cdb_subnet::@100 keys[2]
Definition cdb.h:74
uint32_t iv_index
Definition cdb.h:75
struct bt_mesh_cdb_app_key app_keys[0]
Definition cdb.h:82
struct bt_mesh_cdb_node nodes[0]
Definition cdb.h:80
uint16_t lowest_avail_addr
Definition cdb.h:76
struct bt_mesh_cdb_subnet subnets[0]
Definition cdb.h:81
static void func(void *arg1, void *arg2, void *arg3)
Definition main.c:26
static const intptr_t user_data[5]
Definition main.c:588