xref: /btstack/src/classic/goep_client.h (revision 1b464e99afd70ddaf6b75be1ba7cc563a5f5dfd8)
1 /*
2  * Copyright (C) 2014 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  * 4. Any redistribution, use, or modification is done solely for
17  *    personal benefit and not for any commercial purpose or for
18  *    monetary gain.
19  *
20  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * Please inquire about commercial licensing options at
34  * [email protected]
35  *
36  */
37 
38 #ifndef GOEP_CLIENT_H
39 #define GOEP_CLIENT_H
40 
41 #if defined __cplusplus
42 extern "C" {
43 #endif
44 
45 #include <stdint.h>
46 #include <stdio.h>
47 #include <stdlib.h>
48 #include <string.h>
49 
50 #include "btstack_defines.h"
51 
52 //------------------------------------------------------------------------------------------------------------
53 // goep_client.h
54 //
55 // Communicate with remote OBEX server - General Object Exchange
56 //
57 
58 /* API_START */
59 
60 // remote does not expose PBAP features in SDP record
61 #define PBAP_FEATURES_NOT_PRESENT ((uint32_t) -1)
62 
63 /**
64  * Setup GOEP Client
65  */
66 void goep_client_init(void);
67 
68 /*
69  * @brief Create GOEP connection to a GEOP server with specified UUID on a remote deivce.
70  * @param handler
71  * @param addr
72  * @param uuid
73  * @param out_cid to use for further commands
74  * @result status
75 */
76 uint8_t goep_client_create_connection(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t uuid, uint16_t * out_cid);
77 
78 /**
79  * @brief Disconnects GOEP connection with given identifier.
80  * @param goep_cid
81  * @return status
82  */
83 uint8_t goep_client_disconnect(uint16_t goep_cid);
84 
85 /**
86  * @brief Request emission of GOEP_SUBEVENT_CAN_SEND_NOW as soon as possible
87  * @note GOEP_SUBEVENT_CAN_SEND_NOW might be emitted during call to this function
88  *       so packet handler should be ready to handle it
89  * @param goep_cid
90  */
91 void goep_client_request_can_send_now(uint16_t goep_cid);
92 
93 /**
94  * @brief Get Opcode from last created request, needed for parsing of OBEX response packet
95  * @param goep_cid
96  * @return opcode
97  */
98 uint8_t goep_client_get_request_opcode(uint16_t goep_cid);
99 
100 /**
101  * brief Get PBAP Supported Features found in SDP record during connect
102  */
103 uint32_t goep_client_get_pbap_supported_features(uint16_t goep_cid);
104 
105 /**
106  * @brief Set Connection ID used for newly created requests
107  * @param goep_cid
108  */
109 void goep_client_set_connection_id(uint16_t goep_cid, uint32_t connection_id);
110 
111 /**
112  * @brief Start Connect request
113  * @param goep_cid
114  * @param obex_version_number
115  * @param flags
116  * @param maximum_obex_packet_length
117  */
118 void goep_client_request_create_connect(uint16_t goep_cid, uint8_t obex_version_number, uint8_t flags, uint16_t maximum_obex_packet_length);
119 
120 /**
121  * @brief Start Disconnect request
122  * @param goep_cid
123  */
124 void goep_client_request_create_disconnect(uint16_t goep_cid);
125 
126 /**
127  * @brief Create Get request
128  * @param goep_cid
129  */
130 void goep_client_request_create_get(uint16_t goep_cid);
131 
132 /**
133  * @brief Create Abort request
134  * @param goep_cid
135  */
136 void goep_client_request_create_abort(uint16_t goep_cid);
137 
138 /**
139  * @brief Start Set Path request
140  * @param goep_cid
141  */
142 void goep_client_request_create_set_path(uint16_t goep_cid, uint8_t flags);
143 
144 /**
145  * @brief Create Put request
146  * @param goep_cid
147  */
148 void goep_client_request_create_put(uint16_t goep_cid);
149 
150 /**
151  * @brief Add SRM Enable
152  * @param goep_cid
153  */
154 void goep_client_header_add_srm_enable(uint16_t goep_cid);
155 
156 /**
157  * @brief Add header with single byte value (8 bit)
158  * @param goep_cid
159  * @param header_type
160  * @param value
161  */
162 void goep_client_header_add_byte(uint16_t goep_cid, uint8_t header_type, uint8_t value);
163 
164 /**
165  * @brief Add header with word value (32 bit)
166  * @param goep_cid
167  * @param header_type
168  * @param value
169  */
170 void goep_client_header_add_word(uint16_t goep_cid, uint8_t header_type, uint32_t value);
171 
172 /**
173  * @brief Add header with variable size
174  * @param goep_cid
175  * @param header_type
176  * @param header_data
177  * @param header_data_length
178  */
179 void goep_client_header_add_variable(uint16_t goep_cid, uint8_t header_type, const uint8_t * header_data, uint16_t header_data_length);
180 
181 /**
182  * @brief Add name header to current request
183  * @param goep_cid
184  * @param name
185  */
186 void goep_client_header_add_name(uint16_t goep_cid, const char * name);
187 
188 /**
189  * @brief Add target header to current request
190  * @param goep_cid
191  * @param target
192  * @param length of target
193  */
194 void goep_client_header_add_target(uint16_t goep_cid, const uint8_t * target, uint16_t length);
195 
196 /**
197  * @brief Add type header to current request
198  * @param goep_cid
199  * @param type
200  */
201 void goep_client_header_add_type(uint16_t goep_cid, const char * type);
202 
203 /**
204  * @brief Add count header to current request
205  * @param goep_cid
206  * @param count
207  */
208 void goep_client_header_add_count(uint16_t goep_cid, uint32_t count);
209 
210 /**
211  * @brief Add application parameters header to current request
212  * @param goep_cid
213  * @param data
214  * @param lenght of application parameters
215  */
216 void goep_client_header_add_application_parameters(uint16_t goep_cid, const uint8_t * data, uint16_t length);
217 
218 /**
219  * @brief Add application parameters header to current request
220  * @param goep_cid
221  * @param data
222  * @param lenght of challenge response
223  */
224 void goep_client_header_add_challenge_response(uint16_t goep_cid, const uint8_t * data, uint16_t length);
225 
226 /**
227  * @brief Add body
228  * @param goep_cid
229  * @param data
230  * @param lenght
231  */
232 void goep_client_body_add_static(uint16_t goep_cid, const uint8_t * data, uint32_t length);
233 
234 /**
235  * @brief Execute prepared request
236  * @param goep_cid
237  * @param daa
238  */
239 int goep_client_execute(uint16_t goep_cid);
240 
241 /* API_END */
242 
243 // int goep_client_body_add_dynamic(uint16_t goep_cid, uint32_t length, void (*data_callback)(uint32_t offset, uint8_t * buffer, uint32_t len));
244 
245 #if defined __cplusplus
246 }
247 #endif
248 #endif
249 
250