• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @file    wm_bt_def.h
18  *
19  * @brief   Bluetooth Define
20  *
21  * @author  WinnerMicro
22  *
23  * Copyright (c) 2020 Winner Microelectronics Co., Ltd.
24  */
25 #ifndef WM_BT_DEF_H
26 #define WM_BT_DEF_H
27 
28 /** Bluetooth Error Status */
29 typedef enum {
30     TLS_BT_STATUS_SUCCESS, /**< success */
31     TLS_BT_STATUS_FAIL,
32     TLS_BT_STATUS_NOT_READY,
33     TLS_BT_STATUS_NOMEM, /**< alloc memory failed */
34     TLS_BT_STATUS_BUSY,
35     TLS_BT_STATUS_DONE,        /**< request already completed */
36     TLS_BT_STATUS_UNSUPPORTED,
37     TLS_BT_STATUS_PARM_INVALID,
38     TLS_BT_STATUS_UNHANDLED,
39     TLS_BT_STATUS_AUTH_FAILURE,
40     TLS_BT_STATUS_RMT_DEV_DOWN,
41     TLS_BT_STATUS_AUTH_REJECTED,
42     TLS_BT_STATUS_THREAD_FAILED, /**< create internal thread failed */
43     TLS_BT_STATUS_INTERNAL_ERROR, /**< controller stack internal error */
44     TLS_BT_STATUS_CTRL_ENABLE_FAILED,
45     TLS_BT_STATUS_HOST_ENABLE_FAILED,
46     TLS_BT_STATUS_CTRL_DISABLE_FAILED,
47     TLS_BT_STATUS_HOST_DISABLE_FAILED,
48 } tls_bt_status_t;
49 
50 typedef enum {
51     TLS_BT_CTRL_IDLE     =              (1<<0),
52     TLS_BT_CTRL_ENABLED  =              (1<<1),
53     TLS_BT_CTRL_SLEEPING =              (1<<2),
54     TLS_BT_CTRL_BLE_ROLE_MASTER =       (1<<3),
55     TLS_BT_CTRL_BLE_ROLE_SLAVE =        (1<<4),
56     TLS_BT_CTRL_BLE_ROLE_END =          (1<<5),
57     TLS_BT_CTRL_BLE_STATE_IDLE =        (1<<6),
58     TLS_BT_CTRL_BLE_STATE_ADVERTISING = (1<<7),
59     TLS_BT_CTRL_BLE_STATE_SCANNING =    (1<<8),
60     TLS_BT_CTRL_BLE_STATE_INITIATING =  (1<<9),
61     TLS_BT_CTRL_BLE_STATE_STOPPING =    (1<<10),
62     TLS_BT_CTRL_BLE_STATE_TESTING =     (1<<11),
63 } tls_bt_ctrl_status_t;
64 
65 /** Bluetooth Adapter State */
66 typedef enum {
67     WM_BT_STATE_OFF,
68     WM_BT_STATE_ON
69 } tls_bt_state_t;
70 
71 /** bluetooth host statck events */
72 typedef enum {
73     WM_BT_ADAPTER_STATE_CHG_EVT   = (0x01<<0),
74     WM_BT_ADAPTER_PROP_CHG_EVT    = (0x01<<1),
75     WM_BT_RMT_DEVICE_PROP_EVT     = (0x01<<2),
76     WM_BT_DEVICE_FOUND_EVT        = (0x01<<3),
77     WM_BT_DISCOVERY_STATE_CHG_EVT = (0x01<<4),
78     WM_BT_REQUEST_EVT             = (0x01<<5),
79     WM_BT_SSP_REQUEST_EVT         = (0x01<<6),
80     WM_BT_PIN_REQUEST_EVT         = (0x01<<7),
81     WM_BT_BOND_STATE_CHG_EVT      = (0x01<<8),
82     WM_BT_ACL_STATE_CHG_EVT       = (0x01<<9),
83     WM_BT_ENERGY_INFO_EVT         = (0x01<<10),
84     WM_BT_LE_TEST_EVT             = (0x01<<11),
85 } tls_bt_host_evt_t;
86 
87 typedef struct {
88     tls_bt_state_t         status; /**< bluetooth adapter state */
89 } tls_bt_adapter_state_change_msg_t;
90 
91 /** Bluetooth Adapter and Remote Device property types */
92 typedef enum {
93     /* Properties common to both adapter and remote device */
94     /**
95      * Description - Bluetooth Device Name
96      * Access mode - Adapter name can be GET/SET. Remote device can be GET
97      * Data type   - bt_bdname_t
98      */
99     WM_BT_PROPERTY_BDNAME = 0x1,
100     /**
101      * Description - Bluetooth Device Address
102      * Access mode - Only GET.
103      * Data type   - bt_bdaddr_t
104      */
105     WM_BT_PROPERTY_BDADDR,
106     /**
107      * Description - Bluetooth Service 128-bit UUIDs
108      * Access mode - Only GET.
109      * Data type   - Array of bt_uuid_t (Array size inferred from property length).
110      */
111     WM_BT_PROPERTY_UUIDS,
112     /**
113      * Description - Bluetooth Class of Device as found in Assigned Numbers
114      * Access mode - Only GET.
115      * Data type   - uint32_t.
116      */
117     WM_BT_PROPERTY_CLASS_OF_DEVICE,
118     /**
119      * Description - Device Type - BREDR, BLE or DUAL Mode
120      * Access mode - Only GET.
121      * Data type   - bt_device_type_t
122      */
123     WM_BT_PROPERTY_TYPE_OF_DEVICE,
124     /**
125      * Description - Bluetooth Service Record
126      * Access mode - Only GET.
127      * Data type   - bt_service_record_t
128      */
129     WM_BT_PROPERTY_SERVICE_RECORD,
130 
131     /* Properties unique to adapter */
132     /**
133      * Description - Bluetooth Adapter scan mode
134      * Access mode - GET and SET
135      * Data type   - bt_scan_mode_t.
136      */
137     WM_BT_PROPERTY_ADAPTER_SCAN_MODE,
138     /**
139      * Description - List of bonded devices
140      * Access mode - Only GET.
141      * Data type   - Array of bt_bdaddr_t of the bonded remote devices
142      *               (Array size inferred from property length).
143      */
144     WM_BT_PROPERTY_ADAPTER_BONDED_DEVICES,
145     /**
146      * Description - Bluetooth Adapter Discovery timeout (in seconds)
147      * Access mode - GET and SET
148      * Data type   - uint32_t
149      */
150     WM_BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
151 
152     /* Properties unique to remote device */
153     /**
154      * Description - User defined friendly name of the remote device
155      * Access mode - GET and SET
156      * Data type   - bt_bdname_t.
157      */
158     WM_BT_PROPERTY_REMOTE_FRIENDLY_NAME,
159     /**
160      * Description - RSSI value of the inquired remote device
161      * Access mode - Only GET.
162      * Data type   - int32_t.
163      */
164     WM_BT_PROPERTY_REMOTE_RSSI,
165     /**
166      * Description - Remote version info
167      * Access mode - SET/GET.
168      * Data type   - bt_remote_version_t.
169      */
170 
171     WM_BT_PROPERTY_REMOTE_VERSION_INFO,
172 
173     /**
174      * Description - Local LE features
175      * Access mode - GET.
176      * Data type   - bt_local_le_features_t.
177      */
178     WM_BT_PROPERTY_LOCAL_LE_FEATURES,
179 
180     WM_BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
181 } tls_bt_property_type_t;
182 
183 /** Bluetooth Adapter Property data structure */
184 typedef struct {
185     tls_bt_property_type_t type;
186     int len;
187     void *val;
188 } tls_bt_property_t;
189 
190 typedef struct {
191     tls_bt_status_t     status;
192     int num_properties;
193     tls_bt_property_t *properties; /**< bluetooth adapter property data */
194 } tls_bt_adapter_prop_msg_t;
195 
196 typedef enum {
197     WM_BLE_SCAN_STOP = 0,
198     WM_BLE_SCAN_PASSIVE = 1,
199     WM_BLE_SCAN_ACTIVE = 2,
200 } wm_ble_scan_type_t;
201 
202 typedef enum {
203     WM_BLE_ADV_DATA = 0,
204     WM_BLE_ADV_RSP_DATA,
205 } wm_ble_gap_data_t;
206 
207 typedef enum {
208     WM_BLE_ADV_STOP = 0,
209     WM_BLE_ADV_IND,
210     WM_BLE_ADV_DIRECT_IND_HDC,  /* <high duty cycle, directed advertising> */
211     WM_BLE_ADV_SCAN_IND,
212     WM_BLE_ADV_NONCONN_IND,
213     WM_BLE_ADV_DIRECT_IND_LDC,  /* <low duty cycle, directed advertising> */
214 } wm_ble_adv_type_t;
215 
216 #define WM_BLE_GAP_EVENT_CONNECT               (0x01<<0)
217 #define WM_BLE_GAP_EVENT_DISCONNECT            (0x01<<1)
218 /* Reserved                                 2 */
219 #define WM_BLE_GAP_EVENT_CONN_UPDATE           (0x01<<3)
220 #define WM_BLE_GAP_EVENT_CONN_UPDATE_REQ       (0x01<<4)
221 #define WM_BLE_GAP_EVENT_L2CAP_UPDATE_REQ      (0x01<<5)
222 #define WM_BLE_GAP_EVENT_TERM_FAILURE          (0x01<<6)
223 #define WM_BLE_GAP_EVENT_DISC                  (0x01<<7)
224 #define WM_BLE_GAP_EVENT_DISC_COMPLETE         (0x01<<8)
225 #define WM_BLE_GAP_EVENT_ADV_COMPLETE          (0x01<<9)
226 #define WM_BLE_GAP_EVENT_ENC_CHANGE            (0x01<<10)
227 #define WM_BLE_GAP_EVENT_PASSKEY_ACTION        (0x01<<11)
228 #define WM_BLE_GAP_EVENT_NOTIFY_RX             (0x01<<12)
229 #define WM_BLE_GAP_EVENT_NOTIFY_TX             (0x01<<13)
230 #define WM_BLE_GAP_EVENT_SUBSCRIBE             (0x01<<14)
231 #define WM_BLE_GAP_EVENT_MTU                   (0x01<<15)
232 #define WM_BLE_GAP_EVENT_IDENTITY_RESOLVED     (0x01<<16)
233 #define WM_BLE_GAP_EVENT_REPEAT_PAIRING        (0x01<<17)
234 #define WM_BLE_GAP_EVENT_PHY_UPDATE_COMPLETE   (0x01<<18)
235 #define WM_BLE_GAP_EVENT_EXT_DISC              (0x01<<19)
236 #define WM_BLE_GAP_EVENT_PERIODIC_SYNC         (0x01<<20)
237 #define WM_BLE_GAP_EVENT_PERIODIC_REPORT       (0x01<<21)
238 #define WM_BLE_GAP_EVENT_PERIODIC_SYNC_LOST    (0x01<<22)
239 #define WM_BLE_GAP_EVENT_SCAN_REQ_RCVD         (0x01<<23)
240 #define WM_BLE_GAP_EVENT_PERIODIC_TRANSFER     (0x01<<24)
241 
242 /** Bluetooth Address */
243 typedef struct {
244     uint8_t address[6];
245 } __attribute__((packed))tls_bt_addr_t;
246 
247 typedef struct {
248     tls_bt_status_t     status;
249     tls_bt_addr_t     *address;
250     int num_properties;
251     tls_bt_property_t *properties; /**< bluetooth adapter property data */
252 } tls_bt_remote_dev_prop_msg_t;
253 
254 typedef struct {
255     int num_properties;
256     tls_bt_property_t *properties; /**< bluetooth adapter property data */
257 } tls_bt_device_found_msg_t;
258 
259 /** Bluetooth Adapter Discovery state */
260 typedef enum {
261     WM_BT_DISCOVERY_STOPPED,
262     WM_BT_DISCOVERY_STARTED
263 } tls_bt_discovery_state_t;
264 
265 typedef struct {
266     tls_bt_discovery_state_t state;
267 } tls_bt_discovery_state_chg_msg_t;
268 
269 /** Bluetooth Device Name */
270 typedef struct {
271     uint8_t name[249];
272 } __attribute__((packed))tls_bt_bdname_t;
273 
274 typedef struct {
275     tls_bt_addr_t *remote_bd_addr;
276     tls_bt_bdname_t *bd_name;
277     uint32_t cod;
278     uint8_t  min_16_digit;
279 } tls_bt_pin_request_msg_t;
280 
281 /** Bluetooth SSP Bonding Variant */
282 typedef enum {
283     WM_BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
284     WM_BT_SSP_VARIANT_PASSKEY_ENTRY,
285     WM_BT_SSP_VARIANT_CONSENT,
286     WM_BT_SSP_VARIANT_PASSKEY_NOTIFICATION
287 } tls_bt_ssp_variant_t;
288 
289 /** Bluetooth PinKey Code */
290 typedef struct {
291     uint8_t pin[16];
292 } __attribute__((packed))tls_bt_pin_code_t;
293 
294 typedef struct {
295     tls_bt_addr_t *remote_bd_addr;
296     tls_bt_bdname_t *bd_name;
297     uint32_t cod;
298     tls_bt_ssp_variant_t pairing_variant;
299     uint32_t pass_key;
300 } tls_bt_ssp_request_msg_t;
301 
302 /** Bluetooth Bond state */
303 typedef enum {
304     WM_BT_BOND_STATE_NONE,
305     WM_BT_BOND_STATE_BONDING,
306     WM_BT_BOND_STATE_BONDED
307 } tls_bt_bond_state_t;
308 
309 typedef struct {
310     tls_bt_status_t status;
311     tls_bt_addr_t *remote_bd_addr;
312     tls_bt_bond_state_t state;
313 } tls_bt_bond_state_chg_msg_t;
314 
315 /** Bluetooth ACL connection state */
316 typedef enum {
317     WM_BT_ACL_STATE_CONNECTED,
318     WM_BT_ACL_STATE_DISCONNECTED
319 } tls_bt_acl_state_t;
320 
321 typedef struct {
322     tls_bt_status_t status;
323     tls_bt_addr_t *remote_address;
324     uint8_t link_type;
325     tls_bt_acl_state_t state;
326 } tls_bt_acl_state_chg_msg_t;
327 
328 typedef struct {
329     uint8_t status;
330     uint8_t ctrl_state;     /* stack reported state */
331     uint64_t tx_time;       /* in ms */
332     uint64_t rx_time;       /* in ms */
333     uint64_t idle_time;     /* in ms */
334     uint64_t energy_used;   /* a product of mA, V and ms */
335 } __attribute__((packed))tls_bt_activity_energy_info;
336 
337 typedef struct {
338     tls_bt_activity_energy_info *energy_info;
339 } tls_bt_energy_info_msg_t;
340 
341 typedef struct {
342     uint8_t status;
343     uint32_t count;
344 } tls_bt_ble_test_msg_t;
345 
346 typedef union {
347     tls_bt_adapter_state_change_msg_t        adapter_state_change;
348     tls_bt_adapter_prop_msg_t                adapter_prop;
349     tls_bt_remote_dev_prop_msg_t             remote_device_prop;
350     tls_bt_device_found_msg_t                device_found;
351     tls_bt_discovery_state_chg_msg_t         discovery_state;
352     tls_bt_pin_request_msg_t                 pin_request;
353     tls_bt_ssp_request_msg_t                 ssp_request;
354     tls_bt_bond_state_chg_msg_t              bond_state;
355     tls_bt_acl_state_chg_msg_t               acl_state;
356     tls_bt_energy_info_msg_t                 energy_info;
357     tls_bt_ble_test_msg_t                    ble_test;
358 } tls_bt_host_msg_t;
359 
360 /** BT host callback function */
361 typedef void (*tls_bt_host_callback_t)(tls_bt_host_evt_t event, tls_bt_host_msg_t *p_data);
362 
363 typedef enum {
364     TLS_BT_LOG_NONE = 0,
365     TLS_BT_LOG_ERROR = 1,
366     TLS_BT_LOG_WARNING = 2,
367     TLS_BT_LOG_API = 3,
368     TLS_BT_LOG_EVENT = 4,
369     TLS_BT_LOG_DEBUG = 5,
370     TLS_BT_LOG_VERBOSE = 6,
371 } tls_bt_log_level_t;
372 
373 typedef struct {
374     uint8_t  uart_index;  /**< uart port index, 1~4 */
375     uint32_t band_rate;   /**< band rate: 115200 ~ 2M */
376     uint8_t data_bit;     /**< data bit:5 ~ 8 */
377     uint8_t verify_bit;   /**< 0:NONE, 1 ODD, 2 EVEN */
378     uint8_t stop_bit;     /**< 0:1bit; 1:1.5bit; 2:2bits */
379 } tls_bt_hci_if_t;
380 
381 typedef enum {
382     TLS_BLE_PWR_TYPE_CONN_HDL0,
383     TLS_BLE_PWR_TYPE_CONN_HDL1,
384     TLS_BLE_PWR_TYPE_CONN_HDL2,
385     TLS_BLE_PWR_TYPE_CONN_HDL3,
386     TLS_BLE_PWR_TYPE_CONN_HDL4,
387     TLS_BLE_PWR_TYPE_CONN_HDL5,
388     TLS_BLE_PWR_TYPE_CONN_HDL6,
389     TLS_BLE_PWR_TYPE_CONN_HDL7,
390     TLS_BLE_PWR_TYPE_CONN_HDL8,
391     TLS_BLE_PWR_TYPE_ADV,
392     TLS_BLE_PWR_TYPE_SCAN,
393     TLS_BLE_PWR_TYPE_DEFAULT,
394 } tls_ble_power_type_t;
395 
396 typedef enum {
397     WM_AUDIO_OVER_HCI = 0,
398     WM_AUDIO_INTERNAL_MODE,
399 } tls_sco_data_path_t;
400 
401 typedef struct {
402     void (*notify_controller_avaiable_hci_buffer)(int cnt);
403     void (*notify_host_recv_h4)(uint8_t *ptr, uint16_t length);
404 } tls_bt_host_if_t;
405 
406 /*****************************************************************************
407  **  Constants and Type Definitions
408  *****************************************************************************/
409 
410 /** Attribute permissions */
411 #define WM_GATT_PERM_READ              (1 << 0) /**< bit 0 -  0x0001 */
412 #define WM_GATT_PERM_READ_ENCRYPTED    (1 << 1) /**< bit 1 -  0x0002 */
413 #define WM_GATT_PERM_READ_ENC_MITM     (1 << 2) /**< bit 2 -  0x0004 */
414 #define WM_GATT_PERM_WRITE             (1 << 4) /**< bit 4 -  0x0010 */
415 #define WM_GATT_PERM_WRITE_ENCRYPTED   (1 << 5) /**< bit 5 -  0x0020 */
416 #define WM_GATT_PERM_WRITE_ENC_MITM    (1 << 6) /**< bit 6 -  0x0040 */
417 #define WM_GATT_PERM_WRITE_SIGNED      (1 << 7) /**< bit 7 -  0x0080 */
418 #define WM_GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /**< bit 8 -  0x0100 */
419 
420 /** definition of characteristic properties */
421 #define WM_GATT_CHAR_PROP_BIT_BROADCAST    (1 << 0)   /**< 0x01 */
422 #define WM_GATT_CHAR_PROP_BIT_READ         (1 << 1)   /**< 0x02 */
423 #define WM_GATT_CHAR_PROP_BIT_WRITE_NR     (1 << 2)   /**< 0x04 */
424 #define WM_GATT_CHAR_PROP_BIT_WRITE        (1 << 3)   /**< 0x08 */
425 #define WM_GATT_CHAR_PROP_BIT_NOTIFY       (1 << 4)   /**< 0x10 */
426 #define WM_GATT_CHAR_PROP_BIT_INDICATE     (1 << 5)   /**< 0x20 */
427 #define WM_GATT_CHAR_PROP_BIT_AUTH         (1 << 6)   /**< 0x40 */
428 #define WM_GATT_CHAR_PROP_BIT_EXT_PROP     (1 << 7)   /**< 0x80 */
429 
430 #define WM_BLE_MAX_ATTR_LEN    600/** max client application WM BLE Client can support */
431 #ifndef WM_BLE_CLIENT_MAX
432 #define WM_BLE_CLIENT_MAX              3
433 #endif
434 
435 /** max server application WM BLE Server can support */
436 #define WM_BLE_SERVER_MAX              4
437 #define WM_BLE_ATTRIBUTE_MAX           50
438 
439 #ifndef WM_BLE_SERVER_SECURITY
440 #define WM_BLE_SERVER_SECURITY         BTA_DM_BLE_SEC_NONE
441 #endif
442 
443 #define WM_BLE_INVALID_IF              0xFF
444 #define WM_BLE_INVALID_CONN            0xFFFF
445 
446 #define WM_BLE_GATT_TRANSPORT_LE                           0x02
447 #define WM_BLE_GATT_TRANSPORT_BR_EDR                       0x01
448 #define WM_BLE_GATT_TRANSPORT_LE_BR_EDR                    0x03
449 
450 #define WM_BLE_MAX_PDU_LENGTH                              251
451 
452 /** BLE events */
453 typedef enum {
454     /** BLE Client events */
455     WM_BLE_CL_REGISTER_EVT,      /**< BLE client is registered. */
456     WM_BLE_CL_DEREGISTER_EVT,    /**< BLE client is deregistered. */
457     WM_BLE_CL_READ_CHAR_EVT,
458     WM_BLE_CL_WRITE_CHAR_EVT,
459     WM_BLE_CL_PREP_WRITE_EVT,
460     WM_BLE_CL_EXEC_CMPL_EVT,     /**< Execute complete event */
461     WM_BLE_CL_SEARCH_CMPL_EVT,   /**< GATT discovery complete event */
462     WM_BLE_CL_SEARCH_RES_EVT,    /**< GATT discovery result event */
463     WM_BLE_CL_READ_DESCR_EVT,
464     WM_BLE_CL_WRITE_DESCR_EVT,
465     WM_BLE_CL_NOTIF_EVT,         /**< GATT attribute notification event */
466     WM_BLE_CL_OPEN_EVT,          /**< BLE open request status  event */
467     WM_BLE_CL_CLOSE_EVT,         /**< GATTC  close request status event */
468     WM_BLE_CL_LISTEN_EVT,
469     WM_BLE_CL_CFG_MTU_EVT,       /**< configure MTU complete event */
470     WM_BLE_CL_CONGEST_EVT,       /**< GATT congestion/uncongestion event */
471     WM_BLE_CL_REPORT_DB_EVT,
472     WM_BLE_CL_REG_NOTIFY_EVT,
473     WM_BLE_CL_DEREG_NOTIFY_EVT,
474 
475     /** BLE Server events */
476     WM_BLE_SE_REGISTER_EVT,      /**< BLE Server is registered */
477     WM_BLE_SE_DEREGISTER_EVT,    /**< BLE Server is deregistered */
478     WM_BLE_SE_CONNECT_EVT,
479     WM_BLE_SE_DISCONNECT_EVT,
480     WM_BLE_SE_CREATE_EVT,        /**< Service is created */
481     WM_BLE_SE_ADD_INCL_SRVC_EVT,
482     WM_BLE_SE_ADD_CHAR_EVT,       /**< char data is added */
483     WM_BLE_SE_ADD_CHAR_DESCR_EVT,
484     WM_BLE_SE_START_EVT,         /**< Service is started */
485     WM_BLE_SE_STOP_EVT,          /**< Service is stopped */
486     WM_BLE_SE_DELETE_EVT,
487     WM_BLE_SE_READ_EVT,          /**< Read request from client */
488     WM_BLE_SE_WRITE_EVT,         /**< Write request from client */
489     WM_BLE_SE_EXEC_WRITE_EVT,    /**< Execute Write request from client */
490     WM_BLE_SE_CONFIRM_EVT,       /**< Confirm event */
491     WM_BLE_SE_RESP_EVT,
492     WM_BLE_SE_CONGEST_EVT,       /**< Congestion event */
493     WM_BLE_SE_MTU_EVT,
494 } tls_ble_evt_t;
495 
496 /* WM BLE Client Host callback events */
497 /* Client callback function events */
498 
499 /** Bluetooth 128-bit UUID */
500 typedef struct {
501     uint8_t uu[16];
502 } tls_bt_uuid_t;
503 
504 /* callback event data for WM_BLE_CL_REGISTER_EVT/ event */
505 typedef struct {
506     uint8_t         status; /**< operation status */
507     uint8_t         client_if; /**< Client interface ID */
508     tls_bt_uuid_t          app_uuid;  /**< Client uuid*/
509 } tls_ble_cl_register_msg_t;
510 
511 /** callback event data for WM_BLE_CL_READ_CHAR_EVT /WM_BLE_CL_READ_CHAR_EVTevent */
512 typedef struct {
513     uint16_t              conn_id;
514     uint8_t         status;
515     uint16_t              handle;
516     uint16_t              len;
517     uint8_t               *value;
518     uint16_t              value_type;
519 } tls_ble_cl_read_msg_t;
520 
521 /** callback event data for WM_BLE_CL_WRITE_CHAR_EVT/WM_BLE_CL_PREP_WRITE_EVT/WM_BLE_CL_WRITE_DESCR_EVT event */
522 typedef struct {
523     uint16_t              conn_id;
524     uint8_t         status;
525     uint16_t            handle;
526 } tls_ble_cl_write_msg_t;
527 
528 /** callback event data for WM_BLE_CL_EXEC_CMPL_EVT event */
529 typedef struct {
530     uint16_t              conn_id;
531     uint8_t         status;
532 } tls_ble_cl_exec_cmpl_msg_t;
533 
534 /** callback event data for WM_BLE_CL_SEARCH_CMPL_EVT event */
535 typedef struct {
536     uint16_t              conn_id;
537     uint8_t         status; /**< operation status */
538 } tls_ble_cl_search_cmpl_msg_t;
539 
540 /** callback event data for WM_BLE_CL_SEARCH_RES_EVT event */
541 typedef struct {
542     uint16_t              conn_id;
543     tls_bt_uuid_t             uuid;
544     uint8_t               inst_id;
545 } tls_ble_cl_search_res_msg_t;
546 
547 /** callback event data for WM_BLE_CL_NOTIF_EVT event */
548 typedef struct {
549     uint16_t              conn_id;
550     uint8_t               *value;
551     uint8_t             bda[6];
552     uint16_t            handle;
553     uint16_t              len;
554     bool             is_notify;
555 } tls_ble_cl_notify_msg_t;
556 
557 /** callback event data for WM_BLE_CL_OPEN_EVT event */
558 typedef struct {
559     uint16_t              conn_id;
560     uint8_t         status; /**< operation status */
561     uint8_t         client_if; /**< Client interface ID */
562     uint8_t             bd_addr[6];
563 } tls_ble_cl_open_msg_t;
564 
565 /** callback event data for WM_BLE_CL_CLOSE_EVT event */
566 typedef struct {
567     uint16_t              conn_id;
568     uint8_t         status;
569     uint8_t         client_if;
570     uint8_t             remote_bda[6];
571     uint16_t     reason;         /**< disconnect reason code, not useful when connect event is reported */
572 } tls_ble_cl_close_msg_t;
573 
574 /** callback event data for WM_BLE_CL_LISTEN_EVT event */
575 typedef struct {
576     uint8_t         status;
577     uint8_t        client_if;
578 } tls_ble_cl_listen_msg_t;
579 
580 /** callback event data for WM_BLE_CL_CFG_MTU_EVT event */
581 typedef struct {
582     uint16_t conn_id;
583     uint8_t         status;
584     uint16_t mtu;
585 } tls_ble_cl_cfg_mtu_msg_t;
586 
587 typedef struct {
588     uint16_t              conn_id;
589     bool             congested; /**< congestion indicator */
590 } tls_ble_cl_congest_msg_t;
591 
592 typedef enum {
593     WM_BTGATT_DB_PRIMARY_SERVICE,
594     WM_BTGATT_DB_SECONDARY_SERVICE,
595     WM_BTGATT_DB_INCLUDED_SERVICE,
596     WM_BTGATT_DB_CHARACTERISTIC,
597     WM_BTGATT_DB_DESCRIPTOR,
598 } tls_bt_gatt_db_attribute_type_t;
599 
600 typedef struct {
601     uint16_t             id;
602     tls_bt_uuid_t           uuid;
603     tls_bt_gatt_db_attribute_type_t type;
604     uint16_t            attribute_handle;
605 
606     /*
607      * If |type| is |BTGATT_DB_PRIMARY_SERVICE|, or
608      * |BTGATT_DB_SECONDARY_SERVICE|, this contains the start and end attribute
609      * handles.
610      */
611     uint16_t            start_handle;
612     uint16_t            end_handle;
613 
614     /*
615      * If |type| is |BTGATT_DB_CHARACTERISTIC|, this contains the properties of
616      * the characteristic.
617      */
618     uint8_t             properties;
619 } tls_btgatt_db_element_t;
620 
621 typedef struct {
622     uint16_t conn_id;
623     tls_btgatt_db_element_t *db;
624     int count;
625     uint8_t status;
626 } tls_ble_cl_gatt_db_msg_t;
627 
628 typedef struct {
629     uint16_t conn_id;
630     uint8_t status;
631     bool reg;
632     uint16_t handle;
633 } tls_ble_cl_reg_notify_msg_t;
634 
635 /* WM BLE Server Host callback events */
636 /* Server callback function events */
637 
638 /** callback event data for WM_BLE_SE_REGISTER_EVT/WM_BLE_SE_DEREGISTER_EVT event */
639 typedef struct {
640     uint8_t         status; /* operation status */
641     uint8_t         server_if; /* Server interface ID */
642     tls_bt_uuid_t app_uuid;
643 } tls_ble_se_register_msg_t;
644 
645 /** callback event data for WM_BLE_SE_CONNECT_EVT/WM_BLE_SE_DISCONNECT_EVT event */
646 typedef struct {
647     uint16_t conn_id;
648     uint8_t         server_if; /**< Server interface ID */
649     bool connected;
650     uint16_t reason;
651     uint8_t addr[6];
652 } tls_ble_se_connect_msg_t;
653 
654 typedef tls_ble_se_connect_msg_t tls_ble_se_disconnect_msg_t;
655 
656 /** callback event data for WM_BLE_SE_CREATE_EVT event */
657 typedef struct {
658     uint8_t         status; /**< operation status */
659     uint8_t         server_if;
660     bool is_primary;
661     uint8_t inst_id;
662     tls_bt_uuid_t uuid;
663     uint16_t              service_id;
664 } tls_ble_se_create_msg_t;
665 
666 /** callback event data for WM_BLE_SE_ADD_INCL_SRVC_EVT event */
667 typedef struct {
668     uint8_t         status; /**< operation status */
669     uint8_t         server_if;
670     uint16_t           service_id;
671     uint16_t           attr_id;
672 } tls_ble_se_add_incl_srvc_msg_t;
673 
674 /** callback event data for WM_BLE_SE_ADDCHAR_EVT event */
675 typedef struct {
676     uint8_t         status; /**< operation status */
677     uint8_t         server_if;
678     tls_bt_uuid_t uuid;
679     uint16_t              service_id;
680     uint16_t              attr_id;
681 } tls_ble_se_add_char_msg_t;
682 
683 /** callback event data for WM_BLE_SE_START_EVT event */
684 typedef tls_ble_se_add_char_msg_t tls_ble_se_add_char_descr_msg_t;
685 typedef struct {
686     uint8_t         status; /**< operation status */
687     uint8_t         server_if;
688     uint16_t              service_id;
689 } tls_ble_se_start_msg_t;
690 
691 typedef tls_ble_se_start_msg_t tls_ble_se_stop_msg_t;
692 
693 typedef tls_ble_se_start_msg_t tls_ble_se_delete_msg_t;
694 
695 typedef struct {
696     uint16_t        conn_id;
697     uint32_t        trans_id;
698     uint8_t       remote_bda[6];
699     uint16_t        handle;
700     uint16_t        offset;
701     bool       is_long;
702 } tls_ble_se_read_msg_t;
703 
704 typedef struct {
705     uint16_t              conn_id;
706     uint32_t              trans_id;
707     uint8_t             remote_bda[6];
708     uint16_t              handle;     /**< attribute handle */
709     uint16_t              offset;    /**< attribute value offset, if no offset is needed for the command, ignore it */
710     uint16_t              len;        /**< length of attribute value */
711     bool             need_rsp;   /**< need write response */
712     bool             is_prep;    /**< is prepare write */
713     uint8_t               *value;  /**< the actual attribute value */
714 } tls_ble_se_write_msg_t;
715 
716 typedef struct {
717     uint16_t              conn_id;
718     uint32_t              trans_id;
719     uint8_t             remote_bda[6];
720     uint8_t exec_write;
721 } tls_ble_se_exec_write_msg_t;
722 
723 typedef struct {
724     uint16_t       conn_id;
725     uint8_t         status; /**< operation status */
726 } tls_ble_se_confirm_msg_t;
727 
728 typedef struct {
729     uint8_t         status; /* operation status */
730     uint16_t        conn_id;
731     uint16_t        trans_id;
732 } tls_ble_se_response_msg_t;
733 
734 typedef struct {
735     uint16_t           conn_id;
736     bool             congested; /**< congestion indicator */
737 } tls_ble_se_congest_msg_t;
738 
739 typedef struct {
740     uint16_t        conn_id;
741     uint16_t            mtu;
742 } tls_ble_se_mtu_msg_t;
743 
744 /** Union of data associated with HD callback */
745 typedef union {
746     tls_ble_cl_register_msg_t    cli_register;      /**< WM_BLE_CL_REGISTER_EVT */
747     tls_ble_cl_read_msg_t        cli_read;          /**< WM_BLE_CL_READ_EVT */
748     tls_ble_cl_write_msg_t       cli_write;         /**< WM_BLE_CL_WRITE_EVT */
749     tls_ble_cl_exec_cmpl_msg_t   cli_exec_cmpl;     /**< WM_BLE_CL_EXEC_CMPL_EVT */
750     tls_ble_cl_search_cmpl_msg_t cli_search_cmpl;   /**< WM_BLE_CL_SEARCH_CMPL_EVT */
751     tls_ble_cl_search_res_msg_t  cli_search_res;    /**< WM_BLE_CL_SEARCH_RES_EVT */
752     tls_ble_cl_notify_msg_t      cli_notif;         /**< WM_BLE_CL_NOTIF_EVT */
753     tls_ble_cl_open_msg_t        cli_open;          /**< WM_BLE_CL_OPEN_EVT */
754     tls_ble_cl_close_msg_t       cli_close;         /**< WM_BLE_CL_CLOSE_EVT */
755     tls_ble_cl_listen_msg_t      cli_listen;        /**< WM_BLE_CL_LISTEN_EVT */
756     tls_ble_cl_cfg_mtu_msg_t     cli_cfg_mtu;       /**< WM_BLE_CL_CFG_MTU_EVT */
757     tls_ble_cl_congest_msg_t     cli_congest;       /**< WM_BLE_CL_CONGEST_EVT */
758     tls_ble_cl_gatt_db_msg_t     cli_db;            /* WM_BLE_CL_REPORT_DB_EVT */
759     tls_ble_cl_reg_notify_msg_t  cli_reg_notify;
760 
761     tls_ble_se_register_msg_t    ser_register;     /**< WM_BLE_SE_REGISTER_EVT */
762     tls_ble_se_connect_msg_t     ser_connect;      /**< WM_BLE_SE_OPEN_EVT */
763     tls_ble_se_disconnect_msg_t  ser_disconnect;   /**< WM_BLE_SE_CLOSE_EVT */
764     tls_ble_se_create_msg_t      ser_create;       /**< WM_BLE_SE_CREATE_EVT */
765     tls_ble_se_add_incl_srvc_msg_t ser_add_incl_srvc;
766     tls_ble_se_add_char_msg_t    ser_add_char;     /**< WM_BLE_SE_ADDCHAR_EVT */
767     tls_ble_se_add_char_descr_msg_t ser_add_char_descr;
768     tls_ble_se_start_msg_t       ser_start_srvc;   /**< WM_BLE_SE_START_EVT */
769     tls_ble_se_stop_msg_t        ser_stop_srvc;    /**< WM_BLE_SE_STOP_EVT */
770     tls_ble_se_delete_msg_t      ser_delete_srvc;
771     tls_ble_se_read_msg_t        ser_read;         /**< WM_BLE_SE_READ_EVT */
772     tls_ble_se_write_msg_t       ser_write;        /**< WM_BLE_SE_WRITE_EVT */
773     tls_ble_se_exec_write_msg_t  ser_exec_write;   /**< WM_BLE_SE_EXEC_WRITE_EVT */
774     tls_ble_se_confirm_msg_t     ser_confirm;      /**< WM_BLE_SE_CONFIRM_EVT */
775     tls_ble_se_congest_msg_t     ser_congest;      /**< WM_BLE_CL_CONGEST_EVT */
776     tls_ble_se_mtu_msg_t         ser_mtu;
777     tls_ble_se_response_msg_t    ser_resp;
778 } tls_ble_msg_t;
779 
780 /** WM BLE Client callback function */
781 typedef void (*tls_ble_callback_t)(tls_ble_evt_t event, tls_ble_msg_t *p_data);
782 
783 typedef void (*tls_ble_output_func_ptr)(uint8_t *p_data, uint32_t length);
784 
785 /** BLE dm events */
786 typedef enum {
787     WM_BLE_DM_SET_ADV_DATA_CMPL_EVT   = (0x01<<0),        /**< BLE DM set advertisement data completed*/
788     WM_BLE_DM_TIMER_EXPIRED_EVT       = (0x01<<1),        /**< BLE DM timer expired event. */
789     WM_BLE_DM_TRIGER_EVT              = (0x01<<2),        /**< BLE DM event trigered event, async processing*/
790     WM_BLE_DM_SCAN_RES_EVT            = (0x01<<3),        /**< BLE DM scan result evt*/
791     WM_BLE_DM_SET_SCAN_PARAM_CMPL_EVT = (0x01<<4),
792     WM_BLE_DM_REPORT_RSSI_EVT         = (0x01<<5),
793     WM_BLE_DM_SCAN_RES_CMPL_EVT       = (0x01<<6),
794     WM_BLE_DM_SEC_EVT                 = (0x01<<7),
795     WM_BLE_DM_ADV_STARTED_EVT         = (0x01<<8),
796     WM_BLE_DM_ADV_STOPPED_EVT         = (0x01<<9),
797 } tls_ble_dm_evt_t;
798 
799 /** callback event data for WM_BLE_DM_SET_ADV_DATA */
800 typedef struct {
801     uint8_t         status; /**< operation status */
802 } tls_ble_dm_set_adv_data_cmpl_msg_t;
803 
804 typedef struct {
805     uint8_t status;
806     uint8_t dm_id; // dummy value; who care this value;
807 } tls_ble_dm_set_scan_param_cmpl_msg_t;
808 
809 typedef struct {
810     uint32_t id;
811     int32_t func_ptr;
812 } tls_ble_dm_timer_expired_msg_t;
813 
814 typedef tls_ble_dm_timer_expired_msg_t tls_ble_dm_evt_triger_msg_t;
815 
816 typedef struct {
817     uint8_t address[6];                    /**< device address */
818     int8_t rssi;                        /**< signal strength */
819     uint8_t *value; /**< adv /scan resp value */
820 } tls_ble_dm_scan_res_msg_t;
821 
822 typedef struct {
823     uint8_t address[6];
824     int8_t rssi;
825     uint8_t status;
826 } tls_ble_report_rssi_msg_t;
827 typedef struct {
828     uint8_t address[6];
829     int8_t transport;
830     uint8_t status;
831 } tls_ble_sec_msg_t;
832 
833 typedef struct {
834     uint16_t num_responses;
835 } tls_ble_dm_scan_res_cmpl_msg_t;
836 
837 typedef tls_ble_dm_set_adv_data_cmpl_msg_t tls_ble_dm_adv_cmpl_msg_t;
838 typedef union {
839     tls_ble_dm_set_adv_data_cmpl_msg_t   dm_set_adv_data_cmpl;
840     tls_ble_dm_timer_expired_msg_t       dm_timer_expired;
841     tls_ble_dm_evt_triger_msg_t          dm_evt_trigered;
842     tls_ble_dm_scan_res_msg_t            dm_scan_result;
843     tls_ble_dm_set_scan_param_cmpl_msg_t dm_set_scan_param_cmpl;
844     tls_ble_dm_scan_res_cmpl_msg_t       dm_scan_result_cmpl;
845     tls_ble_report_rssi_msg_t            dm_report_rssi;
846     tls_ble_sec_msg_t                    dm_sec_result;
847     tls_ble_dm_adv_cmpl_msg_t            dm_adv_cmpl;
848 } tls_ble_dm_msg_t;
849 
850 typedef struct {
851     bool set_scan_rsp;
852     bool include_name;
853     bool include_txpower;
854     bool pure_data;
855     int min_interval;
856     int max_interval;
857     int appearance;
858     uint16_t manufacturer_len;
859     uint8_t manufacturer_data[31];
860     uint16_t service_data_len;
861     uint8_t service_data[31];
862     uint16_t service_uuid_len;
863     uint8_t service_uuid[31];
864 } __attribute__((packed)) tls_ble_dm_adv_data_t;
865 
866 typedef struct {
867     uint16_t      adv_int_min;            /* minimum adv interval */
868     uint16_t      adv_int_max;            /* maximum adv interval */
869     tls_bt_addr_t   *dir_addr;
870 } __attribute__((packed)) tls_ble_dm_adv_param_t;
871 
872 typedef struct {
873     uint16_t      adv_int_min;            /* minimum adv interval */
874     uint16_t      adv_int_max;            /* maximum adv interval */
875     uint8_t       adv_type;
876     uint8_t       own_addr_type;
877     uint8_t       chnl_map;
878     uint8_t         afp;
879     uint8_t         peer_addr_type;
880     tls_bt_addr_t   *dir_addr;
881 } __attribute__((packed)) tls_ble_dm_adv_ext_param_t;
882 
883 /** WM BLE device manager callback function */
884 typedef void (*tls_ble_dm_callback_t)(tls_ble_dm_evt_t event, tls_ble_dm_msg_t *p_data);
885 
886 /** WM BLE dm timer callback function */
887 typedef void (*tls_ble_dm_timer_callback_t)(uint8_t timer_id);
888 
889 /** WM BLE device evt triger callback function */
890 typedef void (*tls_ble_dm_triger_callback_t)(uint32_t evt_id);
891 
892 typedef void (*tls_ble_scan_res_notify_t)(tls_ble_dm_scan_res_msg_t *msg);
893 
894 /*********************************************************************************************************/
895 /* Bluetooth AV connection states */
896 typedef enum {
897     WM_BTAV_CONNECTION_STATE_DISCONNECTED = 0,
898     WM_BTAV_CONNECTION_STATE_CONNECTING,
899     WM_BTAV_CONNECTION_STATE_CONNECTED,
900     WM_BTAV_CONNECTION_STATE_DISCONNECTING
901 } tls_btav_connection_state_t;
902 
903 /* Bluetooth AV datapath states */
904 typedef enum {
905     WM_BTAV_AUDIO_STATE_REMOTE_SUSPEND = 0,
906     WM_BTAV_AUDIO_STATE_STOPPED,
907     WM_BTAV_AUDIO_STATE_STARTED,
908 } tls_btav_audio_state_t;
909 
910 /** BR-EDR A2DP sink events */
911 typedef enum {
912     WMBT_A2DP_CONNECTION_STATE_EVT,
913     WMBT_A2DP_AUDIO_STATE_EVT,
914     WMBT_A2DP_AUDIO_CONFIG_EVT,
915     WMBT_A2DP_AUDIO_PAYLOAD_EVT,
916 } tls_bt_av_evt_t;
917 
918 typedef struct {
919     tls_btav_connection_state_t stat;
920     tls_bt_addr_t *bd_addr;
921 } tls_bt_av_connection_state_t;
922 
923 typedef struct {
924     tls_btav_audio_state_t stat;
925     tls_bt_addr_t *bd_addr;
926 } tls_bt_av_audio_state_t;
927 
928 typedef struct {
929     tls_bt_addr_t *bd_addr;
930     uint32_t sample_rate;
931     uint8_t channel_count;
932 } tls_bt_av_audio_config_t;
933 
934 typedef struct {
935     tls_bt_addr_t *bd_addr;
936     uint8_t audio_format;
937     uint8_t *payload;
938     uint16_t payload_length;
939 } tls_bt_av_audio_payload_t;
940 
941 typedef union {
942     tls_bt_av_connection_state_t av_connection_state;
943     tls_bt_av_audio_state_t av_audio_state;
944     tls_bt_av_audio_config_t av_audio_config;
945     tls_bt_av_audio_payload_t av_audio_payload;
946 } tls_bt_av_msg_t;
947 
948 /** WM BT A2DP SINK callback function */
949 typedef void (*tls_bt_a2dp_sink_callback_t)(tls_bt_av_evt_t event, tls_bt_av_msg_t *p_data);
950 
951 /**WM BT A2DP SRC callback function */
952 typedef void (*tls_bt_a2dp_src_callback_t)(tls_bt_av_evt_t event, tls_bt_av_msg_t *p_data);
953 
954 /** BR-EDR WMBT-RC Controller callback events */
955 
956 #define WM_BTRC_MAX_ATTR_STR_LEN       255
957 #define WM_BTRC_UID_SIZE               8
958 #define WM_BTRC_MAX_APP_SETTINGS       8
959 #define WM_BTRC_MAX_FOLDER_DEPTH       4
960 #define WM_BTRC_MAX_APP_ATTR_SIZE      16
961 #define WM_BTRC_MAX_ELEM_ATTR_SIZE     7
962 
963 typedef uint8_t tls_btrc_uid_t[WM_BTRC_UID_SIZE];
964 typedef enum {
965     WM_BTRC_PLAYSTATE_STOPPED = 0x00,    /* Stopped */
966     WM_BTRC_PLAYSTATE_PLAYING = 0x01,    /* Playing */
967     WM_BTRC_PLAYSTATE_PAUSED = 0x02,    /* Paused  */
968     WM_BTRC_PLAYSTATE_FWD_SEEK = 0x03,    /* Fwd Seek */
969     WM_BTRC_PLAYSTATE_REV_SEEK = 0x04,    /* Rev Seek */
970     WM_BTRC_PLAYSTATE_ERROR = 0xFF,    /* Error   */
971 } tls_btrc_play_status_t;
972 
973 typedef enum {
974     WM_BTRC_FEAT_NONE = 0x00,    /* AVRCP 1.0 */
975     WM_BTRC_FEAT_METADATA = 0x01,    /* AVRCP 1.3 */
976     WM_BTRC_FEAT_ABSOLUTE_VOLUME = 0x02,    /* Supports TG role and volume sync */
977     WM_BTRC_FEAT_BROWSE = 0x04,    /* AVRCP 1.4 and up, with Browsing support */
978 } tls_btrc_remote_features_t;
979 typedef enum {
980     WM_BTRC_NOTIFICATION_TYPE_INTERIM = 0,
981     WM_BTRC_NOTIFICATION_TYPE_CHANGED = 1,
982 } tls_btrc_notification_type_t;
983 
984 typedef enum {
985     WM_BTRC_PLAYER_ATTR_EQUALIZER = 0x01,
986     WM_BTRC_PLAYER_ATTR_REPEAT = 0x02,
987     WM_BTRC_PLAYER_ATTR_SHUFFLE = 0x03,
988     WM_BTRC_PLAYER_ATTR_SCAN = 0x04,
989 } tls_btrc_player_attr_t;
990 
991 typedef enum {
992     WM_BTRC_MEDIA_ATTR_TITLE = 0x01,
993     WM_BTRC_MEDIA_ATTR_ARTIST = 0x02,
994     WM_BTRC_MEDIA_ATTR_ALBUM = 0x03,
995     WM_BTRC_MEDIA_ATTR_TRACK_NUM = 0x04,
996     WM_BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05,
997     WM_BTRC_MEDIA_ATTR_GENRE = 0x06,
998     WM_BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07,
999 } tls_btrc_media_attr_t;
1000 
1001 typedef enum {
1002     WM_BTRC_PLAYER_VAL_OFF_REPEAT = 0x01,
1003     WM_BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02,
1004     WM_BTRC_PLAYER_VAL_ALL_REPEAT = 0x03,
1005     WM_BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04
1006 } tls_btrc_player_repeat_val_t;
1007 
1008 typedef enum {
1009     WM_BTRC_EVT_PLAY_STATUS_CHANGED = 0x01,
1010     WM_BTRC_EVT_TRACK_CHANGE = 0x02,
1011     WM_BTRC_EVT_TRACK_REACHED_END = 0x03,
1012     WM_BTRC_EVT_TRACK_REACHED_START = 0x04,
1013     WM_BTRC_EVT_PLAY_POS_CHANGED = 0x05,
1014     WM_BTRC_EVT_APP_SETTINGS_CHANGED = 0x08,
1015 } tls_btrc_event_id_t;
1016 
1017 typedef struct {
1018     uint8_t num_attr;
1019     uint8_t attr_ids[WM_BTRC_MAX_APP_SETTINGS];
1020     uint8_t attr_values[WM_BTRC_MAX_APP_SETTINGS];
1021 } tls_btrc_player_settings_t;
1022 
1023 typedef struct {
1024     uint32_t attr_id;
1025     uint8_t text[WM_BTRC_MAX_ATTR_STR_LEN];
1026 } tls_btrc_element_attr_val_t;
1027 
1028 typedef struct {
1029     uint8_t attr_id;
1030     uint8_t num_val;
1031     uint8_t attr_val[WM_BTRC_MAX_APP_ATTR_SIZE];
1032 } tls_btrc_player_app_attr_t;
1033 typedef struct {
1034     uint8_t   val;
1035     uint16_t  charset_id;
1036     uint16_t  str_len;
1037     uint8_t   *p_str;
1038 } tls_btrc_player_app_ext_attr_val_t;
1039 
1040 typedef struct {
1041     uint8_t   attr_id;
1042     uint16_t  charset_id;
1043     uint16_t  str_len;
1044     uint8_t   *p_str;
1045     uint8_t   num_val;
1046     tls_btrc_player_app_ext_attr_val_t ext_attr_val[WM_BTRC_MAX_APP_ATTR_SIZE];
1047 } tls_btrc_player_app_ext_attr_t;
1048 
1049 typedef union {
1050     tls_btrc_play_status_t play_status;
1051     tls_btrc_uid_t track; /* queue position in NowPlaying */
1052     uint32_t song_pos;
1053     tls_btrc_player_settings_t player_setting;
1054 } tls_btrc_register_notification_t;
1055 
1056 typedef enum {
1057     WM_BTRC_PASSTHROUGH_RSP_EVT,
1058     WM_BTRC_GROUPNAVIGATION_RSP_EVT,
1059     WM_BTRC_CONNECTION_STATE_EVT,
1060     WM_BTRC_CTRL_GETRCFEATURES_EVT,
1061     WM_BTRC_CTRL_SETPLAYERAPPLICATIONSETTING_RSP_EVT,
1062     WM_BTRC_CTRL_PLAYERAPPLICATIONSETTING_EVT,
1063     WM_BTRC_CTRL_PLAYERAPPLICATIONSETTING_CHANGED_EVT,
1064     WM_BTRC_CTRL_SETABSVOL_CMD_EVT,
1065     WM_BTRC_CTRL_REGISTERNOTIFICATION_ABS_VOL_EVT,
1066     WM_BTRC_CTRL_TRACK_CHANGED_EVT,
1067     WM_BTRC_CTRL_PLAY_POSITION_CHANGED_EVT,
1068     WM_BTRC_CTRL_PLAY_STATUS_CHANGED_EVT,
1069 } tls_btrc_ctrl_evt_t;
1070 
1071 typedef struct {
1072     int id;
1073     int key_state;
1074 } tls_btrc_passthrough_rsp_msg_t;
1075 
1076 typedef struct {
1077     int id;
1078     int key_state;
1079 } tls_btrc_groupnavigation_rsp_msg_t;
1080 
1081 typedef struct {
1082     uint8_t state;
1083     tls_bt_addr_t *bd_addr;
1084 } tls_btrc_connection_state_msg_t;
1085 
1086 typedef struct {
1087     tls_bt_addr_t *bd_addr;
1088     int features;
1089 } tls_btrc_ctrl_getrcfeatures_msg_t;
1090 
1091 typedef struct {
1092     tls_bt_addr_t *bd_addr;
1093     uint8_t abs_vol;
1094     uint8_t label;
1095 } tls_btrc_ctrl_setabsvol_msg_t;
1096 
1097 typedef struct {
1098     tls_bt_addr_t *bd_addr;
1099     uint8_t label;
1100 } tls_btrc_ctrl_registernotification_abs_vol_msg_t;
1101 
1102 typedef struct {
1103     tls_bt_addr_t *bd_addr;
1104     uint8_t accepted;
1105 } tls_btrc_ctrl_setplayerapplicationsetting_rsp_msg_t;
1106 
1107 typedef struct {
1108     tls_bt_addr_t *bd_addr;
1109     uint8_t num_attr;
1110     tls_btrc_player_app_attr_t *app_attrs;
1111     uint8_t num_ext_attr;
1112     tls_btrc_player_app_ext_attr_t *ext_attrs;
1113 } tls_btrc_ctrl_playerapplicationsetting_msg_t;
1114 
1115 typedef struct {
1116     tls_bt_addr_t *bd_addr;
1117     tls_btrc_player_settings_t *p_vals;
1118 } tls_btrc_ctrl_playerapplicationsetting_changed_msg_t;
1119 
1120 typedef struct {
1121     tls_bt_addr_t *bd_addr;
1122     uint8_t num_attr;
1123     tls_btrc_element_attr_val_t *p_attrs;
1124 } tls_btrc_ctrl_track_changed_msg_t;
1125 
1126 typedef struct {
1127     tls_bt_addr_t *bd_addr;
1128     uint32_t song_len;
1129     uint32_t song_pos;
1130 } tls_btrc_ctrl_play_position_changed_msg_t;
1131 
1132 typedef struct {
1133     tls_bt_addr_t *bd_addr;
1134     tls_btrc_play_status_t play_status;
1135 } tls_btrc_ctrl_play_status_changed_msg_t;
1136 
1137 typedef union {
1138     tls_btrc_passthrough_rsp_msg_t              passthrough_rsp;
1139     tls_btrc_groupnavigation_rsp_msg_t          groupnavigation_rsp;
1140     tls_btrc_connection_state_msg_t             connection_state;
1141     tls_btrc_ctrl_getrcfeatures_msg_t           getrcfeatures;
1142     tls_btrc_ctrl_setabsvol_msg_t               setabsvol;
1143     tls_btrc_ctrl_registernotification_abs_vol_msg_t       registernotification_abs_vol;
1144     tls_btrc_ctrl_setplayerapplicationsetting_rsp_msg_t    setplayerapplicationsetting_rsp;
1145     tls_btrc_ctrl_playerapplicationsetting_msg_t           playerapplicationsetting;
1146     tls_btrc_ctrl_playerapplicationsetting_changed_msg_t   playerapplicationsetting_changed;
1147     tls_btrc_ctrl_track_changed_msg_t                      track_changed;
1148     tls_btrc_ctrl_play_position_changed_msg_t  play_position_changed;
1149     tls_btrc_ctrl_play_status_changed_msg_t    play_status_changed;
1150 } tls_btrc_ctrl_msg_t;
1151 
1152 /** WM BT RC CTRL callback function */
1153 typedef void (*tls_btrc_ctrl_callback_t)(tls_btrc_ctrl_evt_t event, tls_btrc_ctrl_msg_t *p_data);
1154 
1155 typedef enum {
1156     WM_BTRC_REMOTE_FEATURE_EVT,
1157     WM_BTRC_GET_PLAY_STATUS_EVT,
1158     WM_BTRC_LIST_PLAYER_APP_ATTR_EVT,
1159     WM_BTRC_LIST_PLAYER_APP_VALUES_EVT,
1160     WM_BTRC_GET_PLAYER_APP_VALUE_EVT,
1161     WM_BTRC_GET_PLAYER_APP_ATTRS_TEXT_EVT,
1162     WM_BTRC_GET_PLAYER_APP_VALUES_TEXT_EVT,
1163     WM_BTRC_SET_PLAYER_APP_VALUE_EVT,
1164     WM_BTRC_GET_ELEMENT_ATTR_EVT,
1165     WM_BTRC_REGISTER_NOTIFICATION_EVT,
1166     WM_BTRC_VOLUME_CHANGED_EVT,
1167     WM_BTRC_PASSTHROUGH_CMD_EVT,
1168 } tls_btrc_evt_t;
1169 
1170 typedef struct {
1171     tls_bt_addr_t *bd_addr;
1172     tls_btrc_remote_features_t features;
1173 } tls_btrc_remote_features_msg_t;
1174 
1175 typedef struct {
1176     void *reserved;
1177 } tls_btrc_get_play_status_msg_t;
1178 
1179 typedef struct {
1180     void *reserved;
1181 } tls_btrc_list_player_app_attr_msg_t;
1182 
1183 typedef struct {
1184     tls_btrc_player_attr_t attr_id;
1185 } tls_btrc_list_player_app_values_msg_t;
1186 
1187 typedef struct {
1188     uint8_t num_attr;
1189     tls_btrc_player_attr_t *p_attrs;
1190 } tls_btrc_get_player_app_value_msg_t;
1191 
1192 typedef struct {
1193     uint8_t attr_id;
1194     uint8_t num_val;
1195     uint8_t *p_vals;
1196 } tls_btrc_get_player_app_attrs_text_msg_t;
1197 
1198 typedef struct {
1199     uint8_t num_attr;
1200     tls_btrc_player_attr_t *p_attrs;
1201 } tls_btrc_get_player_app_values_text_msg_t;
1202 
1203 typedef struct {
1204     tls_btrc_player_settings_t *p_vals;
1205 } tls_btrc_set_player_app_value_msg_t;
1206 
1207 typedef struct {
1208     uint8_t num_attr;
1209     tls_btrc_media_attr_t *p_attrs;
1210 } tls_btrc_get_element_attr_msg_t;
1211 
1212 typedef struct {
1213     tls_btrc_event_id_t event_id;
1214     uint32_t param;
1215 } tls_btrc_register_notification_msg_t;
1216 
1217 typedef struct {
1218     uint8_t volume;
1219     uint8_t ctype;
1220 } tls_btrc_volume_change_msg_t;
1221 
1222 typedef struct {
1223     int id;
1224     int key_state;
1225 } tls_btrc_passthrough_cmd_msg_t;
1226 
1227 typedef union {
1228     tls_btrc_remote_features_msg_t      remote_features;
1229     tls_btrc_get_play_status_msg_t      get_play_status;
1230     tls_btrc_list_player_app_attr_msg_t     list_player_app_attr;
1231     tls_btrc_list_player_app_values_msg_t   list_player_app_values;
1232     tls_btrc_get_player_app_value_msg_t     get_player_app_value;
1233     tls_btrc_get_player_app_attrs_text_msg_t    get_player_app_attrs_text;
1234     tls_btrc_get_player_app_values_text_msg_t   get_player_app_values_text;
1235     tls_btrc_set_player_app_value_msg_t     set_player_app_value;
1236     tls_btrc_get_element_attr_msg_t         get_element_attr;
1237     tls_btrc_register_notification_msg_t    register_notification;
1238     tls_btrc_volume_change_msg_t        volume_change;
1239     tls_btrc_passthrough_cmd_msg_t      passthrough_cmd;
1240 } tls_btrc_msg_t;
1241 
1242 /** WM BT RC callback function */
1243 typedef void (*tls_btrc_callback_t)(tls_btrc_evt_t event, tls_btrc_msg_t *p_data);
1244 
1245 /*************************************************************************************************************/
1246 
1247 typedef enum {
1248     WM_BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED = 0,
1249     WM_BTHF_CLIENT_CONNECTION_STATE_CONNECTING,
1250     WM_BTHF_CLIENT_CONNECTION_STATE_CONNECTED,
1251     WM_BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED,
1252     WM_BTHF_CLIENT_CONNECTION_STATE_DISCONNECTING
1253 } tls_bthf_client_connection_state_t;
1254 
1255 typedef enum {
1256     WM_BTHF_CLIENT_AUDIO_STATE_DISCONNECTED = 0,
1257     WM_BTHF_CLIENT_AUDIO_STATE_CONNECTING,
1258     WM_BTHF_CLIENT_AUDIO_STATE_CONNECTED,
1259     WM_BTHF_CLIENT_AUDIO_STATE_CONNECTED_MSBC,
1260 } tls_bthf_client_audio_state_t;
1261 
1262 typedef enum {
1263     WM_BTHF_CLIENT_VR_STATE_STOPPED = 0,
1264     WM_BTHF_CLIENT_VR_STATE_STARTED
1265 } tls_bthf_client_vr_state_t;
1266 
1267 typedef enum {
1268     WM_BTHF_CLIENT_VOLUME_TYPE_SPK = 0,
1269     WM_BTHF_CLIENT_VOLUME_TYPE_MIC
1270 } tls_bthf_client_volume_type_t;
1271 
1272 typedef enum {
1273     WM_BTHF_CLIENT_NETWORK_STATE_NOT_AVAILABLE = 0,
1274     WM_BTHF_CLIENT_NETWORK_STATE_AVAILABLE
1275 } tls_bthf_client_network_state_t;
1276 
1277 typedef enum {
1278     WM_BTHF_CLIENT_SERVICE_TYPE_HOME = 0,
1279     WM_BTHF_CLIENT_SERVICE_TYPE_ROAMING
1280 } tls_bthf_client_service_type_t;
1281 
1282 typedef enum {
1283     WM_BTHF_CLIENT_CALL_STATE_ACTIVE = 0,
1284     WM_BTHF_CLIENT_CALL_STATE_HELD,
1285     WM_BTHF_CLIENT_CALL_STATE_DIALING,
1286     WM_BTHF_CLIENT_CALL_STATE_ALERTING,
1287     WM_BTHF_CLIENT_CALL_STATE_INCOMING,
1288     WM_BTHF_CLIENT_CALL_STATE_WAITING,
1289     WM_BTHF_CLIENT_CALL_STATE_HELD_BY_RESP_HOLD,
1290 } tls_bthf_client_call_state_t;
1291 
1292 typedef enum {
1293     WM_BTHF_CLIENT_CALL_NO_CALLS_IN_PROGRESS = 0,
1294     WM_BTHF_CLIENT_CALL_CALLS_IN_PROGRESS
1295 } tls_bthf_client_call_t;
1296 
1297 typedef enum {
1298     WM_BTHF_CLIENT_CALLSETUP_NONE = 0,
1299     WM_BTHF_CLIENT_CALLSETUP_INCOMING,
1300     WM_BTHF_CLIENT_CALLSETUP_OUTGOING,
1301     WM_BTHF_CLIENT_CALLSETUP_ALERTING
1302 } tls_bthf_client_callsetup_t;
1303 
1304 typedef enum {
1305     WM_BTHF_CLIENT_CALLHELD_NONE = 0,
1306     WM_BTHF_CLIENT_CALLHELD_HOLD_AND_ACTIVE,
1307     WM_BTHF_CLIENT_CALLHELD_HOLD,
1308 } tls_bthf_client_callheld_t;
1309 
1310 typedef enum {
1311     WM_BTHF_CLIENT_RESP_AND_HOLD_HELD = 0,
1312     WM_BTRH_CLIENT_RESP_AND_HOLD_ACCEPT,
1313     WM_BTRH_CLIENT_RESP_AND_HOLD_REJECT,
1314 } tls_bthf_client_resp_and_hold_t;
1315 
1316 typedef enum {
1317     WM_BTHF_CLIENT_CALL_DIRECTION_OUTGOING = 0,
1318     WM_BTHF_CLIENT_CALL_DIRECTION_INCOMING
1319 } tls_bthf_client_call_direction_t;
1320 
1321 typedef enum {
1322     WM_BTHF_CLIENT_CALL_MPTY_TYPE_SINGLE = 0,
1323     WM_BTHF_CLIENT_CALL_MPTY_TYPE_MULTI
1324 } tls_bthf_client_call_mpty_type_t;
1325 
1326 typedef enum {
1327     WM_BTHF_CLIENT_CMD_COMPLETE_OK = 0,
1328     WM_BTHF_CLIENT_CMD_COMPLETE_ERROR,
1329     WM_BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_CARRIER,
1330     WM_BTHF_CLIENT_CMD_COMPLETE_ERROR_BUSY,
1331     WM_BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_ANSWER,
1332     WM_BTHF_CLIENT_CMD_COMPLETE_ERROR_DELAYED,
1333     WM_BTHF_CLIENT_CMD_COMPLETE_ERROR_BLACKLISTED,
1334     WM_BTHF_CLIENT_CMD_COMPLETE_ERROR_CME
1335 } tls_bthf_client_cmd_complete_t;
1336 
1337 typedef enum {
1338     WM_BTHF_CLIENT_CALL_ACTION_CHLD_0 = 0,
1339     WM_BTHF_CLIENT_CALL_ACTION_CHLD_1,
1340     WM_BTHF_CLIENT_CALL_ACTION_CHLD_2,
1341     WM_BTHF_CLIENT_CALL_ACTION_CHLD_3,
1342     WM_BTHF_CLIENT_CALL_ACTION_CHLD_4,
1343     WM_BTHF_CLIENT_CALL_ACTION_CHLD_1x,
1344     WM_BTHF_CLIENT_CALL_ACTION_CHLD_2x,
1345     WM_BTHF_CLIENT_CALL_ACTION_ATA,
1346     WM_BTHF_CLIENT_CALL_ACTION_CHUP,
1347     WM_BTHF_CLIENT_CALL_ACTION_BTRH_0,
1348     WM_BTHF_CLIENT_CALL_ACTION_BTRH_1,
1349     WM_BTHF_CLIENT_CALL_ACTION_BTRH_2,
1350 } tls_bthf_client_call_action_t;
1351 
1352 typedef enum {
1353     WM_BTHF_CLIENT_SERVICE_UNKNOWN = 0,
1354     WM_BTHF_CLIENT_SERVICE_VOICE,
1355     WM_BTHF_CLIENT_SERVICE_FAX
1356 } tls_bthf_client_subscriber_service_type_t;
1357 
1358 typedef enum {
1359     WM_BTHF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED = 0,
1360     WM_BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED,
1361 } tls_bthf_client_in_band_ring_state_t;
1362 
1363 /* Peer features masks */
1364 #define WM_BTHF_CLIENT_PEER_FEAT_3WAY   0x00000001  /* Three-way calling */
1365 #define WM_BTHF_CLIENT_PEER_FEAT_ECNR   0x00000002  /* Echo cancellation and/or noise reduction */
1366 #define WM_BTHF_CLIENT_PEER_FEAT_VREC   0x00000004  /* Voice recognition */
1367 #define WM_BTHF_CLIENT_PEER_FEAT_INBAND 0x00000008  /* In-band ring tone */
1368 #define WM_BTHF_CLIENT_PEER_FEAT_VTAG   0x00000010  /* Attach a phone number to a voice tag */
1369 #define WM_BTHF_CLIENT_PEER_FEAT_REJECT 0x00000020  /* Ability to reject incoming call */
1370 #define WM_BTHF_CLIENT_PEER_FEAT_ECS    0x00000040  /* Enhanced Call Status */
1371 #define WM_BTHF_CLIENT_PEER_FEAT_ECC    0x00000080  /* Enhanced Call Control */
1372 #define WM_BTHF_CLIENT_PEER_FEAT_EXTERR 0x00000100  /* Extended error codes */
1373 #define WM_BTHF_CLIENT_PEER_FEAT_CODEC  0x00000200  /* Codec Negotiation */
1374 
1375 /* Peer call handling features masks */
1376 #define WM_BTHF_CLIENT_CHLD_FEAT_REL           0x00000001  /* 0  Release waiting call or held calls */
1377 #define WM_BTHF_CLIENT_CHLD_FEAT_REL_ACC       0x00000002  /* 1  Release active calls and accept other
1378                                                               (waiting or held) cal */
1379 #define WM_BTHF_CLIENT_CHLD_FEAT_REL_X         0x00000004  /* 1x Release specified active call only */
1380 #define WM_BTHF_CLIENT_CHLD_FEAT_HOLD_ACC      0x00000008  /* 2  Active calls on hold and accept other
1381                                                               (waiting or held) call */
1382 #define WM_BTHF_CLIENT_CHLD_FEAT_PRIV_X        0x00000010  /* 2x Request private mode with specified
1383                                                               call (put the rest on hold) */
1384 #define WM_BTHF_CLIENT_CHLD_FEAT_MERGE         0x00000020  /* 3  Add held call to multiparty */
1385 #define WM_BTHF_CLIENT_CHLD_FEAT_MERGE_DETACH  0x00000040  /* 4  Connect two calls and leave
1386 
1387 typedef enum
1388 {
1389     WM_BTHF_CLIENT_CONNECTION_STATE_EVT,
1390     WM_BTHF_CLIENT_AUDIO_STATE_EVT,
1391     WM_BTHF_CLIENT_VR_CMD_EVT,
1392     WM_BTHF_CLIENT_NETWORK_STATE_EVT,
1393     WM_BTHF_CLIENT_NETWORK_ROAMING_EVT,
1394     WM_BTHF_CLIENT_NETWORK_SIGNAL_EVT,
1395     WM_BTHF_CLIENT_BATTERY_LEVEL_EVT,
1396     WM_BTHF_CLIENT_CURRENT_OPERATOR_EVT,
1397     WM_BTHF_CLIENT_CALL_EVT,
1398     WM_BTHF_CLIENT_CALLSETUP_EVT,
1399     WM_BTHF_CLIENT_CALLHELD_EVT,
1400     WM_BTHF_CLIENT_RESP_AND_HOLD_EVT,
1401     WM_BTHF_CLIENT_CLIP_EVT,
1402     WM_BTHF_CLIENT_CALL_WAITING_EVT,
1403     WM_BTHF_CLIENT_CURRENT_CALLS_EVT,
1404     WM_BTHF_CLIENT_VOLUME_CHANGE_EVT,
1405     WM_BTHF_CLIENT_CMD_COMPLETE_EVT,
1406     WM_BTHF_CLIENT_SUBSCRIBER_INFO_EVT,
1407     WM_BTHF_CLIENT_IN_BAND_RING_TONE_EVT,
1408     WM_BTHF_CLIENT_LAST_VOICE_TAG_NUMBER_EVT,
1409     WM_BTHF_CLIENT_RING_INDICATION_EVT,
1410     WM_BTHF_CLIENT_AUDIO_PAYLOAD_EVT,
1411 } tls_bthf_client_evt_t;
1412 
1413 typedef struct
1414 {
1415     tls_bthf_client_connection_state_t state;
1416     unsigned int peer_feat;
1417     unsigned int chld_feat;
1418     tls_bt_addr_t *bd_addr;
1419 } tls_bthf_client_connection_state_msg_t;
1420 
1421 typedef struct
1422 {
1423     tls_bthf_client_audio_state_t state;
1424     tls_bt_addr_t *bd_addr;
1425 } tls_bthf_client_audio_state_msg_t;
1426 
1427 typedef struct
1428 {
1429     tls_bthf_client_vr_state_t state;
1430 
1431 } tls_bthf_client_vr_cmd_msg_t;
1432 
1433 typedef struct
1434 {
1435     tls_bthf_client_network_state_t state;
1436 
1437 } tls_bthf_client_network_state_msg_t;
1438 
1439 typedef struct
1440 {
1441     tls_bthf_client_service_type_t type;
1442 
1443 } tls_bthf_client_network_roaming_msg_t;
1444 
1445 typedef struct
1446 {
1447     int signal_strength;
1448 
1449 } tls_bthf_client_network_signal_msg_t;
1450 
1451 typedef struct
1452 {
1453     int battery_level;
1454 
1455 } tls_bthf_client_battery_level_msg_t;
1456 
1457 typedef struct
1458 {
1459     char* name;
1460 
1461 } tls_bthf_client_current_operator_msg_t;
1462 
1463 typedef struct
1464 {
1465     tls_bthf_client_call_t call;
1466 
1467 } tls_bthf_client_call_msg_t;
1468 
1469 typedef struct
1470 {
1471     tls_bthf_client_callsetup_t callsetup;
1472 
1473 } tls_bthf_client_callsetup_msg_t;
1474 
1475 typedef struct
1476 {
1477     tls_bthf_client_callheld_t callheld;
1478 
1479 } tls_bthf_client_callheld_msg_t;
1480 
1481 typedef struct
1482 {
1483     tls_bthf_client_resp_and_hold_t resp_and_hold;
1484 
1485 } tls_bthf_client_resp_and_hold_msg_t;
1486 
1487 typedef struct
1488 {
1489     char *number;
1490 
1491 } tls_bthf_client_clip_msg_t;
1492 
1493 typedef struct
1494 {
1495     char *number;
1496 
1497 } tls_bthf_client_call_waiting_msg_t;
1498 
1499 typedef struct
1500 {
1501     int index;
1502     tls_bthf_client_call_direction_t dir;
1503     tls_bthf_client_call_state_t state;
1504     tls_bthf_client_call_mpty_type_t mpty;
1505     char *number;
1506 } tls_bthf_client_current_calls_msg_t;
1507 
1508 typedef struct
1509 {
1510     tls_bthf_client_volume_type_t type;
1511     int volume;
1512 
1513 } tls_bthf_client_volume_change_msg_t;
1514 
1515 typedef struct
1516 {
1517     tls_bthf_client_cmd_complete_t type;
1518     int cme;
1519 
1520 } tls_bthf_client_cmd_complete_msg_t;
1521 
1522 typedef struct
1523 {
1524     const char *name;
1525     tls_bthf_client_subscriber_service_type_t type;
1526 
1527 } tls_bthf_client_subscriber_info_msg_t;
1528 
1529 typedef struct
1530 {
1531     tls_bthf_client_in_band_ring_state_t state;
1532 
1533 } tls_bthf_client_in_band_ring_tone_msg_t;
1534 
1535 typedef struct
1536 {
1537     char *number;
1538 
1539 } tls_bthf_client_last_voice_tag_number_msg_t;
1540 
1541 typedef struct
1542 {
1543     int ring;
1544 
1545 } tls_bthf_client_ring_indication_msg_t;
1546 
1547 typedef struct
1548 {
1549     tls_bt_addr_t *bd_addr;
1550     uint8_t audio_format;
1551     uint8_t *payload;
1552     uint16_t payload_length;
1553 
1554 typedef union
1555 {
1556     tls_bthf_client_connection_state_msg_t  connection_state_msg;
1557     tls_bthf_client_audio_state_msg_t       audio_state_msg;
1558     tls_bthf_client_vr_cmd_msg_t            vr_cmd_msg;
1559     tls_bthf_client_network_state_msg_t     network_state_msg;
1560     tls_bthf_client_network_roaming_msg_t   network_roaming_msg;
1561     tls_bthf_client_network_signal_msg_t    network_signal_msg;
1562     tls_bthf_client_battery_level_msg_t     battery_level_msg;
1563     tls_bthf_client_current_operator_msg_t  current_operator_msg;
1564     tls_bthf_client_call_msg_t              call_msg;
1565     tls_bthf_client_callsetup_msg_t         callsetup_msg;
1566     tls_bthf_client_callheld_msg_t          callheld_msg;
1567     tls_bthf_client_resp_and_hold_msg_t     resp_and_hold_msg;
1568     tls_bthf_client_clip_msg_t              clip_msg;
1569     tls_bthf_client_call_waiting_msg_t      call_waiting_msg;
1570     tls_bthf_client_current_calls_msg_t     current_calls_msg;
1571     tls_bthf_client_volume_change_msg_t     volume_change_msg;
1572     tls_bthf_client_cmd_complete_msg_t      cmd_complete_msg;
1573     tls_bthf_client_subscriber_info_msg_t   subscriber_info_msg;
1574     tls_bthf_client_in_band_ring_tone_msg_t in_band_ring_tone_msg;
1575     tls_bthf_client_last_voice_tag_number_msg_t last_voice_tag_number_msg;
1576     tls_bthf_client_ring_indication_msg_t   ring_indication_msg;
1577     tls_bthf_audio_payload_msg_t            audio_payload_msg;
1578 
1579 } tls_bthf_client_msg_t;
1580 
1581 /** WM BT HFP CLIENT callback function */
1582 
1583 /******************************************************************************************/
1584 /* Security Setting Mask */
1585 #define WM_SPP_SEC_NONE          0x0000  /* No security */
1586 #define WM_SPP_SEC_AUTHORIZE     0x0001  /* Authorization required (only needed for out going connection ) */
1587 #define WM_SPP_SEC_AUTHENTICATE  0x0012  /* Authentication required */
1588 #define WM_SPP_SEC_ENCRYPT       0x0024  /* Encryption required */
1589 #define WM_SPP_SEC_MODE4_LEVEL4  0x0040  /* Mode 4 level 4 service, i.e. incoming/outgoing MITM and P-256 encryption */
1590 #define WM_SPP_SEC_MITM          0x3000  /* Man-In-The_Middle protection */
1591 #define WM_SPP_SEC_IN_16_DIGITS  0x4000  /* Min 16 digit for pin code */
1592 typedef uint16_t wm_spp_sec_t;
1593 
1594 #define WM_SPP_MAX_SCN             31
1595 
1596 typedef enum {
1597     WM_SPP_ROLE_CLIENT     = 0,
1598     WM_SPP_ROLE_SERVER      = 1,
1599 } tls_spp_role_t;
1600 
1601 typedef enum {
1602     WM_SPP_INIT_EVT                    = 0,
1603     WM_SPP_DISCOVERY_COMP_EVT          = 8,
1604     WM_SPP_OPEN_EVT                    = 26,
1605     WM_SPP_CLOSE_EVT                   = 27,
1606     WM_SPP_START_EVT                   = 28,
1607     WM_SPP_CL_INIT_EVT                 = 29,
1608     WM_SPP_DATA_IND_EVT                = 30,
1609     WM_SPP_CONG_EVT                    = 31,
1610     WM_SPP_WRITE_EVT                   = 33,
1611     WM_SPP_SRV_OPEN_EVT                = 34,
1612 } tls_spp_event_t;
1613 
1614 typedef struct {
1615     uint8_t    status;
1616 } tls_spp_init_msg_t ;
1617 
1618 typedef struct {
1619     uint8_t    status;
1620     uint8_t    scn_num;
1621     uint8_t    scn[WM_SPP_MAX_SCN];
1622 } tls_spp_disc_comp_msg_t;
1623 
1624 typedef struct {
1625         uint8_t      status;
1626         uint32_t     handle;
1627         uint8_t     addr[6];
1628 } tls_spp_open_msg_t;
1629 
1630 typedef struct {
1631         uint8_t    status;
1632         uint32_t   handle;
1633         uint32_t   new_listen_handle;
1634         uint8_t     addr[6];
1635 } tls_spp_srv_open_msg_t;
1636 
1637 typedef struct {
1638         uint8_t    status;
1639         uint32_t   port_status;
1640         uint32_t   handle;
1641         bool       local;
1642 } tls_spp_close_msg_t;
1643 
1644 typedef struct {
1645         uint8_t    status;
1646         uint32_t   handle;
1647         uint8_t    sec_id;
1648         bool       use_co_rfc;
1649 } tls_spp_start_msg_t;
1650 
1651 typedef struct {
1652         uint8_t    status;
1653         uint32_t   handle;
1654         uint8_t    sec_id;
1655         bool       use_co_rfc;
1656 } tls_spp_cli_init_msg_t;
1657 
1658 typedef struct {
1659         uint8_t    status;
1660         uint32_t   handle;
1661         int        length;
1662         bool       congest;
1663 } tls_spp_write_msg_t;
1664 
1665 typedef struct {
1666         uint8_t    status;
1667         uint32_t   handle;
1668         uint16_t   length;
1669         uint8_t    *data;
1670 } tls_spp_data_ind_msg_t;
1671 
1672 typedef struct {
1673         uint8_t    status;
1674         uint32_t   handle;
1675         bool       congest;
1676 } tls_spp_cong_msg_t;
1677 
1678 typedef union {
1679     tls_spp_init_msg_t              init_msg;
1680     tls_spp_disc_comp_msg_t         disc_comp_msg;
1681     tls_spp_open_msg_t              open_msg;
1682     tls_spp_srv_open_msg_t          srv_open_msg;
1683     tls_spp_close_msg_t             close_msg;
1684     tls_spp_start_msg_t             start_msg;
1685     tls_spp_cli_init_msg_t          cli_init_msg;
1686     tls_spp_write_msg_t             write_msg;
1687     tls_spp_data_ind_msg_t          data_ind_msg;
1688     tls_spp_cong_msg_t              congest_msg;
1689 } tls_spp_msg_t;
1690 
1691 /** WM BT SPP callback function */
1692 typedef void (*tls_bt_spp_callback_t)(tls_spp_event_t event, tls_spp_msg_t *p_data);
1693 
1694 typedef enum {
1695     BLE_UART_SERVER_MODE,
1696     BLE_UART_CLIENT_MODE,
1697     BLE_UART_UNKNOWN_MODE,
1698 } tls_ble_uart_mode_t;
1699 
1700 typedef void (*tls_ble_output_func_ptr)(uint8_t *p_data, uint32_t length);
1701 #define TLS_HAL_CBACK(P_CB, P_CBACK, ...) \
1702     if (P_CB && P_CB->P_CBACK) {            \
1703         P_CB->P_CBACK(__VA_ARGS__);         \
1704     } else {                                  \
1705         assert(0);  \
1706     }
1707 
1708 #endif /* WM_BT_DEF_H */