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
|
/** @file
EFI Bluetooth Attribute Protocol as defined in UEFI 2.7.
This protocol provides service for Bluetooth ATT (Attribute Protocol) and GATT (Generic
Attribute Profile) based protocol interfaces.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@par Revision Reference:
This Protocol is introduced in UEFI Specification 2.7
**/
#ifndef __EFI_BLUETOOTH_ATTRIBUTE_H__
#define __EFI_BLUETOOTH_ATTRIBUTE_H__
#define EFI_BLUETOOTH_ATTRIBUTE_SERVICE_BINDING_PROTOCOL_GUID \
{ \
0x5639867a, 0x8c8e, 0x408d, { 0xac, 0x2f, 0x4b, 0x61, 0xbd, 0xc0, 0xbb, 0xbb } \
}
#define EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL_GUID \
{ \
0x898890e9, 0x84b2, 0x4f3a, { 0x8c, 0x58, 0xd8, 0x57, 0x78, 0x13, 0xe0, 0xac } \
}
typedef struct _EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL;
#pragma pack(1)
//
// Bluetooth UUID
//
typedef struct {
UINT8 Length;
union {
UINT16 Uuid16;
UINT32 Uuid32;
UINT8 Uuid128[16];
} Data;
} EFI_BLUETOOTH_UUID;
#define UUID_16BIT_TYPE_LEN 2
#define UUID_32BIT_TYPE_LEN 4
#define UUID_128BIT_TYPE_LEN 16
#define BLUETOOTH_IS_ATTRIBUTE_OF_TYPE(a,t) ((a)->Type.Length == UUID_16BIT_TYPE_LEN && (a)->Type.Data.Uuid16 == (t))
//
// Bluetooth Attribute Permission
//
typedef union {
struct {
UINT16 Readable : 1;
UINT16 ReadEncryption : 1;
UINT16 ReadAuthentication : 1;
UINT16 ReadAuthorization : 1;
UINT16 ReadKeySize : 5;
UINT16 Reserved1 : 7;
UINT16 Writeable : 1;
UINT16 WriteEncryption : 1;
UINT16 WriteAuthentication : 1;
UINT16 WriteAuthorization : 1;
UINT16 WriteKeySize : 5;
UINT16 Reserved2 : 7;
} Permission;
UINT32 Data32;
} EFI_BLUETOOTH_ATTRIBUTE_PERMISSION;
typedef struct {
EFI_BLUETOOTH_UUID Type;
UINT16 Length;
UINT16 AttributeHandle;
EFI_BLUETOOTH_ATTRIBUTE_PERMISSION AttributePermission;
} EFI_BLUETOOTH_ATTRIBUTE_HEADER;
typedef struct {
EFI_BLUETOOTH_ATTRIBUTE_HEADER Header;
UINT16 EndGroupHandle;
EFI_BLUETOOTH_UUID ServiceUuid;
} EFI_BLUETOOTH_GATT_PRIMARY_SERVICE_INFO;
typedef struct {
EFI_BLUETOOTH_ATTRIBUTE_HEADER Header;
UINT16 StartGroupHandle;
UINT16 EndGroupHandle;
EFI_BLUETOOTH_UUID ServiceUuid;
} EFI_BLUETOOTH_GATT_INCLUDE_SERVICE_INFO;
typedef struct {
EFI_BLUETOOTH_ATTRIBUTE_HEADER Header;
UINT8 CharacteristicProperties;
UINT16 CharacteristicValueHandle;
EFI_BLUETOOTH_UUID CharacteristicUuid;
} EFI_BLUETOOTH_GATT_CHARACTERISTIC_INFO;
typedef struct {
EFI_BLUETOOTH_ATTRIBUTE_HEADER Header;
EFI_BLUETOOTH_UUID CharacteristicDescriptorUuid;
} EFI_BLUETOOTH_GATT_CHARACTERISTIC_DESCRIPTOR_INFO;
#pragma pack()
typedef struct {
UINT16 AttributeHandle;
} EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER_NOTIFICATION;
typedef struct {
UINT16 AttributeHandle;
} EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER_INDICATION;
typedef struct {
UINT32 Version;
UINT8 AttributeOpCode;
union {
EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER_NOTIFICATION Notification;
EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER_INDICATION Indication;
} Parameter;
} EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER;
typedef struct {
UINT32 Version;
BLUETOOTH_LE_ADDRESS BD_ADDR;
BLUETOOTH_LE_ADDRESS DirectAddress;
UINT8 RSSI;
UINTN AdvertisementDataSize;
VOID *AdvertisementData;
} EFI_BLUETOOTH_LE_DEVICE_INFO;
/**
The callback function to send request.
@param[in] This Pointer to the EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL instance.
@param[in] Data Data received. The first byte is the attribute opcode, followed by opcode specific
fields. See Bluetooth specification, Vol 3, Part F, Attribute Protocol. It might be a
normal RESPONSE message, or ERROR RESPONSE messag
@param[in] DataLength The length of Data in bytes.
@param[in] Context The context passed from the callback registration request.
@retval EFI_SUCCESS The callback function complete successfully.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_FUNCTION) (
IN EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL *This,
IN VOID *Data,
IN UINTN DataLength,
IN VOID *Context
);
/**
Send a "REQUEST" or "COMMAND" message to remote server and receive a "RESPONSE" message
for "REQUEST" from remote server according to Bluetooth attribute protocol data unit(PDU).
@param[in] This Pointer to the EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL instance.
@param[in] Data Data of a REQUEST or COMMAND message. The first byte is the attribute PDU
related opcode, followed by opcode specific fields. See Bluetooth specification,
Vol 3, Part F, Attribute Protocol.
@param[in] DataLength The length of Data in bytes.
@param[in] Callback Callback function to notify the RESPONSE is received to the caller, with the
response buffer. Caller must check the response buffer content to know if the
request action is success or fail. It may be NULL if the data is a COMMAND.
@param[in] Context Data passed into Callback function. It is optional parameter and may be NULL.
@retval EFI_SUCCESS The request is sent successfully.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid due to following conditions:
- The Buffer is NULL.
- The BufferLength is 0.
- The opcode in Buffer is not a valid OPCODE according to Bluetooth specification.
- The Callback is NULL.
@retval EFI_DEVICE_ERROR Sending the request failed due to the host controller or the device error.
@retval EFI_NOT_READY A GATT operation is already underway for this device.
@retval EFI_UNSUPPORTED The attribute does not support the corresponding operation.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_BLUETOOTH_ATTRIBUTE_SEND_REQUEST) (
IN EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL *This,
IN VOID *Data,
IN UINTN DataLength,
IN EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_FUNCTION Callback,
IN VOID *Context
);
/**
Register or unregister a server initiated message, such as NOTIFICATION or INDICATION, on a
characteristic value on remote server.
@param[in] This Pointer to the EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL instance.
@param[in] CallbackParameter The parameter of the callback.
@param[in] Callback Callback function for server initiated attribute protocol. NULL callback
function means unregister the server initiated callback.
@param[in] Context Data passed into Callback function. It is optional parameter and may be NULL.
@retval EFI_SUCCESS The callback function is registered or unregistered successfully
@retval EFI_INVALID_PARAMETER The attribute opcode is not server initiated message opcode. See
Bluetooth specification, Vol 3, Part F, Attribute Protocol.
@retval EFI_ALREADY_STARTED A callback function is already registered on the same attribute
opcode and attribute handle, when the Callback is not NULL.
@retval EFI_NOT_STARTED A callback function is not registered on the same attribute opcode
and attribute handle, when the Callback is NULL.
@retval EFI_NOT_READY A GATT operation is already underway for this device.
@retval EFI_UNSUPPORTED The attribute does not support notification.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_BLUETOOTH_ATTRIBUTE_REGISTER_FOR_SERVER_NOTIFICATION)(
IN EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL *This,
IN EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_PARAMETER *CallbackParameter,
IN EFI_BLUETOOTH_ATTRIBUTE_CALLBACK_FUNCTION Callback,
IN VOID *Context
);
/**
Get Bluetooth discovered service information.
@param[in] This Pointer to the EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL instance.
@param[out] ServiceInfoSize A pointer to the size, in bytes, of the ServiceInfo buffer.
@param[out] ServiceInfo A pointer to a callee allocated buffer that returns Bluetooth
discovered service information. Callee allocates this buffer by
using EFI Boot Service AllocatePool().
@retval EFI_SUCCESS The Bluetooth discovered service information is returned successfully.
@retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the Bluetooth discovered
service information.
**/
typedef
EFI_STATUS
(EFIAPI *EFI_BLUETOOTH_ATTRIBUTE_GET_SERVICE_INFO)(
IN EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL *This,
OUT UINTN *ServiceInfoSize,
OUT VOID **ServiceInfo
);
/**
Get Bluetooth device information.
@param[in] This Pointer to the EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL instance.
@param[out] DeviceInfoSize A pointer to the size, in bytes, of the DeviceInfo buffer.
@param[out] DeviceInfo A pointer to a callee allocated buffer that returns Bluetooth
device information. Callee allocates this buffer by using EFI Boot
Service AllocatePool(). If this device is Bluetooth classic
device, EFI_BLUETOOTH_DEVICE_INFO should be used. If
this device is Bluetooth LE device, EFI_BLUETOOTH_LE_DEVICE_INFO
should be used.
@retval EFI_SUCCESS The Bluetooth device information is returned successfully.
@retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the Bluetooth device
information
**/
typedef
EFI_STATUS
(EFIAPI *EFI_BLUETOOTH_ATTRIBUTE_GET_DEVICE_INFO)(
IN EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL *This,
OUT UINTN *DeviceInfoSize,
OUT VOID **DeviceInfo
);
struct _EFI_BLUETOOTH_ATTRIBUTE_PROTOCOL {
EFI_BLUETOOTH_ATTRIBUTE_SEND_REQUEST SendRequest;
EFI_BLUETOOTH_ATTRIBUTE_REGISTER_FOR_SERVER_NOTIFICATION RegisterForServerNotification;
EFI_BLUETOOTH_ATTRIBUTE_GET_SERVICE_INFO GetServiceInfo;
EFI_BLUETOOTH_ATTRIBUTE_GET_DEVICE_INFO GetDeviceInfo;
};
extern EFI_GUID gEfiBluetoothAttributeProtocolGuid;
extern EFI_GUID gEfiBluetoothAttributeServiceBindingProtocolGuid;
#endif
|