4 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6 * @author: Anupam Roy <anupam.r@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef BT_SERVICE_MESH_CDB_H_
23 #define BT_SERVICE_MESH_CDB_H_
26 #include <sys/types.h>
27 #include "bluetooth-api.h"
28 #include "bluetooth-mesh-api.h"
29 #include <json-c/json.h>
40 uint8_t uuid[16]; /* Network UUID */
41 struct timeval write_time;
47 uint8_t label_uuid[16];
52 void _bt_mesh_conf_free(_bt_mesh_cdb_t *cfg);
54 bool _bt_mesh_conf_parse_data(void *cfg, int k);
56 _bt_mesh_cdb_t * _bt_mesh_conf_database_create(const char *file_name,
57 const uint8_t uuid[16], const uint8_t token[8],
58 const char *network_name,
59 const char *app_cred);
61 bool _bt_mesh_conf_set_phase_network_key(_bt_mesh_cdb_t *cfg,
62 uint16_t net_idx, uint8_t phase);
64 _bt_mesh_cdb_t* _bt_mesh_conf_load(const char *file_name,
67 bool _bt_mesh_conf_delete_application_key(_bt_mesh_cdb_t *cfg,
70 bool _bt_mesh_conf_load_all_nodes(_bt_mesh_cdb_t *cfg);
72 bool _bt_mesh_conf_insert_network_key(_bt_mesh_cdb_t *cfg,
73 uint16_t idx, uint8_t key_refresh);
75 bool _bt_mesh_conf_delete_network_key(_bt_mesh_cdb_t *cfg,
78 bool _bt_mesh_conf_set_unicast_address_range(_bt_mesh_cdb_t *cfg,
79 uint16_t low, uint16_t high);
81 bool _bt_mesh_conf_insert_node_object(_bt_mesh_cdb_t *cfg,
82 uint8_t uuid[16], uint8_t num_els,
83 uint16_t unicast, uint16_t net_idx);
85 bool _bt_mesh_conf_get_element_count(_bt_mesh_cdb_t *cfg,
88 bool _bt_mesh_conf_load_all_keys(_bt_mesh_cdb_t* cfg);
90 bool _bt_mesh_conf_fetch_vendor_specific_info(
91 _bt_mesh_cdb_t *cfg, uint16_t unicast,
92 uint16_t *cid, uint16_t *vid, uint16_t *version,
93 uint16_t *crpl, int *relay, int *frnd,
94 int *proxy, int *lpn);
96 uint16_t** _bt_mesh_conf_get_all_model_info(_bt_mesh_cdb_t *cfg,
97 int element_index, int *num_models);
99 bool _bt_mesh_conf_get_token_info(uint8_t token[8]);
101 bool _bt_mesh_conf_insert_application_key(_bt_mesh_cdb_t *cfg,
102 uint16_t net_idx, uint16_t app_idx);
104 bool _bt_mesh_conf_get_unicast_address_range(uint16_t *low,
107 bool _bt_mesh_conf_node_set_network_transmission(uint16_t unicast,
108 uint8_t cnt, uint16_t interval);
110 bool _bt_mesh_conf_delete_node(_bt_mesh_cdb_t *cfg,
113 bool _bt_mesh_conf_set_node_comp_data(_bt_mesh_cdb_t *cfg,
114 uint16_t unicast, uint8_t *data, uint16_t len);
116 bool _bt_mesh_conf_node_insert_network_key(_bt_mesh_cdb_t *cfg,
117 uint16_t unicast, uint16_t idx);
119 bool _bt_mesh_conf_node_delete_network_key(_bt_mesh_cdb_t *cfg,
120 uint16_t unicast, uint16_t idx);
122 bool _bt_mesh_conf_node_insert_application_key(_bt_mesh_cdb_t *cfg,
123 uint16_t unicast, uint16_t idx);
125 bool _bt_mesh_conf_node_delete_application_key(_bt_mesh_cdb_t *cfg,
126 uint16_t unicast, uint16_t idx);
128 bool _bt_mesh_conf_node_set_timetolive_value(_bt_mesh_cdb_t *cfg,
129 uint16_t unicast, uint8_t ttl);
131 bool _bt_mesh_conf_node_set_write_op_mode(uint16_t unicast,
132 const char *keyword, int value);
134 bool _bt_mesh_conf_bind_model(uint16_t unicast,
135 uint8_t ele, bool vendor,
136 uint32_t mod_id, uint16_t app_idx);
138 bool _bt_mesh_conf_unbind_model(uint16_t unicast,
139 uint8_t ele, bool vendor,
140 uint32_t mod_id, uint16_t app_idx);
142 GSList *_bt_mesh_conf_load_group_info(_bt_mesh_cdb_t *cfg);
144 bool _bt_mesh_conf_insert_group_info(_bt_mesh_cdb_t *cfg,
145 _bt_mesh_group_t *grp);
147 bool _bt_mesh_conf_delete_group_entry(_bt_mesh_cdb_t *cfg,
150 bool _bt_mesh_conf_set_network_friendly_name(_bt_mesh_cdb_t *cfg,
151 const char *network_name);
153 const char * _bt_mesh_conf_get_network_friendly_name(_bt_mesh_cdb_t *cfg);
157 #endif /* __cplusplus */
158 #endif /* BT_SERVICE_MESH_CDB_H_ */