96401c010d24492e3ea81d6153a2c83ddda9f264
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / Lib / SDPServices.c
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 #include "SDPServices.h"
32
33 /* ------------------------------ SDP SERVICE ATTRIBUTES ------------------------------ */
34
35 const struct
36 {
37 uint8_t Header;
38 uint32_t Data;
39 } PROGMEM SDP_Attribute_ServiceHandle =
40 {
41 (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_32Bit),
42 SWAPENDIAN_32(0x00010000),
43 };
44
45 const struct
46 {
47 uint8_t Header;
48 uint16_t Size;
49 ItemUUID_t UUIDList[];
50 } PROGMEM SDP_Attribute_ServiceClassIDs =
51 {
52 (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit),
53 SWAPENDIAN_16(sizeof(ItemUUID_t) * 1),
54 {
55 {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), SDP_CLASS_UUID}
56 }
57 };
58
59 const struct
60 {
61 uint8_t Header;
62 uint8_t Size;
63 Item16Bit_t VersionList[];
64 } PROGMEM SDP_Attribute_Version =
65 {
66 (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),
67 (sizeof(Item16Bit_t) * 1),
68 {
69 {(SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit), SWAPENDIAN_16(0x0100)}
70 }
71 };
72
73 const struct
74 {
75 uint8_t Header;
76 uint8_t Size;
77 char Text[];
78 } PROGMEM SDP_Attribute_ServiceName =
79 {
80 (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit),
81 (sizeof("SDP") - 1),
82 "SDP",
83 };
84
85 const struct
86 {
87 uint8_t Header;
88 uint8_t Size;
89 char Text[];
90 } PROGMEM SDP_Attribute_ServiceDescription =
91 {
92 (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit),
93 (sizeof("Service Discovery Protocol Server") - 1),
94 "Service Discovery Protocol Server",
95 };
96
97 /** Service Discovery Protocol attribute table, listing all supported attributes of the service. */
98 const ServiceAttributeTable_t SDP_Attribute_Table[] PROGMEM =
99 {
100 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &SDP_Attribute_ServiceHandle },
101 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &SDP_Attribute_ServiceClassIDs },
102 {.AttributeID = SDP_ATTRIBUTE_ID_VERSION, .Data = &SDP_Attribute_Version },
103 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &SDP_Attribute_ServiceName },
104 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &SDP_Attribute_ServiceDescription },
105
106 SERVICE_ATTRIBUTE_TABLE_TERMINATOR
107 };
108
109
110 /* ------------------------------ RFCOMM SERVICE ATTRIBUTES ------------------------------ */
111
112
113 const struct
114 {
115 uint8_t Header;
116 uint32_t Data;
117 } PROGMEM RFCOMM_Attribute_ServiceHandle =
118 {
119 (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_32Bit),
120 SWAPENDIAN_32(0x00010001),
121 };
122
123 const struct
124 {
125 uint8_t Header;
126 uint16_t Size;
127 ItemUUID_t UUIDList[];
128 } PROGMEM RFCOMM_Attribute_ServiceClassIDs =
129 {
130 (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit),
131 SWAPENDIAN_16(sizeof(ItemUUID_t) * 1),
132 {
133 {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), SP_CLASS_UUID}
134 }
135 };
136
137 const struct
138 {
139 uint8_t Header;
140 uint16_t Size;
141
142 ItemProtocol_t ProtocolList[];
143 } PROGMEM RFCOMM_Attribute_ProtocolDescriptor =
144 {
145 (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit),
146 SWAPENDIAN_16(sizeof(ItemProtocol_t) * 2),
147 {
148 {
149 (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),
150 sizeof(UUID_t),
151 {
152 {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), L2CAP_UUID},
153 }
154 },
155 {
156 (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),
157 sizeof(UUID_t),
158 {
159 {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), RFCOMM_UUID},
160 }
161 }
162 }
163 };
164
165 const struct
166 {
167 uint8_t Header;
168 uint8_t Size;
169 char Text[];
170 } PROGMEM RFCOMM_Attribute_ServiceName =
171 {
172 (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit),
173 sizeof("Serial Port") - 1,
174 "Serial Port",
175 };
176
177 const struct
178 {
179 uint8_t Header;
180 uint8_t Size;
181 char Text[];
182 } PROGMEM RFCOMM_Attribute_ServiceDescription =
183 {
184 (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit),
185 sizeof("Wireless Serial Port Service") - 1,
186 "Wireless Serial Port Service",
187 };
188
189 const ServiceAttributeTable_t RFCOMM_Attribute_Table[] PROGMEM =
190 {
191 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &RFCOMM_Attribute_ServiceHandle },
192 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &RFCOMM_Attribute_ServiceClassIDs },
193 {.AttributeID = SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST, .Data = &RFCOMM_Attribute_ProtocolDescriptor },
194 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &RFCOMM_Attribute_ServiceName },
195 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &RFCOMM_Attribute_ServiceDescription },
196
197 SERVICE_ATTRIBUTE_TABLE_TERMINATOR
198 };
199
200
201 /* ------------------------------ L2CAP SERVICE ATTRIBUTES ------------------------------ */
202
203
204 const struct
205 {
206 uint8_t Header;
207 uint32_t Data;
208 } PROGMEM L2CAP_Attribute_ServiceHandle =
209 {
210 (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_32Bit),
211 SWAPENDIAN_32(0x00010002),
212 };
213
214 const struct
215 {
216 uint8_t Header;
217 uint16_t Size;
218 ItemUUID_t UUIDList[];
219 } PROGMEM L2CAP_Attribute_ServiceClassIDs =
220 {
221 (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit),
222 SWAPENDIAN_16(sizeof(ItemUUID_t) * 2),
223 {
224 {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), SDP_CLASS_UUID },
225 {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), SP_CLASS_UUID },
226 }
227 };
228
229 const struct
230 {
231 uint8_t Header;
232 uint16_t Size;
233
234 ItemProtocol_t ProtocolList[];
235 } PROGMEM L2CAP_Attribute_ProtocolDescriptor =
236 {
237 (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable16Bit),
238 SWAPENDIAN_16(sizeof(ItemProtocol_t) * 2),
239 {
240 {
241 (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),
242 sizeof(UUID_t),
243 {
244 {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), L2CAP_UUID},
245 }
246 },
247 {
248 (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit),
249 sizeof(UUID_t),
250 {
251 {(SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit), RFCOMM_UUID},
252 }
253 }
254 }
255 };
256
257 const struct
258 {
259 uint8_t Header;
260 uint8_t Size;
261 char Text[];
262 } PROGMEM L2CAP_Attribute_ServiceName =
263 {
264 (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit),
265 sizeof("L2CAP") - 1,
266 "L2CAP",
267 };
268
269 const struct
270 {
271 uint8_t Header;
272 uint8_t Size;
273 char Text[];
274 } PROGMEM L2CAP_Attribute_ServiceDescription =
275 {
276 (SDP_DATATYPE_String | SDP_DATASIZE_Variable8Bit),
277 sizeof("Logical Link Layer") - 1,
278 "Logical Link Layer",
279 };
280
281 const ServiceAttributeTable_t L2CAP_Attribute_Table[] PROGMEM =
282 {
283 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE, .Data = &L2CAP_Attribute_ServiceHandle },
284 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICECLASSIDS, .Data = &L2CAP_Attribute_ServiceClassIDs },
285 {.AttributeID = SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST, .Data = &L2CAP_Attribute_ProtocolDescriptor },
286 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICENAME, .Data = &L2CAP_Attribute_ServiceName },
287 {.AttributeID = SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION, .Data = &L2CAP_Attribute_ServiceDescription },
288
289 SERVICE_ATTRIBUTE_TABLE_TERMINATOR
290 };