Fix byte ordering of UUIDs in the SDP server - host can now successfully pair to...
[pub/lufa.git] / Demos / Host / Incomplete / BluetoothHost / Lib / SDPServices.h
index 654ed94..738cc06 100644 (file)
                #define UUID_SIZE_BYTES                         16\r
                \r
                /** First 80 bits common to all standardized Bluetooth services. */\r
-               #define BASE_80BIT_UUID                         SWAPENDIAN_32(0xFB349B5F), SWAPENDIAN_16(0x8000), SWAPENDIAN_16(0x0080), SWAPENDIAN_16(0x0010)\r
+               #define BASE_80BIT_UUID                         0x0000, 0x0010, 0x0080, {0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}\r
                \r
-               #define SDP_UUID                                {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}\r
-               #define RFCOMM_UUID                             {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}\r
-               #define L2CAP_UUID                              {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x01, 0x00}}\r
-               #define SDP_CLASS_UUID                          {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x10, 0x00}}\r
-               #define SP_CLASS_UUID                           {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x11, 0x01}}\r
-               #define PUBLICBROWSEGROUP_CLASS_UUID            {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x10, 0x02}}\r
+               #define RFCOMM_UUID                             {SWAPENDIAN_32(0x00000003), BASE_80BIT_UUID}\r
+               #define L2CAP_UUID                              {SWAPENDIAN_32(0x00000100), BASE_80BIT_UUID}\r
+               #define SP_CLASS_UUID                           {SWAPENDIAN_32(0x00001101), BASE_80BIT_UUID}\r
+               #define PUBLICBROWSEGROUP_CLASS_UUID            {SWAPENDIAN_32(0x00001002), BASE_80BIT_UUID}\r
                \r
                #define SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE    0x0000\r
                #define SDP_ATTRIBUTE_ID_SERVICECLASSIDS        0x0001\r
                #define SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST 0x0004\r
                #define SDP_ATTRIBUTE_ID_BROWSEGROUPLIST        0x0005\r
                #define SDP_ATTRIBUTE_ID_LANGUAGEBASEATTROFFSET 0x0006\r
-               #define SDP_ATTRIBUTE_ID_VERSION                0x0200\r
                #define SDP_ATTRIBUTE_ID_SERVICENAME            0x0100\r
                #define SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION     0x0101\r
                \r
+               /** Swaps the byte ordering of a 16-bit value at compile time. Do not use this macro for swapping byte orderings\r
+                *  of dynamic values computed at runtime -- use SwapEndian_16() instead.\r
+                *\r
+                *  \param[in]  x  16-bit value whose byte ordering is to be swapped\r
+                *\r
+                *  \return Input value with the byte ordering reversed\r
+                */\r
                #define SWAPENDIAN_16(x)                        ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))\r
-               #define SWAPENDIAN_32(x)                        ((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | \\r
-                                                                (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24))\r
+\r
+               /** Swaps the byte ordering of a 32-bit value at compile time. Do not use this macro for swapping byte orderings\r
+                *  of dynamic values computed at runtime -- use SwapEndian_32() instead.\r
+                *\r
+                *  \param[in]  x  32-bit value whose byte ordering is to be swapped\r
+                *\r
+                *  \return Input value with the byte ordering reversed\r
+                */\r
+               #define SWAPENDIAN_32(x)                        ((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \\r
+                                                                (((x) & 0x0000FF00UL) << 8UL) | (((x) & 0x000000FFUL) << 24UL))\r
                \r
                /** Terminator for a service attribute table of type \ref ServiceAttributeTable_t. */\r
                #define SERVICE_ATTRIBUTE_TABLE_TERMINATOR      {.Data = NULL}\r
                \r
        /* Type Defines: */\r
+               /** Type define for a UUID value structure. This struct can be used to hold full 128-bit UUIDs. */\r
                typedef struct\r
                {\r
-                       uint32_t A;\r
-                       uint16_t B;\r
-                       uint16_t C;\r
-                       uint16_t D;\r
-                       uint8_t  E[6];\r
+                       uint32_t A; /**< Bits 0-31 of the UUID. */\r
+                       uint16_t B; /**< Bits 32-47 of the UUID. */\r
+                       uint16_t C; /**< Bits 48-63 of the UUID. */\r
+                       uint16_t D; /**< Bits 64-79 of the UUID. */\r
+                       uint8_t  E[6]; /**< Bits 80-128 of the UUID. */\r
                } UUID_t;\r
        \r
                /** Structure for the association of attribute ID values to an attribute value in FLASH. A table of these\r
                 *  structures can then be built up for each supported UUID service within the device.\r
+                *\r
+                *  \note This table must be terminated with a \ref SERVICE_ATTRIBUTE_TABLE_TERMINATOR element.\r
                 */\r
                typedef struct\r
                {\r
                        } Protocol;\r
                } ItemProtocol_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
                typedef struct\r
                {\r
-                       Item16Bit_t LanguageID;\r
-                       Item16Bit_t EncodingID;\r
-                       Item16Bit_t OffsetID;\r
-               } ItemLangID_t;\r
+                       Item16Bit_t LanguageID; /**< Language ID for the current language */\r
+                       Item16Bit_t EncodingID; /**< Encoding used for the current language */\r
+                       Item16Bit_t OffsetID; /**< Attribute offset added to all strings using this language within the service */\r
+               } ItemLangEncoding_t;\r
                \r
        /* External Variables: */\r
-               extern const ServiceAttributeTable_t RFCOMM_Attribute_Table[];\r
+               extern const ServiceAttributeTable_t SerialPort_Attribute_Table[];\r
                \r
 #endif\r