Extra protocol value in the RFCOMM protocol is the channel number, not the PSM -...
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 3 Jun 2010 08:33:01 +0000 (08:33 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 3 Jun 2010 08:33:01 +0000 (08:33 +0000)
Add delay to the Connection Request signal processing routine - without this, the host will not create the RFCOMM channel correctly. Need to investigate why this delay is needed.

Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c
Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c
Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c
Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.h

index 1028679..e300dd9 100644 (file)
@@ -291,7 +291,8 @@ void Bluetooth_PacketReceived(void* Data, uint16_t DataLen, Bluetooth_Channel_t*
                        break;
                default:
                        /* Unknown Protocol packet */
                        break;
                default:
                        /* Unknown Protocol packet */
-                       printf_P(PSTR("Unknown Packet Received (Channel 0x%04X, PSM: 0x%02X):\r\n"), Channel->LocalNumber, Channel->PSM);                       
+                       printf_P(PSTR("Unknown Packet Received (Channel 0x%04X, PSM: 0x%02X, Len: 0x%04X):\r\n"),
+                                     Channel->LocalNumber, Channel->PSM, DataLen);                     
                        break;
        }
 }
                        break;
        }
 }
index ba51701..818caac 100644 (file)
@@ -32,6 +32,7 @@
        TODO: Make SendPacket respect receiver's MTU
        TODO: Make ReceivePacket stitch together MTU fragments (?)
        TODO: Add channel opened/closed callbacks
        TODO: Make SendPacket respect receiver's MTU
        TODO: Make ReceivePacket stitch together MTU fragments (?)
        TODO: Add channel opened/closed callbacks
+       TODO: Figure out why delay is needed in connection for services
  */
 
 #define  INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C
  */
 
 #define  INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C
@@ -363,10 +364,12 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
 
        Pipe_ClearIN();
        Pipe_Freeze();
 
        Pipe_ClearIN();
        Pipe_Freeze();
-
+       
        BT_ACL_DEBUG(1, "<< L2CAP Connection Request");
        BT_ACL_DEBUG(2, "-- PSM: 0x%04X", ConnectionRequest.PSM);
        BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel);
        BT_ACL_DEBUG(1, "<< L2CAP Connection Request");
        BT_ACL_DEBUG(2, "-- PSM: 0x%04X", ConnectionRequest.PSM);
        BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel);
+
+       _delay_ms(15); // TODO - Determine why this is needed
        
        /* Try to retrieve the existing channel's information structure if it exists */
        Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConnectionRequest.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER);
        
        /* Try to retrieve the existing channel's information structure if it exists */
        Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConnectionRequest.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER);
index cf32673..a06ebfe 100644 (file)
@@ -56,15 +56,15 @@ const struct
 \r
 const struct\r
 {\r
 \r
 const struct\r
 {\r
-       uint8_t Header;\r
-       uint8_t Size;\r
+       uint8_t               Header;\r
+       uint8_t               Size;\r
 \r
 \r
-       ItemProtocol_t    L2CAP;\r
-       ItemProtocolPSM_t RFCOMM;\r
+       ItemProtocol_t        L2CAP;\r
+       ItemProtocolChannel_t RFCOMM;\r
 } PROGMEM SerialPort_Attribute_ProtocolDescriptor =\r
        {\r
                (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),\r
 } PROGMEM SerialPort_Attribute_ProtocolDescriptor =\r
        {\r
                (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),\r
-               (sizeof(ItemProtocol_t) + sizeof(ItemProtocolPSM_t)),\r
+               (sizeof(ItemProtocol_t) + sizeof(ItemProtocolChannel_t)),\r
                {\r
                        (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),\r
                        sizeof(ItemUUID_t),\r
                {\r
                        (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),\r
                        sizeof(ItemUUID_t),\r
@@ -74,10 +74,10 @@ const struct
                },\r
                {\r
                        (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),\r
                },\r
                {\r
                        (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),\r
-                       (sizeof(ItemUUID_t) + sizeof(Item16Bit_t)),\r
+                       (sizeof(ItemUUID_t) + sizeof(Item8Bit_t)),\r
                        {\r
                                {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), RFCOMM_UUID},\r
                        {\r
                                {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), RFCOMM_UUID},\r
-                               {(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit), SWAPENDIAN_16(CHANNEL_PSM_RFCOMM)},\r
+                               {(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_8Bit), 0x03},\r
                        },\r
                },\r
        };\r
                        },\r
                },\r
        };\r
index 1cfc2b2..7e33638 100644 (file)
                        } Protocol;\r
                } ItemProtocol_t;\r
 \r
                        } Protocol;\r
                } ItemProtocol_t;\r
 \r
-               /** Structure for a list of Data Elements Sequences containing UUID Data Elements and 16-bit PSM values, for service\r
+               /** Structure for a list of Data Elements Sequences containing UUID Data Elements and 8-bit channel values, for service\r
                 *  attributes requiring extended protocol lists.\r
                 */\r
                typedef struct\r
                {\r
                 *  attributes requiring extended protocol lists.\r
                 */\r
                typedef struct\r
                {\r
-                       uint8_t         Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */\r
-                       uint8_t         Size; /**< Size of the inner Data Element sequence */\r
+                       uint8_t        Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */\r
+                       uint8_t        Size; /**< Size of the inner Data Element sequence */\r
                        \r
                        struct\r
                        {\r
                        \r
                        struct\r
                        {\r
-                               ItemUUID_t  UUID; /**< UUID to store in the protocol list Data Element sequence */\r
-                               Item16Bit_t PSM; /**< PSM that is to be used to access the service on created channels */\r
+                               ItemUUID_t UUID; /**< UUID to store in the protocol list Data Element sequence */\r
+                               Item8Bit_t Channel; /**< Channel that is to be used to access the service */\r
                        } Protocol;\r
                        } Protocol;\r
-               } ItemProtocolPSM_t;\r
+               } ItemProtocolChannel_t;\r
                \r
                /** Structure for a list of Data Elements containing language encodings, including the language ID, Encoding ID and\r
                 *  Attribute base offset.\r
                \r
                /** Structure for a list of Data Elements containing language encodings, including the language ID, Encoding ID and\r
                 *  Attribute base offset.\r
                \r
        /* External Variables: */\r
                extern const ServiceAttributeTable_t SerialPort_Attribute_Table[];\r
                \r
        /* External Variables: */\r
                extern const ServiceAttributeTable_t SerialPort_Attribute_Table[];\r
+               extern const ServiceAttributeTable_t PnP_Attribute_Table[];\r
                \r
 #endif\r
                \r
 #endif\r