3 Copyright (C) Dean Camera, 2009.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 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.
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
31 #ifndef _BLUETOOTH_HCICOMMANDS_H_
32 #define _BLUETOOTH_HCICOMMANDS_H_
39 #include <LUFA/Drivers/USB/USB.h>
41 #include "BluetoothStack.h"
42 #include "BluetoothClassCodes.h"
45 #define OGF_LINK_CONTROL 0x01
46 #define OGF_CTRLR_BASEBAND 0x03
47 #define OGF_CTRLR_INFORMATIONAL 0x04
49 #define OCF_LINK_CONTROL_INQUIRY 0x0001
50 #define OCF_LINK_CONTROL_INQUIRY_CANCEL 0x0002
51 #define OCF_LINK_CONTROL_PERIODIC_INQUIRY 0x0003
52 #define OCF_LINK_CONTROL_EXIT_PERIODIC_INQUIRY 0x0004
53 #define OCF_LINK_CONTROL_CREATE_CONNECTION 0x0005
54 #define OCF_LINK_CONTROL_DISCONNECT 0x0006
55 #define OCF_LINK_CONTROL_CREATE_CONNECTION_CANCEL 0x0008
56 #define OCF_LINK_CONTROL_ACCEPT_CONNECTION_REQUEST 0x0009
57 #define OCF_LINK_CONTROL_REJECT_CONNECTION_REQUEST 0x000A
58 #define OCF_LINK_CONTROL_LINK_KEY_REQUEST_REPLY 0x000B
59 #define OCF_LINK_CONTROL_LINK_KEY_REQUEST_NEG_REPLY 0x000C
60 #define OCF_LINK_CONTROL_PIN_CODE_REQUEST_REPLY 0x000D
61 #define OCF_LINK_CONTROL_PIN_CODE_REQUEST_NEG_REPLY 0x000E
62 #define OCF_LINK_CONTROL_CHANGE_CONNECTION_PACKET_TYPE 0x000F
63 #define OCF_LINK_CONTROL_REMOTE_NAME_REQUEST 0x0019
64 #define OCF_CTRLR_BASEBAND_SET_EVENT_MASK 0x0001
65 #define OCF_CTRLR_BASEBAND_RESET 0x0003
66 #define OCF_CTRLR_BASEBAND_WRITE_PIN_TYPE 0x000A
67 #define OCF_CTRLR_BASEBAND_WRITE_LOCAL_NAME 0x0013
68 #define OCF_CTRLR_BASEBAND_READ_LOCAL_NAME 0x0014
69 #define OCF_CTRLR_BASEBAND_WRITE_SCAN_ENABLE 0x001A
70 #define OCF_CTRLR_BASEBAND_WRITE_CLASS_OF_DEVICE 0x0024
71 #define OCF_CTRLR_BASEBAND_WRITE_SIMPLE_PAIRING_MODE 0x0056
72 #define OCF_CTRLR_BASEBAND_WRITE_AUTHENTICATION_ENABLE 0x0020
73 #define OGF_CTRLR_INFORMATIONAL_READBUFFERSIZE 0x0005
75 #define EVENT_COMMAND_STATUS 0x0F
76 #define EVENT_COMMAND_COMPLETE 0x0E
77 #define EVENT_CONNECTION_COMPLETE 0x03
78 #define EVENT_CONNECTION_REQUEST 0x04
79 #define EVENT_DISCONNECTION_COMPLETE 0x05
80 #define EVENT_REMOTE_NAME_REQUEST_COMPLETE 0x07
81 #define EVENT_PIN_CODE_REQUEST 0x16
83 #define ERROR_LIMITED_RESOURCES 0x0D
94 uint8_t ParameterLength
;
96 } Bluetooth_HCICommand_Header_t
;
101 uint8_t ParameterLength
;
102 } Bluetooth_HCIEvent_Header_t
;
106 uint8_t CommandStatus
;
107 uint8_t CommandPackets
;
114 } Bluetooth_HCIEvent_CommandStatus_Header_t
;
118 uint8_t RemoteAddress
[6];
119 uint8_t ClassOfDevice_Service
;
120 uint16_t ClassOfDevice_MajorMinor
;
122 } Bluetooth_HCIEvent_ConnectionRequest_Header_t
;
127 uint16_t ConnectionHandle
;
128 uint8_t RemoteAddress
[6];
130 uint8_t EncryptionEnabled
;
131 } Bluetooth_HCIEvent_ConnectionComplete_Header_t
;
135 uint8_t RemoteAddress
[6];
137 } Bluetooth_HCICommand_AcceptConnectionRequest_Params_t
;
141 uint8_t RemoteAddress
[6];
143 } Bluetooth_HCICommand_RejectConnectionRequest_Params_t
;
147 uint8_t RemoteAddress
[6];
148 uint8_t PINCodeLength
;
150 } Bluetooth_HCICommand_PinCodeResponse_Params_t
;
153 enum Bluetooth_ScanEnable_Modes_t
158 InquiryAndPageScans
= 3,
161 enum BluetoothStack_States_t
164 Bluetooth_Init_Reset
= 1,
165 Bluetooth_Init_ReadBufferSize
= 2,
166 Bluetooth_Init_SetEventMask
= 3,
167 Bluetooth_Init_SetLocalName
= 4,
168 Bluetooth_Init_SetDeviceClass
= 5,
169 Bluetooth_Init_WriteScanEnable
= 6,
170 Bluetooth_PrepareToProcessEvents
= 7,
171 Bluetooth_ProcessEvents
= 8,
172 Bluetooth_Conn_AcceptConnection
= 9,
173 Bluetooth_Conn_RejectConnection
= 10,
174 Bluetooth_Conn_SendPINCode
= 11,
177 /* External Variables: */
178 extern uint8_t Bluetooth_HCIProcessingState
;
180 /* Function Prototypes: */
181 void Bluetooth_ProcessHCICommands(void);
183 #if defined(INCLUDE_FROM_BLUETOOTHHCICOMMANDS_C)
184 static uint8_t Bluetooth_SendHCICommand(void* Parameters
, uint8_t ParamLength
);
185 static bool Bluetooth_GetNextHCIEventHeader(void);
186 static void Bluetooth_DiscardRemainingHCIEventParameters(void);
187 static void Bluetooth_ProcessHCICommands(void);