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>
41 uint8_t uuid[16]; /* Network UUID */
42 struct timeval write_time;
48 uint8_t label_uuid[16];
53 void _bt_mesh_conf_free(_bt_mesh_cdb_t *cfg);
55 bool _bt_mesh_conf_parse_data(void *cfg, int k);
57 bool _bt_mesh_conf_set_vendor_info(_bt_mesh_cdb_t *cfg, uint16_t unicast,
58 uint16_t crpl, uint16_t cid, uint16_t vid, uint16_t pid,
59 int proxy, int relay, int lpn, int frnd);
61 bool _bt_mesh_conf_set_model_info(_bt_mesh_cdb_t *cfg,
62 uint16_t unicast, GSList *models);
64 _bt_mesh_cdb_t * _bt_mesh_conf_database_create(const char *file_name,
65 const uint8_t uuid[16], const uint8_t token[8],
66 const char *network_name,
67 const char *sender, const char *app_cred);
69 bool _bt_mesh_conf_set_phase_network_key(_bt_mesh_cdb_t *cfg,
70 uint16_t net_idx, uint8_t phase);
72 _bt_mesh_cdb_t* _bt_mesh_conf_load(const char *file_name,
75 bool _bt_mesh_conf_delete_application_key(_bt_mesh_cdb_t *cfg,
78 bool _bt_mesh_conf_load_all_nodes(_bt_mesh_cdb_t *cfg);
80 bool _bt_mesh_conf_insert_network_key(_bt_mesh_cdb_t *cfg,
81 uint16_t idx, uint8_t key_refresh);
83 bool _bt_mesh_conf_delete_network_key(_bt_mesh_cdb_t *cfg,
86 bool _bt_mesh_conf_set_unicast_address_range(_bt_mesh_cdb_t *cfg,
87 uint16_t low, uint16_t high);
89 bool _bt_mesh_conf_insert_node_object(_bt_mesh_cdb_t *cfg,
90 uint8_t uuid[16], uint8_t num_els,
91 uint16_t unicast, uint16_t net_idx);
93 bool _bt_mesh_conf_get_element_count(_bt_mesh_cdb_t *cfg,
96 bool _bt_mesh_conf_load_all_keys(_bt_mesh_cdb_t* cfg);
98 bool _bt_mesh_conf_fetch_vendor_specific_info(
99 _bt_mesh_cdb_t *cfg, uint16_t unicast,
100 uint16_t *cid, uint16_t *vid, uint16_t *version,
101 uint16_t *crpl, int *relay, int *frnd,
102 int *proxy, int *lpn);
104 uint16_t** _bt_mesh_conf_get_all_model_info(_bt_mesh_cdb_t *cfg,
105 int element_index, int *num_models);
107 bool _bt_mesh_conf_get_token_info(uint8_t token[8]);
109 bool _bt_mesh_conf_insert_application_key(_bt_mesh_cdb_t *cfg,
110 uint16_t net_idx, uint16_t app_idx);
112 bool _bt_mesh_conf_get_unicast_address_range(uint16_t *low,
115 bool _bt_mesh_conf_node_set_network_transmission(uint16_t unicast,
116 uint8_t cnt, uint16_t interval);
118 bool _bt_mesh_conf_delete_node(_bt_mesh_cdb_t *cfg,
121 bool _bt_mesh_conf_set_node_comp_data(_bt_mesh_cdb_t *cfg,
122 uint16_t unicast, uint8_t *data, uint16_t len);
124 bool _bt_mesh_conf_node_insert_network_key(_bt_mesh_cdb_t *cfg,
125 uint16_t unicast, uint16_t idx);
127 bool _bt_mesh_conf_node_delete_network_key(_bt_mesh_cdb_t *cfg,
128 uint16_t unicast, uint16_t idx);
130 bool _bt_mesh_conf_node_insert_application_key(_bt_mesh_cdb_t *cfg,
131 uint16_t unicast, uint16_t idx);
133 bool _bt_mesh_conf_node_delete_application_key(_bt_mesh_cdb_t *cfg,
134 uint16_t unicast, uint16_t idx);
136 bool _bt_mesh_conf_node_set_timetolive_value(_bt_mesh_cdb_t *cfg,
137 uint16_t unicast, uint8_t ttl);
139 bool _bt_mesh_conf_node_set_write_op_mode(uint16_t unicast,
140 const char *keyword, int value);
142 bool _bt_mesh_conf_bind_model(uint16_t unicast,
143 uint8_t ele, bool vendor,
144 uint32_t mod_id, uint16_t app_idx);
146 bool _bt_mesh_conf_unbind_model(uint16_t unicast,
147 uint8_t ele, bool vendor,
148 uint32_t mod_id, uint16_t app_idx);
150 GSList *_bt_mesh_conf_load_group_info(_bt_mesh_cdb_t *cfg);
152 bool _bt_mesh_conf_insert_group_info(_bt_mesh_cdb_t *cfg,
153 _bt_mesh_group_t *grp);
155 bool _bt_mesh_conf_delete_group_entry(_bt_mesh_cdb_t *cfg,
158 bool _bt_mesh_is_group_subscribed(_bt_mesh_cdb_t *cfg,
161 bool _bt_mesh_conf_add_model_config_data(_bt_mesh_cdb_t *cfg, uint16_t unicast,
162 int element_index, uint32_t model_id, uint16_t group_addr);
164 bool _bt_mesh_conf_delete_model_config_data(_bt_mesh_cdb_t *cfg, uint16_t unicast,
165 int element_index, uint32_t model_id, uint16_t group_addr);
167 bool _bt_mesh_conf_delete_all_model_config_data(_bt_mesh_cdb_t *cfg, uint16_t unicast,
168 int element_index, uint32_t model_id);
170 bool _bt_mesh_conf_overwrite_model_config_data(_bt_mesh_cdb_t *cfg, uint16_t unicast,
171 int element_index, uint32_t model_id, uint16_t group_addr);
173 bool _bt_mesh_conf_set_network_friendly_name(_bt_mesh_cdb_t *cfg,
174 const char *network_name);
176 const char * _bt_mesh_conf_get_network_friendly_name(_bt_mesh_cdb_t *cfg);
180 #endif /* __cplusplus */
181 #endif /* BT_SERVICE_MESH_CDB_H_ */