Add Mecurial repository mirror link to the library documentation.
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / Lib / ServiceDiscoveryProtocol.c
index 0ee0784..5223d29 100644 (file)
   this software.
 */
 
+/** \file
+ *
+ *  SDP layer module. This module implements a simple Service Discovery
+ *  Protocol server, which can broadcast the device's supported services
+ *  to other Bluetooth devices upon request, so that they can determine
+ *  what services are available.
+ */
+
+/*
+       TODO: Honor remote device's buffer size constraints via continuation state
+ */
+
 #define  INCLUDE_FROM_SERVICEDISCOVERYPROTOCOL_C
 #include "ServiceDiscoveryProtocol.h"
 
@@ -40,6 +52,12 @@ const ServiceAttributeTable_t* SDP_Services_Table[] PROGMEM =
 /** Base UUID value common to all standardized Bluetooth services */
 const UUID_t BaseUUID PROGMEM = {0x00000000, BASE_80BIT_UUID};
 
+/** Initializes the SDP service, ready for new connections from a SDP client. */
+void SDP_Initialize(void)
+{
+       /* Not currently used */
+}
+
 /** Main Service Discovery Protocol packet processing routine. This function processes incomming SDP packets from
  *  a connected Bluetooth device, and sends back appropriate responses to allow other devices to determine the
  *  services the local device exposes.
@@ -56,6 +74,7 @@ void SDP_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel)
        BT_SDP_DEBUG(2, "-- PDU ID: 0x%02X", SDPHeader->PDU);
        BT_SDP_DEBUG(2, "-- Param Length: 0x%04X", SDPHeader->ParameterLength);
 
+       /* Dispatch to the correct processing routine for the given SDP packet type */
        switch (SDPHeader->PDU)
        {
                case SDP_PDU_SERVICESEARCHREQUEST:
@@ -486,16 +505,7 @@ static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES], const uint8_
                /* Look for matches in the UUID list against the current attribute UUID value */
                for (uint8_t i = 0; i < TotalUUIDs; i++)
                {
-                       uint8_t CurrentUUID[16];
-                       memcpy_P(CurrentUUID, (CurrAttribute + 1), 16);
-               
-                       BT_SDP_DEBUG(2, "-- TEST UUID: %02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
-                               CurrentUUID[0], CurrentUUID[1], CurrentUUID[2], CurrentUUID[3],
-                               CurrentUUID[4], CurrentUUID[5],
-                                               CurrentUUID[6], CurrentUUID[7],
-                               CurrentUUID[8], CurrentUUID[9],
-                                               CurrentUUID[10], CurrentUUID[11], CurrentUUID[12],  CurrentUUID[13],  CurrentUUID[14],  CurrentUUID[15]);
-
+                       /* Check if the current unmatched UUID is identical to the search UUID */
                        if (!(UUIDMatch[i]) && !(memcmp_P(UUIDList[i], (CurrAttribute + 1), UUID_SIZE_BYTES)))
                        {
                                /* Indicate match found for the current attribute UUID and early-abort */