3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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_STACK_
32 #define _BLUETOOTH_STACK_
35 #include <LUFA/Drivers/USB/USB.h>
37 #include "BluetoothHost.h"
40 #define BLUETOOTH_DATA_IN_PIPE 1
41 #define BLUETOOTH_DATA_OUT_PIPE 2
42 #define BLUETOOTH_EVENTS_PIPE 3
44 #define BLUETOOTH_MAX_OPEN_CHANNELS 2
45 #define BLUETOOTH_CHANNELNUMBER_BASEOFFSET 0x0040
47 #define CHANNEL_PSM_SERVICEDISCOVERY 0x0001
48 #define CHANNEL_PSM_RFCOMM 0x0003
50 #define MAXIMUM_CHANNEL_MTU 255
53 enum BT_ChannelStates_t
56 Channel_WaitConnect
= 1,
57 Channel_WaitConnectRsp
= 2,
58 Channel_Config_WaitConfig
= 3,
59 Channel_Config_WaitSendConfig
= 4,
60 Channel_Config_WaitReqResp
= 5,
61 Channel_Config_WaitResp
= 6,
62 Channel_Config_WaitReq
= 7,
64 Channel_WaitDisconnect
= 9,
67 enum Endpoint_ControlStream_RW_ErrorCodes_t
69 BT_SENDPACKET_NoError
= 0,
70 BT_SENDPACKET_NotConnected
= 1,
71 BT_SENDPACKET_ChannelNotOpen
= 2,
79 uint16_t RemoteNumber
;
83 } Bluetooth_Channel_t
;
88 uint16_t ConnectionHandle
;
89 uint8_t RemoteAddress
[6];
90 Bluetooth_Channel_t Channels
[BLUETOOTH_MAX_OPEN_CHANNELS
];
91 uint8_t SignallingIdentifier
;
92 } Bluetooth_Connection_t
;
102 #include "BluetoothHCICommands.h"
103 #include "BluetoothACLPackets.h"
105 /* Function Prototypes: */
106 void Bluetooth_Stack_Init(void);
107 void Bluetooth_Stack_USBTask(void);
109 bool Bluetooth_ConnectionRequest(uint8_t* RemoteAddress
);
110 void Bluetooth_ConnectionComplete(void);
111 void Bluetooth_DisconnectionComplete(void);
112 void Bluetooth_PacketReceived(uint16_t* PacketLength
, Bluetooth_Channel_t
* Channel
);
113 Bluetooth_Channel_t
* Bluetooth_GetChannelData(uint16_t ChannelNumber
, bool SearchByRemoteChannel
);
114 Bluetooth_Channel_t
* Bluetooth_OpenChannel(uint16_t PSM
);
115 void Bluetooth_CloseChannel(Bluetooth_Channel_t
* Channel
);
116 uint8_t Bluetooth_SendPacket(void* Data
, uint16_t DataLen
, Bluetooth_Channel_t
* Channel
);
118 /* External Variables: */
119 extern Bluetooth_Device_t Bluetooth_DeviceConfiguration
;
120 extern Bluetooth_Connection_t Bluetooth_Connection
;