aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-05-20 08:27:04 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-05-20 08:27:04 +0000
commit141d94fa980b6056c1922cbfeb9f5535227331c5 (patch)
tree7e4cbcca013badb8fcca8b700f7d47c08ca1ec94 /Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h
parenta883cf65dc447c66aa76d9091d6a57d690a2d61a (diff)
downloadlufa-141d94fa980b6056c1922cbfeb9f5535227331c5.tar.gz
lufa-141d94fa980b6056c1922cbfeb9f5535227331c5.tar.bz2
lufa-141d94fa980b6056c1922cbfeb9f5535227331c5.zip
More SDP code improvements - responses to ServiceSearchAttribute service discovery requests should now be valid, even if they do not currently return the device's services and service attributes.
Added more documentation to the incomplete Bluetooth stack code.
Diffstat (limited to 'Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h')
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h85
1 files changed, 67 insertions, 18 deletions
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h
index 4535b3561..ccbfed41e 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h
@@ -59,28 +59,63 @@
#define SDP_ATTRIBUTE_PROVIDER 0x0002
#define SDP_ATTRIBUTE_AVAILABILITY 0x0008
- #define SDP_DATATYPE_NIL (0x00 << 3)
- #define SDP_DATATYPE_UNSIGNED_INT (0x01 << 3)
- #define SDP_DATATYPE_SIGNED_INT (0x02 << 3)
- #define SDP_DATATYPE_UUID (0x03 << 3)
- #define SDP_DATATYPE_TEXT (0x04 << 3)
- #define SDP_DATATYPE_BOOLEAN (0x05 << 3)
- #define SDP_DATATYPE_ELEMENT_SEQUENCE (0x06 << 3)
- #define SDP_DATATYPE_ELEMENT_ALTERNATIVE (0x07 << 3)
- #define SDP_DATATYPE_URL (0x08 << 3)
-
#define UUID_SIZE_BYTES 16
#define BASE_96BIT_UUID 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00
- #define SERVICE_ATTRIBUTE_TEXT(name, string) SERVICE_ATTRIBUTE_LEN8(name, SDP_DATATYPE_TEXT, sizeof(string), string)
+ /** Defines a service attribute as a string of characters.
+ *
+ * \param name Name of the attribute (used to identify the attribute variable only)
+ * \param string String of characters to associate with the attribute
+ */
+ #define SERVICE_ATTRIBUTE_TEXT(name, string) SERVICE_ATTRIBUTE_LEN8(name, SDP_DATATYPE_String, sizeof(string), string)
+
+ /** Defines a service attribute with a contents that can fit into an 8-bit integer.
+ *
+ * \param name Name of the attribute (used to identify the attribute variable only)
+ * \param type Type of attribute contents, a value from the \ref ServiceDiscovery_DataTypes_t enum
+ * \param size Size of the data, in bytes
+ * \param ... Data to associate with the attribute
+ */
#define SERVICE_ATTRIBUTE_LEN8(name, type, size, ...) const ServiceAttributeData8Bit_t name PROGMEM = \
{.Header = (type | 5), .Size = size, .Data = __VA_ARGS__}
+
+ /** Defines a service attribute with a contents that can fit into an 16-bit integer.
+ *
+ * \param name Name of the attribute (used to identify the attribute variable only)
+ * \param type Type of attribute contents, a value from the \ref ServiceDiscovery_DataTypes_t enum
+ * \param size Size of the data, in bytes
+ * \param ... Data to associate with the attribute
+ */
#define SERVICE_ATTRIBUTE_LEN16(name, type, size, ...) const ServiceAttributeData16Bit_t name PROGMEM = \
{.Header = (type | 6), .Size = size, .Data = __VA_ARGS__}
+
+ /** Defines a service attribute with a contents that can fit into an 32-bit integer.
+ *
+ * \param name Name of the attribute (used to identify the attribute variable only)
+ * \param type Type of attribute contents, a value from the \ref ServiceDiscovery_DataTypes_t enum
+ * \param size Size of the data, in bytes
+ * \param ... Data to associate with the attribute
+ */
#define SERVICE_ATTRIBUTE_LEN32(name, type, size, ...) const ServiceAttributeData32Bit_t name PROGMEM = \
{.Header = (type | 7), .Size = size, .Data = __VA_ARGS__}
+
+ /** Terminator for a service attribute table of type \ref ServiceAttributeTable_t. */
#define SERVICE_ATTRIBUTE_TABLE_TERMINATOR {.Data = NULL}
+ /* Enums: */
+ enum ServiceDiscovery_DataTypes_t
+ {
+ SDP_DATATYPE_Nill = (0 << 3),
+ SDP_DATATYPE_UnsignedInt = (1 << 3),
+ SDP_DATATYPE_SignedInt = (2 << 3),
+ SDP_DATATYPE_UUID = (3 << 3),
+ SDP_DATATYPE_String = (4 << 3),
+ SDP_DATATYPE_Boolean = (5 << 3),
+ SDP_DATATYPE_Sequence = (6 << 3),
+ SDP_DATATYPE_Alternative = (7 << 3),
+ SDP_DATATYPE_URL = (8 << 3),
+ };
+
/* Type Defines: */
typedef struct
{
@@ -127,6 +162,27 @@
uint8_t Header;
uint8_t Data[];
} ServiceAttributeData_t;
+
+ /* Inline Functions: */
+ static inline uint16_t* ServiceDiscovery_AddDataElementHeader(uint8_t** BufferPos, const uint8_t Type)
+ {
+ **BufferPos = (6 | Type);
+ *BufferPos += 1;
+
+ uint16_t* SizePos = (uint16_t*)*BufferPos;
+ *SizePos = 0;
+
+ **BufferPos += 2;
+
+ return SizePos;
+ }
+
+ static inline uint16_t ServiceDiscovery_Read16BitParameter(const void** AttributeHeader)
+ {
+ uint16_t ParamValue = *((uint16_t*)*AttributeHeader);
+ *AttributeHeader += sizeof(uint16_t);
+ return ParamValue;
+ }
/* Function Prototypes: */
void ServiceDiscovery_ProcessPacket(void* Data, Bluetooth_Channel_t* Channel);
@@ -135,13 +191,6 @@
static void ServiceDiscovery_ProcessServiceSearch(SDP_PDUHeader_t* SDPHeader, Bluetooth_Channel_t* Channel);
static void ServiceDiscovery_ProcessServiceAttribute(SDP_PDUHeader_t* SDPHeader, Bluetooth_Channel_t* Channel);
static void ServiceDiscovery_ProcessServiceSearchAttribute(SDP_PDUHeader_t* SDPHeader, Bluetooth_Channel_t* Channel);
-
- static inline uint16_t ServiceDiscovery_Read16BitParameter(const void** AttributeHeader)
- {
- uint16_t ParamValue = *((uint16_t*)*AttributeHeader);
- *AttributeHeader += sizeof(uint16_t);
- return ParamValue;
- }
static uint8_t ServiceDiscovery_ProcessAttributes(uint8_t UUIDList[][UUID_SIZE_BYTES], const uint8_t TotalUUIDs,
uint8_t* ResponseBuffer, uint8_t MaxResponseSize,