Add L2CAP service attribute table. Fix up ProtocolDescriptorList attributes, and add macros for used UUIDs to reduce typing and make the code easier to read.

pull/1469/head
Dean Camera 15 years ago
parent b98158bd50
commit da51c1f974

@ -30,6 +30,8 @@
#include "SDPServices.h" #include "SDPServices.h"
/* ------------------------------ SDP SERVICE ATTRIBUTES ------------------------------ */
const struct const struct
{ {
uint8_t Header; uint8_t Header;
@ -50,25 +52,7 @@ const struct
(SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit), (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit),
SWAPENDIAN_16(sizeof(ItemUUID_t) * 1), SWAPENDIAN_16(sizeof(ItemUUID_t) * 1),
{ {
{(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x10, 0x00}}} {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), SDP_CLASS_UUID}
}
};
const struct
{
uint8_t Header;
uint16_t Size;
ItemProtocol_t ProtocolList[];
} PROGMEM SDP_Attribute_ProtocolDescriptor =
{
(SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit),
SWAPENDIAN_16(sizeof(ItemProtocol_t) * 1),
{
{
(SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),
sizeof(UUID_t),
{(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x01, 0x00}}},
}
} }
}; };
@ -115,7 +99,6 @@ const ServiceAttributeTable_t SDP_Attribute_Table[] PROGMEM =
{ {
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &SDP_Attribute_ServiceHandle }, {.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &SDP_Attribute_ServiceHandle },
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &SDP_Attribute_ServiceClassIDs }, {.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &SDP_Attribute_ServiceClassIDs },
// {.AttributeID = SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST, .Data = &SDP_Attribute_ProtocolDescriptor },
{.AttributeID = SDP_ATTRIBUTE_ID_VERSION, .Data = &SDP_Attribute_Version }, {.AttributeID = SDP_ATTRIBUTE_ID_VERSION, .Data = &SDP_Attribute_Version },
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &SDP_Attribute_ServiceName }, {.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &SDP_Attribute_ServiceName },
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &SDP_Attribute_ServiceDescription }, {.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &SDP_Attribute_ServiceDescription },
@ -123,6 +106,10 @@ const ServiceAttributeTable_t SDP_Attribute_Table[] PROGMEM =
SERVICE_ATTRIBUTE_TABLE_TERMINATOR SERVICE_ATTRIBUTE_TABLE_TERMINATOR
}; };
/* ------------------------------ RFCOMM SERVICE ATTRIBUTES ------------------------------ */
const struct const struct
{ {
uint8_t Header; uint8_t Header;
@ -143,21 +130,35 @@ const struct
(SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit), (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit),
SWAPENDIAN_16(sizeof(ItemUUID_t) * 1), SWAPENDIAN_16(sizeof(ItemUUID_t) * 1),
{ {
{(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x11, 0x01}}} {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), SP_CLASS_UUID}
} }
}; };
const struct const struct
{ {
uint8_t Header; uint8_t Header;
uint8_t Size; uint16_t Size;
Item16Bit_t OffsetList[];
} PROGMEM RFCOMM_Attribute_LangOffset = ItemProtocol_t ProtocolList[];
} PROGMEM RFCOMM_Attribute_ProtocolDescriptor =
{ {
(SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit), (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit),
(sizeof(Item16Bit_t) * 1), SWAPENDIAN_16(sizeof(ItemProtocol_t) * 2),
{ {
{(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit), SWAPENDIAN_16(0x0100)} {
(SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),
sizeof(UUID_t),
{
{(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), L2CAP_UUID},
}
},
{
(SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),
sizeof(UUID_t),
{
{(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), RFCOMM_UUID},
}
}
} }
}; };
@ -189,8 +190,101 @@ const ServiceAttributeTable_t RFCOMM_Attribute_Table[] PROGMEM =
{ {
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &RFCOMM_Attribute_ServiceHandle }, {.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &RFCOMM_Attribute_ServiceHandle },
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &RFCOMM_Attribute_ServiceClassIDs }, {.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &RFCOMM_Attribute_ServiceClassIDs },
{.AttributeID = SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST, .Data = &RFCOMM_Attribute_ProtocolDescriptor },
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &RFCOMM_Attribute_ServiceName }, {.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &RFCOMM_Attribute_ServiceName },
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &RFCOMM_Attribute_ServiceDescription }, {.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &RFCOMM_Attribute_ServiceDescription },
SERVICE_ATTRIBUTE_TABLE_TERMINATOR SERVICE_ATTRIBUTE_TABLE_TERMINATOR
}; };
/* ------------------------------ L2CAP SERVICE ATTRIBUTES ------------------------------ */
const struct
{
uint8_t Header;
uint32_t Data;
} PROGMEM L2CAP_Attribute_ServiceHandle =
{
(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_32Bit),
SWAPENDIAN_32(0x00010002),
};
const struct
{
uint8_t Header;
uint16_t Size;
ItemUUID_t UUIDList[];
} PROGMEM L2CAP_Attribute_ServiceClassIDs =
{
(SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit),
SWAPENDIAN_16(sizeof(ItemUUID_t) * 2),
{
{(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), SDP_CLASS_UUID },
{(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), SP_CLASS_UUID },
}
};
const struct
{
uint8_t Header;
uint16_t Size;
ItemProtocol_t ProtocolList[];
} PROGMEM L2CAP_Attribute_ProtocolDescriptor =
{
(SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit),
SWAPENDIAN_16(sizeof(ItemProtocol_t) * 2),
{
{
(SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),
sizeof(UUID_t),
{
{(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), L2CAP_UUID},
}
},
{
(SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),
sizeof(UUID_t),
{
{(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), RFCOMM_UUID},
}
}
}
};
const struct
{
uint8_t Header;
uint8_t Size;
char Text[];
} PROGMEM L2CAP_Attribute_ServiceName =
{
(SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit),
sizeof("L2CAP") - 1,
"L2CAP",
};
const struct
{
uint8_t Header;
uint8_t Size;
char Text[];
} PROGMEM L2CAP_Attribute_ServiceDescription =
{
(SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit),
sizeof("Logical Link Layer") - 1,
"Logical Link Layer",
};
const ServiceAttributeTable_t L2CAP_Attribute_Table[] PROGMEM =
{
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &L2CAP_Attribute_ServiceHandle },
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &L2CAP_Attribute_ServiceClassIDs },
{.AttributeID = SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST, .Data = &L2CAP_Attribute_ProtocolDescriptor },
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &L2CAP_Attribute_ServiceName },
{.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &L2CAP_Attribute_ServiceDescription },
SERVICE_ATTRIBUTE_TABLE_TERMINATOR
};

@ -46,6 +46,14 @@
/** First 80 bits common to all standardized Bluetooth services. */ /** First 80 bits common to all standardized Bluetooth services. */
#define BASE_80BIT_UUID SWAPENDIAN_32(0xFB349B5F), SWAPENDIAN_16(0x8000), SWAPENDIAN_16(0x0080), SWAPENDIAN_16(0x0010) #define BASE_80BIT_UUID SWAPENDIAN_32(0xFB349B5F), SWAPENDIAN_16(0x8000), SWAPENDIAN_16(0x0080), SWAPENDIAN_16(0x0010)
#define SDP_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}
#define RFCOMM_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}
#define L2CAP_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x01, 0x00}}
#define UPNP_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x00, 0x10}}
#define SDP_CLASS_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x10, 0x00}}
#define SP_CLASS_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x11, 0x01}}
#define UPNP_CLASS_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x12, 0x00}}
#define SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE 0x0000 #define SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE 0x0000
#define SDP_ATTRIBUTE_ID_SERVICECLASSIDS 0x0001 #define SDP_ATTRIBUTE_ID_SERVICECLASSIDS 0x0001
#define SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST 0x0004 #define SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST 0x0004
@ -124,11 +132,15 @@
uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */ uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */
uint8_t Size; /**< Size of the inner Data Element sequence */ uint8_t Size; /**< Size of the inner Data Element sequence */
ItemUUID_t UUID; /**< UUID to store in the protocol list Data Element sequence */ struct
{
ItemUUID_t UUID; /**< UUID to store in the protocol list Data Element sequence */
} Protocol;
} ItemProtocol_t; } ItemProtocol_t;
/* External Variables: */ /* External Variables: */
extern const ServiceAttributeTable_t SDP_Attribute_Table[]; extern const ServiceAttributeTable_t SDP_Attribute_Table[];
extern const ServiceAttributeTable_t RFCOMM_Attribute_Table[]; extern const ServiceAttributeTable_t RFCOMM_Attribute_Table[];
extern const ServiceAttributeTable_t L2CAP_Attribute_Table[];
#endif #endif

@ -36,14 +36,9 @@
*/ */
const ServiceTable_t SDP_Services_Table[] PROGMEM = const ServiceTable_t SDP_Services_Table[] PROGMEM =
{ {
{ // 128-bit UUID for the SDP service { .UUID = SDP_UUID , .AttributeTable = SDP_Attribute_Table },
.UUID = {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}, { .UUID = RFCOMM_UUID, .AttributeTable = RFCOMM_Attribute_Table },
.AttributeTable = SDP_Attribute_Table, { .UUID = L2CAP_UUID , .AttributeTable = L2CAP_Attribute_Table },
},
{ // 128-bit UUID for the RFCOMM service
.UUID = {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}},
.AttributeTable = RFCOMM_Attribute_Table,
},
}; };
/** Base UUID value common to all standardized Bluetooth services */ /** Base UUID value common to all standardized Bluetooth services */

Loading…
Cancel
Save