1 /******************************************************************************
2  *
3  *  Copyright (C) 2016 The Android Open Source Project
4  *  Copyright (C) 2009-2012 Broadcom Corporation
5  *  Copyright (C) 2019 Blake Felt
6  *
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at:
10  *
11  *  http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *
19  ******************************************************************************/
20 #ifndef BTC_HD_H
21 #define BTC_HD_H
22 
23 #if BTC_HD_INCLUDED == TRUE
24 
25 #include <stdint.h>
26 #include "bta/bta_hd_api.h"
27 #include "btc/btc_task.h"
28 #include "esp_hidd_api.h"
29 
30 typedef enum {
31     BTC_HD_INIT_EVT = 0,
32     BTC_HD_DEINIT_EVT,
33     BTC_HD_REGISTER_APP_EVT,
34     BTC_HD_UNREGISTER_APP_EVT,
35     BTC_HD_CONNECT_EVT,
36     BTC_HD_DISCONNECT_EVT,
37     BTC_HD_SEND_REPORT_EVT,
38     BTC_HD_REPORT_ERROR_EVT,
39     BTC_HD_UNPLUG_EVT,
40 } BTC_HD_EVT;
41 
42 typedef enum {
43     BTC_HD_DISABLED = 0,
44     BTC_HD_ENABLED,
45     BTC_HD_DISABLING,
46     BTC_HD_CONNECTING,
47     BTC_HD_CONNECTED,
48     BTC_HD_DISCONNECTING,
49     BTC_HD_DISCONNECTED,
50 } BTC_HD_STATUS;
51 
52 /* BTIF-HD control block */
53 typedef struct {
54     BTC_HD_STATUS status;
55     bool app_registered;
56     bool service_dereg_active;
57     bool forced_disc;
58     tBTA_HD_APP_INFO app_info;
59     tBTA_HD_QOS_INFO in_qos;
60     tBTA_HD_QOS_INFO out_qos;
61 } btc_hd_cb_t;
62 
63 /* btc_hidd_args_t */
64 typedef union {
65     // BTC_HD_CONNECT_EVT
66     struct hd_connect_arg {
67         BD_ADDR bd_addr;
68     } connect;
69 
70     // BTC_HD_REGISTER_APP_EVT
71     struct register_app_arg {
72         esp_hidd_app_param_t *app_param;
73         esp_hidd_qos_param_t *in_qos;
74         esp_hidd_qos_param_t *out_qos;
75     } register_app;
76 
77     // BTC_HD_SEND_REPORT_EVT
78     struct send_report_arg {
79         esp_hidd_report_type_t type;
80         uint8_t id;
81         uint16_t len;
82         uint8_t *data;
83     } send_report;
84 
85     // BTC_HD_REPORT_ERROR_EVT
86     uint8_t error;
87 } btc_hidd_args_t;
88 
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
92 
93 /******************************************************************************
94  * Functions
95  ******************************************************************************/
96 void btc_hd_call_handler(btc_msg_t *msg);
97 
98 void btc_hd_cb_handler(btc_msg_t *msg);
99 
100 // extern btc_hd_cb_t btc_hd_cb;
101 // extern void btc_hd_remove_device(bt_bdaddr_t bd_addr);
102 // extern void btc_hd_service_registration();
103 
104 void btc_hd_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
105 void btc_hd_cb_arg_deep_free(btc_msg_t *msg);
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* BTC_HD_INCLUDED == TRUE */
112 #endif /* BTC_HD_H */
113