Commit 2793c88f authored by Dean Camera's avatar Dean Camera

Add master device Host demo makefile.

Copy and convert incomplete Bluetooth Host demo to the library.
parent d47df1cd
......@@ -60,7 +60,6 @@
/** Maximum ADC range for the microphone input. */
#define ADC_MAX_RANGE 0x3FF
/* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1
......
......@@ -98,7 +98,6 @@
#define CSx0 CS10
#endif
/* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1
......
/*
LUFA Library
Copyright (C) Dean Camera, 2009.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
#define INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C
#include "BluetoothACLPackets.h"
void Bluetooth_ProcessACLPackets(void)
{
Bluetooth_ACL_Header_t ACLPacketHeader;
Pipe_SelectPipe(BLUETOOTH_DATA_IN_PIPE);
Pipe_SetToken(PIPE_TOKEN_IN);
Pipe_Unfreeze();
if (!(Pipe_IsReadWriteAllowed()))
{
Pipe_Freeze();
return;
}
Pipe_Read_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader));
Bluetooth_DataPacket_Header_t DataHeader;
Pipe_Read_Stream_LE(&DataHeader, sizeof(DataHeader));
BT_DEBUG("(ACL) Packet Received", NULL);
BT_DEBUG("(ACL) -- Connection Handle: 0x%04X", ACLPacketHeader.ConnectionHandle);
BT_DEBUG("(ACL) -- Data Length: 0x%04X", ACLPacketHeader.DataLength);
BT_DEBUG("(ACL) -- Destination Channel: 0x%04X", DataHeader.DestinationChannel);
BT_DEBUG("(ACL) -- Payload Length: 0x%04X", DataHeader.PayloadLength);
if (DataHeader.DestinationChannel == BLUETOOTH_CHANNEL_SIGNALING)
{
Bluetooth_SignalCommand_Header_t SignalCommandHeader;
Pipe_Read_Stream_LE(&SignalCommandHeader, sizeof(SignalCommandHeader));
switch (SignalCommandHeader.Code)
{
case BLUETOOTH_SIGNAL_CONNECTION_REQUEST:
Bluetooth_ProcessSignalPacket_ConnectionRequest(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);
break;
case BLUETOOTH_SIGNAL_CONFIGURATION_REQUEST:
Bluetooth_ProcessSignalPacket_ConfigurationRequest(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);
break;
default:
BT_DEBUG("(ACL) >> Unknown Signalling Command 0x%02X", SignalCommandHeader.Code);
Pipe_Discard_Stream(ACLPacketHeader.DataLength);
Pipe_ClearIN();
Pipe_Freeze();
break;
}
}
else
{
uint8_t DataPayload[DataHeader.PayloadLength];
Pipe_Read_Stream_LE(&DataPayload, sizeof(DataPayload));
DataHeader.PayloadLength = 0;
BT_DEBUG("(ACL) -- Data Payload: ", NULL);
for (uint16_t B = 0; B < sizeof(DataPayload); B++)
printf("0x%02X ", DataPayload[B]);
BT_DEBUG("", NULL);
Pipe_Discard_Stream(ACLPacketHeader.DataLength);
Pipe_ClearIN();
Pipe_Freeze();
}
}
static inline void Bluetooth_ProcessSignalPacket_ConnectionRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,
Bluetooth_DataPacket_Header_t* DataHeader,
Bluetooth_SignalCommand_Header_t* SignalCommandHeader)
{
Bluetooth_SignalCommand_ConnectionRequest_t ConnectionRequest;
Pipe_Read_Stream_LE(&ConnectionRequest, sizeof(ConnectionRequest));
BT_DEBUG("(ACL) >> L2CAP Connection Request", NULL);
BT_DEBUG("(ACL) -- PSM: 0x%04X", ConnectionRequest.PSM);
BT_DEBUG("(ACL) -- Source Channel: 0x%04X", ConnectionRequest.SourceChannel);
Pipe_ClearIN();
Pipe_Freeze();
Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
Pipe_SetToken(PIPE_TOKEN_OUT);
Pipe_Unfreeze();
Bluetooth_SignalCommand_ConnectionResponse_t ConnectionResponse;
ACLPacketHeader->DataLength = sizeof(*DataHeader) + sizeof(*SignalCommandHeader) + sizeof(ConnectionResponse);
DataHeader->PayloadLength = sizeof(*SignalCommandHeader) + sizeof(ConnectionResponse);
DataHeader->DestinationChannel = BLUETOOTH_CHANNEL_SIGNALING;
SignalCommandHeader->Code = BLUETOOTH_SIGNAL_CONNECTION_RESPONSE;
SignalCommandHeader->Length = sizeof(ConnectionResponse);
Bluetooth_Channel_t* ChannelData = Bluetooth_InitChannelData(ConnectionRequest.SourceChannel, ConnectionRequest.PSM);
ConnectionResponse.Result = (ChannelData == NULL) ? BLUETOOTH_CONNECTION_REFUSED_RESOURCES :
BLUETOOTH_CONNECTION_SUCCESSFUL;
ConnectionResponse.DestinationChannel = ChannelData->LocalNumber;
ConnectionResponse.SourceChannel = ChannelData->RemoteNumber;
ConnectionResponse.Status = 0x00;
Pipe_Write_Stream_LE(ACLPacketHeader, sizeof(*ACLPacketHeader));
Pipe_Write_Stream_LE(DataHeader, sizeof(*DataHeader));
Pipe_Write_Stream_LE(SignalCommandHeader, sizeof(*SignalCommandHeader));
Pipe_Write_Stream_LE(&ConnectionResponse, sizeof(ConnectionResponse));
Pipe_ClearOUT();
Pipe_Freeze();
BT_DEBUG("(ACL) Packet Sent", NULL);
BT_DEBUG("(ACL) -- Connection Handle: 0x%04X", ACLPacketHeader->ConnectionHandle);
BT_DEBUG("(ACL) -- Data Length: 0x%04X", ACLPacketHeader->DataLength);
BT_DEBUG("(ACL) -- Destination Channel: 0x%04X", DataHeader->DestinationChannel);
BT_DEBUG("(ACL) -- Payload Length: 0x%04X", DataHeader->PayloadLength);
BT_DEBUG("(ACL) >> L2CAP Connection Response", NULL);
BT_DEBUG("(ACL) -- Source Channel: 0x%04X", ConnectionResponse.SourceChannel);
BT_DEBUG("(ACL) -- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel);
}
static inline void Bluetooth_ProcessSignalPacket_ConfigurationRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,
Bluetooth_DataPacket_Header_t* DataHeader,
Bluetooth_SignalCommand_Header_t* SignalCommandHeader)
{
Bluetooth_SignalCommand_ConfigurationRequest_t ConfigurationRequest;
Pipe_Read_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest));
BT_DEBUG("(ACL) >> L2CAP Configuration Request", NULL);
BT_DEBUG("(ACL) -- Destination Channel: 0x%04X", ConfigurationRequest.DestinationChannel);
Pipe_ClearIN();
Pipe_Freeze();
Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
Pipe_SetToken(PIPE_TOKEN_OUT);
Pipe_Unfreeze();
Bluetooth_SignalCommand_ConfigurationResponse_t ConfigurationResponse;
ACLPacketHeader->DataLength = sizeof(*DataHeader) + sizeof(*SignalCommandHeader) + sizeof(ConfigurationResponse);
DataHeader->PayloadLength = sizeof(*SignalCommandHeader) + sizeof(ConfigurationResponse);
DataHeader->DestinationChannel = BLUETOOTH_CHANNEL_SIGNALING;
SignalCommandHeader->Code = BLUETOOTH_SIGNAL_CONFIGURATION_RESPONSE;
SignalCommandHeader->Length = sizeof(ConfigurationResponse);
Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConfigurationRequest.DestinationChannel, CHANNEL_LOOKUP_BY_DESTINATION);
if (ChannelData != NULL)
ChannelData->State = Channel_Open;
// TODO: Add channel config data to the tail of ConfigurationResponse
ConfigurationResponse.SourceChannel = ChannelData->RemoteNumber;
ConfigurationResponse.Flags = 0x00;
ConfigurationResponse.Result = (ChannelData != NULL) ? BLUETOOTH_CONFIGURATION_SUCCESSFUL : BLUETOOTH_CONFIGURATION_REJECTED;
Pipe_Write_Stream_LE(ACLPacketHeader, sizeof(*ACLPacketHeader));
Pipe_Write_Stream_LE(DataHeader, sizeof(*DataHeader));
Pipe_Write_Stream_LE(SignalCommandHeader, sizeof(*SignalCommandHeader));
Pipe_Write_Stream_LE(&ConfigurationResponse, sizeof(ConfigurationResponse));
Pipe_ClearOUT();
Pipe_Freeze();
BT_DEBUG("(ACL) Packet Sent", NULL);
BT_DEBUG("(ACL) -- Connection Handle: 0x%04X", ACLPacketHeader->ConnectionHandle);
BT_DEBUG("(ACL) -- Data Length: 0x%04X", ACLPacketHeader->DataLength);
BT_DEBUG("(ACL) -- Destination Channel: 0x%04X", DataHeader->DestinationChannel);
BT_DEBUG("(ACL) -- Payload Length: 0x%04X", DataHeader->PayloadLength);
BT_DEBUG("(ACL) >> L2CAP Configuration Response", NULL);
}
/*
LUFA Library
Copyright (C) Dean Camera, 2009.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
#ifndef _BLUETOOTH_ACLPACKETS_
#define _BLUETOOTH_ACLPACKETS_
/* Includes: */
#include <avr/io.h>
#include <string.h>
#include <stdbool.h>
#include <LUFA/Drivers/USB/USB.h>
#include "BluetoothStack.h"
/* Macros: */
#define BLUETOOTH_CHANNEL_SIGNALING 0x0001
#define BLUETOOTH_CHANNEL_CONNECTIONLESS 0x0002
#define BLUETOOTH_SIGNAL_CONNECTION_REQUEST 0x02
#define BLUETOOTH_SIGNAL_CONNECTION_RESPONSE 0x03
#define BLUETOOTH_SIGNAL_CONFIGURATION_REQUEST 0x04
#define BLUETOOTH_SIGNAL_CONFIGURATION_RESPONSE 0x05
#define BLUETOOTH_CONNECTION_SUCCESSFUL 0x0000
#define BLUETOOTH_CONNECTION_REFUSED_RESOURCES 0x0004
#define BLUETOOTH_CONFIGURATION_SUCCESSFUL 0x0000
#define BLUETOOTH_CONFIGURATION_REJECTED 0x0002
#define BLUETOOTH_CONFIGURATION_UNKNOWNOPTIONS 0x0003
/* Type Defines: */
typedef struct
{
uint16_t ConnectionHandle;
uint16_t DataLength;
} Bluetooth_ACL_Header_t;
typedef struct
{
uint16_t PayloadLength;
uint16_t DestinationChannel;
} Bluetooth_DataPacket_Header_t;
typedef struct
{
uint8_t Code;
uint8_t Identifier;
uint16_t Length;
} Bluetooth_SignalCommand_Header_t;
typedef struct
{
uint16_t PSM;
uint16_t SourceChannel;
} Bluetooth_SignalCommand_ConnectionRequest_t;
typedef struct
{
uint16_t DestinationChannel;
uint16_t SourceChannel;
uint16_t Result;
uint16_t Status;
} Bluetooth_SignalCommand_ConnectionResponse_t;
typedef struct
{
uint16_t DestinationChannel;
uint16_t Flags;
uint8_t Options[];
} Bluetooth_SignalCommand_ConfigurationRequest_t;
typedef struct
{
uint16_t SourceChannel;
uint16_t Flags;
uint16_t Result;
uint8_t Config;
} Bluetooth_SignalCommand_ConfigurationResponse_t;
/* Function Prototypes: */
void Bluetooth_ProcessACLPackets(void);
#if defined(INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C)
static inline void Bluetooth_ProcessSignalPacket_ConnectionRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,
Bluetooth_DataPacket_Header_t* DataHeader,
Bluetooth_SignalCommand_Header_t* SignalCommandHeader);
static inline void Bluetooth_ProcessSignalPacket_ConfigurationRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,
Bluetooth_DataPacket_Header_t* DataHeader,
Bluetooth_SignalCommand_Header_t* SignalCommandHeader);
#endif
#endif
/*
LUFA Library
Copyright (C) Dean Camera, 2009.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
#ifndef _BLUETOOTH_CLASS_CODES_H_
#define _BLUETOOTH_CLASS_CODES_H_
/* Macros: */
#define DEVICE_CLASS_SERVICE_POSITIONING (1UL << 16)
#define DEVICE_CLASS_SERVICE_NETWORKING (1UL << 17)
#define DEVICE_CLASS_SERVICE_RENDERING (1UL << 18)
#define DEVICE_CLASS_SERVICE_CAPTURING (1UL << 19)
#define DEVICE_CLASS_SERVICE_OBJECTTRANSFER (1UL << 20)
#define DEVICE_CLASS_SERVICE_AUDIO (1UL << 21)
#define DEVICE_CLASS_SERVICE_TELEPHONY (1UL << 22)
#define DEVICE_CLASS_SERVICE_INFORMATION (1UL << 23)
#define DEVICE_CLASS_MAJOR_MISC (0x00 << 8)
#define DEVICE_CLASS_MAJOR_COMPUTER (0x01 << 8)
#define DEVICE_CLASS_MAJOR_PHONE (0x02 << 8)
#define DEVICE_CLASS_MAJOR_LAN (0x03 << 8)
#define DEVICE_CLASS_MAJOR_AUDIOVIDEO (0x04 << 8)
#define DEVICE_CLASS_MAJOR_PERIPHERAL (0x05 << 8)
#define DEVICE_CLASS_MAJOR_IMAGING (0x06 << 8)
#define DEVICE_CLASS_MAJOR_UNCLASSIFIED (0x1F << 8)
#define DEVICE_CLASS_MINOR_COMPUTER_UNCATEGORIZED (0x00 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_DESKTOP (0x01 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_SERVER (0x02 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_LAPTOP (0x03 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_HANDHELD (0x04 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_PALM (0x05 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_WEARABLE (0x06 << 2)
#define DEVICE_CLASS_MINOR_PHONE_UNCATEGORIZED (0x00 << 2)
#define DEVICE_CLASS_MINOR_PHONE_CELLULAR (0x01 << 2)
#define DEVICE_CLASS_MINOR_PHONE_CORDLESS (0x02 << 2)
#define DEVICE_CLASS_MINOR_PHONE_SMARTPHONE (0x03 << 2)
#define DEVICE_CLASS_MINOR_PHONE_WIREDMODEM (0x04 << 2)
#define DEVICE_CLASS_MINOR_PHONE_ISDN (0x05 << 2)
#define DEVICE_CLASS_MINOR_LAN_FULLY_AVAILABLE (0x00 << 5)
#define DEVICE_CLASS_MINOR_LAN_1_TO_17_PC_UTILIZED (0x01 << 5)
#define DEVICE_CLASS_MINOR_LAN_17_TO_33_PC_UTILIZED (0x02 << 5)
#define DEVICE_CLASS_MINOR_LAN_33_TO_50_PC_UTILIZED (0x03 << 5)
#define DEVICE_CLASS_MINOR_LAN_50_TO_67_PC_UTILIZED (0x04 << 5)
#define DEVICE_CLASS_MINOR_LAN_67_TO_83_PC_UTILIZED (0x05 << 5)
#define DEVICE_CLASS_MINOR_LAN_83_TO_99_PC_UTILIZED (0x06 << 5)
#define DEVICE_CLASS_MINOR_NO_SERVICE_AVAILABLE (0x07 << 5)
#define DEVICE_CLASS_MINOR_AV_UNCATEGORIZED (0x00 << 2)
#define DEVICE_CLASS_MINOR_AV_HEADSET (0x01 << 2)
#define DEVICE_CLASS_MINOR_AV_HANDSFREE (0x02 << 2)
#define DEVICE_CLASS_MINOR_AV_MICROPHONE (0x04 << 2)
#define DEVICE_CLASS_MINOR_AV_LOUDSPEAKER (0x05 << 2)
#define DEVICE_CLASS_MINOR_AV_HEADPHONES (0x06 << 2)
#define DEVICE_CLASS_MINOR_AV_PORTABLE_AUDIO (0x07 << 2)
#define DEVICE_CLASS_MINOR_AV_CARAUDIO (0x08 << 2)
#define DEVICE_CLASS_MINOR_AV_SETTOP_BOX (0x09 << 2)
#define DEVICE_CLASS_MINOR_AV_HIFI (0x0A << 2)
#define DEVICE_CLASS_MINOR_AV_VCR (0x0B << 2)
#define DEVICE_CLASS_MINOR_AV_VIDEO_CAMERA (0x0C << 2)
#define DEVICE_CLASS_MINOR_AV_CAMCORDER (0x0D << 2)
#define DEVICE_CLASS_MINOR_AV_VIDEO_MONITOR (0x0E << 2)
#define DEVICE_CLASS_MINOR_AV_DISPLAY_AND_LOUDSPEAKER (0x0F << 2)
#define DEVICE_CLASS_MINOR_AV_VIDEO_CONFERENCING (0x10 << 2)
#define DEVICE_CLASS_MINOR_AV_GAMING_TOY (0x12 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_KEYBOARD (0x01 << 6)
#define DEVICE_CLASS_MINOR_PERIPHERAL_POINTING (0x02 << 6)
#define DEVICE_CLASS_MINOR_PERIPHERAL_COMBO (0x03 << 6)
#define DEVICE_CLASS_MINOR_PERIPHERAL_UNCATEGORIZED (0x00 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_JOYSTICK (0x01 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_GAMEPAD (0x02 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_REMOTE_CONTROL (0x03 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_SENSING_DEVICE (0x04 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_DIGITIZER (0x05 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_CARD_READER (0x06 << 2)
#define DEVICE_CLASS_MINOR_IMAGING_DISPLAY (1 << 4)
#define DEVICE_CLASS_MINOR_IMAGING_CAMERA (1 << 5)
#define DEVICE_CLASS_MINOR_IMAGING_SCANNER (1 << 6)
#define DEVICE_CLASS_MINOR_IMAGING_PRINTER (1 << 7)
#endif
This diff is collapsed.
/*
LUFA Library
Copyright (C) Dean Camera, 2009.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
#ifndef _BLUETOOTH_HCICOMMANDS_H_
#define _BLUETOOTH_HCICOMMANDS_H_
/* Includes: */
#include <avr/io.h>
#include <string.h>
#include <stdbool.h>
#include <LUFA/Drivers/USB/USB.h>
#include "BluetoothStack.h"
#include "BluetoothClassCodes.h"
/* Macros: */
#define OGF_LINK_CONTROL 0x01
#define OGF_CTRLR_BASEBAND 0x03
#define OGF_CTRLR_INFORMATIONAL 0x04
#define OCF_LINK_CONTROL_INQUIRY 0x0001
#define OCF_LINK_CONTROL_INQUIRY_CANCEL 0x0002
#define OCF_LINK_CONTROL_PERIODIC_INQUIRY 0x0003
#define OCF_LINK_CONTROL_EXIT_PERIODIC_INQUIRY 0x0004
#define OCF_LINK_CONTROL_CREATE_CONNECTION 0x0005
#define OCF_LINK_CONTROL_DISCONNECT 0x0006
#define OCF_LINK_CONTROL_CREATE_CONNECTION_CANCEL 0x0008
#define OCF_LINK_CONTROL_ACCEPT_CONNECTION_REQUEST 0x0009
#define OCF_LINK_CONTROL_REJECT_CONNECTION_REQUEST 0x000A
#define OCF_LINK_CONTROL_LINK_KEY_REQUEST_REPLY 0x000B
#define OCF_LINK_CONTROL_LINK_KEY_REQUEST_NEG_REPLY 0x000C
#define OCF_LINK_CONTROL_PIN_CODE_REQUEST_REPLY 0x000D
#define OCF_LINK_CONTROL_PIN_CODE_REQUEST_NEG_REPLY 0x000E
#define OCF_LINK_CONTROL_CHANGE_CONNECTION_PACKET_TYPE 0x000F
#define OCF_LINK_CONTROL_REMOTE_NAME_REQUEST 0x0019
#define OCF_CTRLR_BASEBAND_SET_EVENT_MASK 0x0001
#define OCF_CTRLR_BASEBAND_RESET 0x0003
#define OCF_CTRLR_BASEBAND_WRITE_PIN_TYPE 0x000A
#define OCF_CTRLR_BASEBAND_WRITE_LOCAL_NAME 0x0013
#define OCF_CTRLR_BASEBAND_READ_LOCAL_NAME 0x0014
#define OCF_CTRLR_BASEBAND_WRITE_SCAN_ENABLE 0x001A
#define OCF_CTRLR_BASEBAND_WRITE_CLASS_OF_DEVICE 0x0024
#define OCF_CTRLR_BASEBAND_WRITE_SIMPLE_PAIRING_MODE 0x0056
#define OCF_CTRLR_BASEBAND_WRITE_AUTHENTICATION_ENABLE 0x0020
#define OGF_CTRLR_INFORMATIONAL_READBUFFERSIZE 0x0005
#define EVENT_COMMAND_STATUS 0x0F
#define EVENT_COMMAND_COMPLETE 0x0E
#define EVENT_CONNECTION_COMPLETE 0x03
#define EVENT_CONNECTION_REQUEST 0x04
#define EVENT_DISCONNECTION_COMPLETE 0x05
#define EVENT_REMOTE_NAME_REQUEST_COMPLETE 0x07
#define EVENT_PIN_CODE_REQUEST 0x16
#define ERROR_LIMITED_RESOURCES 0x0D
/* Type Defines: */
typedef struct
{
struct
{
int OCF : 10;
int OGF : 6;
} OpCode;
uint8_t ParameterLength;
uint8_t Parameters[];
} Bluetooth_HCICommand_Header_t;
typedef struct
{
uint8_t EventCode;
uint8_t ParameterLength;
} Bluetooth_HCIEvent_Header_t;
typedef struct
{
uint8_t CommandStatus;
uint8_t CommandPackets;
struct
{
int OCF : 10;
int OGF : 6;
} OpCode;
} Bluetooth_HCIEvent_CommandStatus_Header_t;
typedef struct
{
uint8_t RemoteAddress[6];
uint8_t ClassOfDevice_Service;
uint16_t ClassOfDevice_MajorMinor;
uint8_t LinkType;
} Bluetooth_HCIEvent_ConnectionRequest_Header_t;
typedef struct
{
uint8_t Status;
uint16_t ConnectionHandle;
uint8_t RemoteAddress[6];
uint8_t LinkType;
uint8_t EncryptionEnabled;
} Bluetooth_HCIEvent_ConnectionComplete_Header_t;
typedef struct
{
uint8_t RemoteAddress[6];
uint8_t SlaveRole;
} Bluetooth_HCICommand_AcceptConnectionRequest_Params_t;
typedef struct
{
uint8_t RemoteAddress[6];
uint8_t Reason;
} Bluetooth_HCICommand_RejectConnectionRequest_Params_t;
typedef struct
{
uint8_t RemoteAddress[6];
uint8_t PINCodeLength;
char PINCode[16];
} Bluetooth_HCICommand_PinCodeResponse_Params_t;
/* Enums: */
enum Bluetooth_ScanEnable_Modes_t
{
NoScansEnabled = 0,
InquiryScanOnly = 1,
PageScanOnly = 2,
InquiryAndPageScans = 3,
};
enum BluetoothStack_States_t
{
Bluetooth_Init = 0,
Bluetooth_Init_Reset = 1,
Bluetooth_Init_ReadBufferSize = 2,
Bluetooth_Init_SetEventMask = 3,
Bluetooth_Init_SetLocalName = 4,
Bluetooth_Init_SetDeviceClass = 5,
Bluetooth_Init_WriteScanEnable = 6,
Bluetooth_PrepareToProcessEvents = 7,
Bluetooth_ProcessEvents = 8,
Bluetooth_Conn_AcceptConnection = 9,
Bluetooth_Conn_RejectConnection = 10,
Bluetoot