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 { BTC_HD_DISABLED = 0, BTC_HD_ENABLED, BTC_HD_DISABLING } BTC_HD_STATUS;
43 
44 /* BTIF-HD control block */
45 typedef struct {
46     BTC_HD_STATUS status;
47     bool app_registered;
48     bool service_dereg_active;
49     bool forced_disc;
50     tBTA_HD_APP_INFO app_info;
51     tBTA_HD_QOS_INFO in_qos;
52     tBTA_HD_QOS_INFO out_qos;
53 } btc_hd_cb_t;
54 
55 /* btc_hidd_args_t */
56 typedef union {
57     // BTC_HD_CONNECT_EVT
58     struct connect_arg {
59         BD_ADDR bd_addr;
60     } connect;
61 
62     // BTC_HD_REGISTER_APP_EVT
63     struct register_app_arg {
64         esp_hidd_app_param_t *app_param;
65         esp_hidd_qos_param_t *in_qos;
66         esp_hidd_qos_param_t *out_qos;
67     } register_app;
68 
69     // BTC_HD_SEND_REPORT_EVT
70     struct send_report_arg {
71         esp_hidd_report_type_t type;
72         uint8_t id;
73         uint16_t len;
74         uint8_t *data;
75     } send_report;
76 
77     // BTC_HD_REPORT_ERROR_EVT
78     uint8_t error;
79 } btc_hidd_args_t;
80 
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 
85 /******************************************************************************
86  * Functions
87  ******************************************************************************/
88 void btc_hd_call_handler(btc_msg_t *msg);
89 
90 void btc_hd_cb_handler(btc_msg_t *msg);
91 
92 // extern btc_hd_cb_t btc_hd_cb;
93 // extern void btc_hd_remove_device(bt_bdaddr_t bd_addr);
94 // extern void btc_hd_service_registration();
95 
96 void btc_hd_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif /* BTC_HD_INCLUDED == TRUE */
103 #endif /* BTC_HD_H */
104