SDPServices.h 5.47 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
             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
		
46
47
		/** 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)
48
49
50
		
		#define SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE    0x0000
		#define SDP_ATTRIBUTE_ID_SERVICECLASSIDS        0x0001
51
		#define SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST 0x0004
52
53
54
55
56
		#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))
57
58
		#define SWAPENDIAN_32(x)                        ((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | \
		                                                 (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24))
59
60
61
62
63
		
		/** Terminator for a service attribute table of type \ref ServiceAttributeTable_t. */
		#define SERVICE_ATTRIBUTE_TABLE_TERMINATOR      {.Data = NULL}
		
	/* Type Defines: */
64
65
66
67
68
69
70
71
72
		typedef struct
		{
			uint32_t A;
			uint16_t B;
			uint16_t C;
			uint16_t D;
			uint8_t  E[6];
		} UUID_t;
	
73
74
75
76
77
78
79
80
81
82
83
84
85
86
		/** 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
		{
87
			UUID_t      UUID; /**< UUID of a service supported by the device */
88
89
90
91
92
93
			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 8-bit integers, for service attributes requiring such lists. */
		typedef struct
		{
94
			uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_8Bit) */
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
			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;

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
		/** 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) */
			UUID_t  UUID; /**< UUID to store in the list Data Element */
		} ItemUUID_t;
		
		/** Structure for a list of Data Elements Sequences containing UUID Data Elements, for service attributes requiring
		 *  protocol lists.
		 */
		typedef struct
		{
			uint8_t     Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */
			uint8_t     Size; /**< Size of the inner Data Element sequence */
			
			ItemUUID_t  UUID; /**< UUID to store in the protocol list Data Element sequence */
		} ItemProtocol_t;
		
130
131
132
133
134
	/* External Variables: */
		extern const ServiceAttributeTable_t SDP_Attribute_Table[];
		extern const ServiceAttributeTable_t RFCOMM_Attribute_Table[];
		
#endif