Add HCI debugging with verbosity control to the BluetoothHost demo.
[pub/lufa.git] / Demos / Host / Incomplete / BluetoothHost / Lib / BluetoothStack.h
index 20bc956..5ab7a6f 100644 (file)
                #include <LUFA/Drivers/USB/USB.h>\r
                \r
                #include "BluetoothHost.h"\r
-               #include "BluetoothHCICommands.h"\r
-               #include "BluetoothACLPackets.h"\r
                \r
        /* Macros: */\r
-               #define BLUETOOTH_DATA_IN_PIPE   1\r
-               #define BLUETOOTH_DATA_OUT_PIPE  2\r
-               #define BLUETOOTH_EVENTS_PIPE    3\r
+               #define BLUETOOTH_DATA_IN_PIPE                   1\r
+               #define BLUETOOTH_DATA_OUT_PIPE                  2\r
+               #define BLUETOOTH_EVENTS_PIPE                    3\r
 \r
                #define BLUETOOTH_MAX_OPEN_CHANNELS              2\r
-               #define BLUETOOTH_CHANNELNUMBER_BASEOFFSET       0x0040\r
                \r
-               #define CHANNEL_LOOKUP_BY_SOURCE                 true\r
-               #define CHANNEL_LOOKUP_BY_DESTINATION            false\r
+               #define CHANNEL_PSM_SERVICEDISCOVERY             0x0001\r
+               #define CHANNEL_PSM_UDP                          0x0002\r
+               #define CHANNEL_PSM_RFCOMM                       0x0003\r
+               #define CHANNEL_PSM_TCP                          0x0004\r
+               #define CHANNEL_PSM_IP                           0x0009\r
+               #define CHANNEL_PSM_FTP                          0x000A\r
+               #define CHANNEL_PSM_HTTP                         0x000C\r
+               #define CHANNEL_PSM_UPNP                         0x0010\r
+               #define CHANNEL_PSM_HIDP                         0x0011\r
+               \r
+               #define MAXIMUM_CHANNEL_MTU                      255\r
                \r
        /* Enums: */\r
-               enum Bluetooth_Channel_State_t\r
+               enum BT_ChannelStates_t\r
+               {\r
+                       Channel_Closed                = 0,\r
+                       Channel_WaitConnect           = 1,\r
+                       Channel_WaitConnectRsp        = 2,\r
+                       Channel_Config_WaitConfig     = 3,\r
+                       Channel_Config_WaitSendConfig = 4,\r
+                       Channel_Config_WaitReqResp    = 5,\r
+                       Channel_Config_WaitResp       = 6,\r
+                       Channel_Config_WaitReq        = 7,\r
+                       Channel_Open                  = 8,\r
+                       Channel_WaitDisconnect        = 9,\r
+               };\r
+\r
+               enum Endpoint_ControlStream_RW_ErrorCodes_t\r
                {\r
-                       Channel_Closed          = 0,\r
-                       Channel_WaitConnect     = 1,\r
-                       Channel_WaitConnectRsp  = 2,\r
-                       Channel_Config          = 3,\r
-                       Channel_Open            = 4,\r
-                       Channel_WaitDisconnect  = 5,\r
+                       BT_SENDPACKET_NoError            = 0,\r
+                       BT_SENDPACKET_NotConnected       = 1,\r
+                       BT_SENDPACKET_ChannelNotOpen     = 2,\r
                };\r
 \r
        /* Type Defines: */\r
@@ -67,7 +84,8 @@
                        uint16_t LocalNumber;\r
                        uint16_t RemoteNumber;\r
                        uint16_t PSM;\r
-                       uint16_t MTU;\r
+                       uint16_t LocalMTU;\r
+                       uint16_t RemoteMTU;\r
                } Bluetooth_Channel_t;\r
 \r
                typedef struct\r
@@ -76,6 +94,7 @@
                        uint16_t            ConnectionHandle;\r
                        uint8_t             RemoteAddress[6];\r
                        Bluetooth_Channel_t Channels[BLUETOOTH_MAX_OPEN_CHANNELS];\r
+                       uint8_t             SignallingIdentifier;\r
                } Bluetooth_Connection_t;\r
                \r
                typedef struct\r
                        char     PINCode[16];\r
                        char     Name[];\r
                } Bluetooth_Device_t;\r
+       \r
+       /* Includes: */\r
+               #include "BluetoothHCICommands.h"\r
+               #include "BluetoothACLPackets.h"                \r
                \r
-       /* Function Prototypes: */\r
-               Bluetooth_Channel_t* Bluetooth_GetChannelData(uint16_t ChannelNumber, bool SearchBySource);\r
-               Bluetooth_Channel_t* Bluetooth_InitChannelData(uint16_t RemoteChannelNumber, uint16_t PSM);\r
-               \r
-               void Bluetooth_State_Init(void);\r
-               void Bluetooth_Stack_Task(void);\r
+       /* Function Prototypes: */              \r
+               void Bluetooth_Stack_Init(void);\r
+               void Bluetooth_Stack_USBTask(void);\r
+\r
+               bool                 Bluetooth_ConnectionRequest(uint8_t* RemoteAddress);\r
+               void                 Bluetooth_ConnectionComplete(void);\r
+               void                 Bluetooth_DisconnectionComplete(void);\r
+               void                 Bluetooth_PacketReceived(uint16_t* PacketLength, Bluetooth_Channel_t* Channel);\r
+               Bluetooth_Channel_t* Bluetooth_GetChannelData(uint16_t ChannelNumber, bool SearchByRemoteChannel);\r
+               Bluetooth_Channel_t* Bluetooth_OpenChannel(uint16_t PSM);\r
+               void                 Bluetooth_CloseChannel(Bluetooth_Channel_t* Channel);\r
+               uint8_t              Bluetooth_SendPacket(void* Data, uint16_t DataLen, Bluetooth_Channel_t* Channel);\r
 \r
        /* External Variables: */\r
                extern Bluetooth_Device_t     Bluetooth_DeviceConfiguration;\r