]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/BluetoothAttribute.h
MdePkg/Include/Protocol/Tls.h: pack structures from the TLS RFC
[mirror_edk2.git] / MdePkg / Include / Protocol / BluetoothAttribute.h
CommitLineData
9c94cc2c
RN
1/** @file\r
2 EFI Bluetooth Attribute Protocol as defined in UEFI 2.7.\r
3 This protocol provides service for Bluetooth ATT (Attribute Protocol) and GATT (Generic\r
4 Attribute Profile) based protocol interfaces.\r
5\r
6 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
7 This program and the accompanying materials are licensed and made available under\r
8 the terms and conditions of the BSD License that accompanies this distribution.\r
9 The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php.\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15 @par Revision Reference:\r
16 This Protocol is introduced in UEFI Specification 2.7\r
17\r
18**/\r
19\r
20#ifndef __EFI_BLUETOOTH_ATTRIBUTE_H__\r
21#define __EFI_BLUETOOTH_ATTRIBUTE_H__\r
22\r
23#define EFI_BLUETOOTH_ATTRIBUTE_SERVICE_BINDING_PROTOCOL_GUID \\r
24 { \\r
25 0x5639867a, 0x8c8e, 0x408d, { 0xac, 0x2f, 0x4b, 0x61, 0xbd, 0xc0, 0xbb, 0xbb } \\r
26 }\r
27\r
28#define EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL_GUID \\r
29 { \\r
30 0x898890e9, 0x84b2, 0x4f3a, { 0x8c, 0x58, 0xd8, 0x57, 0x78, 0x13, 0xe0, 0xac } \\r
31 }\r
32\r
33typedef struct _EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL;\r
34\r
35#pragma pack(1)\r
36\r
37//\r
38// Bluetooth UUID\r
39//\r
40typedef struct {\r
41 UINT8 Length;\r
42 union {\r
43 UINT16 Uuid16;\r
44 UINT32 Uuid32;\r
45 UINT8 Uuid128[16];\r
46 } Data;\r
47} EFI_BLUETOOTH_UUID;\r
48\r
49\r
50#define UUID_16BIT_TYPE_LEN 2\r
51#define UUID_32BIT_TYPE_LEN 4\r
52#define UUID_128BIT_TYPE_LEN 16\r
53\r
54#define BLUETOOTH_IS_ATTRIBUTE_OF_TYPE(a,t) ((a)->Type.Length == UUID_16BIT_TYPE_LEN && (a)->Type.Data.Uuid16 == (t))\r
55\r
56//\r
57// Bluetooth Attribute Permission\r
58//\r
59typedef union {\r
60 struct {\r
61 UINT16 Readable : 1;\r
62 UINT16 ReadEncryption : 1;\r
63 UINT16 ReadAuthentication : 1;\r
64 UINT16 ReadAuthorization : 1;\r
65 UINT16 ReadKeySize : 5;\r
66 UINT16 Reserved1 : 7;\r
67 UINT16 Writeable : 1;\r
68 UINT16 WriteEncryption : 1;\r
69 UINT16 WriteAuthentication : 1;\r
70 UINT16 WriteAuthorization : 1;\r
71 UINT16 WriteKeySize : 5;\r
72 UINT16 Reserved2 : 7;\r
73 } Permission;\r
74 UINT32 Data32;\r
75} EFI_BLUETOOTH_ATTRIBUTE_PERMISSION;\r
76\r
77typedef struct {\r
78 EFI_BLUETOOTH_UUID Type;\r
79 UINT16 Length;\r
80 UINT16 AttributeHandle;\r
81 EFI_BLUETOOTH_ATTRIBUTE_PERMISSION AttributePermission;\r
82} EFI_BLUETOOTH_ATTRIBUTE_HEADER;\r
83\r
84typedef struct {\r
85 EFI_BLUETOOTH_ATTRIBUTE_HEADER Header;\r
86 UINT16 EndGroupHandle;\r
87 EFI_BLUETOOTH_UUID ServiceUuid;\r
88} EFI_BLUETOOTH_GATT_PRIMARY_SERVICE_INFO;\r
89\r
90typedef struct {\r
91 EFI_BLUETOOTH_ATTRIBUTE_HEADER Header;\r
92 UINT16 StartGroupHandle;\r
93 UINT16 EndGroupHandle;\r
94 EFI_BLUETOOTH_UUID ServiceUuid;\r
95} EFI_BLUETOOTH_GATT_INCLUDE_SERVICE_INFO;\r
96\r
97typedef struct {\r
98 EFI_BLUETOOTH_ATTRIBUTE_HEADER Header;\r
99 UINT8 CharacteristicProperties;\r
100 UINT16 CharacteristicValueHandle;\r
101 EFI_BLUETOOTH_UUID CharacteristicUuid;\r
102} EFI_BLUETOOTH_GATT_CHARACTERISTIC_INFO;\r
103\r
104typedef struct {\r
105 EFI_BLUETOOTH_ATTRIBUTE_HEADER Header;\r
106 EFI_BLUETOOTH_UUID CharacteristicDescriptorUuid;\r
107} EFI_BLUETOOTH_GATT_CHARACTERISTIC_DESCRIPTOR_INFO;\r
108\r
109#pragma pack()\r
110\r
111typedef struct {\r
112 UINT16 AttributeHandle;\r
113} EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER_NOTIFICATION;\r
114\r
115typedef struct {\r
116 UINT16 AttributeHandle;\r
117} EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER_INDICATION;\r
118\r
119typedef struct {\r
120 UINT32 Version;\r
121 UINT8 AttributeOpCode;\r
122 union {\r
123 EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER_NOTIFICATION Notification;\r
124 EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER_INDICATION Indication;\r
125 } Parameter;\r
126} EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER;\r
127\r
128typedef struct {\r
129 UINT32 Version;\r
130 BLUETOOTH_LE_ADDRESS BD_ADDR;\r
131 BLUETOOTH_LE_ADDRESS DirectAddress;\r
132 UINT8 RSSI;\r
133 UINTN AdvertisementDataSize;\r
134 VOID *AdvertisementData;\r
135} EFI_BLUETOOTH_LE_DEVICE_INFO;\r
136\r
137/**\r
138 The callback function to send request.\r
139\r
140 @param[in] This Pointer to the EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL instance.\r
141 @param[in] Data Data received. The first byte is the attribute opcode, followed by opcode specific\r
142 fields. See Bluetooth specification, Vol 3, Part F, Attribute Protocol. It might be a\r
143 normal RESPONSE message, or ERROR RESPONSE messag\r
144 @param[in] DataLength The length of Data in bytes.\r
145 @param[in] Context The context passed from the callback registration request.\r
146\r
147 @retval EFI_SUCCESS The callback function complete successfully.\r
148\r
149**/\r
150typedef\r
151EFI_STATUS\r
152(EFIAPI *EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_FUNCTION) (\r
153 IN EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL *This,\r
154 IN VOID *Data,\r
155 IN UINTN DataLength,\r
156 IN VOID *Context\r
157 );\r
158\r
159/**\r
160 Send a "REQUEST" or "COMMAND" message to remote server and receive a "RESPONSE" message\r
161 for "REQUEST" from remote server according to Bluetooth attribute protocol data unit(PDU).\r
162\r
163 @param[in] This Pointer to the EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL instance.\r
164 @param[in] Data Data of a REQUEST or COMMAND message. The first byte is the attribute PDU\r
165 related opcode, followed by opcode specific fields. See Bluetooth specification,\r
166 Vol 3, Part F, Attribute Protocol.\r
167 @param[in] DataLength The length of Data in bytes.\r
168 @param[in] Callback Callback function to notify the RESPONSE is received to the caller, with the\r
169 response buffer. Caller must check the response buffer content to know if the\r
170 request action is success or fail. It may be NULL if the data is a COMMAND.\r
171 @param[in] Context Data passed into Callback function. It is optional parameter and may be NULL.\r
172\r
173 @retval EFI_SUCCESS The request is sent successfully.\r
174 @retval EFI_INVALID_PARAMETER One or more parameters are invalid due to following conditions:\r
175 - The Buffer is NULL.\r
176 - The BufferLength is 0.\r
177 - The opcode in Buffer is not a valid OPCODE according to Bluetooth specification.\r
178 - The Callback is NULL.\r
179 @retval EFI_DEVICE_ERROR Sending the request failed due to the host controller or the device error.\r
180 @retval EFI_NOT_READY A GATT operation is already underway for this device.\r
181 @retval EFI_UNSUPPORTED The attribute does not support the corresponding operation.\r
182\r
183**/\r
184typedef\r
185EFI_STATUS\r
186(EFIAPI *EFI_BLUETOOTH_ATTRIBUTE_SEND_REQUEST) (\r
187 IN EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL *This,\r
188 IN VOID *Data,\r
189 IN UINTN DataLength,\r
190 IN EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_FUNCTION Callback,\r
191 IN VOID *Context\r
192 );\r
193\r
194/**\r
195 Register or unregister a server initiated message, such as NOTIFICATION or INDICATION, on a\r
196 characteristic value on remote server.\r
197\r
198 @param[in] This Pointer to the EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL instance.\r
199 @param[in] CallbackParameter The parameter of the callback.\r
200 @param[in] Callback Callback function for server initiated attribute protocol. NULL callback\r
201 function means unregister the server initiated callback.\r
202 @param[in] Context Data passed into Callback function. It is optional parameter and may be NULL.\r
203\r
204 @retval EFI_SUCCESS The callback function is registered or unregistered successfully\r
205 @retval EFI_INVALID_PARAMETER The attribute opcode is not server initiated message opcode. See\r
206 Bluetooth specification, Vol 3, Part F, Attribute Protocol.\r
207 @retval EFI_ALREADY_STARTED A callback function is already registered on the same attribute\r
208 opcode and attribute handle, when the Callback is not NULL.\r
209 @retval EFI_NOT_STARTED A callback function is not registered on the same attribute opcode\r
210 and attribute handle, when the Callback is NULL.\r
211 @retval EFI_NOT_READY A GATT operation is already underway for this device.\r
212 @retval EFI_UNSUPPORTED The attribute does not support notification.\r
213\r
214**/\r
215typedef\r
216EFI_STATUS\r
217(EFIAPI *EFI_BLUETOOTH_ATTRIBUTE_REGISTER_FOR_SERVER_NOTIFICATION)(\r
218 IN EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL *This,\r
219 IN EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER *CallbackParameter,\r
220 IN EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_FUNCTION Callback,\r
221 IN VOID *Context\r
222 );\r
223\r
224/**\r
225 Get Bluetooth discovered service information.\r
226\r
227 @param[in] This Pointer to the EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL instance.\r
228 @param[out] ServiceInfoSize A pointer to the size, in bytes, of the ServiceInfo buffer.\r
229 @param[out] ServiceInfo A pointer to a callee allocated buffer that returns Bluetooth\r
230 discovered service information. Callee allocates this buffer by\r
231 using EFI Boot Service AllocatePool().\r
232\r
233 @retval EFI_SUCCESS The Bluetooth discovered service information is returned successfully.\r
234 @retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the Bluetooth discovered\r
235 service information.\r
236\r
237**/\r
238typedef\r
239EFI_STATUS\r
240(EFIAPI *EFI_BLUETOOTH_ATTRIBUTE_GET_SERVICE_INFO)(\r
241 IN EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL *This,\r
242 OUT UINTN *ServiceInfoSize,\r
243 OUT VOID **ServiceInfo\r
244 );\r
245\r
246/**\r
247 Get Bluetooth device information.\r
248\r
249 @param[in] This Pointer to the EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL instance.\r
250 @param[out] DeviceInfoSize A pointer to the size, in bytes, of the DeviceInfo buffer.\r
251 @param[out] DeviceInfo A pointer to a callee allocated buffer that returns Bluetooth\r
252 device information. Callee allocates this buffer by using EFI Boot\r
253 Service AllocatePool(). If this device is Bluetooth classic\r
254 device, EFI_BLUETOOTH_DEVICE_INFO should be used. If\r
255 this device is Bluetooth LE device, EFI_BLUETOOTH_LE_DEVICE_INFO\r
256 should be used.\r
257\r
258 @retval EFI_SUCCESS The Bluetooth device information is returned successfully.\r
259 @retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the Bluetooth device\r
260 information\r
261\r
262**/\r
263typedef\r
264EFI_STATUS\r
265(EFIAPI *EFI_BLUETOOTH_ATTRIBUTE_GET_DEVICE_INFO)(\r
266 IN EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL *This,\r
267 OUT UINTN *DeviceInfoSize,\r
268 OUT VOID **DeviceInfo\r
269 );\r
270\r
271struct _EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL {\r
272 EFI_BLUETOOTH_ATTRIBUTE_SEND_REQUEST SendRequest;\r
273 EFI_BLUETOOTH_ATTRIBUTE_REGISTER_FOR_SERVER_NOTIFICATION RegisterForServerNotification;\r
274 EFI_BLUETOOTH_ATTRIBUTE_GET_SERVICE_INFO GetServiceInfo;\r
275 EFI_BLUETOOTH_ATTRIBUTE_GET_DEVICE_INFO GetDeviceInfo;\r
276};\r
277\r
278\r
279extern EFI_GUID gEfiBluetoothAttributeProtocolGuid;\r
280extern EFI_GUID gEfiBluetoothAttributeServiceBindingProtocolGuid;\r
281\r
282#endif\r
283\r