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(_bt_mesh_cdb_t *cfg,
91 uint16_t *cid, uint16_t *vid, uint16_t *version,
92 uint16_t *crpl, int *relay, int *frnd,
93 int *proxy, int *lpn);
95 uint16_t** _bt_mesh_conf_get_all_model_info(_bt_mesh_cdb_t *cfg,
96 int element_index, int *num_models);
98 bool _bt_mesh_conf_get_token_info(uint8_t token[8]);
100 bool _bt_mesh_conf_insert_application_key(_bt_mesh_cdb_t *cfg,
101 uint16_t net_idx, uint16_t app_idx);
103 bool _bt_mesh_conf_get_unicast_address_range(uint16_t *low,
106 bool _bt_mesh_conf_node_set_network_transmission(uint16_t unicast,
107 uint8_t cnt, uint16_t interval);
109 bool _bt_mesh_conf_delete_node(_bt_mesh_cdb_t *cfg,
112 bool _bt_mesh_conf_set_node_comp_data(_bt_mesh_cdb_t *cfg,
113 uint16_t unicast, uint8_t *data, uint16_t len);
115 bool _bt_mesh_conf_node_insert_network_key(_bt_mesh_cdb_t *cfg,
116 uint16_t unicast, uint16_t idx);
118 bool _bt_mesh_conf_node_delete_network_key(_bt_mesh_cdb_t *cfg,
119 uint16_t unicast, uint16_t idx);
121 bool _bt_mesh_conf_node_insert_application_key(_bt_mesh_cdb_t *cfg,
122 uint16_t unicast, uint16_t idx);
124 bool _bt_mesh_conf_node_delete_application_key(_bt_mesh_cdb_t *cfg,
125 uint16_t unicast, uint16_t idx);
127 bool _bt_mesh_conf_node_set_timetolive_value(_bt_mesh_cdb_t *cfg,
128 uint16_t unicast, uint8_t ttl);
130 bool _bt_mesh_conf_node_set_write_op_mode(uint16_t unicast,
131 const char *keyword, int value);
133 bool _bt_mesh_conf_bind_model(uint16_t unicast,
134 uint8_t ele, bool vendor,
135 uint32_t mod_id, uint16_t app_idx);
137 bool _bt_mesh_conf_unbind_model(uint16_t unicast,
138 uint8_t ele, bool vendor,
139 uint32_t mod_id, uint16_t app_idx);
141 GSList *_bt_mesh_conf_load_group_info(_bt_mesh_cdb_t *cfg);
143 bool _bt_mesh_conf_insert_group_info(_bt_mesh_cdb_t *cfg,
144 _bt_mesh_group_t *grp);
146 bool _bt_mesh_conf_set_network_friendly_name(_bt_mesh_cdb_t *cfg,
147 const char *network_name);
149 const char * _bt_mesh_conf_get_network_friendly_name(_bt_mesh_cdb_t *cfg);
153 #endif /* __cplusplus */
154 #endif /* BT_SERVICE_MESH_CDB_H_ */