a11850dcbb3922f094a8eb7dbdde28bf1aa3bf66
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / Lib / SDPServices.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * Header file for SDPServices.c.
34 */
35
36 #ifndef _SDPSERVICES_H_
37 #define _SDPSERVICES_H_
38
39 /* Includes: */
40 #include "ServiceDiscoveryProtocol.h"
41
42 /* Macros: */
43 /** Size of a full 128 bit UUID, in bytes. */
44 #define UUID_SIZE_BYTES 16
45
46 /** First 80 bits common to all standardized Bluetooth services. */
47 #define BASE_80BIT_UUID SWAPENDIAN_32(0xFB349B5F), SWAPENDIAN_16(0x8000), SWAPENDIAN_16(0x0080), SWAPENDIAN_16(0x0010)
48
49 #define SDP_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}
50 #define RFCOMM_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}
51 #define L2CAP_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x01, 0x00}}
52 #define UPNP_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x00, 0x10}}
53 #define SDP_CLASS_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x10, 0x00}}
54 #define SP_CLASS_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x11, 0x01}}
55 #define UPNP_CLASS_UUID {BASE_80BIT_UUID, {0x00, 0x00, 0x00, 0x00, 0x12, 0x00}}
56
57 #define SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE 0x0000
58 #define SDP_ATTRIBUTE_ID_SERVICECLASSIDS 0x0001
59 #define SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST 0x0004
60 #define SDP_ATTRIBUTE_ID_VERSION 0x0200
61 #define SDP_ATTRIBUTE_ID_SERVICENAME 0x0100
62 #define SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION 0x0101
63
64 #define SWAPENDIAN_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
65 #define SWAPENDIAN_32(x) ((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | \
66 (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24))
67
68 /** Terminator for a service attribute table of type \ref ServiceAttributeTable_t. */
69 #define SERVICE_ATTRIBUTE_TABLE_TERMINATOR {.Data = NULL}
70
71 /* Type Defines: */
72 typedef struct
73 {
74 uint32_t A;
75 uint16_t B;
76 uint16_t C;
77 uint16_t D;
78 uint8_t E[6];
79 } UUID_t;
80
81 /** Structure for the association of attribute ID values to an attribute value in FLASH. A table of these
82 * structures can then be built up for each supported UUID service within the device.
83 */
84 typedef struct
85 {
86 uint16_t AttributeID; /**< Attribute ID of the table element which the UUID service supports */
87 const void* Data; /**< Pointer to the attribute data, located in PROGMEM memory space */
88 } ServiceAttributeTable_t;
89
90 /** Structure for the association of service UUID values to attribute tables stored in FLASH. A table of these
91 * structures can then be built up for each supported UUID service within the device.
92 */
93 typedef struct
94 {
95 UUID_t UUID; /**< UUID of a service supported by the device */
96 const void* AttributeTable; /**< Pointer to the UUID's attribute table, located in PROGMEM memory space */
97 } ServiceTable_t;
98
99 /** Structure for a list of Data Elements containing 8-bit integers, for service attributes requiring such lists. */
100 typedef struct
101 {
102 uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_8Bit) */
103 uint8_t Value; /**< Value to store in the list Data Element */
104 } Item8Bit_t;
105
106 /** Structure for a list of Data Elements containing 16-bit integers, for service attributes requiring such lists. */
107 typedef struct
108 {
109 uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit) */
110 uint16_t Value; /**< Value to store in the list Data Element */
111 } Item16Bit_t;
112
113 /** Structure for a list of Data Elements containing 32-bit integers, for service attributes requiring such lists. */
114 typedef struct
115 {
116 uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_32Bit) */
117 uint32_t Value; /**< Value to store in the list Data Element */
118 } Item32Bit_t;
119
120 /** Structure for a list of Data Elements containing UUIDs, for service attributes requiring UUID lists. */
121 typedef struct
122 {
123 uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit) */
124 UUID_t UUID; /**< UUID to store in the list Data Element */
125 } ItemUUID_t;
126
127 /** Structure for a list of Data Elements Sequences containing UUID Data Elements, for service attributes requiring
128 * protocol lists.
129 */
130 typedef struct
131 {
132 uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */
133 uint8_t Size; /**< Size of the inner Data Element sequence */
134
135 struct
136 {
137 ItemUUID_t UUID; /**< UUID to store in the protocol list Data Element sequence */
138 } Protocol;
139 } ItemProtocol_t;
140
141 /* External Variables: */
142 extern const ServiceAttributeTable_t SDP_Attribute_Table[];
143 extern const ServiceAttributeTable_t RFCOMM_Attribute_Table[];
144 extern const ServiceAttributeTable_t L2CAP_Attribute_Table[];
145
146 #endif