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