summaryrefslogtreecommitdiff
path: root/android/hal-msg.h
blob: f86e6b77136b18ad87d8d6aa812092727465e09c (plain)
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
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
/*
 *
 *  BlueZ - Bluetooth protocol stack for Linux
 *
 *  Copyright (C) 2013  Intel Corporation. All rights reserved.
 *
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";

#define HAL_MINIMUM_EVENT		0x81

#define HAL_SERVICE_ID_CORE		0
#define HAL_SERVICE_ID_BLUETOOTH	1
#define HAL_SERVICE_ID_SOCKET		2
#define HAL_SERVICE_ID_HIDHOST		3
#define HAL_SERVICE_ID_PAN		4
#define HAL_SERVICE_ID_HANDSFREE	5
#define HAL_SERVICE_ID_A2DP		6
#define HAL_SERVICE_ID_HEALTH		7
#define HAL_SERVICE_ID_AVRCP		8
#define HAL_SERVICE_ID_GATT		9
#define HAL_SERVICE_ID_HANDSFREE_CLIENT	10
#define HAL_SERVICE_ID_MAP_CLIENT	11

#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_MAP_CLIENT

/* Core Service */

#define HAL_STATUS_SUCCESS		IPC_STATUS_SUCCESS
#define HAL_STATUS_FAILED		0x01
#define HAL_STATUS_NOT_READY		0x02
#define HAL_STATUS_NOMEM		0x03
#define HAL_STATUS_BUSY			0x04
#define HAL_STATUS_DONE			0x05
#define HAL_STATUS_UNSUPPORTED		0x06
#define HAL_STATUS_INVALID		0x07
#define HAL_STATUS_UNHANDLED		0x08
#define HAL_STATUS_AUTH_FAILURE		0x09
#define HAL_STATUS_REMOTE_DEVICE_DOWN	0x0a

#define HAL_OP_STATUS			IPC_OP_STATUS

#define HAL_MODE_DEFAULT		0x00
#define HAL_MODE_BREDR			0x01
#define HAL_MODE_LE			0x02

#define HAL_OP_REGISTER_MODULE		0x01
struct hal_cmd_register_module {
	uint8_t service_id;
	uint8_t mode;
	int32_t max_clients;
} __attribute__((packed));

#define HAL_OP_UNREGISTER_MODULE	0x02
struct hal_cmd_unregister_module {
	uint8_t service_id;
} __attribute__((packed));

#define HAL_CONFIG_VENDOR		0x00
#define HAL_CONFIG_MODEL		0x01
#define HAL_CONFIG_NAME			0x02
#define HAL_CONFIG_SERIAL_NUMBER	0x03
#define HAL_CONFIG_SYSTEM_ID		0x04
#define HAL_CONFIG_PNP_ID		0x05
#define HAL_CONFIG_FW_REV		0x06
#define HAL_CONFIG_HW_REV		0x07

struct hal_config_prop {
	uint8_t type;
	uint16_t len;
	uint8_t val[0];
} __attribute__((packed));

#define HAL_OP_CONFIGURATION		0x03
struct hal_cmd_configuration {
	uint8_t num;
	struct hal_config_prop props[0];
} __attribute__((packed));

/* Bluetooth Core HAL API */

#define HAL_OP_ENABLE			0x01

#define HAL_OP_DISABLE			0x02

#define HAL_OP_GET_ADAPTER_PROPS	0x03

#define HAL_OP_GET_ADAPTER_PROP		0x04
struct hal_cmd_get_adapter_prop {
	uint8_t type;
} __attribute__((packed));

#define HAL_MAX_NAME_LENGTH		249

#define HAL_PROP_ADAPTER_NAME			0x01
#define HAL_PROP_ADAPTER_ADDR			0x02
#define HAL_PROP_ADAPTER_UUIDS			0x03
#define HAL_PROP_ADAPTER_CLASS			0x04
#define HAL_PROP_ADAPTER_TYPE			0x05
#define HAL_PROP_ADAPTER_SERVICE_REC		0x06
#define HAL_PROP_ADAPTER_SCAN_MODE		0x07
#define HAL_PROP_ADAPTER_BONDED_DEVICES		0x08
#define HAL_PROP_ADAPTER_DISC_TIMEOUT		0x09

#define HAL_PROP_DEVICE_NAME			0x01
#define HAL_PROP_DEVICE_ADDR			0x02
#define HAL_PROP_DEVICE_UUIDS			0x03
#define HAL_PROP_DEVICE_CLASS			0x04
#define HAL_PROP_DEVICE_TYPE			0x05
#define HAL_PROP_DEVICE_SERVICE_REC		0x06
struct hal_prop_device_service_rec {
	uint8_t uuid[16];
	uint16_t channel;
	uint8_t name_len;
	uint8_t name[];
} __attribute__((packed));

#define HAL_PROP_DEVICE_FRIENDLY_NAME		0x0a
#define HAL_PROP_DEVICE_RSSI			0x0b
#define HAL_PROP_DEVICE_VERSION_INFO		0x0c
struct hal_prop_device_info {
	uint8_t version;
	uint16_t sub_version;
	uint16_t manufacturer;
} __attribute__((packed));

#define HAL_PROP_DEVICE_TIMESTAMP		0xFF

#define HAL_ADAPTER_SCAN_MODE_NONE		0x00
#define HAL_ADAPTER_SCAN_MODE_CONN		0x01
#define HAL_ADAPTER_SCAN_MODE_CONN_DISC	0x02

#define HAL_TYPE_BREDR				0x01
#define HAL_TYPE_LE				0x02
#define HAL_TYPE_DUAL				0x03

#define HAL_OP_SET_ADAPTER_PROP		0x05
struct hal_cmd_set_adapter_prop {
	uint8_t  type;
	uint16_t len;
	uint8_t  val[0];
} __attribute__((packed));

#define HAL_OP_GET_REMOTE_DEVICE_PROPS	0x06
struct hal_cmd_get_remote_device_props {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_GET_REMOTE_DEVICE_PROP	0x07
struct hal_cmd_get_remote_device_prop {
	uint8_t bdaddr[6];
	uint8_t type;
} __attribute__((packed));

#define HAL_OP_SET_REMOTE_DEVICE_PROP	0x08
struct hal_cmd_set_remote_device_prop {
	uint8_t  bdaddr[6];
	uint8_t  type;
	uint16_t len;
	uint8_t  val[0];
} __attribute__((packed));

#define HAL_OP_GET_REMOTE_SERVICE_REC	0x09
struct hal_cmd_get_remote_service_rec {
	uint8_t bdaddr[6];
	uint8_t uuid[16];
} __attribute__((packed));

#define HAL_OP_GET_REMOTE_SERVICES	0x0a
struct hal_cmd_get_remote_services {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_START_DISCOVERY		0x0b

#define HAL_OP_CANCEL_DISCOVERY		0x0c

#define BT_TRANSPORT_UNKNOWN		0x00
#define BT_TRANSPORT_BR_EDR		0x01
#define BT_TRANSPORT_LE			0x02

#define HAL_OP_CREATE_BOND		0x0d
struct hal_cmd_create_bond {
	uint8_t bdaddr[6];
	uint8_t transport;
} __attribute__((packed));

#define HAL_OP_REMOVE_BOND		0x0e
struct hal_cmd_remove_bond {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_CANCEL_BOND		0x0f
struct hal_cmd_cancel_bond {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_PIN_REPLY		0x10
struct hal_cmd_pin_reply {
	uint8_t bdaddr[6];
	uint8_t accept;
	uint8_t pin_len;
	uint8_t pin_code[16];
} __attribute__((packed));

#define HAL_SSP_VARIANT_CONFIRM		0x00
#define HAL_SSP_VARIANT_ENTRY		0x01
#define HAL_SSP_VARIANT_CONSENT		0x02
#define HAL_SSP_VARIANT_NOTIF		0x03

#define HAL_OP_SSP_REPLY		0x11
struct hal_cmd_ssp_reply {
	uint8_t  bdaddr[6];
	uint8_t  ssp_variant;
	uint8_t  accept;
	uint32_t passkey;
} __attribute__((packed));

#define HAL_OP_DUT_MODE_CONF		0x12
struct hal_cmd_dut_mode_conf {
	uint8_t enable;
} __attribute__((packed));

#define HAL_OP_DUT_MODE_SEND		0x13
struct hal_cmd_dut_mode_send {
	uint16_t opcode;
	uint8_t  len;
	uint8_t  data[0];
} __attribute__((packed));

#define HAL_OP_LE_TEST_MODE		0x14
struct hal_cmd_le_test_mode {
	uint16_t opcode;
	uint8_t  len;
	uint8_t  data[0];
} __attribute__((packed));

/* Bluetooth Socket HAL api */

#define HAL_SOCK_RFCOMM		0x01
#define HAL_SOCK_SCO		0x02
#define HAL_SOCK_L2CAP		0x03

#define HAL_SOCK_FLAG_ENCRYPT	0x01
#define HAL_SOCK_FLAG_AUTH	0x02

#define HAL_OP_SOCKET_LISTEN		0x01
struct hal_cmd_socket_listen {
	uint8_t type;
	uint8_t name[256];
	uint8_t uuid[16];
	int32_t channel;
	uint8_t flags;
} __attribute__((packed));

#define HAL_OP_SOCKET_CONNECT		0x02
struct hal_cmd_socket_connect {
	uint8_t bdaddr[6];
	uint8_t type;
	uint8_t uuid[16];
	int32_t channel;
	uint8_t flags;
} __attribute__((packed));

/* Bluetooth HID Host HAL API */

#define HAL_OP_HIDHOST_CONNECT		0x01
struct hal_cmd_hidhost_connect {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HIDHOST_DISCONNECT		0x02
struct hal_cmd_hidhost_disconnect {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HIDHOST_VIRTUAL_UNPLUG		0x03
struct hal_cmd_hidhost_virtual_unplug {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HIDHOST_SET_INFO		0x04
struct hal_cmd_hidhost_set_info {
	uint8_t  bdaddr[6];
	uint8_t  attr;
	uint8_t  subclass;
	uint8_t  app_id;
	uint16_t vendor;
	uint16_t product;
	uint16_t country;
	uint16_t descr_len;
	uint8_t  descr[0];
} __attribute__((packed));

#define HAL_HIDHOST_REPORT_PROTOCOL		0x00
#define HAL_HIDHOST_BOOT_PROTOCOL		0x01
#define HAL_HIDHOST_UNSUPPORTED_PROTOCOL	0xff

#define HAL_OP_HIDHOST_GET_PROTOCOL	0x05
struct hal_cmd_hidhost_get_protocol {
	uint8_t bdaddr[6];
	uint8_t mode;
} __attribute__((packed));

#define HAL_OP_HIDHOST_SET_PROTOCOL	0x06
struct hal_cmd_hidhost_set_protocol {
	uint8_t bdaddr[6];
	uint8_t mode;
} __attribute__((packed));

#define HAL_HIDHOST_INPUT_REPORT		0x01
#define HAL_HIDHOST_OUTPUT_REPORT		0x02
#define HAL_HIDHOST_FEATURE_REPORT		0x03

#define HAL_OP_HIDHOST_GET_REPORT		0x07
struct hal_cmd_hidhost_get_report {
	uint8_t  bdaddr[6];
	uint8_t  type;
	uint8_t  id;
	uint16_t buf_size;
} __attribute__((packed));

#define HAL_OP_HIDHOST_SET_REPORT		0x08
struct hal_cmd_hidhost_set_report {
	uint8_t  bdaddr[6];
	uint8_t  type;
	uint16_t len;
	uint8_t  data[0];
} __attribute__((packed));

#define HAL_OP_HIDHOST_SEND_DATA		0x09
struct hal_cmd_hidhost_send_data {
	uint8_t  bdaddr[6];
	uint16_t len;
	uint8_t  data[0];
} __attribute__((packed));

/* a2dp HAL API */

#define HAL_OP_A2DP_CONNECT	0x01
struct hal_cmd_a2dp_connect {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_A2DP_DISCONNECT	0x02
struct hal_cmd_a2dp_disconnect {
	uint8_t bdaddr[6];
} __attribute__((packed));

/* PAN HAL API */

/* PAN Roles */
#define HAL_PAN_ROLE_NONE	0x00
#define HAL_PAN_ROLE_NAP	0x01
#define HAL_PAN_ROLE_PANU	0x02

/* PAN Control states */
#define HAL_PAN_CTRL_ENABLED	0x00
#define HAL_PAN_CTRL_DISABLED	0x01

/* PAN Connection states */
#define HAL_PAN_STATE_CONNECTED		0x00
#define HAL_PAN_STATE_CONNECTING	0x01
#define HAL_PAN_STATE_DISCONNECTED	0x02
#define HAL_PAN_STATE_DISCONNECTING	0x03

/* PAN status values */
#define HAL_PAN_STATUS_FAIL		0x01
#define HAL_PAN_STATUS_NOT_READY	0x02
#define HAL_PAN_STATUS_NO_MEMORY	0x03
#define HAL_PAN_STATUS_BUSY		0x04
#define HAL_PAN_STATUS_DONE		0x05
#define HAL_PAN_STATUS_UNSUPORTED	0x06
#define HAL_PAN_STATUS_INVAL		0x07
#define HAL_PAN_STATUS_UNHANDLED	0x08
#define HAL_PAN_STATUS_AUTH_FAILED	0x09
#define HAL_PAN_STATUS_DEVICE_DOWN	0x0A

#define HAL_OP_PAN_ENABLE	0x01
struct hal_cmd_pan_enable {
	uint8_t local_role;
} __attribute__((packed));

#define HAL_OP_PAN_GET_ROLE	0x02
struct hal_rsp_pan_get_role {
	uint8_t local_role;
} __attribute__((packed));

#define HAL_OP_PAN_CONNECT	0x03
struct hal_cmd_pan_connect {
	uint8_t bdaddr[6];
	uint8_t local_role;
	uint8_t remote_role;
} __attribute__((packed));

#define HAL_OP_PAN_DISCONNECT	0x04
struct hal_cmd_pan_disconnect {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_HEALTH_MDEP_ROLE_SOURCE	0x00
#define HAL_HEALTH_MDEP_ROLE_SINK	0x01

#define HAL_HEALTH_CHANNEL_TYPE_RELIABLE	0x00
#define HAL_HEALTH_CHANNEL_TYPE_STREAMING	0x01
#define HAL_HEALTH_CHANNEL_TYPE_ANY		0x02

#define HAL_OP_HEALTH_REG_APP		0x01
struct hal_cmd_health_reg_app {
	uint8_t  num_of_mdep;
	uint16_t app_name_off;
	uint16_t provider_name_off;
	uint16_t service_name_off;
	uint16_t service_descr_off;
	uint16_t len;
	uint8_t  data[0];
} __attribute__((packed));

struct hal_rsp_health_reg_app {
	uint16_t app_id;
} __attribute__((packed));

#define HAL_OP_HEALTH_MDEP		0x02
struct hal_cmd_health_mdep {
	uint16_t app_id;
	uint8_t  role;
	uint16_t data_type;
	uint8_t  channel_type;
	uint16_t descr_len;
	uint8_t  descr[0];
} __attribute__((packed));

#define HAL_OP_HEALTH_UNREG_APP		0x03
struct hal_cmd_health_unreg_app {
	uint16_t app_id;
} __attribute__((packed));

#define HAL_OP_HEALTH_CONNECT_CHANNEL	0x04
struct hal_cmd_health_connect_channel {
	uint16_t app_id;
	uint8_t  bdaddr[6];
	uint8_t  mdep_index;
} __attribute__((packed));

struct hal_rsp_health_connect_channel {
	uint16_t  channel_id;
} __attribute__((packed));

#define HAL_OP_HEALTH_DESTROY_CHANNEL	0x05
struct hal_cmd_health_destroy_channel {
	uint16_t channel_id;
} __attribute__((packed));

/* Handsfree HAL API */

#define HAL_MODE_HANDSFREE_HSP_ONLY		HAL_MODE_DEFAULT
#define HAL_MODE_HANDSFREE_HFP			0x01
#define HAL_MODE_HANDSFREE_HFP_WBS		0x02

#define HAL_OP_HANDSFREE_CONNECT		0x01
struct hal_cmd_handsfree_connect {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HANDSFREE_DISCONNECT		0x02
struct hal_cmd_handsfree_disconnect {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HANDSFREE_CONNECT_AUDIO		0x03
struct hal_cmd_handsfree_connect_audio {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HANDSFREE_DISCONNECT_AUDIO	0x04
struct hal_cmd_handsfree_disconnect_audio {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HANDSFREE_START_VR		0x05
struct hal_cmd_handsfree_start_vr {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HANDSFREE_STOP_VR		0x06
struct hal_cmd_handsfree_stop_vr {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_HANDSFREE_VOLUME_TYPE_SPEAKER	0x00
#define HAL_HANDSFREE_VOLUME_TYPE_MIC		0x01

#define HAL_OP_HANDSFREE_VOLUME_CONTROL		0x07
struct hal_cmd_handsfree_volume_control {
	uint8_t type;
	uint8_t volume;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_HANDSFREE_NETWORK_STATE_NOT_AVAILABLE	0x00
#define HAL_HANDSFREE_NETWORK_STATE_AVAILABLE		0x01

#define HAL_HANDSFREE_SERVICE_TYPE_HOME		0x00
#define HAL_HANDSFREE_SERVICE_TYPE_ROAMING	0x01

#define HAL_OP_HANDSFREE_DEVICE_STATUS_NOTIF	0x08
struct hal_cmd_handsfree_device_status_notif {
	uint8_t state;
	uint8_t type;
	uint8_t signal;
	uint8_t battery;
} __attribute__((packed));

#define HAL_OP_HANDSFREE_COPS_RESPONSE		0x09
struct hal_cmd_handsfree_cops_response {
	uint16_t len;
	uint8_t bdaddr[6];
	uint8_t buf[0];
} __attribute__((packed));

#define HAL_HANDSFREE_CALL_STATE_ACTIVE		0x00
#define HAL_HANDSFREE_CALL_STATE_HELD		0x01
#define HAL_HANDSFREE_CALL_STATE_DIALING	0x02
#define HAL_HANDSFREE_CALL_STATE_ALERTING	0x03
#define HAL_HANDSFREE_CALL_STATE_INCOMING	0x04
#define HAL_HANDSFREE_CALL_STATE_WAITING	0x05
#define HAL_HANDSFREE_CALL_STATE_IDLE		0x06

#define HAL_OP_HANDSFREE_CIND_RESPONSE		0x0A
struct hal_cmd_handsfree_cind_response {
	uint8_t svc;
	uint8_t num_active;
	uint8_t num_held;
	uint8_t state;
	uint8_t signal;
	uint8_t roam;
	uint8_t batt_chg;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HANDSFREE_FORMATTED_AT_RESPONSE	0x0B
struct hal_cmd_handsfree_formatted_at_response {
	uint16_t len;
	uint8_t bdaddr[6];
	uint8_t buf[0];
} __attribute__((packed));

#define HAL_HANDSFREE_AT_RESPONSE_ERROR		0x00
#define HAL_HANDSFREE_AT_RESPONSE_OK		0x01

#define HAL_OP_HANDSFREE_AT_RESPONSE		0x0C
struct hal_cmd_handsfree_at_response {
	uint8_t response;
	uint8_t error;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_HANDSFREE_CALL_DIRECTION_OUTGOING	0x00
#define HAL_HANDSFREE_CALL_DIRECTION_INCOMING	0x01

#define HAL_HANDSFREE_CALL_TYPE_VOICE		0x00
#define HAL_HANDSFREE_CALL_TYPE_DATA		0x01
#define HAL_HANDSFREE_CALL_TYPE_FAX		0x02

#define HAL_HANDSFREE_CALL_MPTY_TYPE_SINGLE	0x00
#define HAL_HANDSFREE_CALL_MPTY_TYPE_MULTI	0x01

#define HAL_HANDSFREE_CALL_ADDRTYPE_UNKNOWN	0x81
#define HAL_HANDSFREE_CALL_ADDRTYPE_INTERNATIONAL	0x91

#define HAL_OP_HANDSFREE_CLCC_RESPONSE		0x0D
struct hal_cmd_handsfree_clcc_response {
	uint8_t index;
	uint8_t dir;
	uint8_t state;
	uint8_t mode;
	uint8_t mpty;
	uint8_t type;
	uint8_t bdaddr[6];
	uint16_t number_len;
	uint8_t number[0];
} __attribute__((packed));

#define HAL_OP_HANDSFREE_PHONE_STATE_CHANGE	0x0E
struct hal_cmd_handsfree_phone_state_change {
	uint8_t num_active;
	uint8_t num_held;
	uint8_t state;
	uint8_t type;
	uint16_t number_len;
	uint8_t number[0];
} __attribute__((packed));

/* AVRCP HAL API */

#define HAL_AVRCP_PLAY_STATUS_STOPPED	0x00
#define HAL_AVRCP_PLAY_STATUS_PLAYING	0x01
#define HAL_AVRCP_PLAY_STATUS_PAUSED	0x02
#define HAL_AVRCP_PLAY_STATUS_FWD_SEEK	0x03
#define HAL_AVRCP_PLAY_STATUS_REV_SEEK	0x04
#define HAL_AVRCP_PLAY_STATUS_ERROR	0xff

#define HAL_OP_AVRCP_GET_PLAY_STATUS	0x01
struct hal_cmd_avrcp_get_play_status {
	uint8_t status;
	uint32_t duration;
	uint32_t position;
} __attribute__((packed));

#define HAL_AVRCP_PLAYER_ATTR_EQUALIZER	0x01
#define HAL_AVRCP_PLAYER_ATTR_REPEAT	0x02
#define HAL_AVRCP_PLAYER_ATTR_SHUFFLE	0x03
#define HAL_AVRCP_PLAYER_ATTR_SCAN	0x04

#define HAL_OP_AVRCP_LIST_PLAYER_ATTRS	0x02
struct hal_cmd_avrcp_list_player_attrs {
	uint8_t number;
	uint8_t attrs[0];
} __attribute__((packed));

#define HAL_OP_AVRCP_LIST_PLAYER_VALUES	0x03
struct hal_cmd_avrcp_list_player_values {
	uint8_t number;
	uint8_t values[0];
} __attribute__((packed));

struct hal_avrcp_player_attr_value {
	uint8_t attr;
	uint8_t value;
} __attribute__((packed));

#define HAL_OP_AVRCP_GET_PLAYER_ATTRS	0x04
struct hal_cmd_avrcp_get_player_attrs {
	uint8_t number;
	struct hal_avrcp_player_attr_value attrs[0];
} __attribute__((packed));

struct hal_avrcp_player_setting_text {
	uint8_t id;
	uint8_t len;
	uint8_t text[0];
} __attribute__((packed));

#define HAL_OP_AVRCP_GET_PLAYER_ATTRS_TEXT	0x05
struct hal_cmd_avrcp_get_player_attrs_text {
	uint8_t number;
	struct hal_avrcp_player_setting_text attrs[0];
} __attribute__((packed));

#define HAL_OP_AVRCP_GET_PLAYER_VALUES_TEXT	0x06
struct hal_cmd_avrcp_get_player_values_text {
	uint8_t number;
	struct hal_avrcp_player_setting_text values[0];
} __attribute__((packed));

#define HAL_AVRCP_MEDIA_ATTR_TITLE		0x01
#define HAL_AVRCP_MEDIA_ATTR_ARTIST		0x02
#define HAL_AVRCP_MEDIA_ATTR_ALBUM		0x03
#define HAL_AVRCP_MEDIA_ATTR_TRACK_NUM		0x04
#define HAL_AVRCP_MEDIA_ATTR_NUM_TRACKS		0x05
#define HAL_AVRCP_MEDIA_ATTR_GENRE		0x06
#define HAL_AVRCP_MEDIA_ATTR_DURATION		0x07

#define HAL_OP_AVRCP_GET_ELEMENT_ATTRS_TEXT	0x07
struct hal_cmd_avrcp_get_element_attrs_text {
	uint8_t number;
	struct hal_avrcp_player_setting_text values[0];
} __attribute__((packed));

#define HAL_OP_AVRCP_SET_PLAYER_ATTRS_VALUE	0x08
struct hal_cmd_avrcp_set_player_attrs_value {
	uint8_t status;
} __attribute__((packed));

#define HAL_AVRCP_EVENT_STATUS_CHANGED		0x01
#define HAL_AVRCP_EVENT_TRACK_CHANGED		0x02
#define HAL_AVRCP_EVENT_TRACK_REACHED_END	0x03
#define HAL_AVRCP_EVENT_TRACK_REACHED_START	0x04
#define HAL_AVRCP_EVENT_POSITION_CHANGED	0x05
#define HAL_AVRCP_EVENT_SETTING_CHANGED		0x08

#define HAL_AVRCP_EVENT_TYPE_INTERIM		0x00
#define HAL_AVRCP_EVENT_TYPE_CHANGED		0x01

#define HAL_OP_AVRCP_REGISTER_NOTIFICATION	0x09
struct hal_cmd_avrcp_register_notification {
	uint8_t event;
	uint8_t type;
	uint8_t len;
	uint8_t data[0];
} __attribute__((packed));

#define HAL_OP_AVRCP_SET_VOLUME			0x0a
struct hal_cmd_avrcp_set_volume {
	uint8_t value;
} __attribute__((packed));

/* GATT HAL API */

#define HAL_OP_GATT_CLIENT_REGISTER		0x01
struct hal_cmd_gatt_client_register {
	uint8_t uuid[16];
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_UNREGISTER		0x02
struct hal_cmd_gatt_client_unregister {
	int32_t client_if;
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_SCAN			0x03
struct hal_cmd_gatt_client_scan {
	int32_t client_if;
	uint8_t start;
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_CONNECT		0x04
struct hal_cmd_gatt_client_connect {
	int32_t client_if;
	uint8_t bdaddr[6];
	uint8_t is_direct;
	int32_t transport;
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_DISCONNECT		0x05
struct hal_cmd_gatt_client_disconnect {
	int32_t client_if;
	uint8_t bdaddr[6];
	int32_t conn_id;
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_LISTEN		0x06
struct hal_cmd_gatt_client_listen {
	int32_t client_if;
	uint8_t start;
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_REFRESH		0x07
struct hal_cmd_gatt_client_refresh {
	int32_t client_if;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_SEARCH_SERVICE	0x08
struct hal_cmd_gatt_client_search_service {
	int32_t conn_id;
	uint8_t filtered;
	uint8_t filter_uuid[0];
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_GET_INCLUDED_SERVICE	0x09
struct hal_gatt_srvc_id {
	uint8_t uuid[16];
	uint8_t inst_id;
	uint8_t is_primary;
} __attribute__((packed));

struct hal_cmd_gatt_client_get_included_service {
	int32_t conn_id;
	struct hal_gatt_srvc_id srvc_id;
	uint8_t continuation;
	struct hal_gatt_srvc_id incl_srvc_id[0];
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_GET_CHARACTERISTIC	0x0a
struct hal_gatt_gatt_id {
	uint8_t uuid[16];
	uint8_t inst_id;
} __attribute__((packed));

struct hal_cmd_gatt_client_get_characteristic {
	int32_t conn_id;
	struct hal_gatt_srvc_id srvc_id;
	uint8_t continuation;
	struct hal_gatt_gatt_id char_id[0];
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_GET_DESCRIPTOR	0x0b
struct hal_cmd_gatt_client_get_descriptor {
	int32_t conn_id;
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
	uint8_t continuation;
	struct hal_gatt_gatt_id descr_id[0];
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_READ_CHARACTERISTIC	0x0c
struct hal_cmd_gatt_client_read_characteristic {
	int32_t conn_id;
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
	int32_t auth_req;
} __attribute__((packed));

#define GATT_WRITE_TYPE_NO_RESPONSE	0x01
#define GATT_WRITE_TYPE_DEFAULT		0x02
#define GATT_WRITE_TYPE_PREPARE		0x03
#define GATT_WRITE_TYPE_SIGNED		0x04

#define HAL_OP_GATT_CLIENT_WRITE_CHARACTERISTIC	0x0d
struct hal_cmd_gatt_client_write_characteristic {
	int32_t conn_id;
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
	int32_t write_type;
	int32_t len;
	int32_t auth_req;
	uint8_t value[0];
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_READ_DESCRIPTOR	0x0e
struct hal_cmd_gatt_client_read_descriptor {
	int32_t conn_id;
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
	struct hal_gatt_gatt_id descr_id;
	int32_t auth_req;
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_WRITE_DESCRIPTOR	0x0f
struct hal_cmd_gatt_client_write_descriptor {
	int32_t conn_id;
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
	struct hal_gatt_gatt_id descr_id;
	int32_t write_type;
	int32_t len;
	int32_t auth_req;
	uint8_t value[0];
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_EXECUTE_WRITE	0x10
struct hal_cmd_gatt_client_execute_write {
	int32_t conn_id;
	int32_t execute;
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_REGISTER_FOR_NOTIFICATION	0x11
struct hal_cmd_gatt_client_register_for_notification {
	int32_t client_if;
	uint8_t bdaddr[6];
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_DEREGISTER_FOR_NOTIFICATION	0x12
struct hal_cmd_gatt_client_deregister_for_notification {
	int32_t client_if;
	uint8_t bdaddr[6];
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_READ_REMOTE_RSSI	0x13
struct hal_cmd_gatt_client_read_remote_rssi {
	int32_t client_if;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_GET_DEVICE_TYPE	0x14
struct hal_cmd_gatt_client_get_device_type {
	uint8_t bdaddr[6];
} __attribute__((packed));

struct hal_rsp_gatt_client_get_device_type {
	uint8_t type;
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_SET_ADV_DATA		0x015
struct hal_cmd_gatt_client_set_adv_data {
	int32_t  server_if;
	uint8_t  set_scan_rsp;
	uint8_t  include_name;
	uint8_t  include_txpower;
	int32_t  min_interval;
	int32_t  max_interval;
	int32_t  appearance;
	uint16_t manufacturer_len;
	uint16_t service_data_len;
	uint16_t service_uuid_len;
	uint8_t  data[0];
} __attribute__((packed));

#define GATT_CLIENT_TEST_CMD_ENABLE		0x01
#define GATT_CLIENT_TEST_CMD_CONNECT		0x02
#define GATT_CLIENT_TEST_CMD_DISCONNECT		0x03
#define GATT_CLIENT_TEST_CMD_DISCOVER		0x04
#define GATT_CLIENT_TEST_CMD_READ		0xe0
#define GATT_CLIENT_TEST_CMD_WRITE		0xe1
#define GATT_CLIENT_TEST_CMD_INCREASE_SECURITY	0xe2
#define GATT_CLIENT_TEST_CMD_PAIRING_CONFIG	0xf0

#define HAL_OP_GATT_CLIENT_TEST_COMMAND		0x16
struct hal_cmd_gatt_client_test_command {
	int32_t command;
	uint8_t  bda1[6];
	uint8_t  uuid1[16];
	uint16_t u1;
	uint16_t u2;
	uint16_t u3;
	uint16_t u4;
	uint16_t u5;
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_REGISTER		0x17
struct hal_cmd_gatt_server_register {
	uint8_t uuid[16];
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_UNREGISTER		0x18
struct hal_cmd_gatt_server_unregister {
	int32_t server_if;
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_CONNECT		0x19
struct hal_cmd_gatt_server_connect {
	int32_t server_if;
	uint8_t bdaddr[6];
	uint8_t is_direct;
	int32_t transport;
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_DISCONNECT		0x1a
struct hal_cmd_gatt_server_disconnect {
	int32_t server_if;
	uint8_t bdaddr[6];
	int32_t conn_id;
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_ADD_SERVICE		0x1b
struct hal_cmd_gatt_server_add_service {
	int32_t server_if;
	struct hal_gatt_srvc_id srvc_id;
	int32_t num_handles;
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_ADD_INC_SERVICE	0x1c
struct hal_cmd_gatt_server_add_inc_service {
	int32_t server_if;
	int32_t service_handle;
	int32_t included_handle;
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_ADD_CHARACTERISTIC	0x1d
struct hal_cmd_gatt_server_add_characteristic {
	int32_t server_if;
	int32_t service_handle;
	uint8_t uuid[16];
	int32_t properties;
	int32_t permissions;
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_ADD_DESCRIPTOR	0x1e
struct hal_cmd_gatt_server_add_descriptor {
	int32_t server_if;
	int32_t service_handle;
	uint8_t uuid[16];
	int32_t permissions;
} __attribute__((packed));

#define GATT_SERVER_TRANSPORT_LE		0x00
#define GATT_SERVER_TRANSPORT_BREDR		0x01
#define GATT_SERVER_TRANSPORT_LE_BREDR		0x02

#define HAL_OP_GATT_SERVER_START_SERVICE	0x1f
struct hal_cmd_gatt_server_start_service {
	int32_t server_if;
	int32_t service_handle;
	int32_t transport;
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_STOP_SERVICE		0x20
struct hal_cmd_gatt_server_stop_service {
	int32_t server_if;
	int32_t service_handle;
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_DELETE_SERVICE	0x21
struct hal_cmd_gatt_server_delete_service {
	int32_t server_if;
	int32_t service_handle;
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_SEND_INDICATION	0x22
struct hal_cmd_gatt_server_send_indication {
	int32_t server_if;
	int32_t attribute_handle;
	int32_t conn_id;
	int32_t len;
	int32_t confirm;
	uint8_t value[0];
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_SEND_RESPONSE	0x23
struct hal_cmd_gatt_server_send_response {
	int32_t conn_id;
	int32_t trans_id;
	uint16_t handle;
	uint16_t offset;
	uint8_t auth_req;
	int32_t status;
	uint16_t len;
	uint8_t data[0];
} __attribute__((packed));

/* Handsfree client HAL API */

#define HAL_OP_HF_CLIENT_CONNECT		0x01
struct hal_cmd_hf_client_connect {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HF_CLIENT_DISCONNECT		0x02
struct hal_cmd_hf_client_disconnect {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HF_CLIENT_CONNECT_AUDIO		0x03
struct hal_cmd_hf_client_connect_audio {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HF_CLIENT_DISCONNECT_AUDIO	0x04
struct hal_cmd_hf_client_disconnect_audio {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_OP_HF_CLIENT_START_VR		0x05
#define HAL_OP_HF_CLIENT_STOP_VR		0x06

#define HF_CLIENT_VOLUME_TYPE_SPEAKER	0x00
#define HF_CLIENT_VOLUME_TYPE_MIC	0x01

#define HAL_OP_HF_CLIENT_VOLUME_CONTROL		0x07
struct hal_cmd_hf_client_volume_control {
	uint8_t type;
	uint8_t volume;
} __attribute__((packed));

#define HAL_OP_HF_CLIENT_DIAL			0x08
struct hal_cmd_hf_client_dial {
	uint16_t number_len;
	uint8_t number[0];
} __attribute__((packed));

#define HAL_OP_HF_CLIENT_DIAL_MEMORY		0x09
struct hal_cmd_hf_client_dial_memory {
	int32_t location;
} __attribute__((packed));

#define HAL_HF_CLIENT_ACTION_CHLD_0		0x00
#define HAL_HF_CLIENT_ACTION_CHLD_1		0x01
#define HAL_HF_CLIENT_ACTION_CHLD_2		0x02
#define HAL_HF_CLIENT_ACTION_CHLD_3		0x03
#define HAL_HF_CLIENT_ACTION_CHLD_4		0x04
#define HAL_HF_CLIENT_ACTION_CHLD_1x		0x05
#define HAL_HF_CLIENT_ACTION_CHLD_2x		0x06
#define HAL_HF_CLIENT_ACTION_ATA		0x07
#define HAL_HF_CLIENT_ACTION_CHUP		0x08
#define HAL_HF_CLIENT_ACTION_BRTH_0		0x09
#define HAL_HF_CLIENT_ACTION_BRTH_1		0x0a
#define HAL_HF_CLIENT_ACTION_BRTH_02		0x0b

#define HAL_OP_HF_CLIENT_CALL_ACTION		0x0a
struct hal_cmd_hf_client_call_action {
	uint8_t action;
	uint8_t index;
} __attribute__((packed));

#define HAL_OP_HF_CLIENT_QUERY_CURRENT_CALLS	0x0b
#define HAL_OP_HF_CLIENT_QUERY_OPERATOR_NAME	0x0c
#define HAL_OP_HF_CLIENT_RETRIEVE_SUBSCR_INFO	0x0d

#define HAL_OP_HF_CLIENT_SEND_DTMF		0x0e
struct hal_cmd_hf_client_send_dtmf {
	uint8_t tone;
} __attribute__((packed));

#define HAL_OP_HF_CLIENT_GET_LAST_VOICE_TAG_NUM	0x0f

/* MAP CLIENT HAL API */

#define HAL_OP_MAP_CLIENT_GET_INSTANCES	0x01
struct hal_cmd_map_client_get_instances {
	uint8_t bdaddr[6];
} __attribute__((packed));

/* Notifications and confirmations */

#define HAL_POWER_OFF			0x00
#define HAL_POWER_ON			0x01

#define HAL_EV_ADAPTER_STATE_CHANGED	0x81
struct hal_ev_adapter_state_changed {
	uint8_t state;
} __attribute__((packed));

#define HAL_EV_ADAPTER_PROPS_CHANGED	0x82
struct hal_property {
	uint8_t  type;
	uint16_t len;
	uint8_t  val[0];
} __attribute__((packed));
struct hal_ev_adapter_props_changed {
	uint8_t              status;
	uint8_t              num_props;
	struct  hal_property props[0];
} __attribute__((packed));

#define HAL_EV_REMOTE_DEVICE_PROPS	0x83
struct hal_ev_remote_device_props {
	uint8_t             status;
	uint8_t             bdaddr[6];
	uint8_t             num_props;
	struct hal_property props[0];
} __attribute__((packed));

#define HAL_EV_DEVICE_FOUND		0x84
struct hal_ev_device_found {
	uint8_t             num_props;
	struct hal_property props[0];
} __attribute__((packed));

#define HAL_DISCOVERY_STATE_STOPPED	0x00
#define HAL_DISCOVERY_STATE_STARTED	0x01

#define HAL_EV_DISCOVERY_STATE_CHANGED	0x85
struct hal_ev_discovery_state_changed {
	uint8_t state;
} __attribute__((packed));

#define HAL_EV_PIN_REQUEST		0x86
struct hal_ev_pin_request {
	uint8_t  bdaddr[6];
	uint8_t  name[249];
	uint32_t class_of_dev;
} __attribute__((packed));

#define HAL_EV_SSP_REQUEST		0x87
struct hal_ev_ssp_request {
	uint8_t  bdaddr[6];
	uint8_t  name[249];
	uint32_t class_of_dev;
	uint8_t  pairing_variant;
	uint32_t passkey;
} __attribute__((packed));

#define HAL_BOND_STATE_NONE 0
#define HAL_BOND_STATE_BONDING 1
#define HAL_BOND_STATE_BONDED 2

#define HAL_EV_BOND_STATE_CHANGED	0x88
struct hal_ev_bond_state_changed {
	uint8_t status;
	uint8_t bdaddr[6];
	uint8_t state;
} __attribute__((packed));

#define HAL_ACL_STATE_CONNECTED		0x00
#define HAL_ACL_STATE_DISCONNECTED	0x01

#define HAL_EV_ACL_STATE_CHANGED	0x89
struct hal_ev_acl_state_changed {
	uint8_t status;
	uint8_t bdaddr[6];
	uint8_t state;
} __attribute__((packed));

#define HAL_EV_DUT_MODE_RECEIVE		0x8a
struct hal_ev_dut_mode_receive {
	uint16_t opcode;
	uint8_t  len;
	uint8_t  data[0];
} __attribute__((packed));

#define HAL_EV_LE_TEST_MODE		0x8b
struct hal_ev_le_test_mode {
	uint8_t  status;
	uint16_t num_packets;
} __attribute__((packed));

#define HAL_HIDHOST_STATE_CONNECTED		0x00
#define HAL_HIDHOST_STATE_CONNECTING	0x01
#define HAL_HIDHOST_STATE_DISCONNECTED	0x02
#define HAL_HIDHOST_STATE_DISCONNECTING	0x03
#define HAL_HIDHOST_STATE_NO_HID		0x07
#define HAL_HIDHOST_STATE_FAILED		0x08
#define HAL_HIDHOST_STATE_UNKNOWN		0x09

#define HAL_EV_HIDHOST_CONN_STATE		0x81
struct hal_ev_hidhost_conn_state {
	uint8_t bdaddr[6];
	uint8_t state;
} __attribute__((packed));

#define HAL_HIDHOST_STATUS_OK		0x00
#define HAL_HIDHOST_GENERAL_ERROR	0x06

#define HAL_EV_HIDHOST_INFO			0x82
struct hal_ev_hidhost_info {
	uint8_t  bdaddr[6];
	uint8_t  attr;
	uint8_t  subclass;
	uint8_t  app_id;
	uint16_t vendor;
	uint16_t product;
	uint16_t version;
	uint8_t  country;
	uint16_t descr_len;
	uint8_t  descr[884];
} __attribute__((packed));

#define HAL_EV_HIDHOST_PROTO_MODE		0x83
struct hal_ev_hidhost_proto_mode {
	uint8_t bdaddr[6];
	uint8_t status;
	uint8_t mode;
} __attribute__((packed));

#define HAL_EV_HIDHOST_IDLE_TIME		0x84
struct hal_ev_hidhost_idle_time {
	uint8_t bdaddr[6];
	uint8_t status;
	uint32_t idle_rate;
} __attribute__((packed));

#define HAL_EV_HIDHOST_GET_REPORT		0x85
struct hal_ev_hidhost_get_report {
	uint8_t  bdaddr[6];
	uint8_t  status;
	uint16_t len;
	uint8_t  data[0];
} __attribute__((packed));

#define HAL_EV_HIDHOST_VIRTUAL_UNPLUG		0x86
struct hal_ev_hidhost_virtual_unplug {
	uint8_t  bdaddr[6];
	uint8_t  status;
} __attribute__((packed));

#define HAL_EV_PAN_CTRL_STATE			0x81
struct hal_ev_pan_ctrl_state {
	uint8_t  state;
	uint8_t  status;
	uint8_t  local_role;
	uint8_t  name[17];
} __attribute__((packed));

#define HAL_EV_PAN_CONN_STATE			0x82
struct hal_ev_pan_conn_state {
	uint8_t  state;
	uint8_t  status;
	uint8_t  bdaddr[6];
	uint8_t  local_role;
	uint8_t  remote_role;
} __attribute__((packed));

#define HAL_HEALTH_APP_REG_SUCCESS		0x00
#define HAL_HEALTH_APP_REG_FAILED		0x01
#define HAL_HEALTH_APP_DEREG_SUCCESS		0x02
#define HAL_HEALTH_APP_DEREG_FAILED		0x03

#define HAL_HEALTH_CHANNEL_CONNECTING		0x00
#define HAL_HEALTH_CHANNEL_CONNECTED		0x01
#define HAL_HEALTH_CHANNEL_DISCONNECTING	0x02
#define HAL_HEALTH_CHANNEL_DISCONNECTED		0x03
#define HAL_HEALTH_CHANNEL_DESTROYED		0x04

#define HAL_EV_HEALTH_APP_REG_STATE		0x81
struct hal_ev_health_app_reg_state {
	uint16_t id;
	uint8_t  state;
} __attribute__((packed));

#define HAL_EV_HEALTH_CHANNEL_STATE		0x82
struct hal_ev_health_channel_state {
	uint16_t app_id;
	uint8_t  bdaddr[6];
	uint8_t  mdep_index;
	uint16_t channel_id;
	uint8_t  channel_state;
} __attribute__((packed));

#define HAL_A2DP_STATE_DISCONNECTED		0x00
#define HAL_A2DP_STATE_CONNECTING		0x01
#define HAL_A2DP_STATE_CONNECTED		0x02
#define HAL_A2DP_STATE_DISCONNECTING		0x03

#define HAL_EV_A2DP_CONN_STATE			0x81
struct hal_ev_a2dp_conn_state {
	uint8_t state;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_AUDIO_SUSPEND			0x00
#define HAL_AUDIO_STOPPED			0x01
#define HAL_AUDIO_STARTED			0x02

#define HAL_EV_A2DP_AUDIO_STATE			0x82
struct hal_ev_a2dp_audio_state {
	uint8_t state;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_CONN_STATE_DISCONNECTED	0x00
#define HAL_EV_HANDSFREE_CONN_STATE_CONNECTING		0x01
#define HAL_EV_HANDSFREE_CONN_STATE_CONNECTED		0x02
#define HAL_EV_HANDSFREE_CONN_STATE_SLC_CONNECTED	0x03
#define HAL_EV_HANDSFREE_CONN_STATE_DISCONNECTING	0x04

#define HAL_EV_HANDSFREE_CONN_STATE		0x81
struct hal_ev_handsfree_conn_state {
	uint8_t state;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED	0x00
#define HAL_EV_HANDSFREE_AUDIO_STATE_CONNECTING		0x01
#define HAL_EV_HANDSFREE_AUDIO_STATE_CONNECTED		0x02
#define HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTING	0x03

#define HAL_EV_HANDSFREE_AUDIO_STATE		0x82
struct hal_ev_handsfree_audio_state {
	uint8_t state;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_HANDSFREE_VR_STOPPED	0x00
#define HAL_HANDSFREE_VR_STARTED	0x01

#define HAL_EV_HANDSFREE_VR		0x83
struct hal_ev_handsfree_vr_state {
	uint8_t state;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_ANSWER		0x84
struct hal_ev_handsfree_answer {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_HANGUP		0x85
struct hal_ev_handsfree_hangup {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_VOLUME		0x86
struct hal_ev_handsfree_volume {
	uint8_t type;
	uint8_t volume;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_DIAL		0x87
struct hal_ev_handsfree_dial {
	uint8_t bdaddr[6];
	uint16_t number_len;
	uint8_t number[0];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_DTMF		0x88
struct hal_ev_handsfree_dtmf {
	uint8_t tone;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_HANDSFREE_NREC_STOP		0x00
#define HAL_HANDSFREE_NREC_START	0x01

#define HAL_EV_HANDSFREE_NREC		0x89
struct hal_ev_handsfree_nrec {
	uint8_t nrec;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_HANDSFREE_CHLD_TYPE_RELEASEHELD			0x00
#define HAL_HANDSFREE_CHLD_TYPE_RELEASEACTIVE_ACCEPTHELD	0x01
#define HAL_HANDSFREE_CHLD_TYPE_HOLDACTIVE_ACCEPTHELD		0x02
#define HAL_HANDSFREE_CHLD_TYPE_ADDHELDTOCONF			0x03

#define HAL_EV_HANDSFREE_CHLD		0x8A
struct hal_ev_handsfree_chld {
	uint8_t chld;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_CNUM		0x8B
struct hal_ev_handsfree_cnum {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_CIND		0x8C
struct hal_ev_handsfree_cind {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_COPS		0x8D
struct hal_ev_handsfree_cops {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_CLCC		0x8E
struct hal_ev_handsfree_clcc {
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_UNKNOWN_AT	0x8F
struct hal_ev_handsfree_unknown_at {
	uint8_t bdaddr[6];
	uint16_t len;
	uint8_t buf[0];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_HSP_KEY_PRESS	0x90

#define HAL_AVRCP_FEATURE_NONE			0x00
#define HAL_AVRCP_FEATURE_METADATA		0x01
#define HAL_AVRCP_FEATURE_ABSOLUTE_VOLUME	0x02
#define HAL_AVRCP_FEATURE_BROWSE		0x04

#define HAL_EV_AVRCP_REMOTE_FEATURES		0x81
struct hal_ev_avrcp_remote_features {
	uint8_t bdaddr[6];
	uint8_t features;
} __attribute__((packed));

#define HAL_EV_AVRCP_GET_PLAY_STATUS		0x82
#define HAL_EV_AVRCP_LIST_PLAYER_ATTRS		0x83

#define HAL_EV_AVRCP_LIST_PLAYER_VALUES		0x84
struct hal_ev_avrcp_list_player_values {
	uint8_t attr;
} __attribute__((packed));

#define HAL_EV_AVRCP_GET_PLAYER_VALUES		0x85
struct hal_ev_avrcp_get_player_values {
	uint8_t number;
	uint8_t attrs[0];
} __attribute__((packed));

#define HAL_EV_AVRCP_GET_PLAYER_ATTRS_TEXT	0x86
struct hal_ev_avrcp_get_player_attrs_text {
	uint8_t number;
	uint8_t attrs[0];
} __attribute__((packed));

#define HAL_EV_AVRCP_GET_PLAYER_VALUES_TEXT	0x87
struct hal_ev_avrcp_get_player_values_text {
	uint8_t attr;
	uint8_t number;
	uint8_t values[0];
} __attribute__((packed));

#define HAL_EV_AVRCP_SET_PLAYER_VALUES		0x88
struct hal_ev_avrcp_set_player_values {
	uint8_t number;
	struct hal_avrcp_player_attr_value attrs[0];
} __attribute__((packed));

#define HAL_EV_AVRCP_GET_ELEMENT_ATTRS		0x89
struct hal_ev_avrcp_get_element_attrs {
	uint8_t number;
	uint8_t attrs[0];
} __attribute__((packed));

#define HAL_EV_AVRCP_REGISTER_NOTIFICATION	0x8a
struct hal_ev_avrcp_register_notification {
	uint8_t event;
	uint32_t param;
} __attribute__((packed));

#define HAL_EV_AVRCP_VOLUME_CHANGED		0x8b
struct hal_ev_avrcp_volume_changed {
	uint8_t volume;
	uint8_t type;
} __attribute__((packed));

#define HAL_EV_AVRCP_PASSTHROUGH_CMD		0x8c
struct hal_ev_avrcp_passthrough_cmd {
	uint8_t id;
	uint8_t state;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_REGISTER_CLIENT	0x81
struct hal_ev_gatt_client_register_client {
	int32_t status;
	int32_t client_if;
	uint8_t app_uuid[16];
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_SCAN_RESULT	0x82
struct hal_ev_gatt_client_scan_result {
	uint8_t  bda[6];
	int32_t  rssi;
	uint16_t len;
	uint8_t  adv_data[0];
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_CONNECT	0x83
struct hal_ev_gatt_client_connect {
	int32_t conn_id;
	int32_t status;
	int32_t client_if;
	uint8_t bda[6];
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_DISCONNECT	0x84
struct hal_ev_gatt_client_disconnect {
	int32_t conn_id;
	int32_t status;
	int32_t client_if;
	uint8_t bda[6];
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_SEARCH_COMPLETE	0x85
struct hal_ev_gatt_client_search_complete {
	int32_t conn_id;
	int32_t status;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_SEARCH_RESULT	0x86
struct hal_ev_gatt_client_search_result {
	int32_t conn_id;
	struct hal_gatt_srvc_id srvc_id;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_GET_CHARACTERISTIC	0x87
struct hal_ev_gatt_client_get_characteristic {
	int32_t conn_id;
	int32_t status;
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
	int32_t char_prop;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_GET_DESCRIPTOR	0x88
struct hal_ev_gatt_client_get_descriptor {
	int32_t conn_id;
	int32_t status;
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
	struct hal_gatt_gatt_id descr_id;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_GET_INC_SERVICE	0X89
struct hal_ev_gatt_client_get_inc_service {
	int32_t conn_id;
	int32_t status;
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_srvc_id incl_srvc_id;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_REGISTER_FOR_NOTIF	0x8a
struct hal_ev_gatt_client_reg_for_notif {
	int32_t conn_id;
	int32_t registered;
	int32_t status;
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_NOTIFY		0x8b
struct hal_ev_gatt_client_notify {
	int32_t conn_id;
	uint8_t bda[6];
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
	uint8_t  is_notify;
	uint16_t len;
	uint8_t  value[0];
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_READ_CHARACTERISTIC	0x8c
struct hal_gatt_read_params {
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
	struct hal_gatt_gatt_id descr_id;
	uint8_t  status;
	uint16_t value_type;
	uint16_t len;
	uint8_t  value[0];
} __attribute__((packed));

struct hal_ev_gatt_client_read_characteristic {
	int32_t conn_id;
	int32_t status;
	struct hal_gatt_read_params data;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_WRITE_CHARACTERISTIC	0x8d
struct hal_gatt_write_params {
	struct hal_gatt_srvc_id srvc_id;
	struct hal_gatt_gatt_id char_id;
	struct hal_gatt_gatt_id descr_id;
	uint8_t status;
} __attribute__((packed));

struct hal_ev_gatt_client_write_characteristic {
	int32_t conn_id;
	int32_t status;
	struct hal_gatt_write_params data;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_READ_DESCRIPTOR	0x8e
struct hal_ev_gatt_client_read_descriptor {
	int32_t conn_id;
	int32_t status;
	struct hal_gatt_read_params data;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_WRITE_DESCRIPTOR	0x8f
struct hal_ev_gatt_client_write_descriptor {
	int32_t conn_id;
	int32_t status;
	struct hal_gatt_write_params data;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_EXEC_WRITE		0x90
struct hal_ev_gatt_client_exec_write {
	int32_t conn_id;
	int32_t status;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_READ_REMOTE_RSSI	0x91
struct hal_ev_gatt_client_read_remote_rssi {
	int32_t client_if;
	uint8_t address[6];
	int32_t rssi;
	int32_t status;
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_LISTEN		0x92
struct hal_ev_gatt_client_listen {
	int32_t status;
	int32_t server_if;
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_REGISTER		0x93
struct hal_ev_gatt_server_register {
	int32_t status;
	int32_t server_if;
	uint8_t uuid[16];
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_CONNECTION		0x94
struct hal_ev_gatt_server_connection {
	int32_t conn_id;
	int32_t server_if;
	int32_t connected;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_SERVICE_ADDED	0x95
struct hal_ev_gatt_server_service_added {
	int32_t status;
	int32_t server_if;
	struct hal_gatt_srvc_id srvc_id;
	int32_t srvc_handle;
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_INC_SRVC_ADDED	0x96
struct hal_ev_gatt_server_inc_srvc_added {
	int32_t status;
	int32_t server_if;
	int32_t srvc_handle;
	int32_t incl_srvc_handle;
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_CHAR_ADDED		0x97
struct hal_ev_gatt_server_characteristic_added {
	int32_t status;
	int32_t server_if;
	uint8_t uuid[16];
	int32_t srvc_handle;
	int32_t char_handle;
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_DESCRIPTOR_ADDED	0x98
struct hal_ev_gatt_server_descriptor_added {
	int32_t status;
	int32_t server_if;
	uint8_t uuid[16];
	int32_t srvc_handle;
	int32_t descr_handle;
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_SERVICE_STARTED	0x99
struct hal_ev_gatt_server_service_started {
	int32_t status;
	int32_t server_if;
	int32_t srvc_handle;
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_SERVICE_STOPPED	0x9a
struct hal_ev_gatt_server_service_stopped {
	int32_t status;
	int32_t server_if;
	int32_t srvc_handle;
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_SERVICE_DELETED	0x9b
struct hal_ev_gatt_server_service_deleted {
	int32_t status;
	int32_t server_if;
	int32_t srvc_handle;
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_REQUEST_READ		0x9c
struct hal_ev_gatt_server_request_read {
	int32_t conn_id;
	int32_t trans_id;
	uint8_t bdaddr[6];
	int32_t attr_handle;
	int32_t offset;
	uint8_t is_long;
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_REQUEST_WRITE	0x9d
struct hal_ev_gatt_server_request_write {
	int32_t conn_id;
	int32_t trans_id;
	uint8_t bdaddr[6];
	int32_t attr_handle;
	int32_t offset;
	int32_t length;
	uint8_t need_rsp;
	uint8_t is_prep;
	uint8_t value[0];
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_REQUEST_EXEC_WRITE	0x9e
struct hal_ev_gatt_server_request_exec_write {
	int32_t conn_id;
	int32_t trans_id;
	uint8_t bdaddr[6];
	int32_t exec_write;
} __attribute__((packed));

#define HAL_EV_GATT_SERVER_RSP_CONFIRMATION	0x9f
struct hal_ev_gatt_server_rsp_confirmation {
	int32_t status;
	int32_t handle;
} __attribute__((packed));

#define HAL_GATT_PERMISSION_READ			0x0001
#define HAL_GATT_PERMISSION_READ_ENCRYPTED		0x0002
#define HAL_GATT_PERMISSION_READ_ENCRYPTED_MITM		0x0004
#define HAL_GATT_PERMISSION_WRITE			0x0010
#define HAL_GATT_PERMISSION_WRITE_ENCRYPTED		0x0020
#define HAL_GATT_PERMISSION_WRITE_ENCRYPTED_MITM	0x0040
#define HAL_GATT_PERMISSION_WRITE_SIGNED		0x0080
#define HAL_GATT_PERMISSION_WRITE_SIGNED_MITM		0x0100

#define HAL_GATT_AUTHENTICATION_NONE		0
#define HAL_GATT_AUTHENTICATION_NO_MITM		1
#define HAL_GATT_AUTHENTICATION_MITM		2

#define HAL_HF_CLIENT_CONN_STATE_DISCONNECTED		0x00
#define HAL_HF_CLIENT_CONN_STATE_CONNECTING		0x01
#define HAL_HF_CLIENT_CONN_STATE_SLC_CONNECTED		0x02
#define HAL_HF_CLIENT_CONN_STATE_DISCONNECTING		0x03

#define HAL_HF_CLIENT_PEER_FEAT_3WAY		0x00000001
#define HAL_HF_CLIENT_PEER_FEAT_ECNR		0x00000002
#define HAL_HF_CLIENT_PEER_FEAT_VREC		0x00000004
#define HAL_HF_CLIENT_PEER_FEAT_INBAND		0x00000008
#define HAL_HF_CLIENT_PEER_FEAT_VTAG		0x00000010
#define HAL_HF_CLIENT_PEER_FEAT_REJECT		0x00000020
#define HAL_HF_CLIENT_PEER_FEAT_ECS		0x00000040
#define HAL_HF_CLIENT_PEER_FEAT_ECC		0x00000080
#define HAL_HF_CLIENT_PEER_FEAT_EXTERR		0x00000100
#define HAL_HF_CLIENT_PEER_FEAT_CODEC		0x00000200

#define HAL_HF_CLIENT_CHLD_FEAT_REL		0x00000001
#define HAL_HF_CLIENT_CHLD_FEAT_REL_ACC		0x00000002
#define HAL_HF_CLIENT_CHLD_FEAT_REL_X		0x00000004
#define HAL_HF_CLIENT_CHLD_FEAT_HOLD_ACC	0x00000008
#define HAL_HF_CLIENT_CHLD_FEAT_PRIV_X		0x00000010
#define HAL_HF_CLIENT_CHLD_FEAT_MERGE		0x00000020
#define HAL_HF_CLIENT_CHLD_FEAT_MERGE_DETACH	0x00000040

#define HAL_EV_HF_CLIENT_CONN_STATE			0x81
struct hal_ev_hf_client_conn_state {
	uint8_t state;
	uint32_t peer_feat;
	uint32_t chld_feat;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_HF_CLIENT_AUDIO_STATE_DISCONNECTED		0x00
#define HAL_HF_CLIENT_AUDIO_STATE_CONNECTING		0x01
#define HAL_HF_CLIENT_AUDIO_STATE_CONNECTED		0x02
#define HAL_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC	0x03

#define HAL_EV_HF_CLIENT_AUDIO_STATE			0x82
struct hal_ev_hf_client_audio_state {
	uint8_t state;
	uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_HF_CLIENT_VR_STOPPED	0x00
#define HAL_HF_CLIENT_VR_STARTED	0x01

#define HAL_EV_HF_CLIENT_VR_STATE			0x83
struct hal_ev_hf_client_vr_state {
	uint8_t state;
} __attribute__((packed));

#define HAL_HF_CLIENT_NET_NOT_AVAILABLE		0x00
#define HAL_HF_CLIENT_NET_AVAILABLE		0x01

#define HAL_EV_HF_CLIENT_NET_STATE			0x84
struct hal_ev_hf_client_net_state {
	uint8_t state;
} __attribute__((packed));

#define HAL_HF_CLIENT_NET_ROAMING_TYPE_HOME		0x00
#define HAL_HF_CLIENT_NET_ROAMING_TYPE_ROAMING		0x01

#define HAL_EV_HF_CLIENT_NET_ROAMING_TYPE		0x85
struct hal_ev_hf_client_net_roaming_type {
	uint8_t state;
} __attribute__((packed));

#define HAL_EV_HF_CLIENT_NET_SIGNAL_STRENGTH		0x86
struct hal_ev_hf_client_net_signal_strength {
	uint8_t signal_strength;
} __attribute__((packed));

#define HAL_EV_HF_CLIENT_BATTERY_LEVEL			0x87
struct hal_ev_hf_client_battery_level {
	uint8_t battery_level;
} __attribute__((packed));

#define HAL_EV_HF_CLIENT_OPERATOR_NAME			0x88
struct hal_ev_hf_client_operator_name {
	uint16_t name_len;
	uint8_t name[0];
} __attribute__((packed));

#define HAL_HF_CLIENT_CALL_IND_NO_CALL_IN_PROGERSS	0x00
#define HAL_HF_CLIENT_CALL_IND_CALL_IN_PROGERSS		0x01

#define HAL_EV_HF_CLIENT_CALL_INDICATOR			0x89
struct hal_ev_hf_client_call_indicator {
	uint8_t call;
} __attribute__((packed));

#define HAL_HF_CLIENT_CALL_SETUP_NONE			0x00
#define HAL_HF_CLIENT_CALL_SETUP_INCOMING		0x01
#define HAL_HF_CLIENT_CALL_SETUP_OUTGOING		0x02
#define HAL_HF_CLIENT_CALL_SETUP_ALERTING		0x03

#define HAL_EV_HF_CLIENT_CALL_SETUP_INDICATOR		0x8a
struct hal_ev_hf_client_call_setup_indicator {
	uint8_t call_setup;
} __attribute__((packed));

#define HAL_HF_CLIENT_CALL_HELD_IND_NONE		0x00
#define HAL_HF_CLIENT_CALL_HELD_IND_HOLD_AND_ACTIVE	0x01
#define HAL_HF_CLIENT_CALL_SETUP_IND_HOLD		0x02

#define HAL_EV_HF_CLIENT_CALL_HELD_INDICATOR		0x8b
struct hal_ev_hf_client_call_held_indicator {
	uint8_t call_held;
} __attribute__((packed));

#define HAL_HF_CLIENT_RESP_AND_HOLD_STATUS_HELD		0x00
#define HAL_HF_CLIENT_RESP_AND_HOLD_STATUS_ACCEPT	0x01
#define HAL_HF_CLIENT_RESP_AND_HOLD_STATUS_REJECT	0x02

#define HAL_EV_HF_CLIENT_RESPONSE_AND_HOLD_STATUS	0x8c
struct hal_ev_hf_client_response_and_hold_status {
	uint8_t status;
} __attribute__((packed));

#define HAL_EV_HF_CLIENT_CALLING_LINE_IDENT		0x8d
struct hal_ev_hf_client_calling_line_ident {
	uint16_t number_len;
	uint8_t number[0];
} __attribute__((packed));

#define HAL_EV_HF_CLIENT_CALL_WAITING			0x8e
struct hal_ev_hf_client_call_waiting {
	uint16_t number_len;
	uint8_t number[0];
} __attribute__((packed));

#define HAL_HF_CLIENT_DIRECTION_OUTGOING	0x00
#define HAL_HF_CLIENT_DIRECTION_INCOMIGN	0x01

#define HAL_HF_CLIENT_CALL_STATE_ACTIVE			0x00
#define HAL_HF_CLIENT_CALL_STATE_HELD			0x01
#define HAL_HF_CLIENT_CALL_STATE_DIALING		0x02
#define HAL_HF_CLIENT_CALL_STATE_ALERTING		0x03
#define HAL_HF_CLIENT_CALL_STATE_INCOMING		0x04
#define HAL_HF_CLIENT_CALL_STATE_WAITING		0x05
#define HAL_HF_CLIENT_CALL_STATE_HELD_BY_RESP_AND_HOLD	0x06

#define HAL_EV_HF_CLIENT_CURRENT_CALL			0x8f
struct hal_ev_hf_client_current_call {
	uint8_t index;
	uint8_t direction;
	uint8_t call_state;
	uint8_t multiparty;
	uint16_t number_len;
	uint8_t number[0];
} __attribute__((packed));

#define HAL_EV_CLIENT_VOLUME_CHANGED			0x90
struct hal_ev_hf_client_volume_changed {
	uint8_t type;
	uint8_t volume;
} __attribute__((packed));

#define HAL_HF_CLIENT_CMD_COMP_OK			0x00
#define HAL_HF_CLIENT_CMD_COMP_ERR			0x01
#define HAL_HF_CLIENT_CMD_COMP_ERR_NO_CARRIER		0x02
#define HAL_HF_CLIENT_CMD_COMP_ERR_BUSY			0x03
#define HAL_HF_CLIENT_CMD_COMP_ERR_NO_ANSWER		0x04
#define HAL_HF_CLIENT_CMD_COMP_ERR_DELAYED		0x05
#define HAL_HF_CLIENT_CMD_COMP_ERR_BACKLISTED		0x06
#define HAL_HF_CLIENT_CMD_COMP_ERR_CME			0x07

#define HAL_EV_CLIENT_COMMAND_COMPLETE			0x91
struct hal_ev_hf_client_command_complete {
	uint8_t type;
	uint8_t cme;
} __attribute__((packed));

#define HAL_HF_CLIENT_SUBSCR_TYPE_UNKNOWN	0x00
#define HAL_HF_CLIENT_SUBSCR_TYPE_VOICE		0x01
#define HAL_HF_CLIENT_SUBSCR_TYPE_FAX		0x02

#define HAL_EV_CLIENT_SUBSCRIBER_SERVICE_INFO		0x92
struct hal_ev_hf_client_subscriber_service_info {
	uint8_t type;
	uint16_t name_len;
	uint8_t name[0];
} __attribute__((packed));

#define HAL_HF_CLIENT_INBAND_RINGTONE_NOT_PROVIDED	0x00
#define HAL_HF_CLIENT_INBAND_RINGTONE_PROVIDED		0x01

#define HAL_EV_CLIENT_INBAND_SETTINGS			0x93
struct hal_ev_hf_client_inband_settings {
	uint8_t state;
} __attribute__((packed));

#define HAL_EV_CLIENT_LAST_VOICE_CALL_TAG_NUM		0x94
struct hal_ev_hf_client_last_void_call_tag_num {
	uint16_t number_len;
	uint8_t number[0];
} __attribute__((packed));

#define HAL_EV_CLIENT_RING_INDICATION			0x95

#define HAL_EV_MAP_CLIENT_REMOTE_MAS_INSTANCES	0x81
struct hal_map_client_mas_instance {
	int32_t id;
	int32_t scn;
	int32_t msg_types;
	int32_t name_len;
	uint8_t name[0];
} __attribute__((packed));

struct hal_ev_map_client_remote_mas_instances {
	int8_t status;
	uint8_t bdaddr[6];
	int32_t num_instances;
	struct hal_map_client_mas_instance instances[0];
} __attribute__((packed));