Add bidirectional channel configuration -- remote device is not ACKing sent Configura...
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / Lib / BluetoothACLPackets.c
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 #define INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C
32 #include "BluetoothACLPackets.h"
33
34 void Bluetooth_ACLTask(void)
35 {
36 Bluetooth_ProcessACLPackets();
37
38 for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)
39 {
40 Bluetooth_Channel_t* ChannelData = &Bluetooth_Connection.Channels[i];
41
42 bool MustSendConfigReq = true;
43
44 switch (ChannelData->State)
45 {
46 case Channel_Config_WaitConfig:
47 ChannelData->State = Channel_Config_WaitReqResp;
48 break;
49 case Channel_Config_WaitSendConfig:
50 ChannelData->State = Channel_Config_WaitResp;
51 break;
52 default:
53 MustSendConfigReq = false;
54 break;
55 }
56
57 if (MustSendConfigReq)
58 {
59 BT_ACL_Header_t ACLPacketHeader;
60 BT_DataPacket_Header_t DataHeader;
61 BT_Signal_Header_t SignalCommandHeader;
62 BT_Signal_ConfigurationReq_t ConfigurationRequest;
63
64 ACLPacketHeader.ConnectionHandle = Bluetooth_Connection.ConnectionHandle;
65 ACLPacketHeader.DataLength = sizeof(DataHeader) + sizeof(SignalCommandHeader) + sizeof(ConfigurationRequest);
66 DataHeader.PayloadLength = sizeof(SignalCommandHeader) + sizeof(ConfigurationRequest);
67 DataHeader.DestinationChannel = BT_CHANNEL_SIGNALING;
68 SignalCommandHeader.Code = BT_SIGNAL_CONFIGURATION_REQUEST;
69 SignalCommandHeader.Identifier = ++Bluetooth_Connection.SignallingIdentifier;
70 SignalCommandHeader.Length = sizeof(ConfigurationRequest);
71
72 ConfigurationRequest.DestinationChannel = ChannelData->RemoteNumber;
73 ConfigurationRequest.Flags = 0;
74
75 Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
76 Pipe_Unfreeze();
77
78 Pipe_Write_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader));
79 Pipe_Write_Stream_LE(&DataHeader, sizeof(DataHeader));
80 Pipe_Write_Stream_LE(&SignalCommandHeader, sizeof(SignalCommandHeader));
81 Pipe_Write_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest));
82
83 Pipe_Freeze();
84
85 #if (ACL_DEBUG_LEVEL > 1)
86 BT_ACL_DEBUG("Packet Sent", NULL);
87 BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF));
88 BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader.DataLength);
89 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader.DestinationChannel);
90 BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader.PayloadLength);
91 #endif
92 #if (ACL_DEBUG_LEVEL > 0)
93 BT_ACL_DEBUG(">> L2CAP Configuration Request", NULL);
94 #endif
95 #if (ACL_DEBUG_LEVEL > 1)
96 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", ConfigurationRequest.DestinationChannel);
97 #endif
98 }
99 }
100 }
101
102 static void Bluetooth_ProcessACLPackets(void)
103 {
104 BT_ACL_Header_t ACLPacketHeader;
105 BT_DataPacket_Header_t DataHeader;
106
107 Pipe_SelectPipe(BLUETOOTH_DATA_IN_PIPE);
108 Pipe_Unfreeze();
109
110 if (!(Pipe_IsReadWriteAllowed()))
111 {
112 Pipe_Freeze();
113 return;
114 }
115
116 Pipe_Read_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader));
117 Pipe_Read_Stream_LE(&DataHeader, sizeof(DataHeader));
118
119 #if (ACL_DEBUG_LEVEL > 1)
120 BT_ACL_DEBUG("Packet Received", NULL);
121 BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF));
122 BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader.DataLength);
123 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader.DestinationChannel);
124 BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader.PayloadLength);
125 #endif
126
127 if (DataHeader.DestinationChannel == BT_CHANNEL_SIGNALING)
128 {
129 BT_Signal_Header_t SignalCommandHeader;
130 Pipe_Read_Stream_LE(&SignalCommandHeader, sizeof(SignalCommandHeader));
131
132 switch (SignalCommandHeader.Code)
133 {
134 case BT_SIGNAL_CONNECTION_REQUEST:
135 Bluetooth_Signal_ConnectionReq(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);
136 break;
137 case BT_SIGNAL_CONFIGURATION_REQUEST:
138 Bluetooth_Signal_ConfigurationReq(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);
139 break;
140 case BT_SIGNAL_DISCONNECTION_REQUEST:
141 Bluetooth_Signal_DisconnectionReq(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);
142 break;
143 case BT_SIGNAL_ECHO_REQUEST:
144 Bluetooth_Signal_EchoReq(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);
145 break;
146 case BT_SIGNAL_INFORMATION_REQUEST:
147 Bluetooth_Signal_InformationReq(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);
148 break;
149 default:
150 #if (ACL_DEBUG_LEVEL > 0)
151 BT_ACL_DEBUG("<< Unknown Signaling Command 0x%02X", SignalCommandHeader.Code);
152 #endif
153
154 Pipe_Discard_Stream(ACLPacketHeader.DataLength);
155 Pipe_ClearIN();
156 Pipe_Freeze();
157 break;
158 }
159 }
160 else
161 {
162 Bluetooth_PacketReceived(&DataHeader.PayloadLength, Bluetooth_GetChannelData(DataHeader.DestinationChannel, true));
163
164 Pipe_SelectPipe(BLUETOOTH_DATA_IN_PIPE);
165 Pipe_Discard_Stream(DataHeader.PayloadLength);
166 Pipe_ClearIN();
167 Pipe_Freeze();
168 }
169 }
170
171 uint8_t Bluetooth_SendPacket(uint8_t* Data, uint16_t DataLen, Bluetooth_Channel_t* Channel)
172 {
173 BT_ACL_Header_t ACLPacketHeader;
174 BT_DataPacket_Header_t DataHeader;
175
176 if (Bluetooth_Connection.IsConnected)
177 return BT_SENDPACKET_NotConnected;
178
179 if (Channel->State != Channel_Open)
180 return BT_SENDPACKET_ChannelNotOpen;
181
182 ACLPacketHeader.ConnectionHandle = Bluetooth_Connection.ConnectionHandle;
183 ACLPacketHeader.DataLength = sizeof(DataHeader) + DataLen;
184 DataHeader.DestinationChannel = Channel->RemoteNumber;
185 DataHeader.PayloadLength = DataLen;
186
187 Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
188 Pipe_Unfreeze();
189
190 Pipe_Write_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader));
191 Pipe_Write_Stream_LE(&DataHeader, sizeof(DataHeader));
192 Pipe_Write_Stream_LE(Data, DataLen);
193
194 Pipe_Freeze();
195
196 return BT_SENDPACKET_NoError;
197 }
198
199 static inline void Bluetooth_Signal_ConnectionReq(BT_ACL_Header_t* ACLPacketHeader,
200 BT_DataPacket_Header_t* DataHeader,
201 BT_Signal_Header_t* SignalCommandHeader)
202 {
203 BT_Signal_ConnectionReq_t ConnectionRequest;
204
205 Pipe_Read_Stream_LE(&ConnectionRequest, sizeof(ConnectionRequest));
206
207 #if (ACL_DEBUG_LEVEL > 0)
208 BT_ACL_DEBUG("<< L2CAP Connection Request", NULL);
209 #endif
210 #if (ACL_DEBUG_LEVEL > 1)
211 BT_ACL_DEBUG("-- PSM: 0x%04X", ConnectionRequest.PSM);
212 BT_ACL_DEBUG("-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel);
213 #endif
214
215 Pipe_ClearIN();
216 Pipe_Freeze();
217 Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
218 Pipe_Unfreeze();
219
220 BT_Signal_ConnectionResp_t ConnectionResponse;
221
222 ACLPacketHeader->DataLength = sizeof(*DataHeader) + sizeof(*SignalCommandHeader) + sizeof(ConnectionResponse);
223 DataHeader->PayloadLength = sizeof(*SignalCommandHeader) + sizeof(ConnectionResponse);
224 DataHeader->DestinationChannel = BT_CHANNEL_SIGNALING;
225 SignalCommandHeader->Code = BT_SIGNAL_CONNECTION_RESPONSE;
226 SignalCommandHeader->Length = sizeof(ConnectionResponse);
227
228 Bluetooth_Channel_t* ChannelData = Bluetooth_InitChannelData(ConnectionRequest.SourceChannel, ConnectionRequest.PSM);
229
230 ConnectionResponse.Result = (ChannelData == NULL) ? BT_CONNECTION_REFUSED_RESOURCES : BT_CONNECTION_SUCCESSFUL;
231 ConnectionResponse.DestinationChannel = ChannelData->LocalNumber;
232 ConnectionResponse.SourceChannel = ChannelData->RemoteNumber;
233 ConnectionResponse.Status = 0x00;
234
235 Pipe_Write_Stream_LE(ACLPacketHeader, sizeof(*ACLPacketHeader));
236 Pipe_Write_Stream_LE(DataHeader, sizeof(*DataHeader));
237 Pipe_Write_Stream_LE(SignalCommandHeader, sizeof(*SignalCommandHeader));
238 Pipe_Write_Stream_LE(&ConnectionResponse, sizeof(ConnectionResponse));
239
240 Pipe_ClearOUT();
241 Pipe_Freeze();
242
243 #if (ACL_DEBUG_LEVEL > 1)
244 BT_ACL_DEBUG("Packet Sent", NULL);
245 BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader->ConnectionHandle & 0x0FFF));
246 BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader->DataLength);
247 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader->DestinationChannel);
248 BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader->PayloadLength);
249 #endif
250 #if (ACL_DEBUG_LEVEL > 0)
251 BT_ACL_DEBUG(">> L2CAP Connection Response", NULL);
252 #endif
253 #if (ACL_DEBUG_LEVEL > 1)
254 BT_ACL_DEBUG("-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel);
255 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel);
256 #endif
257 }
258
259 static inline void Bluetooth_Signal_ConfigurationReq(BT_ACL_Header_t* ACLPacketHeader,
260 BT_DataPacket_Header_t* DataHeader,
261 BT_Signal_Header_t* SignalCommandHeader)
262 {
263 BT_Signal_ConfigurationReq_t ConfigurationRequest;
264 Pipe_Read_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest));
265
266 // TODO: Process/Discard configuration options here
267 Pipe_Discard_Stream(DataHeader->PayloadLength - sizeof(*SignalCommandHeader));
268
269 #if (ACL_DEBUG_LEVEL > 0)
270 BT_ACL_DEBUG("<< L2CAP Configuration Request", NULL);
271 #endif
272 #if (ACL_DEBUG_LEVEL > 1)
273 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", ConfigurationRequest.DestinationChannel);
274 #endif
275
276 Pipe_ClearIN();
277 Pipe_Freeze();
278 Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
279 Pipe_Unfreeze();
280
281 BT_Signal_ConfigurationResp_t ConfigurationResponse;
282
283 ACLPacketHeader->DataLength = sizeof(*DataHeader) + sizeof(*SignalCommandHeader) + sizeof(ConfigurationResponse);
284 DataHeader->PayloadLength = sizeof(*SignalCommandHeader) + sizeof(ConfigurationResponse);
285 DataHeader->DestinationChannel = BT_CHANNEL_SIGNALING;
286 SignalCommandHeader->Code = BT_SIGNAL_CONFIGURATION_RESPONSE;
287 SignalCommandHeader->Length = sizeof(ConfigurationResponse);
288
289 Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConfigurationRequest.DestinationChannel, false);
290
291 if (ChannelData != NULL)
292 {
293 switch (ChannelData->State)
294 {
295 case Channel_Config_WaitConfig:
296 ChannelData->State = Channel_Config_WaitSendConfig;
297 break;
298 case Channel_Config_WaitReqResp:
299 ChannelData->State = Channel_Config_WaitResp;
300 break;
301 case Channel_Config_WaitReq:
302 ChannelData->State = Channel_Open;
303 break;
304 }
305 }
306
307 // TODO: Add channel config data to the tail of ConfigurationResponse
308
309 ConfigurationResponse.SourceChannel = ChannelData->RemoteNumber;
310 ConfigurationResponse.Flags = 0x00;
311 ConfigurationResponse.Result = (ChannelData != NULL) ? BT_CONFIGURATION_SUCCESSFUL : BT_CONFIGURATION_REJECTED;
312
313 Pipe_Write_Stream_LE(ACLPacketHeader, sizeof(*ACLPacketHeader));
314 Pipe_Write_Stream_LE(DataHeader, sizeof(*DataHeader));
315 Pipe_Write_Stream_LE(SignalCommandHeader, sizeof(*SignalCommandHeader));
316 Pipe_Write_Stream_LE(&ConfigurationResponse, sizeof(ConfigurationResponse));
317
318 Pipe_ClearOUT();
319 Pipe_Freeze();
320
321 #if (ACL_DEBUG_LEVEL > 1)
322 BT_ACL_DEBUG("Packet Sent", NULL);
323 BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader->ConnectionHandle & 0x0FFF));
324 BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader->DataLength);
325 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader->DestinationChannel);
326 BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader->PayloadLength);
327 #endif
328 #if (ACL_DEBUG_LEVEL > 0)
329 BT_ACL_DEBUG(">> L2CAP Configuration Response", NULL);
330 #endif
331 #if (ACL_DEBUG_LEVEL > 1)
332 BT_ACL_DEBUG("-- Result: 0x%02X", ConfigurationResponse.Result);
333 #endif
334 }
335
336 static inline void Bluetooth_Signal_DisconnectionReq(BT_ACL_Header_t* ACLPacketHeader,
337 BT_DataPacket_Header_t* DataHeader,
338 BT_Signal_Header_t* SignalCommandHeader)
339 {
340 BT_Signal_DisconnectionReq_t DisconnectionRequest;
341
342 Pipe_Read_Stream_LE(&DisconnectionRequest, sizeof(DisconnectionRequest));
343
344 #if (ACL_DEBUG_LEVEL > 0)
345 BT_ACL_DEBUG("<< L2CAP Disconnection Request", NULL);
346 #endif
347 #if (ACL_DEBUG_LEVEL > 1)
348 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DisconnectionRequest.DestinationChannel);
349 BT_ACL_DEBUG("-- Source Channel: 0x%04X", DisconnectionRequest.SourceChannel);
350 #endif
351
352 Pipe_ClearIN();
353 Pipe_Freeze();
354 Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
355 Pipe_Unfreeze();
356
357 BT_Signal_DisconnectionResp_t DisconnectionResponse;
358
359 ACLPacketHeader->DataLength = sizeof(*DataHeader) + sizeof(*SignalCommandHeader) + sizeof(DisconnectionResponse);
360 DataHeader->PayloadLength = sizeof(*SignalCommandHeader) + sizeof(DisconnectionResponse);
361 DataHeader->DestinationChannel = BT_CHANNEL_SIGNALING;
362 SignalCommandHeader->Code = BT_SIGNAL_DISCONNECTION_RESPONSE;
363 SignalCommandHeader->Length = sizeof(DisconnectionResponse);
364
365 Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(DisconnectionRequest.SourceChannel, true);
366
367 if (ChannelData != NULL)
368 ChannelData->State = Channel_Closed;
369
370 DisconnectionResponse.DestinationChannel = ChannelData->LocalNumber;
371 DisconnectionResponse.SourceChannel = ChannelData->RemoteNumber;
372
373 Pipe_Write_Stream_LE(ACLPacketHeader, sizeof(*ACLPacketHeader));
374 Pipe_Write_Stream_LE(DataHeader, sizeof(*DataHeader));
375 Pipe_Write_Stream_LE(SignalCommandHeader, sizeof(*SignalCommandHeader));
376 Pipe_Write_Stream_LE(&DisconnectionResponse, sizeof(DisconnectionResponse));
377
378 Pipe_ClearOUT();
379 Pipe_Freeze();
380
381 #if (ACL_DEBUG_LEVEL > 1)
382 BT_ACL_DEBUG("Packet Sent", NULL);
383 BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader->ConnectionHandle & 0x0FFF));
384 BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader->DataLength);
385 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader->DestinationChannel);
386 BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader->PayloadLength);
387 #endif
388 #if (ACL_DEBUG_LEVEL > 0)
389 BT_ACL_DEBUG(">> L2CAP Disconnection Response", NULL);
390 #endif
391 #if (ACL_DEBUG_LEVEL > 1)
392 BT_ACL_DEBUG("-- Source Channel: 0x%04X", DisconnectionResponse.SourceChannel);
393 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DisconnectionResponse.DestinationChannel);
394 #endif
395 }
396
397 static inline void Bluetooth_Signal_EchoReq(BT_ACL_Header_t* ACLPacketHeader,
398 BT_DataPacket_Header_t* DataHeader,
399 BT_Signal_Header_t* SignalCommandHeader)
400 {
401 #if (ACL_DEBUG_LEVEL > 0)
402 BT_ACL_DEBUG("<< L2CAP Echo Request", NULL);
403 #endif
404
405 Pipe_ClearIN();
406 Pipe_Freeze();
407 Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
408 Pipe_Unfreeze();
409
410 ACLPacketHeader->DataLength = sizeof(*DataHeader) + sizeof(*SignalCommandHeader);
411 DataHeader->PayloadLength = sizeof(*SignalCommandHeader);
412 DataHeader->DestinationChannel = BT_CHANNEL_SIGNALING;
413 SignalCommandHeader->Code = BT_SIGNAL_ECHO_RESPONSE;
414 SignalCommandHeader->Length = 0;
415
416 Pipe_Write_Stream_LE(ACLPacketHeader, sizeof(*ACLPacketHeader));
417 Pipe_Write_Stream_LE(DataHeader, sizeof(*DataHeader));
418 Pipe_Write_Stream_LE(SignalCommandHeader, sizeof(*SignalCommandHeader));
419
420 Pipe_ClearOUT();
421 Pipe_Freeze();
422
423 #if (ACL_DEBUG_LEVEL > 1)
424 BT_ACL_DEBUG("Packet Sent", NULL);
425 BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader->ConnectionHandle & 0x0FFF));
426 BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader->DataLength);
427 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader->DestinationChannel);
428 BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader->PayloadLength);
429 #endif
430 #if (ACL_DEBUG_LEVEL > 0)
431 BT_ACL_DEBUG(">> L2CAP Echo Response", NULL);
432 #endif
433 }
434
435 static inline void Bluetooth_Signal_InformationReq(BT_ACL_Header_t* ACLPacketHeader,
436 BT_DataPacket_Header_t* DataHeader,
437 BT_Signal_Header_t* SignalCommandHeader)
438 {
439 BT_Signal_InformationReq_t InformationRequest;
440
441 Pipe_Read_Stream_LE(&InformationRequest, sizeof(InformationRequest));
442
443 #if (ACL_DEBUG_LEVEL > 0)
444 BT_ACL_DEBUG("<< Information Request", NULL);
445 #endif
446 #if (ACL_DEBUG_LEVEL > 1)
447 BT_ACL_DEBUG("-- Info Type: 0x%04X", InformationRequest.InfoType);
448 #endif
449
450 Pipe_ClearIN();
451 Pipe_Freeze();
452 Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
453 Pipe_Unfreeze();
454
455 BT_Signal_InformationResp_t InformationResponse;
456 uint8_t ResponseData[4];
457 uint8_t ResponseLen;
458
459 switch (InformationRequest.InfoType)
460 {
461 case BT_INFOREQ_MTU:
462 InformationResponse.Result = BT_INFORMATION_SUCCESSFUL;
463 ResponseLen = 2;
464
465 *((uint16_t*)&ResponseData) = 65533;
466 break;
467 case BT_INFOREQ_EXTENDEDFEATURES:
468 InformationResponse.Result = BT_INFORMATION_SUCCESSFUL;
469 ResponseLen = 4;
470
471 *((uint32_t*)&ResponseData) = 0;
472 break;
473 default:
474 InformationResponse.Result = BT_INFORMATION_NOTSUPPORTED;
475 ResponseLen = 0;
476 break;
477 }
478
479 ACLPacketHeader->DataLength = sizeof(*DataHeader) + sizeof(*SignalCommandHeader) + sizeof(InformationResponse) +
480 ResponseLen;
481 DataHeader->PayloadLength = sizeof(*SignalCommandHeader) + sizeof(InformationResponse) + ResponseLen;
482 DataHeader->DestinationChannel = BT_CHANNEL_SIGNALING;
483 SignalCommandHeader->Code = BT_SIGNAL_INFORMATION_RESPONSE;
484 SignalCommandHeader->Length = sizeof(InformationResponse) + ResponseLen;
485
486 Pipe_Write_Stream_LE(ACLPacketHeader, sizeof(*ACLPacketHeader));
487 Pipe_Write_Stream_LE(DataHeader, sizeof(*DataHeader));
488 Pipe_Write_Stream_LE(SignalCommandHeader, sizeof(*SignalCommandHeader));
489 Pipe_Write_Stream_LE(&InformationResponse, sizeof(InformationResponse));
490 Pipe_Write_Stream_LE(ResponseData, ResponseLen);
491
492 Pipe_ClearOUT();
493 Pipe_Freeze();
494
495 #if (ACL_DEBUG_LEVEL > 1)
496 BT_ACL_DEBUG("Packet Sent", NULL);
497 BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader->ConnectionHandle & 0x0FFF));
498 BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader->DataLength);
499 BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader->DestinationChannel);
500 BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader->PayloadLength);
501 #endif
502 #if (ACL_DEBUG_LEVEL > 0)
503 BT_ACL_DEBUG(">> L2CAP Information Response", NULL);
504 #endif
505 #if (ACL_DEBUG_LEVEL > 1)
506 BT_ACL_DEBUG("-- Result: 0x%02X", InformationResponse.Result);
507 #endif
508 }