1 /* bttester.h - Bluetooth tester headers */
2 
3 /*
4  * Copyright (c) 2015-2016 Intel Corporation
5  * Copyright (c) 2022 Codecoup
6  *
7  * SPDX-License-Identifier: Apache-2.0
8  */
9 
10 #include <zephyr/sys/util.h>
11 #include <zephyr/bluetooth/addr.h>
12 
13 #include "bttester.h"
14 #include "btp_core.h"
15 #include "btp_gap.h"
16 #include "btp_gatt.h"
17 #include "btp_l2cap.h"
18 #include "btp_mesh.h"
19 #include "btp_vcs.h"
20 #include "btp_aics.h"
21 #include "btp_vocs.h"
22 #include "btp_ias.h"
23 #include "btp_pacs.h"
24 #include "btp_ascs.h"
25 #include "btp_bap.h"
26 #include "btp_has.h"
27 #include "btp_csis.h"
28 #include "btp_micp.h"
29 #include "btp_mics.h"
30 #include "btp_ccp.h"
31 #include "btp_vcp.h"
32 #include "btp_cas.h"
33 #include "btp_mcp.h"
34 #include "btp_mcs.h"
35 #include "btp_hap.h"
36 #include "btp_csip.h"
37 #include "btp_cap.h"
38 #include "btp_tbs.h"
39 #include "btp_tmap.h"
40 #include "btp_ots.h"
41 
42 #define BTP_MTU 1024
43 #define BTP_DATA_MAX_SIZE (BTP_MTU - sizeof(struct btp_hdr))
44 
45 #define BTP_INDEX_NONE		0xff
46 #define BTP_INDEX		0x00
47 
48 #define BTP_SERVICE_ID_CORE	0
49 #define BTP_SERVICE_ID_GAP	1
50 #define BTP_SERVICE_ID_GATT	2
51 #define BTP_SERVICE_ID_L2CAP	3
52 #define BTP_SERVICE_ID_MESH	4
53 #define BTP_SERVICE_ID_MESH_MDL	5
54 #define BTP_SERVICE_GATT_CLIENT	6
55 #define BTP_SERVICE_GATT_SERVER	7
56 #define BTP_SERVICE_ID_VCS	8
57 #define BTP_SERVICE_ID_IAS	9
58 #define BTP_SERVICE_ID_AICS	10
59 #define BTP_SERVICE_ID_VOCS	11
60 #define BTP_SERVICE_ID_PACS	12
61 #define BTP_SERVICE_ID_ASCS	13
62 #define BTP_SERVICE_ID_BAP	14
63 #define BTP_SERVICE_ID_HAS	15
64 #define BTP_SERVICE_ID_MICP	16
65 #define BTP_SERVICE_ID_CSIS	17
66 #define BTP_SERVICE_ID_MICS	18
67 #define BTP_SERVICE_ID_CCP	19
68 #define BTP_SERVICE_ID_VCP	20
69 #define BTP_SERVICE_ID_CAS	21
70 #define BTP_SERVICE_ID_MCP	22
71 #define BTP_SERVICE_ID_GMCS	23
72 #define BTP_SERVICE_ID_HAP	24
73 #define BTP_SERVICE_ID_CSIP	25
74 #define BTP_SERVICE_ID_CAP	26
75 #define BTP_SERVICE_ID_TBS	27
76 #define BTP_SERVICE_ID_TMAP	28
77 #define BTP_SERVICE_ID_OTS	29
78 
79 #define BTP_SERVICE_ID_MAX	BTP_SERVICE_ID_OTS
80 
81 #define BTP_STATUS_SUCCESS	0x00
82 #define BTP_STATUS_FAILED	0x01
83 #define BTP_STATUS_UNKNOWN_CMD	0x02
84 #define BTP_STATUS_NOT_READY	0x03
85 
86 #define BTP_STATUS_VAL(err) (err) ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS
87 
88 /* TODO indicate delay response, should be removed when all commands are
89  * converted to cmd+status+ev pattern
90  */
91 #define BTP_STATUS_DELAY_REPLY	0xFF
92 
93 struct btp_hdr {
94 	uint8_t  service;
95 	uint8_t  opcode;
96 	uint8_t  index;
97 	uint16_t len;
98 	uint8_t  data[];
99 } __packed;
100 
101 #define BTP_STATUS		0x00
102 struct btp_status {
103 	uint8_t code;
104 } __packed;
105