1 /*
2  * SPDX-FileCopyrightText: 2018 Intel Corporation
3  * SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO LTD
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #ifndef _SETTINGS_H_
9 #define _SETTINGS_H_
10 
11 #include "net.h"
12 #include "provisioner_main.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #define BLE_MESH_SETTINGS_ROLE_NONE     0
19 #define BLE_MESH_SETTINGS_ROLE_NODE     (BIT(BLE_MESH_NODE))
20 #define BLE_MESH_SETTINGS_ROLE_PROV     (BIT(BLE_MESH_PROVISIONER))
21 #define BLE_MESH_SETTINGS_ROLE_BIT_MASK (BIT(BLE_MESH_NODE) | BIT(BLE_MESH_PROVISIONER))
22 
23 void bt_mesh_store_role(void);
24 void bt_mesh_store_net(void);
25 void bt_mesh_store_iv(bool only_duration);
26 void bt_mesh_store_seq(void);
27 void bt_mesh_clear_seq(void);
28 void bt_mesh_store_rpl(struct bt_mesh_rpl *rpl);
29 void bt_mesh_store_subnet(struct bt_mesh_subnet *sub);
30 void bt_mesh_store_app_key(struct bt_mesh_app_key *key);
31 void bt_mesh_store_hb_pub(void);
32 void bt_mesh_store_cfg(void);
33 void bt_mesh_store_mod_bind(struct bt_mesh_model *mod);
34 void bt_mesh_store_mod_sub(struct bt_mesh_model *mod);
35 void bt_mesh_store_mod_pub(struct bt_mesh_model *mod);
36 void bt_mesh_store_label(void);
37 
38 void bt_mesh_clear_role(void);
39 void bt_mesh_clear_net(void);
40 void bt_mesh_clear_subnet(struct bt_mesh_subnet *sub);
41 void bt_mesh_clear_app_key(struct bt_mesh_app_key *key);
42 void bt_mesh_clear_rpl(void);
43 
44 #if CONFIG_BLE_MESH_PROVISIONER
45 void bt_mesh_store_prov_info(uint16_t primary_addr, uint16_t alloc_addr);
46 void bt_mesh_clear_prov_info(void);
47 void bt_mesh_store_p_net_idx(void);
48 void bt_mesh_clear_p_net_idx(void);
49 void bt_mesh_store_p_app_idx(void);
50 void bt_mesh_clear_p_app_idx(void);
51 void bt_mesh_store_p_subnet(struct bt_mesh_subnet *sub);
52 void bt_mesh_store_p_app_key(struct bt_mesh_app_key *key);
53 void bt_mesh_clear_p_subnet(uint16_t net_idx);
54 void bt_mesh_clear_p_app_key(uint16_t app_idx);
55 void bt_mesh_clear_rpl_single(uint16_t src);
56 void bt_mesh_store_node_info(struct bt_mesh_node *node);
57 void bt_mesh_clear_node_info(uint16_t unicast_addr);
58 void bt_mesh_store_node_name(struct bt_mesh_node *node);
59 void bt_mesh_store_node_comp_data(struct bt_mesh_node *node);
60 #endif
61 
62 void bt_mesh_settings_lock(void);
63 void bt_mesh_settings_unlock(void);
64 
65 int settings_core_init(void);
66 int settings_core_load(void);
67 int settings_core_commit(void);
68 int settings_core_deinit(void);
69 int settings_core_erase(void);
70 
71 int bt_mesh_settings_init(void);
72 int bt_mesh_settings_deinit(bool erase);
73 void bt_mesh_settings_reset(bool erase);
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif /* _SETTINGS_H_ */
80