Tizen 2.0 Release
[framework/connectivity/bluez.git] / health / mcap.h
1 /*
2  *
3  *  MCAP for BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
6  *  Copyright (C) 2010 Signove
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23
24 #ifndef __MCAP_H
25 #define __MCAP_H
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #define MCAP_VERSION    0x0100  /* current version 01.00 */
32
33 /* bytes to get MCAP Supported Procedures */
34 #define MCAP_SUP_PROC   0x06
35
36 /* maximum transmission unit for channels */
37 #define MCAP_CC_MTU     48
38 #define MCAP_DC_MTU     L2CAP_DEFAULT_MTU
39
40 /* MCAP Standard Op Codes */
41 #define MCAP_ERROR_RSP                  0x00
42 #define MCAP_MD_CREATE_MDL_REQ          0x01
43 #define MCAP_MD_CREATE_MDL_RSP          0x02
44 #define MCAP_MD_RECONNECT_MDL_REQ       0x03
45 #define MCAP_MD_RECONNECT_MDL_RSP       0x04
46 #define MCAP_MD_ABORT_MDL_REQ           0x05
47 #define MCAP_MD_ABORT_MDL_RSP           0x06
48 #define MCAP_MD_DELETE_MDL_REQ          0x07
49 #define MCAP_MD_DELETE_MDL_RSP          0x08
50
51 /* MCAP Clock Sync Op Codes */
52 #define MCAP_MD_SYNC_CAP_REQ            0x11
53 #define MCAP_MD_SYNC_CAP_RSP            0x12
54 #define MCAP_MD_SYNC_SET_REQ            0x13
55 #define MCAP_MD_SYNC_SET_RSP            0x14
56 #define MCAP_MD_SYNC_INFO_IND           0x15
57
58 /* MCAP Response codes */
59 #define MCAP_SUCCESS                    0x00
60 #define MCAP_INVALID_OP_CODE            0x01
61 #define MCAP_INVALID_PARAM_VALUE        0x02
62 #define MCAP_INVALID_MDEP               0x03
63 #define MCAP_MDEP_BUSY                  0x04
64 #define MCAP_INVALID_MDL                0x05
65 #define MCAP_MDL_BUSY                   0x06
66 #define MCAP_INVALID_OPERATION          0x07
67 #define MCAP_RESOURCE_UNAVAILABLE       0x08
68 #define MCAP_UNSPECIFIED_ERROR          0x09
69 #define MCAP_REQUEST_NOT_SUPPORTED      0x0A
70 #define MCAP_CONFIGURATION_REJECTED     0x0B
71
72 /* MDL IDs */
73 #define MCAP_MDLID_RESERVED             0x0000
74 #define MCAP_MDLID_INITIAL              0x0001
75 #define MCAP_MDLID_FINAL                0xFEFF
76 #define MCAP_ALL_MDLIDS                 0xFFFF
77
78 /* MDEP IDs */
79 #define MCAP_MDEPID_INITIAL             0x00
80 #define MCAP_MDEPID_FINAL               0x7F
81
82 /* CSP special values */
83 #define MCAP_BTCLOCK_IMMEDIATE          0xffffffffUL
84 #define MCAP_TMSTAMP_DONTSET            0xffffffffffffffffULL
85 #define MCAP_BTCLOCK_MAX                0x0fffffff
86 #define MCAP_BTCLOCK_FIELD              (MCAP_BTCLOCK_MAX + 1)
87
88 /*
89  * MCAP Request Packet Format
90  */
91
92 typedef struct {
93         uint8_t         op;
94         uint16_t        mdl;
95         uint8_t         mdep;
96         uint8_t         conf;
97 } __attribute__ ((packed)) mcap_md_create_mdl_req;
98
99 typedef struct {
100         uint8_t         op;
101         uint16_t        mdl;
102 } __attribute__ ((packed)) mcap_md_req;
103
104 /*
105  * MCAP Response Packet Format
106  */
107
108 typedef struct {
109         uint8_t         op;
110         uint8_t         rc;
111         uint16_t        mdl;
112         uint8_t         data[0];
113 } __attribute__ ((packed)) mcap_rsp;
114
115 /*
116  * MCAP Clock Synchronization Protocol
117  */
118
119 typedef struct {
120         uint8_t         op;
121         uint16_t        timest;
122 } __attribute__ ((packed)) mcap_md_sync_cap_req;
123
124 typedef struct {
125         uint8_t         op;
126         uint8_t         rc;
127 } __attribute__ ((packed)) mcap_md_sync_rsp;
128
129 typedef struct {
130         uint8_t         op;
131         uint8_t         rc;
132         uint8_t         btclock;
133         uint16_t        sltime;
134         uint16_t        timestnr;
135         uint16_t        timestna;
136 } __attribute__ ((packed)) mcap_md_sync_cap_rsp;
137
138 typedef struct {
139         uint8_t         op;
140         uint8_t         timestui;
141         uint32_t        btclock;
142         uint64_t        timestst;
143 } __attribute__ ((packed)) mcap_md_sync_set_req;
144
145 typedef struct {
146         int8_t          op;
147         uint8_t         rc;
148         uint32_t        btclock;
149         uint64_t        timestst;
150         uint16_t        timestsa;
151 } __attribute__ ((packed)) mcap_md_sync_set_rsp;
152
153 typedef struct {
154         uint8_t         op;
155         uint32_t        btclock;
156         uint64_t        timestst;
157         uint16_t        timestsa;
158 } __attribute__ ((packed)) mcap_md_sync_info_ind;
159
160 #ifdef __cplusplus
161 }
162 #endif
163
164 #endif /* __MCAP_H */