--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#ifndef _BLUETOOTH_HCICOMMANDS_H_\r
+#define _BLUETOOTH_HCICOMMANDS_H_\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <string.h>\r
+ #include <stdbool.h>\r
+\r
+ #include <LUFA/Drivers/USB/USB.h>\r
+\r
+ #include "BluetoothStack.h"\r
+ #include "BluetoothClassCodes.h"\r
+\r
+ /* Macros: */\r
+ #define OGF_LINK_CONTROL 0x01\r
+ #define OGF_CTRLR_BASEBAND 0x03\r
+ #define OGF_CTRLR_INFORMATIONAL 0x04\r
+\r
+ #define OCF_LINK_CONTROL_INQUIRY 0x0001\r
+ #define OCF_LINK_CONTROL_INQUIRY_CANCEL 0x0002\r
+ #define OCF_LINK_CONTROL_PERIODIC_INQUIRY 0x0003\r
+ #define OCF_LINK_CONTROL_EXIT_PERIODIC_INQUIRY 0x0004\r
+ #define OCF_LINK_CONTROL_CREATE_CONNECTION 0x0005\r
+ #define OCF_LINK_CONTROL_DISCONNECT 0x0006\r
+ #define OCF_LINK_CONTROL_CREATE_CONNECTION_CANCEL 0x0008\r
+ #define OCF_LINK_CONTROL_ACCEPT_CONNECTION_REQUEST 0x0009\r
+ #define OCF_LINK_CONTROL_REJECT_CONNECTION_REQUEST 0x000A\r
+ #define OCF_LINK_CONTROL_LINK_KEY_REQUEST_REPLY 0x000B\r
+ #define OCF_LINK_CONTROL_LINK_KEY_REQUEST_NEG_REPLY 0x000C\r
+ #define OCF_LINK_CONTROL_PIN_CODE_REQUEST_REPLY 0x000D\r
+ #define OCF_LINK_CONTROL_PIN_CODE_REQUEST_NEG_REPLY 0x000E\r
+ #define OCF_LINK_CONTROL_CHANGE_CONNECTION_PACKET_TYPE 0x000F\r
+ #define OCF_LINK_CONTROL_REMOTE_NAME_REQUEST 0x0019\r
+ #define OCF_CTRLR_BASEBAND_SET_EVENT_MASK 0x0001\r
+ #define OCF_CTRLR_BASEBAND_RESET 0x0003\r
+ #define OCF_CTRLR_BASEBAND_WRITE_PIN_TYPE 0x000A\r
+ #define OCF_CTRLR_BASEBAND_WRITE_LOCAL_NAME 0x0013\r
+ #define OCF_CTRLR_BASEBAND_READ_LOCAL_NAME 0x0014\r
+ #define OCF_CTRLR_BASEBAND_WRITE_SCAN_ENABLE 0x001A\r
+ #define OCF_CTRLR_BASEBAND_WRITE_CLASS_OF_DEVICE 0x0024\r
+ #define OCF_CTRLR_BASEBAND_WRITE_SIMPLE_PAIRING_MODE 0x0056\r
+ #define OCF_CTRLR_BASEBAND_WRITE_AUTHENTICATION_ENABLE 0x0020\r
+ #define OGF_CTRLR_INFORMATIONAL_READBUFFERSIZE 0x0005\r
+ \r
+ #define EVENT_COMMAND_STATUS 0x0F\r
+ #define EVENT_COMMAND_COMPLETE 0x0E\r
+ #define EVENT_CONNECTION_COMPLETE 0x03\r
+ #define EVENT_CONNECTION_REQUEST 0x04\r
+ #define EVENT_DISCONNECTION_COMPLETE 0x05\r
+ #define EVENT_REMOTE_NAME_REQUEST_COMPLETE 0x07\r
+ #define EVENT_PIN_CODE_REQUEST 0x16\r
+ \r
+ #define ERROR_LIMITED_RESOURCES 0x0D\r
+ \r
+ /* Type Defines: */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ int OCF : 10;\r
+ int OGF : 6;\r
+ } OpCode;\r
+\r
+ uint8_t ParameterLength;\r
+ uint8_t Parameters[];\r
+ } Bluetooth_HCICommand_Header_t;\r
+\r
+ typedef struct\r
+ {\r
+ uint8_t EventCode;\r
+ uint8_t ParameterLength;\r
+ } Bluetooth_HCIEvent_Header_t;\r
+\r
+ typedef struct\r
+ {\r
+ uint8_t CommandStatus;\r
+ uint8_t CommandPackets;\r
+\r
+ struct\r
+ {\r
+ int OCF : 10;\r
+ int OGF : 6;\r
+ } OpCode;\r
+ } Bluetooth_HCIEvent_CommandStatus_Header_t;\r
+ \r
+ typedef struct\r
+ {\r
+ uint8_t RemoteAddress[6];\r
+ uint8_t ClassOfDevice_Service;\r
+ uint16_t ClassOfDevice_MajorMinor;\r
+ uint8_t LinkType;\r
+ } Bluetooth_HCIEvent_ConnectionRequest_Header_t;\r
+\r
+ typedef struct\r
+ {\r
+ uint8_t Status;\r
+ uint16_t ConnectionHandle;\r
+ uint8_t RemoteAddress[6];\r
+ uint8_t LinkType;\r
+ uint8_t EncryptionEnabled;\r
+ } Bluetooth_HCIEvent_ConnectionComplete_Header_t;\r
+ \r
+ typedef struct\r
+ {\r
+ uint8_t RemoteAddress[6];\r
+ uint8_t SlaveRole;\r
+ } Bluetooth_HCICommand_AcceptConnectionRequest_Params_t;\r
+ \r
+ typedef struct\r
+ {\r
+ uint8_t RemoteAddress[6];\r
+ uint8_t Reason;\r
+ } Bluetooth_HCICommand_RejectConnectionRequest_Params_t;\r
+\r
+ typedef struct\r
+ {\r
+ uint8_t RemoteAddress[6];\r
+ uint8_t PINCodeLength;\r
+ char PINCode[16];\r
+ } Bluetooth_HCICommand_PinCodeResponse_Params_t;\r
+ \r
+ /* Enums: */\r
+ enum Bluetooth_ScanEnable_Modes_t\r
+ {\r
+ NoScansEnabled = 0,\r
+ InquiryScanOnly = 1,\r
+ PageScanOnly = 2,\r
+ InquiryAndPageScans = 3,\r
+ };\r
+\r
+ enum BluetoothStack_States_t\r
+ {\r
+ Bluetooth_Init = 0,\r
+ Bluetooth_Init_Reset = 1,\r
+ Bluetooth_Init_ReadBufferSize = 2,\r
+ Bluetooth_Init_SetEventMask = 3,\r
+ Bluetooth_Init_SetLocalName = 4,\r
+ Bluetooth_Init_SetDeviceClass = 5,\r
+ Bluetooth_Init_WriteScanEnable = 6,\r
+ Bluetooth_PrepareToProcessEvents = 7,\r
+ Bluetooth_ProcessEvents = 8,\r
+ Bluetooth_Conn_AcceptConnection = 9,\r
+ Bluetooth_Conn_RejectConnection = 10,\r
+ Bluetooth_Conn_SendPINCode = 11,\r
+ };\r
+ \r
+ /* External Variables: */\r
+ extern uint8_t Bluetooth_HCIProcessingState;\r
+\r
+ /* Function Prototypes: */\r
+ void Bluetooth_ProcessHCICommands(void);\r
+\r
+ #if defined(INCLUDE_FROM_BLUETOOTHHCICOMMANDS_C)\r
+ static uint8_t Bluetooth_SendHCICommand(void* Parameters, uint8_t ParamLength);\r
+ static bool Bluetooth_GetNextHCIEventHeader(void);\r
+ static void Bluetooth_DiscardRemainingHCIEventParameters(void);\r
+ static void Bluetooth_ProcessHCICommands(void);\r
+ #endif\r
+ \r
+#endif\r