More improvements to the incomplete BluetoothHost demo - add Disconnection Event...
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / Lib / BluetoothACLPackets.h
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 #ifndef _BLUETOOTH_ACLPACKETS_
32 #define _BLUETOOTH_ACLPACKETS_
33
34 /* Includes: */
35 #include <avr/io.h>
36 #include <string.h>
37 #include <stdbool.h>
38
39 #include <LUFA/Drivers/USB/USB.h>
40
41 #include "BluetoothStack.h"
42
43 /* Macros: */
44 #define BT_ACL_DEBUG(s, ...) printf_P(PSTR("(ACL) " s "\r\n"), __VA_ARGS__)
45
46 #define BLUETOOTH_CHANNEL_SIGNALING 0x0001
47 #define BLUETOOTH_CHANNEL_CONNECTIONLESS 0x0002
48
49 #define BLUETOOTH_SIGNAL_CONNECTION_REQUEST 0x02
50 #define BLUETOOTH_SIGNAL_CONNECTION_RESPONSE 0x03
51 #define BLUETOOTH_SIGNAL_CONFIGURATION_REQUEST 0x04
52 #define BLUETOOTH_SIGNAL_CONFIGURATION_RESPONSE 0x05
53 #define BLUETOOTH_SIGNAL_INFORMATION_REQUEST 0x0A
54
55 #define BLUETOOTH_CONNECTION_SUCCESSFUL 0x0000
56 #define BLUETOOTH_CONNECTION_REFUSED_RESOURCES 0x0004
57
58 #define BLUETOOTH_CONFIGURATION_SUCCESSFUL 0x0000
59 #define BLUETOOTH_CONFIGURATION_REJECTED 0x0002
60 #define BLUETOOTH_CONFIGURATION_UNKNOWNOPTIONS 0x0003
61
62 /* Type Defines: */
63 typedef struct
64 {
65 uint16_t ConnectionHandle;
66 uint16_t DataLength;
67 } Bluetooth_ACL_Header_t;
68
69 typedef struct
70 {
71 uint16_t PayloadLength;
72 uint16_t DestinationChannel;
73 } Bluetooth_DataPacket_Header_t;
74
75 typedef struct
76 {
77 uint8_t Code;
78 uint8_t Identifier;
79 uint16_t Length;
80 } Bluetooth_SignalCommand_Header_t;
81
82 typedef struct
83 {
84 uint16_t PSM;
85 uint16_t SourceChannel;
86 } Bluetooth_SignalCommand_ConnectionRequest_t;
87
88 typedef struct
89 {
90 uint16_t DestinationChannel;
91 uint16_t SourceChannel;
92 uint16_t Result;
93 uint16_t Status;
94 } Bluetooth_SignalCommand_ConnectionResponse_t;
95
96 typedef struct
97 {
98 uint16_t DestinationChannel;
99 uint16_t Flags;
100 uint8_t Options[];
101 } Bluetooth_SignalCommand_ConfigurationRequest_t;
102
103 typedef struct
104 {
105 uint16_t SourceChannel;
106 uint16_t Flags;
107 uint16_t Result;
108 uint8_t Config;
109 } Bluetooth_SignalCommand_ConfigurationResponse_t;
110
111 /* Function Prototypes: */
112 void Bluetooth_ProcessACLPackets(void);
113
114 #if defined(INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C)
115 static inline void Bluetooth_ProcessSignalPacket_ConnectionRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,
116 Bluetooth_DataPacket_Header_t* DataHeader,
117 Bluetooth_SignalCommand_Header_t* SignalCommandHeader);
118 static inline void Bluetooth_ProcessSignalPacket_ConfigurationRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,
119 Bluetooth_DataPacket_Header_t* DataHeader,
120 Bluetooth_SignalCommand_Header_t* SignalCommandHeader);
121 #endif
122
123 #endif