1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
24
25
26
27
28
34
35
38
39
48
61
70
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
102
108
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
142
143
144
145
146
147
148
149
150
151
152
153
154
155
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
189
190
191
192
193
194
195
196
197
198
199
200
211
212
213
214
215
216
217
218
219
220
221
230
231
232
233
234
235
236
237
238
239
249
250
251
252
253
254
255
256
257
258
268
269
270
271
272
273
274
275
276
277
287
/* ... */
/* ... */
#include "common/bt_target.h"
#if defined(BTA_HD_INCLUDED) && (BTA_HD_INCLUDED == TRUE)
#include "bta/bta_hd_api.h"
#include "bta_hd_int.h"
#include "osi/allocator.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>6 includes
/* ... */
static const tBTA_SYS_REG bta_hd_reg = {bta_hd_hdl_event, BTA_HdDisable};
/* ... */
void BTA_HdEnable(tBTA_HD_CBACK *p_cback)
{
tBTA_HD_API_ENABLE *p_buf;
APPL_TRACE_API("%s", __func__);
bta_sys_register(BTA_ID_HD, &bta_hd_reg);
p_buf = (tBTA_HD_API_ENABLE *)osi_malloc((uint16_t)sizeof(tBTA_HD_API_ENABLE));
if (p_buf != NULL) {
memset(p_buf, 0, sizeof(tBTA_HD_API_ENABLE));
p_buf->hdr.event = BTA_HD_API_ENABLE_EVT;
p_buf->p_cback = p_cback;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
void BTA_HdDisable(void)
{
BT_HDR *p_buf;
APPL_TRACE_API("%s", __func__);
bta_sys_deregister(BTA_ID_HD);
if ((p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_HD_API_DISABLE_EVT;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
extern void BTA_HdRegisterApp(tBTA_HD_APP_INFO *p_app_info, tBTA_HD_QOS_INFO *p_in_qos, tBTA_HD_QOS_INFO *p_out_qos)
{
tBTA_HD_REGISTER_APP *p_buf;
APPL_TRACE_API("%s", __func__);
if ((p_buf = (tBTA_HD_REGISTER_APP *)osi_malloc(sizeof(tBTA_HD_REGISTER_APP))) != NULL) {
p_buf->hdr.event = BTA_HD_API_REGISTER_APP_EVT;
if (p_app_info->p_name) {
strncpy(p_buf->name, p_app_info->p_name, BTA_HD_APP_NAME_LEN);
p_buf->name[BTA_HD_APP_NAME_LEN] = '\0';
}{...} else {
p_buf->name[0] = '\0';
}{...}
if (p_app_info->p_description) {
strncpy(p_buf->description, p_app_info->p_description, BTA_HD_APP_DESCRIPTION_LEN);
p_buf->description[BTA_HD_APP_DESCRIPTION_LEN] = '\0';
}{...} else {
p_buf->description[0] = '\0';
}{...}
if (p_app_info->p_provider) {
strncpy(p_buf->provider, p_app_info->p_provider, BTA_HD_APP_PROVIDER_LEN);
p_buf->provider[BTA_HD_APP_PROVIDER_LEN] = '\0';
}{...} else {
p_buf->provider[0] = '\0';
}{...}
p_buf->subclass = p_app_info->subclass;
p_buf->d_len = p_app_info->descriptor.dl_len;
memcpy(p_buf->d_data, p_app_info->descriptor.dsc_list, p_app_info->descriptor.dl_len);
memcpy(&p_buf->in_qos, p_in_qos, sizeof(tBTA_HD_QOS_INFO));
memcpy(&p_buf->out_qos, p_out_qos, sizeof(tBTA_HD_QOS_INFO));
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
extern void BTA_HdUnregisterApp(void)
{
BT_HDR *p_buf;
APPL_TRACE_API("%s", __func__);
if ((p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_HD_API_UNREGISTER_APP_EVT;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
extern void BTA_HdSendReport(tBTA_HD_REPORT *p_report)
{
tBTA_HD_SEND_REPORT *p_buf;
APPL_TRACE_VERBOSE("%s", __func__);
if (p_report->len > BTA_HD_REPORT_LEN) {
APPL_TRACE_WARNING("%s, report len (%d) > MTU len (%d), can't send report."
" Increase value of HID_DEV_MTU_SIZE to send larger reports",
__func__, p_report->len, BTA_HD_REPORT_LEN);
return;
}{...}
if ((p_buf = (tBTA_HD_SEND_REPORT *)osi_malloc(sizeof(tBTA_HD_SEND_REPORT))) != NULL) {
p_buf->hdr.event = BTA_HD_API_SEND_REPORT_EVT;
p_buf->use_intr = p_report->use_intr;
p_buf->type = p_report->type;
p_buf->id = p_report->id;
p_buf->len = p_report->len;
memcpy(p_buf->data, p_report->p_data, p_report->len);
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
extern void BTA_HdVirtualCableUnplug(void)
{
BT_HDR *p_buf;
APPL_TRACE_API("%s", __func__);
if ((p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_HD_API_VC_UNPLUG_EVT;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
extern void BTA_HdConnect(BD_ADDR addr)
{
tBTA_HD_DEVICE_CTRL *p_buf;
APPL_TRACE_API("%s", __func__);
if ((p_buf = (tBTA_HD_DEVICE_CTRL *)osi_malloc(sizeof(tBTA_HD_DEVICE_CTRL))) != NULL) {
p_buf->hdr.event = BTA_HD_API_CONNECT_EVT;
memcpy(p_buf->addr, addr, sizeof(BD_ADDR));
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
extern void BTA_HdDisconnect(void)
{
BT_HDR *p_buf;
APPL_TRACE_API("%s", __func__);
if ((p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_HD_API_DISCONNECT_EVT;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
extern void BTA_HdAddDevice(BD_ADDR addr)
{
tBTA_HD_DEVICE_CTRL *p_buf;
APPL_TRACE_API("%s", __func__);
if ((p_buf = (tBTA_HD_DEVICE_CTRL *)osi_malloc(sizeof(tBTA_HD_DEVICE_CTRL))) != NULL) {
p_buf->hdr.event = BTA_HD_API_ADD_DEVICE_EVT;
memcpy(p_buf->addr, addr, sizeof(BD_ADDR));
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
extern void BTA_HdRemoveDevice(BD_ADDR addr)
{
tBTA_HD_DEVICE_CTRL *p_buf;
APPL_TRACE_API("%s", __func__);
if ((p_buf = (tBTA_HD_DEVICE_CTRL *)osi_malloc(sizeof(tBTA_HD_DEVICE_CTRL))) != NULL) {
p_buf->hdr.event = BTA_HD_API_REMOVE_DEVICE_EVT;
memcpy(p_buf->addr, addr, sizeof(BD_ADDR));
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */
extern void BTA_HdReportError(uint8_t error)
{
tBTA_HD_REPORT_ERR *p_buf;
APPL_TRACE_API("%s", __func__);
if ((p_buf = (tBTA_HD_REPORT_ERR *)osi_malloc(sizeof(tBTA_HD_REPORT_ERR))) != NULL) {
p_buf->hdr.event = BTA_HD_API_REPORT_ERROR_EVT;
p_buf->error = error;
bta_sys_sendmsg(p_buf);
}{...}
}{...}
/* ... */#endif