From e0ef5741d49dc5b36f3bb8165506b51006e68ee3 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Tue, 1 Jun 2010 03:07:05 +0000 Subject: [PATCH] Move SDP service tables out into a new set of files, to make the SDP service code cleaner. --- .../BluetoothHost/Lib/BluetoothACLPackets.h | 5 + .../BluetoothHost/Lib/BluetoothClassCodes.h | 7 + .../BluetoothHost/Lib/BluetoothHCICommands.h | 5 + .../BluetoothHost/Lib/BluetoothStack.h | 5 + .../BluetoothHost/Lib/SDPServices.c | 174 ++++++++++++++++++ .../BluetoothHost/Lib/SDPServices.h | 114 ++++++++++++ .../Lib/ServiceDiscoveryProtocol.c | 147 +-------------- .../Lib/ServiceDiscoveryProtocol.h | 72 +------- Demos/Host/Incomplete/BluetoothHost/makefile | 1 + LUFA.pnproj | 2 +- 10 files changed, 320 insertions(+), 212 deletions(-) create mode 100644 Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c create mode 100644 Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.h diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h index 48e8e47e9d..c655971fcf 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h @@ -28,6 +28,11 @@ this software. */ +/** \file + * + * Header file for BluetoothACLPackets.c. + */ + #ifndef _BLUETOOTH_ACLPACKETS_ #define _BLUETOOTH_ACLPACKETS_ diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothClassCodes.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothClassCodes.h index 209256fd08..3dd9d70c96 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothClassCodes.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothClassCodes.h @@ -5,6 +5,7 @@ dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ + /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) @@ -27,6 +28,12 @@ this software. */ +/** \file + * + * Bluetooth class codes, used to describe the type and overall function of a + * Bluetooth device to other Bluetooth devices. + */ + #ifndef _BLUETOOTH_CLASS_CODES_H_ #define _BLUETOOTH_CLASS_CODES_H_ diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h index 5f98e34a91..5a556e1141 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h @@ -28,6 +28,11 @@ this software. */ +/** \file + * + * Header file for BluetoothHCICommands.c. + */ + #ifndef _BLUETOOTH_HCICOMMANDS_H_ #define _BLUETOOTH_HCICOMMANDS_H_ diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h index ff1dec749a..4b16a8f48e 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h @@ -28,6 +28,11 @@ this software. */ +/** \file + * + * Header file for BluetoothStack.c. + */ + #ifndef _BLUETOOTH_STACK_ #define _BLUETOOTH_STACK_ diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c new file mode 100644 index 0000000000..9df89d51b6 --- /dev/null +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c @@ -0,0 +1,174 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "SDPServices.h" + +const struct +{ + uint8_t Header; + uint32_t Data; +} PROGMEM SDP_Attribute_ServiceHandle = {(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_32Bit), SWAPENDIAN_32(0x00010000)}; + +const struct +{ + uint8_t Header; + uint16_t Size; + ClassUUID_t UUIDList[]; +} PROGMEM SDP_Attribute_ServiceClassIDs = + { + .Header = (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit), + .Size = SWAPENDIAN_16(sizeof(ClassUUID_t) * 1), + .UUIDList = + { + {.Header = (SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), .UUID = {BASE_96BIT_UUID, 0x00, 0x10, 0x00, 0x00}} + } + }; + +const struct +{ + uint8_t Header; + uint8_t Size; + Item16Bit_t VersionList[]; +} PROGMEM SDP_Attribute_Version = + { + .Header = (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit), + .Size = (sizeof(Item16Bit_t) * 1), + .VersionList = + { + {.Header = (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit), .Value = SWAPENDIAN_16(0x0100)} + } + }; + +const struct +{ + uint8_t Header; + uint8_t Size; + Item16Bit_t OffsetList[]; +} PROGMEM SDP_Attribute_LangOffset = + { + .Header = (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit), + .Size = (sizeof(Item16Bit_t) * 1), + .OffsetList = + { + {.Header = (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit), .Value = SWAPENDIAN_16(0x0100)} + } + }; + +const struct +{ + uint8_t Header; + uint8_t Size; + char Text[]; +} PROGMEM SDP_Attribute_ServiceName = + { + .Header = (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit), + .Size = sizeof("SDP") - 1, + .Text = "SDP", + }; + +const struct +{ + uint8_t Header; + uint8_t Size; + char Text[]; +} PROGMEM SDP_Attribute_ServiceDescription = + { + .Header = (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit), + .Size = sizeof("Service Discovery Protocol Server") - 1, + .Text = "Service Discovery Protocol Server", + }; + +/** Service Discovery Protocol attribute table, listing all supported attributes of the service. */ +const ServiceAttributeTable_t SDP_Attribute_Table[] PROGMEM = + { + {.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &SDP_Attribute_ServiceHandle }, + {.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &SDP_Attribute_ServiceClassIDs }, + {.AttributeID = SDP_ATTRIBUTE_ID_VERSION, .Data = &SDP_Attribute_Version }, + {.AttributeID = SDP_ATTRIBUTE_ID_LANGIDOFFSET, .Data = &SDP_Attribute_LangOffset }, + {.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &SDP_Attribute_ServiceName }, + {.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &SDP_Attribute_ServiceDescription }, + + SERVICE_ATTRIBUTE_TABLE_TERMINATOR + }; + +const struct +{ + uint8_t Header; + uint32_t Data; +} PROGMEM RFCOMM_Attribute_ServiceHandle = {(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_32Bit), SWAPENDIAN_32(0x00010001)}; + +const struct +{ + uint8_t Header; + uint16_t Size; + ClassUUID_t UUIDList[]; +} PROGMEM RFCOMM_Attribute_ServiceClassIDs = + { + .Header = (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit), + .Size = SWAPENDIAN_16(sizeof(ClassUUID_t) * 1), + .UUIDList = + { + {.Header = (SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), .UUID = {BASE_96BIT_UUID, 0x01, 0x11, 0x00, 0x00}} + } + }; + +const struct +{ + uint8_t Header; + uint8_t Size; + char Text[]; +} PROGMEM RFCOMM_Attribute_ServiceName = + { + .Header = (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit), + .Size = sizeof("Serial Port") - 1, + .Text = "Serial Port", + }; + +const struct +{ + uint8_t Header; + uint8_t Size; + char Text[]; +} PROGMEM RFCOMM_Attribute_ServiceDescription = + { + .Header = (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit), + .Size = sizeof("Wireless Serial Port Service") - 1, + .Text = "Wireless Serial Port Service", + }; + +const ServiceAttributeTable_t RFCOMM_Attribute_Table[] PROGMEM = + { + {.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &RFCOMM_Attribute_ServiceHandle }, + {.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &RFCOMM_Attribute_ServiceClassIDs }, + {.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &RFCOMM_Attribute_ServiceName }, + {.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &RFCOMM_Attribute_ServiceDescription }, + + SERVICE_ATTRIBUTE_TABLE_TERMINATOR + }; diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.h b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.h new file mode 100644 index 0000000000..ce920579bd --- /dev/null +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.h @@ -0,0 +1,114 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Header file for SDPServices.c. + */ + +#ifndef _SDPSERVICES_H_ +#define _SDPSERVICES_H_ + + /* Includes: */ + #include "ServiceDiscoveryProtocol.h" + + /* Macros: */ + /** Size of a full 128 bit UUID, in bytes. */ + #define UUID_SIZE_BYTES 16 + + /** First 96 bits common to all standardized Bluetooth services. */ + #define BASE_96BIT_UUID 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00 + + #define SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE 0x0000 + #define SDP_ATTRIBUTE_ID_SERVICECLASSIDS 0x0001 + #define SDP_ATTRIBUTE_ID_LANGIDOFFSET 0x0006 + #define SDP_ATTRIBUTE_ID_AVAILABILITY 0x0008 + #define SDP_ATTRIBUTE_ID_VERSION 0x0200 + #define SDP_ATTRIBUTE_ID_SERVICENAME 0x0100 + #define SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION 0x0101 + + #define SWAPENDIAN_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) + #define SWAPENDIAN_32(x) (SWAPENDIAN_16(((x) & 0xFFFF0000) >> 16) | SWAPENDIAN_16(((x) & 0x0000FFFF) << 16)) + + /** Terminator for a service attribute table of type \ref ServiceAttributeTable_t. */ + #define SERVICE_ATTRIBUTE_TABLE_TERMINATOR {.Data = NULL} + + /* Type Defines: */ + /** Structure for the association of attribute ID values to an attribute value in FLASH. A table of these + * structures can then be built up for each supported UUID service within the device. + */ + typedef struct + { + uint16_t AttributeID; /**< Attribute ID of the table element which the UUID service supports */ + const void* Data; /**< Pointer to the attribute data, located in PROGMEM memory space */ + } ServiceAttributeTable_t; + + /** Structure for the association of service UUID values to attribute tables stored in FLASH. A table of these + * structures can then be built up for each supported UUID service within the device. + */ + typedef struct + { + uint8_t UUID[UUID_SIZE_BYTES]; /**< UUID of a service supported by the device */ + const void* AttributeTable; /**< Pointer to the UUID's attribute table, located in PROGMEM memory space */ + } ServiceTable_t; + + /** Structure for a list of Data Elements containing UUIDs, for service attributes requiring UUID lists. */ + typedef struct + { + uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit) */ + uint8_t UUID[UUID_SIZE_BYTES]; /**< UUID to store in the list Data Element */ + } ClassUUID_t; + + /** Structure for a list of Data Elements containing 8-bit integers, for service attributes requiring such lists. */ + typedef struct + { + uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_8Bit) */ + uint8_t Value; /**< Value to store in the list Data Element */ + } Item8Bit_t; + + /** Structure for a list of Data Elements containing 16-bit integers, for service attributes requiring such lists. */ + typedef struct + { + uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit) */ + uint16_t Value; /**< Value to store in the list Data Element */ + } Item16Bit_t; + + /** Structure for a list of Data Elements containing 32-bit integers, for service attributes requiring such lists. */ + typedef struct + { + uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_32Bit) */ + uint32_t Value; /**< Value to store in the list Data Element */ + } Item32Bit_t; + + /* External Variables: */ + extern const ServiceAttributeTable_t SDP_Attribute_Table[]; + extern const ServiceAttributeTable_t RFCOMM_Attribute_Table[]; + +#endif diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c index ba6670716d..2b61cb4633 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c @@ -31,149 +31,9 @@ #define INCLUDE_FROM_SERVICEDISCOVERYPROTOCOL_C #include "ServiceDiscoveryProtocol.h" -const struct -{ - uint8_t Header; - uint32_t Data; -} PROGMEM SDP_Attribute_ServiceHandle = {(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_32Bit), SWAPENDIAN_32(0x00010000)}; - -const struct -{ - uint8_t Header; - uint16_t Size; - ClassUUID_t UUIDList[]; -} PROGMEM SDP_Attribute_ServiceClassIDs = - { - .Header = (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit), - .Size = SWAPENDIAN_16(sizeof(ClassUUID_t) * 1), - .UUIDList = - { - {.Header = (SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), .UUID = {BASE_96BIT_UUID, 0x00, 0x10, 0x00, 0x00}} - } - }; - -const struct -{ - uint8_t Header; - uint8_t Size; - Item16Bit_t VersionList[]; -} PROGMEM SDP_Attribute_Version = - { - .Header = (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit), - .Size = (sizeof(Item16Bit_t) * 1), - .VersionList = - { - {.Header = (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit), .Value = SWAPENDIAN_16(0x0100)} - } - }; - -const struct -{ - uint8_t Header; - uint8_t Size; - Item16Bit_t OffsetList[]; -} PROGMEM SDP_Attribute_LangOffset = - { - .Header = (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit), - .Size = (sizeof(Item16Bit_t) * 1), - .OffsetList = - { - {.Header = (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit), .Value = SWAPENDIAN_16(0x0100)} - } - }; - -const struct -{ - uint8_t Header; - uint8_t Size; - char Text[]; -} PROGMEM SDP_Attribute_ServiceName = - { - .Header = (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit), - .Size = sizeof("SDP") - 1, - .Text = "SDP", - }; - -const struct -{ - uint8_t Header; - uint8_t Size; - char Text[]; -} PROGMEM SDP_Attribute_ServiceDescription = - { - .Header = (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit), - .Size = sizeof("Service Discovery Protocol Server") - 1, - .Text = "Service Discovery Protocol Server", - }; - -/** Service Discovery Protocol attribute table, listing all supported attributes of the service. */ -const ServiceAttributeTable_t SDP_Attribute_Table[] PROGMEM = - { - {.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &SDP_Attribute_ServiceHandle }, - {.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &SDP_Attribute_ServiceClassIDs }, - {.AttributeID = SDP_ATTRIBUTE_ID_VERSION, .Data = &SDP_Attribute_Version }, - {.AttributeID = SDP_ATTRIBUTE_ID_LANGIDOFFSET, .Data = &SDP_Attribute_LangOffset }, - {.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &SDP_Attribute_ServiceName }, - {.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &SDP_Attribute_ServiceDescription }, - - SERVICE_ATTRIBUTE_TABLE_TERMINATOR - }; - -const struct -{ - uint8_t Header; - uint32_t Data; -} PROGMEM RFCOMM_Attribute_ServiceHandle = {(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_32Bit), SWAPENDIAN_32(0x00010001)}; - -const struct -{ - uint8_t Header; - uint16_t Size; - ClassUUID_t UUIDList[]; -} PROGMEM RFCOMM_Attribute_ServiceClassIDs = - { - .Header = (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit), - .Size = SWAPENDIAN_16(sizeof(ClassUUID_t) * 1), - .UUIDList = - { - {.Header = (SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), .UUID = {BASE_96BIT_UUID, 0x01, 0x11, 0x00, 0x00}} - } - }; - -const struct -{ - uint8_t Header; - uint8_t Size; - char Text[]; -} PROGMEM RFCOMM_Attribute_ServiceName = - { - .Header = (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit), - .Size = sizeof("Serial Port") - 1, - .Text = "Serial Port", - }; - -const struct -{ - uint8_t Header; - uint8_t Size; - char Text[]; -} PROGMEM RFCOMM_Attribute_ServiceDescription = - { - .Header = (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit), - .Size = sizeof("Wireless Serial Port Service") - 1, - .Text = "Wireless Serial Port Service", - }; - -const ServiceAttributeTable_t RFCOMM_Attribute_Table[] PROGMEM = - { - {.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &RFCOMM_Attribute_ServiceHandle }, - {.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &RFCOMM_Attribute_ServiceClassIDs }, - {.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &RFCOMM_Attribute_ServiceName }, - {.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &RFCOMM_Attribute_ServiceDescription }, +/** Base UUID value common to all standardized Bluetooth services */ +const uint8_t BaseUUID[] PROGMEM = {BASE_96BIT_UUID, 0x00, 0x00, 0x00, 0x00}; - SERVICE_ATTRIBUTE_TABLE_TERMINATOR - }; - /** Master service table, listing all supported services (and their attribute tables) of the device, including * each service's UUID. */ @@ -189,9 +49,6 @@ const ServiceTable_t SDP_Services_Table[] PROGMEM = }, }; -/** Base UUID value common to all standardized Bluetooth services */ -const uint8_t BaseUUID[] PROGMEM = {BASE_96BIT_UUID, 0x00, 0x00, 0x00, 0x00}; - /** 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 diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h index 4765200568..ce7d5f26dc 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h @@ -28,6 +28,11 @@ this software. */ +/** \file + * + * Header file for ServiceDiscoveryProtocol.c. + */ + #ifndef _SERVICEDISCOVERYPROTOCOL_H_ #define _SERVICEDISCOVERYPROTOCOL_H_ @@ -41,6 +46,7 @@ #include #include "BluetoothStack.h" + #include "SDPServices.h" /* Macros: */ #define BT_SDP_DEBUG(l, s, ...) do { if (SDP_DEBUG_LEVEL >= l) printf_P(PSTR("(SDP) " s "\r\n"), ##__VA_ARGS__); } while (0) @@ -54,26 +60,6 @@ #define SDP_PDU_SERVICESEARCHATTRIBUTEREQUEST 0x06 #define SDP_PDU_SERVICESEARCHATTRIBUTERESPONSE 0x07 - #define SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE 0x0000 - #define SDP_ATTRIBUTE_ID_SERVICECLASSIDS 0x0001 - #define SDP_ATTRIBUTE_ID_LANGIDOFFSET 0x0006 - #define SDP_ATTRIBUTE_ID_AVAILABILITY 0x0008 - #define SDP_ATTRIBUTE_ID_VERSION 0x0200 - #define SDP_ATTRIBUTE_ID_SERVICENAME 0x0100 - #define SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION 0x0101 - - #define SWAPENDIAN_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) - #define SWAPENDIAN_32(x) (SWAPENDIAN_16(((x) & 0xFFFF0000) >> 16) | SWAPENDIAN_16(((x) & 0x0000FFFF) << 16)) - - /** Size of a full 128 bit UUID, in bytes. */ - #define UUID_SIZE_BYTES 16 - - /** First 96 bits common to all standadized Bluetooth services. */ - #define BASE_96BIT_UUID 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00 - - /** Terminator for a service attribute table of type \ref ServiceAttributeTable_t. */ - #define SERVICE_ATTRIBUTE_TABLE_TERMINATOR {.Data = NULL} - /* Enums: */ /** Data sizes for SDP Data Element headers, to indicate the size of the data contained in the element. When creating * a Data Element, a value from this enum should be ORed with a value from the \ref ServiceDiscovery_DataTypes_t enum. @@ -117,52 +103,6 @@ uint16_t ParameterLength; /**< Length of the data following the SDP header */ } SDP_PDUHeader_t; - /** Structure for the association of attribute ID values to an attribute value in FLASH. A table of these - * structures can then be built up for each supported UUID service within the device. - */ - typedef struct - { - uint16_t AttributeID; /**< Attribute ID of the table element which the UUID service supports */ - const void* Data; /**< Pointer to the attribute data, located in PROGMEM memory space */ - } ServiceAttributeTable_t; - - /** Structure for the association of service UUID values to attribute tables stored in FLASH. A table of these - * structures can then be built up for each supported UUID service within the device. - */ - typedef struct - { - uint8_t UUID[UUID_SIZE_BYTES]; /**< UUID of a service supported by the device */ - const void* AttributeTable; /**< Pointer to the UUID's attribute table, located in PROGMEM memory space */ - } ServiceTable_t; - - /** Structure for a list of Data Elements containing UUIDs, for service attributes requiring UUID lists. */ - typedef struct - { - uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit) */ - uint8_t UUID[UUID_SIZE_BYTES]; /**< UUID to store in the list Data Element */ - } ClassUUID_t; - - /** Structure for a list of Data Elements containing 8-bit integers, for service attributes requiring such lists. */ - typedef struct - { - uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_8Bit) */ - uint8_t Value; /**< Value to store in the list Data Element */ - } Item8Bit_t; - - /** Structure for a list of Data Elements containing 16-bit integers, for service attributes requiring such lists. */ - typedef struct - { - uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit) */ - uint16_t Value; /**< Value to store in the list Data Element */ - } Item16Bit_t; - - /** Structure for a list of Data Elements containing 32-bit integers, for service attributes requiring such lists. */ - typedef struct - { - uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_32Bit) */ - uint32_t Value; /**< Value to store in the list Data Element */ - } Item32Bit_t; - /* Inline Functions: */ /** Adds a new Data Element container of the given type with a 16-bit size header to the buffer. The * buffer pointer's position is advanced past the added header once the element has been added. The diff --git a/Demos/Host/Incomplete/BluetoothHost/makefile b/Demos/Host/Incomplete/BluetoothHost/makefile index ab535f9065..76571f8bda 100644 --- a/Demos/Host/Incomplete/BluetoothHost/makefile +++ b/Demos/Host/Incomplete/BluetoothHost/makefile @@ -136,6 +136,7 @@ SRC = $(TARGET).c \ Lib/BluetoothHCICommands.c \ Lib/BluetoothACLPackets.c \ Lib/ServiceDiscoveryProtocol.c \ + Lib/SDPServices.c \ $(LUFA_PATH)/LUFA/Drivers/Peripheral/SerialStream.c \ $(LUFA_PATH)/LUFA/Drivers/Peripheral/Serial.c \ $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \ diff --git a/LUFA.pnproj b/LUFA.pnproj index c34faf9c3a..22c051037b 100644 --- a/LUFA.pnproj +++ b/LUFA.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file