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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
|
/******************************************************************************
*
* Copyright (C) 2003-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/******************************************************************************
*
* Routes connection status callbacks from various sub systems to DM
*
******************************************************************************/
#include "bta_api.h"
#include "bta_sys.h"
#include "bta_sys_int.h"
#include "gki.h"
/*******************************************************************************
**
** Function bta_sys_rm_register
**
** Description Called by BTA DM to register role management callbacks
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_rm_register(tBTA_SYS_CONN_CBACK * p_cback)
{
bta_sys_cb.prm_cb = p_cback;
}
/*******************************************************************************
**
** Function bta_sys_policy_register
**
** Description Called by BTA DM to register link policy change callbacks
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_policy_register(tBTA_SYS_CONN_CBACK * p_cback)
{
bta_sys_cb.p_policy_cb = p_cback;
}
/*******************************************************************************
**
** Function bta_sys_role_chg_register
**
** Description Called by BTA AV to register role change callbacks
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK * p_cback)
{
bta_sys_cb.p_role_cb = p_cback;
}
/*******************************************************************************
**
** Function bta_sys_ssr_cfg_register
**
** Description Called by BTA DM to register SSR configuration callback
**
**
** Returns void
**
*******************************************************************************/
#if (BTM_SSR_INCLUDED == TRUE)
void bta_sys_ssr_cfg_register(tBTA_SYS_SSR_CFG_CBACK * p_cback)
{
bta_sys_cb.p_ssr_cb = p_cback;
}
#endif
/*******************************************************************************
**
** Function bta_sys_role_chg_register
**
** Description Called by BTA AV to register role change callbacks
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_notify_role_chg(BD_ADDR_PTR p_bda, UINT8 new_role, UINT8 hci_status)
{
if (bta_sys_cb.p_role_cb)
{
bta_sys_cb.p_role_cb(BTA_SYS_ROLE_CHANGE, new_role, hci_status, p_bda);
}
}
/*******************************************************************************
**
** Function bta_sys_collision_register
**
** Description Called by any BTA module to register for collision event.
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_collision_register(UINT8 bta_id, tBTA_SYS_CONN_CBACK *p_cback)
{
UINT8 index;
for (index = 0; index < MAX_COLLISION_REG; index++)
{
if ((bta_sys_cb.colli_reg.id[index] == bta_id) ||
(bta_sys_cb.colli_reg.id[index] == 0))
{
bta_sys_cb.colli_reg.id[index] = bta_id;
bta_sys_cb.colli_reg.p_coll_cback[index] = p_cback;
return;
}
}
}
/*******************************************************************************
**
** Function bta_sys_notify_collision
**
** Description Called by BTA DM to notify collision event.
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_notify_collision (BD_ADDR_PTR p_bda)
{
UINT8 index;
for (index = 0; index < MAX_COLLISION_REG; index++)
{
if ((bta_sys_cb.colli_reg.id[index] != 0) &&
(bta_sys_cb.colli_reg.p_coll_cback[index] != NULL))
{
bta_sys_cb.colli_reg.p_coll_cback[index] (0, BTA_ID_SYS, 0, p_bda);
}
}
}
/*******************************************************************************
**
** Function bta_sys_sco_register
**
** Description Called by BTA AV to register sco connection change callbacks
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_sco_register(tBTA_SYS_CONN_CBACK * p_cback)
{
bta_sys_cb.p_sco_cb = p_cback;
}
/*******************************************************************************
**
** Function bta_sys_pm_register
**
** Description Called by BTA DM to register power management callbacks
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_pm_register(tBTA_SYS_CONN_CBACK * p_cback)
{
bta_sys_cb.ppm_cb = p_cback;
}
/*******************************************************************************
**
** Function bta_sys_conn_open
**
** Description Called by BTA subsystems when a connection is made to
** the service
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_conn_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
{
if(bta_sys_cb.prm_cb)
{
bta_sys_cb.prm_cb(BTA_SYS_CONN_OPEN, id, app_id, peer_addr);
}
if(bta_sys_cb.ppm_cb)
{
bta_sys_cb.ppm_cb(BTA_SYS_CONN_OPEN, id, app_id, peer_addr);
}
}
/*******************************************************************************
**
** Function bta_sys_conn_close
**
** Description Called by BTA subsystems when a connection to the service
** is closed
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_conn_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
{
if(bta_sys_cb.prm_cb)
{
bta_sys_cb.prm_cb(BTA_SYS_CONN_CLOSE, id, app_id, peer_addr);
}
if(bta_sys_cb.ppm_cb)
{
bta_sys_cb.ppm_cb(BTA_SYS_CONN_CLOSE, id, app_id, peer_addr);
}
}
/*******************************************************************************
**
** Function bta_sys_app_open
**
** Description Called by BTA subsystems when application initiates connection
** to a peer device
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_app_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
{
if(bta_sys_cb.ppm_cb)
{
bta_sys_cb.ppm_cb(BTA_SYS_APP_OPEN, id, app_id, peer_addr);
}
}
/*******************************************************************************
**
** Function bta_sys_app_close
**
** Description Called by BTA subsystems when application initiates close
** of connection to peer device
**
** Returns void
**
*******************************************************************************/
void bta_sys_app_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
{
if(bta_sys_cb.ppm_cb)
{
bta_sys_cb.ppm_cb(BTA_SYS_APP_CLOSE, id, app_id, peer_addr);
}
}
/*******************************************************************************
**
** Function bta_sys_sco_open
**
** Description Called by BTA subsystems when sco connection for that service
** is open
**
** Returns void
**
*******************************************************************************/
void bta_sys_sco_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
{
/* AG triggers p_sco_cb by bta_sys_sco_use. */
if((id != BTA_ID_AG) && (bta_sys_cb.p_sco_cb))
{
/* without querying BTM_GetNumScoLinks() */
bta_sys_cb.p_sco_cb(BTA_SYS_SCO_OPEN, 1, app_id, peer_addr);
}
if(bta_sys_cb.ppm_cb)
{
bta_sys_cb.ppm_cb(BTA_SYS_SCO_OPEN, id, app_id, peer_addr);
}
}
/*******************************************************************************
**
** Function bta_sys_sco_close
**
** Description Called by BTA subsystems when sco connection for that service
** is closed
**
** Returns void
**
*******************************************************************************/
void bta_sys_sco_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
{
UINT8 num_sco_links;
if((id != BTA_ID_AG) && (bta_sys_cb.p_sco_cb))
{
num_sco_links = BTM_GetNumScoLinks();
bta_sys_cb.p_sco_cb(BTA_SYS_SCO_CLOSE, num_sco_links, app_id, peer_addr);
}
if(bta_sys_cb.ppm_cb)
{
bta_sys_cb.ppm_cb(BTA_SYS_SCO_CLOSE, id, app_id, peer_addr);
}
}
/*******************************************************************************
**
** Function bta_sys_sco_use
**
** Description Called by BTA subsystems when that service needs to use sco.
**
**
** Returns void
**
*******************************************************************************/
void bta_sys_sco_use(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
{
/* AV streaming need to be suspended before SCO is connected. */
if(bta_sys_cb.p_sco_cb)
{
/* without querying BTM_GetNumScoLinks() */
bta_sys_cb.p_sco_cb(BTA_SYS_SCO_OPEN, 1, app_id, peer_addr);
}
}
/*******************************************************************************
**
** Function bta_sys_sco_unuse
**
** Description Called by BTA subsystems when sco connection for that service
** is no longer needed.
**
** Returns void
**
*******************************************************************************/
void bta_sys_sco_unuse(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
{
UINT8 num_sco_links;
if((bta_sys_cb.p_sco_cb))
{
num_sco_links = BTM_GetNumScoLinks();
bta_sys_cb.p_sco_cb(BTA_SYS_SCO_CLOSE, num_sco_links, app_id, peer_addr);
}
}
/*******************************************************************************
**
** Function bta_sys_chg_ssr_config
**
** Description Called by BTA subsystems to indicate that the given app SSR setting
** need to be changed.
**
** Returns void
**
*******************************************************************************/
#if (BTM_SSR_INCLUDED == TRUE)
void bta_sys_chg_ssr_config (UINT8 id, UINT8 app_id, UINT16 max_latency, UINT16 min_tout)
{
if(bta_sys_cb.p_ssr_cb)
{
bta_sys_cb.p_ssr_cb(id, app_id, max_latency, min_tout);
}
}
#endif
/*******************************************************************************
**
** Function bta_sys_set_policy
**
** Description Called by BTA subsystems to indicate that the given link
** policy to peer device should be set
**
** Returns void
**
*******************************************************************************/
void bta_sys_set_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr)
{
if(bta_sys_cb.p_policy_cb)
{
bta_sys_cb.p_policy_cb(BTA_SYS_PLCY_SET, id, policy, peer_addr);
}
}
/*******************************************************************************
**
** Function bta_sys_clear_policy
**
** Description Called by BTA subsystems to indicate that the given link
** policy to peer device should be clear
**
** Returns void
**
*******************************************************************************/
void bta_sys_clear_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr)
{
if(bta_sys_cb.p_policy_cb)
{
bta_sys_cb.p_policy_cb(BTA_SYS_PLCY_CLR, id, policy, peer_addr);
}
}
/*******************************************************************************
**
** Function bta_sys_set_default_policy
**
** Description Called by BTA subsystems to indicate that the given default
** link policy should be set
**
** Returns void
**
*******************************************************************************/
void bta_sys_set_default_policy (UINT8 id, UINT8 policy)
{
if(bta_sys_cb.p_policy_cb)
{
bta_sys_cb.p_policy_cb(BTA_SYS_PLCY_DEF_SET, id, policy, NULL);
}
}
/*******************************************************************************
**
** Function bta_sys_clear_default_policy
**
** Description Called by BTA subsystems to indicate that the given default
** link policy should be clear
**
** Returns void
**
*******************************************************************************/
void bta_sys_clear_default_policy (UINT8 id, UINT8 policy)
{
if(bta_sys_cb.p_policy_cb)
{
bta_sys_cb.p_policy_cb(BTA_SYS_PLCY_DEF_CLR, id, policy, NULL);
}
}
/*******************************************************************************
**
** Function bta_sys_idle
**
** Description Called by BTA subsystems to indicate that the connection to
** peer device is idle
**
** Returns void
**
*******************************************************************************/
void bta_sys_idle(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
{
if(bta_sys_cb.prm_cb)
{
bta_sys_cb.prm_cb(BTA_SYS_CONN_IDLE, id, app_id, peer_addr);
}
if(bta_sys_cb.ppm_cb)
{
bta_sys_cb.ppm_cb(BTA_SYS_CONN_IDLE, id, app_id, peer_addr);
}
}
/*******************************************************************************
**
** Function bta_sys_busy
**
** Description Called by BTA subsystems to indicate that the connection to
** peer device is busy
**
** Returns void
**
*******************************************************************************/
void bta_sys_busy(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
{
if(bta_sys_cb.prm_cb)
{
bta_sys_cb.prm_cb(BTA_SYS_CONN_BUSY, id, app_id, peer_addr);
}
if(bta_sys_cb.ppm_cb)
{
bta_sys_cb.ppm_cb(BTA_SYS_CONN_BUSY, id, app_id, peer_addr);
}
}
#if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&(BTA_EIR_CANNED_UUID_LIST != TRUE)
/*******************************************************************************
**
** Function bta_sys_eir_register
**
** Description Called by BTA DM to register EIR utility function that can be
** used by the other BTA modules to add/remove UUID.
**
** Returns void
**
*******************************************************************************/
void bta_sys_eir_register(tBTA_SYS_EIR_CBACK * p_cback)
{
bta_sys_cb.eir_cb = p_cback;
}
/*******************************************************************************
**
** Function bta_sys_add_uuid
**
** Description Called by BTA subsystems to indicate to DM that new service
** class UUID is added.
**
** Returns void
**
*******************************************************************************/
void bta_sys_add_uuid(UINT16 uuid16)
{
if(bta_sys_cb.eir_cb)
{
bta_sys_cb.eir_cb(uuid16, TRUE );
}
}
/*******************************************************************************
**
** Function bta_sys_remove_uuid
**
** Description Called by BTA subsystems to indicate to DM that the service
** class UUID is removed.
**
** Returns void
**
*******************************************************************************/
void bta_sys_remove_uuid(UINT16 uuid16)
{
if(bta_sys_cb.eir_cb)
{
bta_sys_cb.eir_cb(uuid16, FALSE);
}
}
#endif
|