Add Bluetooth signalling echo request/response handlers, disconnection request/respon...
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 5 Apr 2010 12:13:33 +0000 (12:13 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 5 Apr 2010 12:13:33 +0000 (12:13 +0000)
Add Bluetooth connection request/complete/disconnection callbacks.

Remove debugging from HCI layer, as it is now operational -- add guards to ACL debug statements to reduce logging chattyness so that the overall command sequences can be observed and debugged.

Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c
Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c
Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h
Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c
Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h
Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.c
Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h

index 338997f..a3ca0aa 100644 (file)
@@ -195,3 +195,30 @@ void Bluetooth_Host_Task(void)
                        break;\r
        }\r
 }\r
                        break;\r
        }\r
 }\r
+\r
+bool Bluetooth_ConnectionRequest(uint8_t* RemoteAddress)\r
+{\r
+       printf_P(PSTR("Connection Request from Device %02X:%02X:%02X:%02X:%02X:%02X\r\n"),\r
+                RemoteAddress[5], RemoteAddress[4],\r
+                RemoteAddress[3], RemoteAddress[2],\r
+                RemoteAddress[1], RemoteAddress[0]);\r
+\r
+       /* Always accept connections from remote devices */\r
+       return true;\r
+}\r
+\r
+void Bluetooth_ConnectionComplete(void)\r
+{\r
+       printf_P(PSTR("Connection Complete to Device %02X:%02X:%02X:%02X:%02X:%02X\r\n"), \r
+                Bluetooth_Connection.RemoteAddress[5], Bluetooth_Connection.RemoteAddress[4],\r
+                Bluetooth_Connection.RemoteAddress[3], Bluetooth_Connection.RemoteAddress[2],\r
+                Bluetooth_Connection.RemoteAddress[1], Bluetooth_Connection.RemoteAddress[0]);\r
+}\r
+\r
+void Bluetooth_DisconnectionComplete(void)\r
+{\r
+       printf_P(PSTR("Disconnection Complete to Device %02X:%02X:%02X:%02X:%02X:%02X\r\n"), \r
+                Bluetooth_Connection.RemoteAddress[5], Bluetooth_Connection.RemoteAddress[4],\r
+                Bluetooth_Connection.RemoteAddress[3], Bluetooth_Connection.RemoteAddress[2],\r
+                Bluetooth_Connection.RemoteAddress[1], Bluetooth_Connection.RemoteAddress[0]);\r
+}\r
index e8daa05..ed39d5c 100644 (file)
@@ -48,11 +48,13 @@ void Bluetooth_ProcessACLPackets(void)
        Pipe_Read_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader));\r
        Pipe_Read_Stream_LE(&DataHeader, sizeof(DataHeader));\r
 \r
        Pipe_Read_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader));\r
        Pipe_Read_Stream_LE(&DataHeader, sizeof(DataHeader));\r
 \r
+#if (ACL_DEBUG_LEVEL > 1)\r
        BT_ACL_DEBUG("Packet Received", NULL);\r
        BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF));\r
        BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader.DataLength);\r
        BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader.DestinationChannel);\r
        BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader.PayloadLength);\r
        BT_ACL_DEBUG("Packet Received", NULL);\r
        BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF));\r
        BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader.DataLength);\r
        BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader.DestinationChannel);\r
        BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader.PayloadLength);\r
+#endif\r
 \r
        if (DataHeader.DestinationChannel == BLUETOOTH_CHANNEL_SIGNALING)\r
        {\r
 \r
        if (DataHeader.DestinationChannel == BLUETOOTH_CHANNEL_SIGNALING)\r
        {\r
@@ -62,20 +64,26 @@ void Bluetooth_ProcessACLPackets(void)
                switch (SignalCommandHeader.Code)\r
                {\r
                        case BLUETOOTH_SIGNAL_CONNECTION_REQUEST:\r
                switch (SignalCommandHeader.Code)\r
                {\r
                        case BLUETOOTH_SIGNAL_CONNECTION_REQUEST:\r
-                               Bluetooth_ProcessSignalPacket_ConnectionRequest(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);\r
+                               Bluetooth_SignalPacket_ConnectionRequest(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);\r
                                break;\r
                        case BLUETOOTH_SIGNAL_CONFIGURATION_REQUEST:\r
                                break;\r
                        case BLUETOOTH_SIGNAL_CONFIGURATION_REQUEST:\r
-                               Bluetooth_ProcessSignalPacket_ConfigurationRequest(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);\r
+                               Bluetooth_SignalPacket_ConfigurationRequest(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);\r
+                               break;\r
+                       case BLUETOOTH_SIGNAL_DISCONNECTION_REQUEST:\r
+                               Bluetooth_SignalPacket_DisconnectionRequest(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);\r
+                               break;                  \r
+                       case BLUETOOTH_SIGNAL_ECHO_REQUEST:\r
+                               Bluetooth_SignalPacket_EchoRequest(&ACLPacketHeader, &DataHeader, &SignalCommandHeader);\r
                                break;\r
                        case BLUETOOTH_SIGNAL_INFORMATION_REQUEST:\r
                                break;\r
                        case BLUETOOTH_SIGNAL_INFORMATION_REQUEST:\r
-                               BT_ACL_DEBUG(">> Information Request, Discarded", NULL);\r
+                               BT_ACL_DEBUG("<< Information Request", NULL);\r
 \r
                                Pipe_Discard_Stream(ACLPacketHeader.DataLength);\r
                                Pipe_ClearIN();         \r
                                Pipe_Freeze();\r
                                break;\r
                        default:\r
 \r
                                Pipe_Discard_Stream(ACLPacketHeader.DataLength);\r
                                Pipe_ClearIN();         \r
                                Pipe_Freeze();\r
                                break;\r
                        default:\r
-                               BT_ACL_DEBUG(">> Unknown Signaling Command 0x%02X", SignalCommandHeader.Code);\r
+                               BT_ACL_DEBUG("<< Unknown Signaling Command 0x%02X", SignalCommandHeader.Code);\r
                                        \r
                                Pipe_Discard_Stream(ACLPacketHeader.DataLength);\r
                                Pipe_ClearIN();         \r
                                        \r
                                Pipe_Discard_Stream(ACLPacketHeader.DataLength);\r
                                Pipe_ClearIN();         \r
@@ -100,17 +108,19 @@ void Bluetooth_ProcessACLPackets(void)
        }\r
 }\r
 \r
        }\r
 }\r
 \r
-static inline void Bluetooth_ProcessSignalPacket_ConnectionRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
-                                                                   Bluetooth_DataPacket_Header_t* DataHeader,\r
-                                                                   Bluetooth_SignalCommand_Header_t* SignalCommandHeader)\r
+static inline void Bluetooth_SignalPacket_ConnectionRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
+                                                            Bluetooth_DataPacket_Header_t* DataHeader,\r
+                                                            Bluetooth_SignalCommand_Header_t* SignalCommandHeader)\r
 {\r
        Bluetooth_SignalCommand_ConnectionRequest_t ConnectionRequest;\r
        \r
        Pipe_Read_Stream_LE(&ConnectionRequest, sizeof(ConnectionRequest));\r
 \r
 {\r
        Bluetooth_SignalCommand_ConnectionRequest_t ConnectionRequest;\r
        \r
        Pipe_Read_Stream_LE(&ConnectionRequest, sizeof(ConnectionRequest));\r
 \r
-       BT_ACL_DEBUG(">> L2CAP Connection Request", NULL);\r
+       BT_ACL_DEBUG("<< L2CAP Connection Request", NULL);\r
+#if (ACL_DEBUG_LEVEL > 1)\r
        BT_ACL_DEBUG("-- PSM: 0x%04X", ConnectionRequest.PSM);\r
        BT_ACL_DEBUG("-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel);\r
        BT_ACL_DEBUG("-- PSM: 0x%04X", ConnectionRequest.PSM);\r
        BT_ACL_DEBUG("-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel);\r
+#endif\r
        \r
        Pipe_ClearIN();\r
        Pipe_Freeze();\r
        \r
        Pipe_ClearIN();\r
        Pipe_Freeze();\r
@@ -141,26 +151,32 @@ static inline void Bluetooth_ProcessSignalPacket_ConnectionRequest(Bluetooth_ACL
        Pipe_ClearOUT();                \r
        Pipe_Freeze();\r
        \r
        Pipe_ClearOUT();                \r
        Pipe_Freeze();\r
        \r
+#if (ACL_DEBUG_LEVEL > 1)\r
        BT_ACL_DEBUG("Packet Sent", NULL);\r
        BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader->ConnectionHandle & 0x0FFF));\r
        BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader->DataLength);\r
        BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader->DestinationChannel);\r
        BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader->PayloadLength);                   \r
        BT_ACL_DEBUG("Packet Sent", NULL);\r
        BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader->ConnectionHandle & 0x0FFF));\r
        BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader->DataLength);\r
        BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader->DestinationChannel);\r
        BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader->PayloadLength);                   \r
+#endif\r
        BT_ACL_DEBUG(">> L2CAP Connection Response", NULL);\r
        BT_ACL_DEBUG(">> L2CAP Connection Response", NULL);\r
+#if (ACL_DEBUG_LEVEL > 1)\r
        BT_ACL_DEBUG("-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel);\r
        BT_ACL_DEBUG("-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel);\r
        BT_ACL_DEBUG("-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel);\r
        BT_ACL_DEBUG("-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel);\r
+#endif\r
 }\r
 \r
 }\r
 \r
-static inline void Bluetooth_ProcessSignalPacket_ConfigurationRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
-                                                                      Bluetooth_DataPacket_Header_t* DataHeader,\r
-                                                                      Bluetooth_SignalCommand_Header_t* SignalCommandHeader)\r
+static inline void Bluetooth_SignalPacket_ConfigurationRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
+                                                               Bluetooth_DataPacket_Header_t* DataHeader,\r
+                                                               Bluetooth_SignalCommand_Header_t* SignalCommandHeader)\r
 {\r
        Bluetooth_SignalCommand_ConfigurationRequest_t ConfigurationRequest;\r
        \r
        Pipe_Read_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest));\r
 \r
 {\r
        Bluetooth_SignalCommand_ConfigurationRequest_t ConfigurationRequest;\r
        \r
        Pipe_Read_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest));\r
 \r
-       BT_ACL_DEBUG(">> L2CAP Configuration Request", NULL);\r
+       BT_ACL_DEBUG("<< L2CAP Configuration Request", NULL);\r
+#if (ACL_DEBUG_LEVEL > 1)\r
        BT_ACL_DEBUG("-- Destination Channel: 0x%04X", ConfigurationRequest.DestinationChannel);\r
        BT_ACL_DEBUG("-- Destination Channel: 0x%04X", ConfigurationRequest.DestinationChannel);\r
+#endif\r
        \r
        Pipe_ClearIN();\r
        Pipe_Freeze();\r
        \r
        Pipe_ClearIN();\r
        Pipe_Freeze();\r
@@ -175,7 +191,7 @@ static inline void Bluetooth_ProcessSignalPacket_ConfigurationRequest(Bluetooth_
        SignalCommandHeader->Code             = BLUETOOTH_SIGNAL_CONFIGURATION_RESPONSE;\r
        SignalCommandHeader->Length           = sizeof(ConfigurationResponse);\r
        \r
        SignalCommandHeader->Code             = BLUETOOTH_SIGNAL_CONFIGURATION_RESPONSE;\r
        SignalCommandHeader->Length           = sizeof(ConfigurationResponse);\r
        \r
-       Bluetooth_Channel_t* ChannelData      = Bluetooth_GetChannelData(ConfigurationRequest.DestinationChannel, CHANNEL_LOOKUP_BY_DESTINATION);\r
+       Bluetooth_Channel_t* ChannelData      = Bluetooth_GetChannelData(ConfigurationRequest.DestinationChannel, false);\r
 \r
        if (ChannelData != NULL)\r
          ChannelData->State = Channel_Open;\r
 \r
        if (ChannelData != NULL)\r
          ChannelData->State = Channel_Open;\r
@@ -191,13 +207,106 @@ static inline void Bluetooth_ProcessSignalPacket_ConfigurationRequest(Bluetooth_
        Pipe_Write_Stream_LE(SignalCommandHeader, sizeof(*SignalCommandHeader));\r
        Pipe_Write_Stream_LE(&ConfigurationResponse, sizeof(ConfigurationResponse));\r
        \r
        Pipe_Write_Stream_LE(SignalCommandHeader, sizeof(*SignalCommandHeader));\r
        Pipe_Write_Stream_LE(&ConfigurationResponse, sizeof(ConfigurationResponse));\r
        \r
-       Pipe_ClearOUT();                \r
+       Pipe_ClearOUT();\r
        Pipe_Freeze();\r
        \r
        Pipe_Freeze();\r
        \r
+#if (ACL_DEBUG_LEVEL > 1)\r
        BT_ACL_DEBUG("Packet Sent", NULL);\r
        BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader->ConnectionHandle & 0x0FFF));\r
        BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader->DataLength);\r
        BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader->DestinationChannel);\r
        BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader->PayloadLength);                   \r
        BT_ACL_DEBUG("Packet Sent", NULL);\r
        BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader->ConnectionHandle & 0x0FFF));\r
        BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader->DataLength);\r
        BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader->DestinationChannel);\r
        BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader->PayloadLength);                   \r
+#endif\r
        BT_ACL_DEBUG(">> L2CAP Configuration Response", NULL);\r
 }\r
        BT_ACL_DEBUG(">> L2CAP Configuration Response", NULL);\r
 }\r
+\r
+static inline void Bluetooth_SignalPacket_DisconnectionRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
+                                                               Bluetooth_DataPacket_Header_t* DataHeader,\r
+                                                               Bluetooth_SignalCommand_Header_t* SignalCommandHeader)\r
+{\r
+       Bluetooth_SignalCommand_DisconnectionRequest_t DisconnectionRequest;\r
+       \r
+       Pipe_Read_Stream_LE(&DisconnectionRequest, sizeof(DisconnectionRequest));\r
+\r
+       BT_ACL_DEBUG("<< L2CAP Disconnection Request", NULL);\r
+#if (ACL_DEBUG_LEVEL > 1)\r
+       BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DisconnectionRequest.DestinationChannel);\r
+       BT_ACL_DEBUG("-- Source Channel: 0x%04X", DisconnectionRequest.SourceChannel);\r
+#endif\r
+       \r
+       Pipe_ClearIN();\r
+       Pipe_Freeze();\r
+       Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);\r
+       Pipe_Unfreeze();\r
+       \r
+       Bluetooth_SignalCommand_DisconnectionResponse_t DisconnectionResponse;\r
+\r
+       ACLPacketHeader->DataLength           = sizeof(*DataHeader) + sizeof(*SignalCommandHeader) + sizeof(DisconnectionResponse);\r
+       DataHeader->PayloadLength             = sizeof(*SignalCommandHeader) + sizeof(DisconnectionResponse);\r
+       DataHeader->DestinationChannel        = BLUETOOTH_CHANNEL_SIGNALING;\r
+       SignalCommandHeader->Code             = BLUETOOTH_SIGNAL_DISCONNECTION_RESPONSE;\r
+       SignalCommandHeader->Length           = sizeof(DisconnectionResponse);\r
+       \r
+       Bluetooth_Channel_t* ChannelData      = Bluetooth_GetChannelData(DisconnectionRequest.SourceChannel, true);\r
+\r
+       if (ChannelData != NULL)\r
+         ChannelData->State = Channel_Closed;\r
+       \r
+       DisconnectionResponse.DestinationChannel = ChannelData->LocalNumber;\r
+       DisconnectionResponse.SourceChannel      = ChannelData->RemoteNumber;\r
+\r
+       Pipe_Write_Stream_LE(ACLPacketHeader, sizeof(*ACLPacketHeader));\r
+       Pipe_Write_Stream_LE(DataHeader, sizeof(*DataHeader));\r
+       Pipe_Write_Stream_LE(SignalCommandHeader, sizeof(*SignalCommandHeader));\r
+       Pipe_Write_Stream_LE(&DisconnectionResponse, sizeof(DisconnectionResponse));\r
+       \r
+       Pipe_ClearOUT();\r
+       Pipe_Freeze();\r
+       \r
+#if (ACL_DEBUG_LEVEL > 1)\r
+       BT_ACL_DEBUG("Packet Sent", NULL);\r
+       BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader->ConnectionHandle & 0x0FFF));\r
+       BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader->DataLength);\r
+       BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader->DestinationChannel);\r
+       BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader->PayloadLength);                   \r
+#endif\r
+       BT_ACL_DEBUG(">> L2CAP Disconnection Response", NULL);\r
+#if (ACL_DEBUG_LEVEL > 1)\r
+       BT_ACL_DEBUG("-- Source Channel: 0x%04X", DisconnectionResponse.SourceChannel);\r
+       BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DisconnectionResponse.DestinationChannel);\r
+#endif\r
+}\r
+\r
+static inline void Bluetooth_SignalPacket_EchoRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
+                                                      Bluetooth_DataPacket_Header_t* DataHeader,\r
+                                                      Bluetooth_SignalCommand_Header_t* SignalCommandHeader)\r
+{\r
+       BT_ACL_DEBUG("<< L2CAP Echo Request", NULL);\r
+       \r
+       Pipe_ClearIN();\r
+       Pipe_Freeze();\r
+       Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);\r
+       Pipe_Unfreeze();\r
+       \r
+       ACLPacketHeader->DataLength           = sizeof(*DataHeader) + sizeof(*SignalCommandHeader);\r
+       DataHeader->PayloadLength             = sizeof(*SignalCommandHeader);\r
+       DataHeader->DestinationChannel        = BLUETOOTH_CHANNEL_SIGNALING;\r
+       SignalCommandHeader->Code             = BLUETOOTH_SIGNAL_ECHO_RESPONSE;\r
+       SignalCommandHeader->Length           = 0;\r
+       \r
+       Pipe_Write_Stream_LE(ACLPacketHeader, sizeof(*ACLPacketHeader));\r
+       Pipe_Write_Stream_LE(DataHeader, sizeof(*DataHeader));\r
+       Pipe_Write_Stream_LE(SignalCommandHeader, sizeof(*SignalCommandHeader));\r
+       \r
+       Pipe_ClearOUT();                \r
+       Pipe_Freeze();\r
+       \r
+#if (ACL_DEBUG_LEVEL > 1)\r
+       BT_ACL_DEBUG("Packet Sent", NULL);\r
+       BT_ACL_DEBUG("-- Connection Handle: 0x%04X", (ACLPacketHeader->ConnectionHandle & 0x0FFF));\r
+       BT_ACL_DEBUG("-- Data Length: 0x%04X", ACLPacketHeader->DataLength);\r
+       BT_ACL_DEBUG("-- Destination Channel: 0x%04X", DataHeader->DestinationChannel);\r
+       BT_ACL_DEBUG("-- Payload Length: 0x%04X", DataHeader->PayloadLength);                   \r
+#endif\r
+       BT_ACL_DEBUG(">> L2CAP Echo Response", NULL);\r
+}\r
index c0fd1f6..9c7bd26 100644 (file)
@@ -42,6 +42,7 @@
                \r
        /* Macros: */\r
                #define BT_ACL_DEBUG(s, ...)                     printf_P(PSTR("(ACL) " s "\r\n"), __VA_ARGS__)\r
                \r
        /* Macros: */\r
                #define BT_ACL_DEBUG(s, ...)                     printf_P(PSTR("(ACL) " s "\r\n"), __VA_ARGS__)\r
+               #define ACL_DEBUG_LEVEL 1\r
 \r
                #define BLUETOOTH_CHANNEL_SIGNALING              0x0001\r
                #define BLUETOOTH_CHANNEL_CONNECTIONLESS         0x0002\r
 \r
                #define BLUETOOTH_CHANNEL_SIGNALING              0x0001\r
                #define BLUETOOTH_CHANNEL_CONNECTIONLESS         0x0002\r
                #define BLUETOOTH_SIGNAL_CONNECTION_RESPONSE     0x03\r
                #define BLUETOOTH_SIGNAL_CONFIGURATION_REQUEST   0x04\r
                #define BLUETOOTH_SIGNAL_CONFIGURATION_RESPONSE  0x05\r
                #define BLUETOOTH_SIGNAL_CONNECTION_RESPONSE     0x03\r
                #define BLUETOOTH_SIGNAL_CONFIGURATION_REQUEST   0x04\r
                #define BLUETOOTH_SIGNAL_CONFIGURATION_RESPONSE  0x05\r
+               #define BLUETOOTH_SIGNAL_DISCONNECTION_REQUEST   0x06\r
+               #define BLUETOOTH_SIGNAL_DISCONNECTION_RESPONSE  0x07\r
+               #define BLUETOOTH_SIGNAL_ECHO_REQUEST            0x08\r
+               #define BLUETOOTH_SIGNAL_ECHO_RESPONSE           0x09\r
                #define BLUETOOTH_SIGNAL_INFORMATION_REQUEST     0x0A\r
                #define BLUETOOTH_SIGNAL_INFORMATION_REQUEST     0x0A\r
+               #define BLUETOOTH_SIGNAL_INFORMATION_RESPONSE    0x0B\r
                \r
                #define BLUETOOTH_CONNECTION_SUCCESSFUL          0x0000\r
                #define BLUETOOTH_CONNECTION_REFUSED_RESOURCES   0x0004\r
                \r
                #define BLUETOOTH_CONNECTION_SUCCESSFUL          0x0000\r
                #define BLUETOOTH_CONNECTION_REFUSED_RESOURCES   0x0004\r
                        uint16_t Result;\r
                        uint16_t Status;\r
                } Bluetooth_SignalCommand_ConnectionResponse_t;\r
                        uint16_t Result;\r
                        uint16_t Status;\r
                } Bluetooth_SignalCommand_ConnectionResponse_t;\r
+\r
+               typedef struct\r
+               {\r
+                       uint16_t DestinationChannel;\r
+                       uint16_t SourceChannel;\r
+               } Bluetooth_SignalCommand_DisconnectionRequest_t;\r
                \r
                typedef struct\r
                {\r
                        uint16_t DestinationChannel;\r
                \r
                typedef struct\r
                {\r
                        uint16_t DestinationChannel;\r
+                       uint16_t SourceChannel;\r
+               } Bluetooth_SignalCommand_DisconnectionResponse_t;              \r
+\r
+               typedef struct\r
+               {\r
+                       uint16_t DestinationChannel;\r
                        uint16_t Flags;\r
                        uint8_t  Options[];\r
                } Bluetooth_SignalCommand_ConfigurationRequest_t;\r
                        uint16_t Flags;\r
                        uint8_t  Options[];\r
                } Bluetooth_SignalCommand_ConfigurationRequest_t;\r
                void Bluetooth_ProcessACLPackets(void);\r
 \r
                #if defined(INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C)\r
                void Bluetooth_ProcessACLPackets(void);\r
 \r
                #if defined(INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C)\r
-                       static inline void Bluetooth_ProcessSignalPacket_ConnectionRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
-                                                                   Bluetooth_DataPacket_Header_t* DataHeader,\r
-                                                                   Bluetooth_SignalCommand_Header_t* SignalCommandHeader);\r
-                       static inline void Bluetooth_ProcessSignalPacket_ConfigurationRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
-                                                                   Bluetooth_DataPacket_Header_t* DataHeader,\r
-                                                                   Bluetooth_SignalCommand_Header_t* SignalCommandHeader);\r
+                       static inline void Bluetooth_SignalPacket_ConnectionRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
+                                                                  Bluetooth_DataPacket_Header_t* DataHeader,\r
+                                                                  Bluetooth_SignalCommand_Header_t* SignalCommandHeader);\r
+                       static inline void Bluetooth_SignalPacket_EchoRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
+                                                                  Bluetooth_DataPacket_Header_t* DataHeader,\r
+                                                                  Bluetooth_SignalCommand_Header_t* SignalCommandHeader);\r
+                       static inline void Bluetooth_SignalPacket_ConfigurationRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
+                                                                  Bluetooth_DataPacket_Header_t* DataHeader,\r
+                                                                  Bluetooth_SignalCommand_Header_t* SignalCommandHeader);\r
+                       static inline void Bluetooth_SignalPacket_DisconnectionRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,\r
+                                                                  Bluetooth_DataPacket_Header_t* DataHeader,\r
+                                                                  Bluetooth_SignalCommand_Header_t* SignalCommandHeader);\r
                #endif\r
                \r
 #endif\r
                #endif\r
                \r
 #endif\r
index a6e59d6..9d67b70 100644 (file)
@@ -86,23 +86,15 @@ void Bluetooth_ProcessHCICommands(void)
                                Pipe_Read_Stream_LE(&EventParams, HCIEventHeader.ParameterLength);\r
                                Pipe_ClearIN();\r
 \r
                                Pipe_Read_Stream_LE(&EventParams, HCIEventHeader.ParameterLength);\r
                                Pipe_ClearIN();\r
 \r
-                               BT_HCI_DEBUG("Event Code: 0x%02X", HCIEventHeader.EventCode);\r
-                               \r
                                switch (HCIEventHeader.EventCode)\r
                                {\r
                                        case EVENT_COMMAND_COMPLETE:\r
                                                Bluetooth_HCIProcessingState = Bluetooth_HCINextState;\r
                                switch (HCIEventHeader.EventCode)\r
                                {\r
                                        case EVENT_COMMAND_COMPLETE:\r
                                                Bluetooth_HCIProcessingState = Bluetooth_HCINextState;\r
-\r
-                                               BT_HCI_DEBUG(">> Command Complete (Opcode 0x%04x)", \r
-                                                        ((Bluetooth_HCIEvent_CommandComplete_t*)&EventParams)->Opcode);\r
                                                break;\r
                                        case EVENT_COMMAND_STATUS:\r
                                                /* If the execution of a command failed, reset the stack */\r
                                                if (((Bluetooth_HCIEvent_CommandStatus_t*)&EventParams)->Status)\r
                                                  Bluetooth_HCIProcessingState = Bluetooth_Init;\r
                                                break;\r
                                        case EVENT_COMMAND_STATUS:\r
                                                /* If the execution of a command failed, reset the stack */\r
                                                if (((Bluetooth_HCIEvent_CommandStatus_t*)&EventParams)->Status)\r
                                                  Bluetooth_HCIProcessingState = Bluetooth_Init;\r
-\r
-                                               BT_HCI_DEBUG(">> Command Status: 0x%02X",\r
-                                                        ((Bluetooth_HCIEvent_CommandStatus_t*)&EventParams)->Status);                                  \r
                                                break;\r
                                        case EVENT_CONNECTION_REQUEST:\r
                                                /* Need to store the remote device's BT address in a temporary buffer for later use */\r
                                                break;\r
                                        case EVENT_CONNECTION_REQUEST:\r
                                                /* Need to store the remote device's BT address in a temporary buffer for later use */\r
@@ -115,12 +107,8 @@ void Bluetooth_ProcessHCICommands(void)
                                                /* Only accept the connection if it is a ACL (data) connection, a device is not already connected\r
                                                   and the user application has indicated that the connection should be allowed */\r
                                                Bluetooth_HCIProcessingState = (Bluetooth_Connection.IsConnected || !(IsACLConnection) ||\r
                                                /* Only accept the connection if it is a ACL (data) connection, a device is not already connected\r
                                                   and the user application has indicated that the connection should be allowed */\r
                                                Bluetooth_HCIProcessingState = (Bluetooth_Connection.IsConnected || !(IsACLConnection) ||\r
-                                                                                                           !(CALLBACK_Bluetooth_ConnectionRequest(Bluetooth_TempDeviceAddress))) ?\r
+                                                                                                           !(Bluetooth_ConnectionRequest(Bluetooth_TempDeviceAddress))) ?\r
                                                                                                           Bluetooth_Conn_RejectConnection : Bluetooth_Conn_AcceptConnection;\r
                                                                                                           Bluetooth_Conn_RejectConnection : Bluetooth_Conn_AcceptConnection;\r
-\r
-                                               BT_HCI_DEBUG(">> Connection Request from Device %02X:%02X:%02X:%02X:%02X:%02X",\r
-                                                                Bluetooth_TempDeviceAddress[5], Bluetooth_TempDeviceAddress[4], Bluetooth_TempDeviceAddress[3],\r
-                                                                Bluetooth_TempDeviceAddress[2], Bluetooth_TempDeviceAddress[1], Bluetooth_TempDeviceAddress[0]);\r
                                                break;\r
                                        case EVENT_PIN_CODE_REQUEST:\r
                                                /* Need to store the remote device's BT address in a temporary buffer for later use */\r
                                                break;\r
                                        case EVENT_PIN_CODE_REQUEST:\r
                                                /* Need to store the remote device's BT address in a temporary buffer for later use */\r
@@ -129,10 +117,6 @@ void Bluetooth_ProcessHCICommands(void)
                                                       sizeof(Bluetooth_TempDeviceAddress));\r
 \r
                                                Bluetooth_HCIProcessingState = Bluetooth_Conn_SendPINCode;\r
                                                       sizeof(Bluetooth_TempDeviceAddress));\r
 \r
                                                Bluetooth_HCIProcessingState = Bluetooth_Conn_SendPINCode;\r
-\r
-                                               BT_HCI_DEBUG(">> PIN Request from Device %02X:%02X:%02X:%02X:%02X:%02X", \r
-                                                                Bluetooth_TempDeviceAddress[5], Bluetooth_TempDeviceAddress[4], Bluetooth_TempDeviceAddress[3],\r
-                                                                Bluetooth_TempDeviceAddress[2], Bluetooth_TempDeviceAddress[1], Bluetooth_TempDeviceAddress[0]);\r
                                                break;\r
                                        case EVENT_CONNECTION_COMPLETE:\r
                                                /* Need to store the remote device's BT address in a temporary buffer for later use */\r
                                                break;\r
                                        case EVENT_CONNECTION_COMPLETE:\r
                                                /* Need to store the remote device's BT address in a temporary buffer for later use */\r
@@ -143,19 +127,15 @@ void Bluetooth_ProcessHCICommands(void)
                                                /* Store the created connection handle and indicate that the connection has been established */\r
                                                Bluetooth_Connection.ConnectionHandle = ((Bluetooth_HCIEvent_ConnectionComplete_t*)&EventParams)->ConnectionHandle;\r
                                                Bluetooth_Connection.IsConnected      = true;\r
                                                /* Store the created connection handle and indicate that the connection has been established */\r
                                                Bluetooth_Connection.ConnectionHandle = ((Bluetooth_HCIEvent_ConnectionComplete_t*)&EventParams)->ConnectionHandle;\r
                                                Bluetooth_Connection.IsConnected      = true;\r
-\r
-                                               BT_HCI_DEBUG(">> Connection Complete to Device %02X:%02X:%02X:%02X:%02X:%02X, Handle 0x%04x", \r
-                                                                Bluetooth_Connection.RemoteAddress[5], Bluetooth_Connection.RemoteAddress[4],\r
-                                                                Bluetooth_Connection.RemoteAddress[3], Bluetooth_Connection.RemoteAddress[2],\r
-                                                                Bluetooth_Connection.RemoteAddress[1], Bluetooth_Connection.RemoteAddress[0],\r
-                                                                Bluetooth_Connection.ConnectionHandle);\r
+                                               \r
+                                               Bluetooth_ConnectionComplete();                                         \r
                                                break;\r
                                        case EVENT_DISCONNECTION_COMPLETE:\r
                                                break;\r
                                        case EVENT_DISCONNECTION_COMPLETE:\r
-                                               BT_HCI_DEBUG(">> Disconnection Complete", NULL);\r
-\r
                                                /* Device disconnected, indicate connection information no longer valid */\r
                                                Bluetooth_Connection.IsConnected = false;\r
                                                \r
                                                /* Device disconnected, indicate connection information no longer valid */\r
                                                Bluetooth_Connection.IsConnected = false;\r
                                                \r
+                                               Bluetooth_DisconnectionComplete();\r
+                                               \r
                                                Bluetooth_HCIProcessingState = Bluetooth_Init;\r
                                                break;                                  \r
                                }\r
                                                Bluetooth_HCIProcessingState = Bluetooth_Init;\r
                                                break;                                  \r
                                }\r
@@ -176,8 +156,6 @@ void Bluetooth_ProcessHCICommands(void)
                                OpCode: {OGF: OGF_CTRLR_BASEBAND, OCF: OCF_CTRLR_BASEBAND_RESET},\r
                                ParameterLength: 0,\r
                        };\r
                                OpCode: {OGF: OGF_CTRLR_BASEBAND, OCF: OCF_CTRLR_BASEBAND_RESET},\r
                                ParameterLength: 0,\r
                        };\r
-                       \r
-                       BT_HCI_DEBUG("Enter State: Bluetooth_Init_Reset", NULL);\r
 \r
                        /* Send the command to reset the bluetooth dongle controller */\r
                        Bluetooth_SendHCICommand(NULL, 0);\r
 \r
                        /* Send the command to reset the bluetooth dongle controller */\r
                        Bluetooth_SendHCICommand(NULL, 0);\r
@@ -192,9 +170,6 @@ void Bluetooth_ProcessHCICommands(void)
                                        ParameterLength: 248,\r
                                };\r
 \r
                                        ParameterLength: 248,\r
                                };\r
 \r
-                       BT_HCI_DEBUG("Enter State: Bluetooth_Init_SetLocalName", NULL);\r
-                       BT_HCI_DEBUG("-- Name: %s", Bluetooth_DeviceConfiguration.Name);\r
-\r
                        /* Send the command to set the bluetooth dongle's name for other devices to see */\r
                        Bluetooth_SendHCICommand(Bluetooth_DeviceConfiguration.Name, strlen(Bluetooth_DeviceConfiguration.Name));\r
 \r
                        /* Send the command to set the bluetooth dongle's name for other devices to see */\r
                        Bluetooth_SendHCICommand(Bluetooth_DeviceConfiguration.Name, strlen(Bluetooth_DeviceConfiguration.Name));\r
 \r
@@ -208,8 +183,6 @@ void Bluetooth_ProcessHCICommands(void)
                                        ParameterLength: 3,\r
                                };\r
 \r
                                        ParameterLength: 3,\r
                                };\r
 \r
-                       BT_HCI_DEBUG("Enter State: Bluetooth_Init_SetDeviceClass", NULL);\r
-\r
                        /* Send the command to set the class of the device for other devices to see */\r
                        Bluetooth_SendHCICommand(&Bluetooth_DeviceConfiguration.Class, 3);\r
 \r
                        /* Send the command to set the class of the device for other devices to see */\r
                        Bluetooth_SendHCICommand(&Bluetooth_DeviceConfiguration.Class, 3);\r
 \r
@@ -222,8 +195,6 @@ void Bluetooth_ProcessHCICommands(void)
                                OpCode: {OGF: OGF_CTRLR_BASEBAND, OCF: OCF_CTRLR_BASEBAND_WRITE_SCAN_ENABLE},\r
                                ParameterLength: 1,\r
                        };\r
                                OpCode: {OGF: OGF_CTRLR_BASEBAND, OCF: OCF_CTRLR_BASEBAND_WRITE_SCAN_ENABLE},\r
                                ParameterLength: 1,\r
                        };\r
-                       \r
-                       BT_HCI_DEBUG("Enter State: Bluetooth_Init_WriteScanEnable", NULL);\r
 \r
                        uint8_t Interval = BT_SCANMODE_InquiryAndPageScans;\r
                        \r
 \r
                        uint8_t Interval = BT_SCANMODE_InquiryAndPageScans;\r
                        \r
@@ -239,8 +210,6 @@ void Bluetooth_ProcessHCICommands(void)
                                        OpCode: {OGF: OGF_LINK_CONTROL, OCF: OCF_LINK_CONTROL_ACCEPT_CONNECTION_REQUEST},\r
                                        ParameterLength: sizeof(Bluetooth_HCICommand_AcceptConnectionRequest_t),\r
                                };\r
                                        OpCode: {OGF: OGF_LINK_CONTROL, OCF: OCF_LINK_CONTROL_ACCEPT_CONNECTION_REQUEST},\r
                                        ParameterLength: sizeof(Bluetooth_HCICommand_AcceptConnectionRequest_t),\r
                                };\r
-                       \r
-                       BT_HCI_DEBUG("Enter State: Bluetooth_Conn_AcceptConnection", NULL);\r
 \r
                        /* Copy over the temporary BT device address saved from the Connection Request event, indicate slave\r
                           connection role */\r
 \r
                        /* Copy over the temporary BT device address saved from the Connection Request event, indicate slave\r
                           connection role */\r
@@ -260,8 +229,6 @@ void Bluetooth_ProcessHCICommands(void)
                                        OpCode: {OGF: OGF_LINK_CONTROL, OCF: OCF_LINK_CONTROL_REJECT_CONNECTION_REQUEST},\r
                                        ParameterLength: sizeof(Bluetooth_HCICommand_RejectConnectionRequest_t),\r
                                };\r
                                        OpCode: {OGF: OGF_LINK_CONTROL, OCF: OCF_LINK_CONTROL_REJECT_CONNECTION_REQUEST},\r
                                        ParameterLength: sizeof(Bluetooth_HCICommand_RejectConnectionRequest_t),\r
                                };\r
-                       \r
-                       BT_HCI_DEBUG("Enter State: Bluetooth_Conn_RejectConnection", NULL);\r
 \r
                        /* Copy over the temporary BT device address saved from the Connection Request event, indicate failure\r
                           to accept the connection due to limited device resources or incorrect device address */\r
 \r
                        /* Copy over the temporary BT device address saved from the Connection Request event, indicate failure\r
                           to accept the connection due to limited device resources or incorrect device address */\r
@@ -280,9 +247,6 @@ void Bluetooth_ProcessHCICommands(void)
                                        OpCode: {OGF: OGF_LINK_CONTROL, OCF: OCF_LINK_CONTROL_PIN_CODE_REQUEST_REPLY},\r
                                        ParameterLength: sizeof(Bluetooth_HCICommand_PinCodeResponse_t),\r
                                };\r
                                        OpCode: {OGF: OGF_LINK_CONTROL, OCF: OCF_LINK_CONTROL_PIN_CODE_REQUEST_REPLY},\r
                                        ParameterLength: sizeof(Bluetooth_HCICommand_PinCodeResponse_t),\r
                                };\r
-                       \r
-                       BT_HCI_DEBUG("Enter State: Bluetooth_Conn_SendPINCode", NULL);\r
-                       BT_HCI_DEBUG("-- PIN: %s", Bluetooth_DeviceConfiguration.PINCode);\r
 \r
                        /* Copy over the temporary BT device address saved from the PIN Code Request event, copy over the\r
                           local PIN authentication code to the response */\r
 \r
                        /* Copy over the temporary BT device address saved from the PIN Code Request event, copy over the\r
                           local PIN authentication code to the response */\r
index 317ebc7..2295e55 100644 (file)
@@ -42,8 +42,6 @@
                #include "BluetoothClassCodes.h"\r
 \r
        /* Macros: */\r
                #include "BluetoothClassCodes.h"\r
 \r
        /* Macros: */\r
-               #define BT_HCI_DEBUG(s, ...)                           printf_P(PSTR("(HCI) " s "\r\n"), __VA_ARGS__)\r
-       \r
                #define OGF_LINK_CONTROL                               0x01\r
                #define OGF_CTRLR_BASEBAND                             0x03\r
                #define OGF_CTRLR_INFORMATIONAL                        0x04\r
                #define OGF_LINK_CONTROL                               0x01\r
                #define OGF_CTRLR_BASEBAND                             0x03\r
                #define OGF_CTRLR_INFORMATIONAL                        0x04\r
                void Bluetooth_ProcessHCICommands(void);\r
                void Bluetooth_ProcessHCIEvents(void);\r
                \r
                void Bluetooth_ProcessHCICommands(void);\r
                void Bluetooth_ProcessHCIEvents(void);\r
                \r
-               bool CALLBACK_Bluetooth_ConnectionRequest(uint8_t* RemoteAddress);\r
-\r
+               bool Bluetooth_ConnectionRequest(uint8_t* RemoteAddress);\r
+               void Bluetooth_ConnectionComplete(void);\r
+               void Bluetooth_DisconnectionComplete(void);\r
+                       \r
                #if defined(INCLUDE_FROM_BLUETOOTHHCICOMMANDS_C)\r
                        static uint8_t Bluetooth_SendHCICommand(void* Parameters, uint16_t ParameterLength);\r
                #endif\r
                #if defined(INCLUDE_FROM_BLUETOOTHHCICOMMANDS_C)\r
                        static uint8_t Bluetooth_SendHCICommand(void* Parameters, uint16_t ParameterLength);\r
                #endif\r
index 4e0330e..5da4d0b 100644 (file)
@@ -54,21 +54,14 @@ void Bluetooth_Stack_USBTask(void)
        Bluetooth_ProcessACLPackets();\r
 }\r
 \r
        Bluetooth_ProcessACLPackets();\r
 }\r
 \r
-bool CALLBACK_Bluetooth_ConnectionRequest(uint8_t* RemoteAddress)\r
-{\r
-       /* Always accept connections from remote devices */\r
-       return true;\r
-}\r
-\r
 Bluetooth_Channel_t* Bluetooth_GetChannelData(uint16_t ChannelNumber, bool SearchBySource)\r
 {\r
 Bluetooth_Channel_t* Bluetooth_GetChannelData(uint16_t ChannelNumber, bool SearchBySource)\r
 {\r
-       Bluetooth_Channel_t* CurrentChannelStructure;\r
-\r
        for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)\r
        {\r
        for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)\r
        {\r
-               CurrentChannelStructure = &Bluetooth_Connection.Channels[i];\r
+               Bluetooth_Channel_t* CurrentChannelStructure = &Bluetooth_Connection.Channels[i];\r
        \r
        \r
-               uint16_t CurrentChannelNumber = ((SearchBySource) ? CurrentChannelStructure->RemoteNumber : CurrentChannelStructure->LocalNumber);\r
+               uint16_t CurrentChannelNumber = (SearchBySource) ? CurrentChannelStructure->RemoteNumber :\r
+                                                                  CurrentChannelStructure->LocalNumber;\r
        \r
                if (CurrentChannelNumber == ChannelNumber)\r
                  return CurrentChannelStructure;\r
        \r
                if (CurrentChannelNumber == ChannelNumber)\r
                  return CurrentChannelStructure;\r
@@ -79,11 +72,9 @@ Bluetooth_Channel_t* Bluetooth_GetChannelData(uint16_t ChannelNumber, bool Searc
 \r
 Bluetooth_Channel_t* Bluetooth_InitChannelData(uint16_t RemoteChannelNumber, uint16_t PSM)\r
 {\r
 \r
 Bluetooth_Channel_t* Bluetooth_InitChannelData(uint16_t RemoteChannelNumber, uint16_t PSM)\r
 {\r
-       Bluetooth_Channel_t* CurrentChannelStructure;\r
-\r
        for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)\r
        {\r
        for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)\r
        {\r
-               CurrentChannelStructure = &Bluetooth_Connection.Channels[i];\r
+               Bluetooth_Channel_t* CurrentChannelStructure = &Bluetooth_Connection.Channels[i];\r
        \r
                if (CurrentChannelStructure->State == Channel_Closed)\r
                {\r
        \r
                if (CurrentChannelStructure->State == Channel_Closed)\r
                {\r
index b3ac684..1cc0d92 100644 (file)
                #include "BluetoothACLPackets.h"\r
                \r
        /* Macros: */\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
 \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_RFCOMM                       0x0003\r
                \r
        /* Enums: */\r
                enum Bluetooth_Channel_State_t\r
                \r
        /* Enums: */\r
                enum Bluetooth_Channel_State_t\r