xref: /btstack/src/classic/obex.h (revision b1b7748945861455419c67430c5d24a312163683)
1f1b34e8dSMatthias Ringwald /*
2f1b34e8dSMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
3f1b34e8dSMatthias Ringwald  *
4f1b34e8dSMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5f1b34e8dSMatthias Ringwald  * modification, are permitted provided that the following conditions
6f1b34e8dSMatthias Ringwald  * are met:
7f1b34e8dSMatthias Ringwald  *
8f1b34e8dSMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9f1b34e8dSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10f1b34e8dSMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11f1b34e8dSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12f1b34e8dSMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13f1b34e8dSMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14f1b34e8dSMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15f1b34e8dSMatthias Ringwald  *    from this software without specific prior written permission.
16f1b34e8dSMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17f1b34e8dSMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18f1b34e8dSMatthias Ringwald  *    monetary gain.
19f1b34e8dSMatthias Ringwald  *
20f1b34e8dSMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21f1b34e8dSMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22f1b34e8dSMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
232fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
242fca4dadSMilanka Ringwald  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25f1b34e8dSMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26f1b34e8dSMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27f1b34e8dSMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28f1b34e8dSMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29f1b34e8dSMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30f1b34e8dSMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31f1b34e8dSMatthias Ringwald  * SUCH DAMAGE.
32f1b34e8dSMatthias Ringwald  *
33f1b34e8dSMatthias Ringwald  * Please inquire about commercial licensing options at
34f1b34e8dSMatthias Ringwald  * [email protected]
35f1b34e8dSMatthias Ringwald  *
36f1b34e8dSMatthias Ringwald  */
37f1b34e8dSMatthias Ringwald 
3880e33422SMatthias Ringwald #ifndef OBEX_H
3980e33422SMatthias Ringwald #define OBEX_H
40f1b34e8dSMatthias Ringwald 
41d3eadd6dSMatthias Ringwald #include <stdint.h>
42d3eadd6dSMatthias Ringwald 
43378b1cb2SMatthias Ringwald // From IR OBEX V1.5 - some opcodes have high bit always set
44f1b34e8dSMatthias Ringwald #define OBEX_OPCODE_CONNECT                0x80
45f1b34e8dSMatthias Ringwald #define OBEX_OPCODE_DISCONNECT             0x81
46f1b34e8dSMatthias Ringwald #define OBEX_OPCODE_PUT                    0x02
47f1b34e8dSMatthias Ringwald #define OBEX_OPCODE_GET                    0x03
48f1b34e8dSMatthias Ringwald #define OBEX_OPCODE_SETPATH                0x85
49378b1cb2SMatthias Ringwald #define OBEX_OPCODE_ACTION                 0x06
50f1b34e8dSMatthias Ringwald #define OBEX_OPCODE_SESSION                0x87
51f1b34e8dSMatthias Ringwald #define OBEX_OPCODE_ABORT                  0xFF
52f1b34e8dSMatthias Ringwald 
53e28a217eSMatthias Ringwald #define OBEX_OPCODE_FINAL_BIT_MASK         0x80
54e28a217eSMatthias Ringwald 
55f1b34e8dSMatthias Ringwald #define OBEX_RESP_CONTINUE                 0x90
563e031d3bSMatthias Ringwald #define OBEX_RESP_SUCCESS                  0xA0
5715a62af0SMatthias Ringwald #define OBEX_RESP_BAD_REQUEST              0xC0
5815a62af0SMatthias Ringwald #define OBEX_RESP_UNAUTHORIZED             0xC1
5915a62af0SMatthias Ringwald #define OBEX_RESP_FORBIDDEN                0xC3
60f1b34e8dSMatthias Ringwald #define OBEX_RESP_NOT_FOUND                0xC4
6116ded4feSMatthias Ringwald #define OBEX_RESP_NOT_ACCEPTABLE           0xC6
6266a7447dSMatthias Ringwald #define OBEX_RESP_UNSUPPORTED_MEDIA_TYPE   0xCF
6366a7447dSMatthias Ringwald #define OBEX_RESP_ENTITY_TOO_LARGE         0xCD
6466a7447dSMatthias Ringwald #define OBEX_RESP_NOT_IMPLEMENTED          0xD1
65f1b34e8dSMatthias Ringwald 
66*b1b77489SMatthias Ringwald #define OBEX_HEADER_TYPE_16BIT_LENGTH_0       0		// 16-bit length info prefixed
67*b1b77489SMatthias Ringwald #define OBEX_HEADER_TYPE_16BIT_LENGTH_1       1		// 16-bit length info prefixed
68*b1b77489SMatthias Ringwald #define OBEX_HEADER_TYPE_8BIT_VALUE_2         2		// 8-bit Value
69*b1b77489SMatthias Ringwald #define OBEX_HEADER_TYPE_32BIT_VALUE_3       32		// 32-bit Value
70f1b34e8dSMatthias Ringwald #define OBEX_HEADER_NAME                           0x01
71f1b34e8dSMatthias Ringwald #define OBEX_HEADER_DESCRIPTION                    0x05
723e031d3bSMatthias Ringwald // user defined 0x30..0x3f: unicode string
733e031d3bSMatthias Ringwald #define OBEX_HEADER_IMG_HANDLE                     0x30
743e031d3bSMatthias Ringwald #define OBEX_HEADER_TYPE                           0x42
753e031d3bSMatthias Ringwald #define OBEX_HEADER_TIME_ISO_8601                  0x44
76f1b34e8dSMatthias Ringwald #define OBEX_HEADER_TARGET                         0x46
77f1b34e8dSMatthias Ringwald #define OBEX_HEADER_HTTP                           0x47
783e031d3bSMatthias Ringwald #define OBEX_HEADER_BODY                           0x48
793e031d3bSMatthias Ringwald #define OBEX_HEADER_END_OF_BODY                    0x49
80f1b34e8dSMatthias Ringwald #define OBEX_HEADER_WHO                            0x4A
81f1b34e8dSMatthias Ringwald #define OBEX_HEADER_APPLICATION_PARAMETERS         0x4C
82e28a217eSMatthias Ringwald #define OBEX_HEADER_AUTHENTICATION_CHALLENGE       0x4D
83e28a217eSMatthias Ringwald #define OBEX_HEADER_AUTHENTICATION_RESPONSE        0x4E
843e031d3bSMatthias Ringwald #define OBEX_HEADER_OBJECT_CLASS                   0x4F
853e031d3bSMatthias Ringwald // user defined 0x70..0x7f: byte sequence
863e031d3bSMatthias Ringwald #define OBEX_HEADER_IMG_DESCRIPTOR                 0x71
874f574fb1SMatthias Ringwald #define OBEX_HEADER_SINGLE_RESPONSE_MODE           0x97
884f574fb1SMatthias Ringwald #define OBEX_HEADER_SINGLE_RESPONSE_MODE_PARAMETER 0x98
893e031d3bSMatthias Ringwald // user defined 0xB0..0xBF: single byte
903e031d3bSMatthias Ringwald #define OBEX_HEADER_COUNT                          0xC0
913e031d3bSMatthias Ringwald #define OBEX_HEADER_LENGTH                         0xC3
923e031d3bSMatthias Ringwald #define OBEX_HEADER_TIME_4_BYTE                    0xC4
933e031d3bSMatthias Ringwald #define OBEX_HEADER_CONNECTION_ID                  0xCB
943e031d3bSMatthias Ringwald // user defined 0xF0..0xFF: 4 byte integer
95f1b34e8dSMatthias Ringwald 
96f1b34e8dSMatthias Ringwald #define OBEX_VERSION                       0x14
97f1b34e8dSMatthias Ringwald 
98f1b34e8dSMatthias Ringwald #define OBEX_PACKET_HEADER_SIZE            3
99f1b34e8dSMatthias Ringwald #define OBEX_PACKET_OPCODE_OFFSET          0
100f1b34e8dSMatthias Ringwald #define OBEX_PACKET_LENGTH_OFFSET          1
101f1b34e8dSMatthias Ringwald #define OBEX_MAX_PACKETLEN_DEFAULT         0xffff
102f1b34e8dSMatthias Ringwald 
103f1b34e8dSMatthias Ringwald #define OBEX_CONNECTION_ID_INVALID         0xFFFFFFFF
10468d80beeSMatthias Ringwald 
10568d80beeSMatthias Ringwald /* SRM header values */
10668d80beeSMatthias Ringwald #define OBEX_SRM_DISABLE                            0x00
10768d80beeSMatthias Ringwald #define OBEX_SRM_ENABLE                             0x01
10868d80beeSMatthias Ringwald #define OBEX_SRM_INDICATE                           0x02
10968d80beeSMatthias Ringwald 
110*b1b77489SMatthias Ringwald /** SRMP header values
111*b1b77489SMatthias Ringwald * BLUETOOTH SPECIFICATION Generic Object Exchange Profile (GOEP) v1.1.1 page 16
112*b1b77489SMatthias Ringwald * 4.6.1 MP Use Cases
113*b1b77489SMatthias Ringwald * The SRMP header shall support the following two use cases. Both cases utilize the
114*b1b77489SMatthias Ringwald * SRMP “wait” option (0x01). At this time no valid use cases exist for the SRMP
115*b1b77489SMatthias Ringwald * “additional request” (0x00) and “additional request + wait” (0x02) options, therefore they
116*b1b77489SMatthias Ringwald * shall not be used.
117*b1b77489SMatthias Ringwald */
118*b1b77489SMatthias Ringwald #define OBEX_SRMP_NEXT                              0x00 // should not be sent
119*b1b77489SMatthias Ringwald #define OBEX_SRMP_WAIT                              0x01 // only viable option to be sent
120*b1b77489SMatthias Ringwald #define OBEX_SRMP_NEXT_WAIT                         0x02 // should not be sent
12168d80beeSMatthias Ringwald 
122*b1b77489SMatthias Ringwald /* SETPATH header Values */
123*b1b77489SMatthias Ringwald #define OBEX_SP_BIT0_DIR_UP							0x01
124*b1b77489SMatthias Ringwald #define OBEX_SP_BIT1_DONT_CREATE_DIR	     		0x02
125f1b34e8dSMatthias Ringwald 
126e69ef764SMatthias Ringwald /**
127e69ef764SMatthias Ringwald  * PBAP
128e69ef764SMatthias Ringwald  */
129e69ef764SMatthias Ringwald 
130e69ef764SMatthias Ringwald // PBAP Application Parameters Tag IDs
131e69ef764SMatthias Ringwald 
132e69ef764SMatthias Ringwald // Order - 0x01 - 1 byte: 0x00 = indexed 0x01 = alphanumeric 0x02 = phonetic
133e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_ORDER 0x01
134e69ef764SMatthias Ringwald // SearchValue - 0x02 - variable - Text
135e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_SEARCH_VALUE 0x02
136e69ef764SMatthias Ringwald // SearchProperty - 0x03 - 1 byte - 0x00= Name 0x01= Number 0x02= Sound
137e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_SEARCH_PROPERTY 0x03
138e69ef764SMatthias Ringwald // MaxListCount - 0x04 - 2 bytes - 0x0000 to 0xFFFF
139e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_MAX_LIST_COUNT 0x04
140e69ef764SMatthias Ringwald // ListStartOffset - 0x05 - 2 bytes - 0x0000 to 0xFFFF
141e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_LIST_START_OFFSET 0x05
142e69ef764SMatthias Ringwald // PropertySelector - 0x06 - 8 bytes - 64 bits mask
143e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_PROPERTY_SELECTOR 0x06
144e69ef764SMatthias Ringwald // Format - 0x07 - 1 byte - 0x00 = 2.1 0x01 = 3.0
145e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_FORMAT 0x07
146e69ef764SMatthias Ringwald // PhonebookSize - 0x08 - 2 bytes - 0x0000 to 0xFFFF
147e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_PHONEBOOK_SIZE 0x08
148e69ef764SMatthias Ringwald // NewMissedCalls - 0x09 - 1 byte - 0x00 to 0xFF
149e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_NEW_MISSED_CALLS 0x09
150e69ef764SMatthias Ringwald // PrimaryVersionCounter - 0x0A - 16 bytes - 0 to (2128 – 1)
151e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_PRIMARY_VERSION_COUNTER 0x0A
152e69ef764SMatthias Ringwald // SecondaryVersionCounter - 0x0B - 16 bytes - 0 to (2128 – 1)
153e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_SECONDARY_VERSION_COUNTER 0x0B
154e69ef764SMatthias Ringwald // vCardSelector - 0x0C - 8 bytes - 64 bits mask
155e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_VCARD_SELECTOR 0x0C
156e69ef764SMatthias Ringwald // DatabaseIdentifier - 0x0D - 16 bytes - 0 to (2128 – 1)
157e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_DATABASE_IDENTIFIER 0x0D
158e69ef764SMatthias Ringwald // vCardSelectorOperator - 0x0E - 1 byte - 0x00 = OR 0x01 = AND
159e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_VCARD_SELECTOR_OPERATOR 0x0E
160e69ef764SMatthias Ringwald // ResetNewMissedCalls -   0x0F -  1 byte
161e69ef764SMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_RESET_NEW_MISSED_CALLS 0x0F
162bca6857aSMatthias Ringwald // PbapSupportedFeatures - 0x10 - 4 bytes
163bca6857aSMatthias Ringwald #define PBAP_APPLICATION_PARAMETER_PBAP_SUPPORTED_FEATURES 0x10
164e69ef764SMatthias Ringwald 
165ba008c5fSMatthias Ringwald /**
166ba008c5fSMatthias Ringwald  * MAP
167ba008c5fSMatthias Ringwald  */
168ba008c5fSMatthias Ringwald 
169ba008c5fSMatthias Ringwald // MAP Application Parameters Tag IDs
170*b1b77489SMatthias Ringwald //#define MAP_APPLICATION_PARAMETER_MAX_LIST_COUNT			0x01
171*b1b77489SMatthias Ringwald //#define MAP_APPLICATION_PARAMETER_ATTACHEMENT				0x0A
172*b1b77489SMatthias Ringwald //#define MAP_APPLICATION_PARAMETER_PARAMETER_MASK			0x10
173*b1b77489SMatthias Ringwald //#define MAP_APPLICATION_PARAMETER_CHARSET					0x14
174*b1b77489SMatthias Ringwald //#define MAP_APPLICATION_PARAMETER_STATUS_INDICATOR			0x17
175*b1b77489SMatthias Ringwald //#define MAP_APPLICATION_PARAMETER_STATUS_VALUE				0x18
176*b1b77489SMatthias Ringwald //#define MAP_APPLICATION_PARAMETER_MAP_SUPPORTED_FEATURES	0x29
177ba008c5fSMatthias Ringwald 
178d3eadd6dSMatthias Ringwald 
179f1b34e8dSMatthias Ringwald #endif
180