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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
use crate::param::macros::param;
use crate::param::{BdAddr, ConnHandle};
param! {
bitfield PacketType[2] {
// ACL Link_Type bits
(1, shall_not_be_used_2dh1, set_shall_not_be_used_2dh1);
(2, shall_not_be_used_3dh1, set_shall_not_be_used_3dh1);
// Bit 3: Ignored; DM1 may be used whether or not this bit is set
(4, dh1_may_be_used, set_dh1_may_be_used);
// SCO Link_Type bits
(5, hv1_may_be_used, set_hv1_may_be_used);
(6, hv2_may_be_used, set_hv2_may_be_used);
(7, hv3_may_be_used, set_hv3_may_be_used);
// ACL Link_Type bits (continued)
(8, shall_not_be_used_2dh3, set_shall_not_be_used_2dh3);
(9, shall_not_be_used_3dh3, set_shall_not_be_used_3dh3);
(10, dm3_may_be_used, set_dm3_may_be_used);
(11, dh3_may_be_used, set_dh3_may_be_used);
(12, shall_not_be_used_2dh5, set_shall_not_be_used_2dh5);
(13, shall_not_be_used_3dh5, set_shall_not_be_used_3dh5);
(14, dm5_may_be_used, set_dm5_may_be_used);
(15, dh5_may_be_used, set_dh5_may_be_used);
}
}
param! {
bitfield SyncPacketType[2]{
// Basic synchronous packet types
(0, hv1_may_be_used, set_hv1_may_be_used);
(1, hv2_may_be_used, set_hv2_may_be_used);
(2, hv3_may_be_used, set_hv3_may_be_used);
// Extended synchronous packet types
(3, ev3_may_be_used, set_ev3_may_be_used);
(4, ev4_may_be_used, set_ev4_may_be_used);
(5, ev5_may_be_used, set_ev5_may_be_used);
// EDR synchronous packet types that shall not be used
(6, shall_not_be_used_2ev3, set_shall_not_be_used_2ev3);
(7, shall_not_be_used_3ev3, set_shall_not_be_used_3ev3);
(8, shall_not_be_used_2ev5, set_shall_not_be_used_2ev5);
(9, shall_not_be_used_3ev5, set_shall_not_be_used_3ev5);
// All other bits reserved for future use
}
}
param! {
bitfield ClockOffset[2] {
// Bits 0-14: Bits 2 to 16 of CLKNPeripheral - CLK
(0, clock_offset_0, set_clock_offset_0);
(1, clock_offset_1, set_clock_offset_1);
(2, clock_offset_2, set_clock_offset_2);
(3, clock_offset_3, set_clock_offset_3);
(4, clock_offset_4, set_clock_offset_4);
(5, clock_offset_5, set_clock_offset_5);
(6, clock_offset_6, set_clock_offset_6);
(7, clock_offset_7, set_clock_offset_7);
(8, clock_offset_8, set_clock_offset_8);
(9, clock_offset_9, set_clock_offset_9);
(10, clock_offset_10, set_clock_offset_10);
(11, clock_offset_11, set_clock_offset_11);
(12, clock_offset_12, set_clock_offset_12);
(13, clock_offset_13, set_clock_offset_13);
(14, clock_offset_14, set_clock_offset_14);
// Bit 15: Clock_Offset_Valid_Flag (0 = Invalid, 1 = Valid)
(15, clock_offset_valid_flag, set_clock_offset_valid_flag);
}
}
param! {
bitfield VoiceSetting[2]{
// Bits 0-1: Air coding format
(0, air_coding_format_0, set_air_coding_format_0);
(1, air_coding_format_1, set_air_coding_format_1);
// Bits 2-4: Linear PCM bit position
(2, linear_pcm_bit_position_0, set_linear_pcm_bit_position_0);
(3, linear_pcm_bit_position_1, set_linear_pcm_bit_position_1);
(4, linear_pcm_bit_position_2, set_linear_pcm_bit_position_2);
// Bit 5: Input sample size (only for linear PCM)
(5, input_sample_size, set_input_sample_size);
// Bits 6-7: Input data format
(6, input_data_format_0, set_input_data_format_0);
(7, input_data_format_1, set_input_data_format_1);
// Bits 8-9: Input coding format
(8, input_coding_format_0, set_input_coding_format_0);
(9, input_coding_format_1, set_input_coding_format_1);
// Bits 10-15: Reserved for future use
}
}
param! {
enum PageScanRepetitionMode{
/// Page scan repetition mode 0
R0 = 0x00,
/// Page scan repetition mode 1
R1 = 0x01,
/// Page scan repetition mode 2
R2 = 0x02,
// Reserved for future use
}
}
param! {
enum AllowRoleSwitch{
/// The local device will be a Central, and will not accept a role switch requested by
/// the remote device at the connection setup.
NotAllowed = 0x00,
/// The local device may be a Central, or may become a Peripheral after accepting a role switch
/// requested by the remote device at the connection setup.
Allowed = 0x01,
// Reserved for future use
}
}
param! {
enum ConnectionLinkType {
/// SCO connection
Sco = 0x00,
/// ACL connection (Data Channels)
Acl = 0x01,
/// eSCO connection (Enhanced Data Channels)
EnhancedSco = 0x02,
// All other values reserved for future use
}
}
param! {
enum LinkKeyType {
/// Combination Key
CombinationKey = 0x00,
/// Debug Combination Key
DebugCombinationKey = 0x03,
/// Unauthenticated Combination Key generated from P-192
UnauthenticatedCombinationKeyP192 = 0x04,
/// Authenticated Combination Key generated from P-192
AuthenticatedCombinationKeyP192 = 0x05,
/// Changed Combination Key
ChangedCombinationKey = 0x06,
/// Unauthenticated Combination Key generated from P-256
UnauthenticatedCombinationKeyP256 = 0x07,
/// Authenticated Combination Key generated from P-256
AuthenticatedCombinationKeyP256 = 0x08,
// All other values reserved for future use
}
}
param! {
enum IoCapability{
/// Display Only
DisplayOnly = 0x00,
/// Display Yes/No
DisplayYesNo = 0x01,
/// Keyboard Only
KeyboardOnly = 0x02,
/// No Input No Output
NoInputNoOutput = 0x03,
// All other values reserved for future use
}
}
param! {
enum OobDataPresent {
/// OOB authentication data not present
NotPresent = 0x00,
/// P-192 OOB authentication data from remote device present
P192Present = 0x01,
/// P-256 OOB authentication data from remote device present
P256Present = 0x02,
/// P-192 and P-256 OOB authentication data from remote device present
P192AndP256Present = 0x03,
// All other values reserved for future use
}
}
param! {
enum AuthenticationRequirements {
/// MITM Protection Not Required – No Bonding. Numeric comparison with automatic accept allowed.
MitmNotRequiredNoBonding = 0x00,
/// MITM Protection Required – No Bonding. Use IO Capabilities to determine authentication procedure
MitmRequiredNoBonding = 0x01,
/// MITM Protection Not Required – Dedicated Bonding. Numeric comparison with automatic accept allowed.
MitmNotRequiredDedicatedBonding = 0x02,
/// MITM Protection Required – Dedicated Bonding. Use IO Capabilities to determine authentication procedure
MitmRequiredDedicatedBonding = 0x03,
/// MITM Protection Not Required – General Bonding. Numeric Comparison with automatic accept allowed.
MitmNotRequiredGeneralBonding = 0x04,
/// MITM Protection Required – General Bonding. Use IO capabilities to determine authentication procedure.
MitmRequiredGeneralBonding = 0x05,
// All other values reserved for future use
}
}
param! {
enum Role {
/// Become the Central for this connection. The LM will perform the role switch.
Central = 0x00,
/// Remain the Peripheral for this connection. The LM will NOT perform the role switch.
Peripheral = 0x01,
}
}
param! {
enum RejectReason {
/// Connection Rejected due to Limited Resources
LimitedResources = 0x0D,
/// Connection Rejected Due To Security Reasons
SecurityReasons = 0x0E,
/// Connection Rejected due to Unacceptable BD_ADDR
UnacceptableBdAddr = 0x0F,
}
}
param! {
enum KeyFlag{
/// Use semi-permanent Link Keys.
SemiPermanent = 0x00,
/// Use Temporary Link Key.
Temporary = 0x01,
}
}
param! {
enum RetransmissionEffort{
/// No retransmissions (SCO or eSCO connection allowed)
NoRetransmissions = 0x00,
/// At least one retransmission, optimize for power consumption (eSCO connection required)
OptimizePowerConsumption = 0x01,
/// At least one retransmission, optimize for link quality (eSCO connection required)
OptimizeLinkQuality = 0x02,
/// Don't care (SCO or eSCO connection allowed)
DontCare = 0xFF,
// All other values reserved for future use
}
}
param! {
enum ServiceType{
/// No Traffic Available.
NoTraffic = 0x00,
/// Best Effort Available.
BestEffort = 0x01,
/// Guaranteed Available.
Guaranteed = 0x02,
// All other values reserved for future use
}
}
param! {
enum Mode {
/// Active mode
Active = 0x00,
/// Hold mode
Hold = 0x01,
/// Sniff mode
Sniff = 0x02,
// All other values reserved for future use
}
}
param! {
enum MaxSlots {
/// 1 slot
OneSlot = 0x01,
/// 3 slots
ThreeSlots = 0x03,
/// 5 slots
FiveSlots = 0x05,
// All other values reserved for future use
}
}
param! {
enum FlowDirection {
/// Outgoing Flow i.e., traffic sent over the ACL connection.
Outgoing = 0x00,
/// Incoming Flow i.e., traffic received over the ACL connection.
Incoming = 0x01,
// All other values reserved for future use
}
}
param! {
enum KeypressNotificationType {
/// Passkey entry started
PasskeyEntryStarted = 0x00,
/// Passkey digit entered
PasskeyDigitEntered = 0x01,
/// Passkey digit erased
PasskeyDigitErased = 0x02,
/// Passkey cleared
PasskeyCleared = 0x03,
/// Passkey entry completed
PasskeyEntryCompleted = 0x04,
// All other values reserved for future use
}
}
param! {
enum ClockType {
/// Local clock
Local = 0x00,
/// Piconet Clock
Piconet = 0x01,
// All other values reserved for future use
}
}
param! {
enum EncryptionEnabledLevel {
/// Link Level Encryption is OFF
Off = 0x00,
/// Link Level Encryption is ON with E0 for BR/EDR or AES-CCM for LE
OnE0OrAesCcm = 0x01,
/// Link Level Encryption is ON with AES-CCM for BR/EDR
OnAesCcm = 0x02,
// All other values reserved for future use
}
}
param! {
/// Separate params for the Enhanced Setup Synchronous Connection command since they have too many fields
struct EnhancedSetupSynchronousConnectionParams {
handle: ConnHandle,
transmit_bandwidth: u32,
receive_bandwidth: u32,
transmit_coding_format: [u8; 5],
receive_coding_format: [u8; 5],
transmit_codec_frame_size: u16,
receive_codec_frame_size: u16,
input_bandwidth: u32,
output_bandwidth: u32,
input_coding_format: [u8; 5],
output_coding_format: [u8; 5],
input_coded_data_size: u16,
output_coded_data_size: u16,
input_pcm_data_format: u8,
output_pcm_data_format: u8,
input_pcm_sample_payload_msb_position: u8,
output_pcm_sample_payload_msb_position: u8,
input_data_path: u8,
output_data_path: u8,
input_transport_unit_size: u8,
output_transport_unit_size: u8,
max_latency: u16,
packet_type: SyncPacketType,
retransmission_effort: RetransmissionEffort,
}
}
param! {
/// Separate params for the Enhanced Accept Synchronous Connection Request command since they have too many fields
struct EnhancedAcceptSynchronousConnectionRequestParams {
bd_addr: BdAddr,
transmit_bandwidth: u32,
receive_bandwidth: u32,
transmit_coding_format: [u8; 5],
receive_coding_format: [u8; 5],
transmit_codec_frame_size: u16,
receive_codec_frame_size: u16,
input_bandwidth: u32,
output_bandwidth: u32,
input_coding_format: [u8; 5],
output_coding_format: [u8; 5],
input_coded_data_size: u16,
output_coded_data_size: u16,
input_pcm_data_format: u8,
output_pcm_data_format: u8,
input_pcm_sample_payload_msb_position: u8,
output_pcm_sample_payload_msb_position: u8,
input_data_path: u8,
output_data_path: u8,
input_transport_unit_size: u8,
output_transport_unit_size: u8,
max_latency: u16,
packet_type: SyncPacketType,
retransmission_effort: RetransmissionEffort,
}
}