1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
49
50
51
52
53
54
55
64
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
117
120
123
124
127
130
133
136
138
139
140
141
/* ... */
#include <string.h>
#include "common/bt_target.h"
#include "gap_int.h"
#if (CLASSIC_BT_INCLUDED == TRUE)
/* ... */
tGAP_INFO *gap_allocate_cb (void)
{
tGAP_INFO *p_cb = &gap_cb.blk[0];
UINT8 x;
for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++) {
if (!p_cb->in_use) {
memset (p_cb, 0, sizeof (tGAP_INFO));
p_cb->in_use = TRUE;
p_cb->index = x;
p_cb->p_data = (void *)NULL;
return (p_cb);
}{...}
}{...}
return (NULL);
}{...}
/* ... */
void gap_free_cb (tGAP_INFO *p_cb)
{
if (p_cb) {
p_cb->gap_cback = NULL;
p_cb->in_use = FALSE;
}{...}
}{...}
/* ... */
BOOLEAN gap_is_service_busy (UINT16 request)
{
tGAP_INFO *p_cb = &gap_cb.blk[0];
UINT8 x;
for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++) {
if (p_cb->in_use && p_cb->event == request) {
return (TRUE);
}{...}
}{...}
return (FALSE);
}{...}
/* ... */
UINT16 gap_convert_btm_status (tBTM_STATUS btm_status)
{
switch (btm_status) {
case BTM_SUCCESS:
return (BT_PASS);
...
case BTM_CMD_STARTED:
return (GAP_CMD_INITIATED);
...
case BTM_BUSY:
return (GAP_ERR_BUSY);
...
case BTM_MODE_UNSUPPORTED:
case BTM_ILLEGAL_VALUE:
return (GAP_ERR_ILL_PARM);
...
case BTM_WRONG_MODE:
return (GAP_DEVICE_NOT_UP);
...
case BTM_UNKNOWN_ADDR:
return (GAP_BAD_BD_ADDR);
...
case BTM_DEVICE_TIMEOUT:
return (GAP_ERR_TIMEOUT);
...
default:
return (GAP_ERR_PROCESSING);...
}{...}
}{...}
/* ... */
#endif