2 * Copyright (C) 2020 Samsung Electronics Company Ltd.
4 * @author: Anupam Roy <anupam.r@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #ifndef TIZEN_INCLUDE_BT_MESH_H
20 #define TIZEN_INCLUDE_BT_MESH_H
27 /* Mesh Authentication types */
29 /*< Output authentication request types */
30 BT_HAL_MESH_AUTH_ALPHANUMERIC_DISPLAY = 0,
31 BT_HAL_MESH_AUTH_NUMERIC_DISPLAY,
32 BT_HAL_MESH_AUTH_PUSH_COUNT_DISPLAY,
33 BT_HAL_MESH_AUTH_TWIST_COUNT_DISPLAY,
35 /*< Input authentication request types */
36 BT_HAL_MESH_AUTH_REQ_ALPHANUMERIC_INPUT,
37 BT_HAL_MESH_AUTH_REQ_NUMERIC_INPUT,
38 BT_HAL_MESH_AUTH_REQ_BLINK_COUNT_INPUT,
39 BT_HAL_MESH_AUTH_REQ_BEEP_COUNT_INPUT,
40 BT_HAL_MESH_AUTH_REQ_VIBRATE_COUNT_INPUT,
42 /**< OOB Key Inputs */
43 BT_HAL_MESH_AUTH_REQ_OOB_PUBLIC_KEY_INPUT,
44 BT_HAL_MESH_AUTH_REQ_OOB_STATIC_KEY_INPUT,
45 BT_HAL_MESH_UNKNOWN_AUTH_METHOD
46 } bt_hal_mesh_auth_variant_e;
48 /* Spec defined Error Codes */
50 BT_HAL_MESH_PROV_ERR_INTERNAL = -1,
51 BT_HAL_MESH_PROV_ERR_SUCCESS = 0x00,
52 BT_HAL_MESH_PROV_ERR_INVALID_PDU = 0x01,
53 BT_HAL_MESH_PROV_ERR_INVALID_FORMAT = 0x02,
54 BT_HAL_MESH_PROV_ERR_UNEXPECTED_PDU = 0x03,
55 BT_HAL_MESH_PROV_ERR_CONFIRM_FAILED = 0x04,
56 BT_HAL_MESH_PROV_ERR_INSUF_RESOURCE = 0x05,
57 BT_HAL_MESH_PROV_ERR_DECRYPT_FAILED = 0x06,
58 BT_HAL_MESH_PROV_ERR_UNEXPECTED_ERR = 0x07,
59 BT_HAL_MESH_PROV_ERR_CANT_ASSIGN_ADDR = 0x08,
60 /* Internally generated by Stack */
61 BT_HAL_MESH_PROV_ERR_TIMEOUT = 0xFF,
62 } bt_hal_mesh_prov_error_codes_e;
64 /* Mesh Node Properties */
74 } bt_hal_mesh_vendor_info_t;
76 /* Mesh Model: 2 bytes for BT SIG Model & 4 bytes for Vendor Model */
80 } bt_hal_mesh_model_t;
82 /* Mesh Element structure */
86 } bt_hal_mesh_element_t;
88 /* Mesh Node structure */
90 bt_hal_mesh_vendor_info_t vendor_info;
91 uint16_t num_elements;
92 uint16_t primary_unicast;
100 /** Bluetooth Mesh Security Token */
107 } bt_hal_mesh_scan_param_t;
114 } bt_hal_mesh_prov_caps_t;
116 /** Bluetooth Mesh Security Token */
122 } bt_mesh_scan_result_t;
124 /** Bluetooth Mesh Scan state */
126 BT_MESH_SCAN_STOPPED,
128 } bt_mesh_scan_state_t;
130 /** Bluetooth Mesh Scan state */
137 /** Callback Signatures */
138 typedef void (*btmesh_network_proxy_added_callback)(bt_status_t status);
140 typedef void (*btmesh_network_attached_callback)(bt_status_t status,
141 bool is_prov, bt_mesh_token_t *token, bt_uuid_t *uuid);
143 typedef void (*btmesh_network_destroyed_callback)(bt_status_t status,
144 bt_mesh_token_t *token, bt_uuid_t *uuid);
146 typedef void (*btmesh_network_scan_status_callback)(
147 bt_mesh_scan_state_t scan_state, bt_status_t status,
148 bt_uuid_t *net_uuid);
150 typedef void (*btmesh_network_scan_result_callback)(bt_status_t status,
151 bt_uuid_t *net_uuid, bt_mesh_scan_result_t *scan_result);
153 typedef void (*btmesh_network_provisioning_status_callback)(
154 bt_status_t status, bt_uuid_t *net_uuid, bt_uuid_t *dev_uuid);
156 typedef void (*btmesh_network_provisioning_finished_callback)(
157 bt_status_t status, int reason, bt_uuid_t *net_uuid,
158 bt_uuid_t *dev_uuid, uint16_t unicast, uint8_t count);
160 typedef void (*btmesh_network_provisioning_data_requested_callback)(
161 bt_uuid_t *net_uuid, uint8_t count);
163 typedef void (*btmesh_network_authentication_requested_callback)(
165 bt_hal_mesh_auth_variant_e auth_type, char auth_value[]);
167 typedef void (*btmesh_network_netkey_execute_callback)(
168 bt_status_t status, bt_uuid_t *net_uuid,
169 uint8_t key_event, uint16_t netkey_idx);
171 typedef void (*btmesh_network_appkey_execute_callback)(
172 bt_status_t status, bt_uuid_t *net_uuid, uint8_t key_event,
173 uint16_t netkey_idx, uint16_t appkey_idx);
175 typedef void (*btmesh_devkey_message_received_callback)(bt_uuid_t *net_uuid,
176 uint16_t source_addr, bool is_devkey_remote, uint16_t netkey_idx,
177 uint16_t data_len, uint8_t *data);
179 typedef void (*btmesh_message_received_callback)(bt_uuid_t *net_uuid, bool is_prov,
180 uint16_t source_addr, uint16_t dest_addr, uint16_t key_idx,
181 uint16_t data_len, uint8_t *data);
183 /** BT-Mesh callback structure. */
185 /** set to sizeof(btmesh_callbacks_t) */
187 btmesh_network_proxy_added_callback network_proxy_added_cb;
188 btmesh_network_attached_callback network_attached_cb;
189 btmesh_network_destroyed_callback network_destroyed_cb;
190 btmesh_network_scan_status_callback scan_status_cb;
191 btmesh_network_scan_result_callback scan_result_cb;
192 btmesh_network_provisioning_status_callback provisioning_status_cb;
193 btmesh_network_provisioning_finished_callback provisioning_finished_cb;
194 btmesh_network_provisioning_data_requested_callback provisioning_data_requested_cb;
195 btmesh_network_authentication_requested_callback authentication_requested_cb;
196 btmesh_network_netkey_execute_callback netkey_execute_cb;
197 btmesh_network_appkey_execute_callback appkey_execute_cb;
198 btmesh_devkey_message_received_callback devkey_msg_cb;
199 btmesh_message_received_callback msg_cb;
200 } btmesh_callbacks_t;
202 /** Represents the standard BT-MESH interface. */
205 /** set to sizeof(btmesh_interface_t) */
208 * Register the BT Mesh callbacks
210 bt_status_t (*init)(btmesh_callbacks_t* callbacks);
211 bt_status_t (*create)(bt_hal_mesh_node_t *node,
212 GSList *model_list, bool is_prov);
213 bt_status_t (*destroy)(bt_uuid_t *network);
214 bt_status_t (*join)(bt_hal_mesh_node_t *node,
216 bt_status_t (*cancel)(bt_uuid_t *node);
217 bt_status_t (*release)(bt_uuid_t *network);
218 bt_status_t (*delete_node)(bt_uuid_t *network, uint16_t unicast,
220 bt_status_t (*scan)(bt_uuid_t *network,
221 bt_hal_mesh_scan_param_t *param);
222 bt_status_t (*scan_cancel)(bt_uuid_t *network);
223 bt_status_t (*capability)(bt_uuid_t *network,
224 bt_hal_mesh_prov_caps_t *param);
225 bt_status_t (*provision)(bt_uuid_t *network, bt_uuid_t *dev_uuid);
226 bt_status_t (*provision_data)(bt_uuid_t* network_uuid,
227 uint16_t netkey_idx, uint16_t unicast);
228 bt_status_t (*auth_reply)(bt_hal_mesh_auth_variant_e auth_type,
229 const char *auth_value);
230 bt_status_t (*subnet_execute)(bt_uuid_t* network_uuid,
231 bt_mesh_key_op_e op, uint16_t netkey_idx);
232 bt_status_t (*appkey_execute)(bt_uuid_t* network_uuid,
233 bt_mesh_key_op_e op, uint16_t netkey_idx, uint16_t appkey_idx);
234 bt_status_t (*config_send)(bt_uuid_t *network, uint16_t dest,
235 bool is_dev_key, uint16_t netkey_idx, uint8_t *buf, int len);
236 bt_status_t (*key_send)(bt_uuid_t *network, uint16_t dest,
237 bool is_netkey, bool is_update, uint16_t key_idx, uint16_t netkey_idx);
238 bt_status_t (*msg_execute)(bt_uuid_t *network, uint16_t dest,
239 uint16_t appkey_idx, uint8_t *buf, int len);
240 bt_status_t (*attach)(void);
241 /** Closes the interface. */
242 void (*cleanup)(void);
243 } btmesh_interface_t;
246 #endif /* TIZEN_INCLUDE_BT_MESH_H */