xref: /btstack/src/classic/goep_client.h (revision cd5f23a3250874824c01a2b3326a9522fea3f99f)
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 <stdlib.h>
46 #include <string.h>
47 
48 #include "btstack_defines.h"
49 
50 //------------------------------------------------------------------------------------------------------------
51 // goep_client.h
52 //
53 // Communicate with remote OBEX server - General Object Exchange
54 //
55 
56 /* API_START */
57 
58 // remote does not expose PBAP features in SDP record
59 #define PBAP_FEATURES_NOT_PRESENT ((uint32_t) -1)
60 
61 /**
62  * Setup GOEP Client
63  */
64 void goep_client_init(void);
65 
66 /*
67  * @brief Create GOEP connection to a GEOP server with specified UUID on a remote deivce.
68  * @param handler
69  * @param addr
70  * @param uuid
71  * @param out_cid to use for further commands
72  * @result status
73 */
74 uint8_t goep_client_create_connection(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t uuid, uint16_t * out_cid);
75 
76 /**
77  * @brief Disconnects GOEP connection with given identifier.
78  * @param goep_cid
79  * @return status
80  */
81 uint8_t goep_client_disconnect(uint16_t goep_cid);
82 
83 /**
84  * @brief Request emission of GOEP_SUBEVENT_CAN_SEND_NOW as soon as possible
85  * @note GOEP_SUBEVENT_CAN_SEND_NOW might be emitted during call to this function
86  *       so packet handler should be ready to handle it
87  * @param goep_cid
88  */
89 void goep_client_request_can_send_now(uint16_t goep_cid);
90 
91 /**
92  * @brief Get Opcode from last created request, needed for parsing of OBEX response packet
93  * @param goep_cid
94  * @return opcode
95  */
96 uint8_t goep_client_get_request_opcode(uint16_t goep_cid);
97 
98 /**
99  * brief Get PBAP Supported Features found in SDP record during connect
100  */
101 uint32_t goep_client_get_pbap_supported_features(uint16_t goep_cid);
102 
103 /**
104  * @brief Set Connection ID used for newly created requests
105  * @param goep_cid
106  */
107 void goep_client_set_connection_id(uint16_t goep_cid, uint32_t connection_id);
108 
109 /**
110  * @brief Start Connect request
111  * @param goep_cid
112  * @param obex_version_number
113  * @param flags
114  * @param maximum_obex_packet_length
115  */
116 void goep_client_request_create_connect(uint16_t goep_cid, uint8_t obex_version_number, uint8_t flags, uint16_t maximum_obex_packet_length);
117 
118 /**
119  * @brief Start Disconnect request
120  * @param goep_cid
121  */
122 void goep_client_request_create_disconnect(uint16_t goep_cid);
123 
124 /**
125  * @brief Create Get request
126  * @param goep_cid
127  */
128 void goep_client_request_create_get(uint16_t goep_cid);
129 
130 /**
131  * @brief Create Abort request
132  * @param goep_cid
133  */
134 void goep_client_request_create_abort(uint16_t goep_cid);
135 
136 /**
137  * @brief Start Set Path request
138  * @param goep_cid
139  */
140 void goep_client_request_create_set_path(uint16_t goep_cid, uint8_t flags);
141 
142 /**
143  * @brief Create Put request
144  * @param goep_cid
145  */
146 void goep_client_request_create_put(uint16_t goep_cid);
147 
148 /**
149  * @brief Add SRM Enable
150  * @param goep_cid
151  */
152 void goep_client_header_add_srm_enable(uint16_t goep_cid);
153 
154 /**
155  * @brief Add header with single byte value (8 bit)
156  * @param goep_cid
157  * @param header_type
158  * @param value
159  */
160 void goep_client_header_add_byte(uint16_t goep_cid, uint8_t header_type, uint8_t value);
161 
162 /**
163  * @brief Add header with word value (32 bit)
164  * @param goep_cid
165  * @param header_type
166  * @param value
167  */
168 void goep_client_header_add_word(uint16_t goep_cid, uint8_t header_type, uint32_t value);
169 
170 /**
171  * @brief Add header with variable size
172  * @param goep_cid
173  * @param header_type
174  * @param header_data
175  * @param header_data_length
176  */
177 void goep_client_header_add_variable(uint16_t goep_cid, uint8_t header_type, const uint8_t * header_data, uint16_t header_data_length);
178 
179 /**
180  * @brief Add name header to current request
181  * @param goep_cid
182  * @param name
183  */
184 void goep_client_header_add_name(uint16_t goep_cid, const char * name);
185 
186 /**
187  * @brief Add target header to current request
188  * @param goep_cid
189  * @param target
190  * @param length of target
191  */
192 void goep_client_header_add_target(uint16_t goep_cid, const uint8_t * target, uint16_t length);
193 
194 /**
195  * @brief Add type header to current request
196  * @param goep_cid
197  * @param type
198  */
199 void goep_client_header_add_type(uint16_t goep_cid, const char * type);
200 
201 /**
202  * @brief Add count header to current request
203  * @param goep_cid
204  * @param count
205  */
206 void goep_client_header_add_count(uint16_t goep_cid, uint32_t count);
207 
208 /**
209  * @brief Add application parameters header to current request
210  * @param goep_cid
211  * @param data
212  * @param lenght of application parameters
213  */
214 void goep_client_header_add_application_parameters(uint16_t goep_cid, const uint8_t * data, uint16_t length);
215 
216 /**
217  * @brief Add application parameters header to current request
218  * @param goep_cid
219  * @param data
220  * @param lenght of challenge response
221  */
222 void goep_client_header_add_challenge_response(uint16_t goep_cid, const uint8_t * data, uint16_t length);
223 
224 /**
225  * @brief Add body
226  * @param goep_cid
227  * @param data
228  * @param lenght
229  */
230 void goep_client_body_add_static(uint16_t goep_cid, const uint8_t * data, uint32_t length);
231 
232 /**
233  * @brief Execute prepared request
234  * @param goep_cid
235  * @param daa
236  */
237 int goep_client_execute(uint16_t goep_cid);
238 
239 /**
240  * @brief De-Init GOEP Client
241  */
242 void goep_client_deinit(void);
243 
244 /* API_END */
245 
246 // 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));
247 
248 #if defined __cplusplus
249 }
250 #endif
251 #endif
252 
253