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 40 #if defined __cplusplus 41 extern "C" { 42 #endif 43 44 #include <stdint.h> 45 #include <stdio.h> 46 #include <stdlib.h> 47 #include <string.h> 48 49 #include "btstack_defines.h" 50 51 //------------------------------------------------------------------------------------------------------------ 52 // goep_client.h 53 // 54 // Communicate with remote OBEX server - General Object Exchange 55 // 56 57 /* API_START */ 58 59 /** 60 * Setup GOEP Client 61 */ 62 void goep_client_init(void); 63 64 /* 65 * @brief Create GOEP connection to a GEOP server with specified UUID on a remote deivce. 66 * @param handler 67 * @param addr 68 * @param uuid 69 * @param out_cid to use for further commands 70 * @result status 71 */ 72 uint8_t goep_client_create_connection(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t uuid, uint16_t * out_cid); 73 74 /** 75 * @brief Disconnects GOEP connection with given identifier. 76 * @param gope_cid 77 * @return status 78 */ 79 uint8_t goep_client_disconnect(uint16_t goep_cid); 80 81 /** 82 * @brief Request emission of GOEP_SUBEVENT_CAN_SEND_NOW as soon as possible 83 * @note GOEP_SUBEVENT_CAN_SEND_NOW might be emitted during call to this function 84 * so packet handler should be ready to handle it 85 * @param goep_cid 86 */ 87 void goep_client_request_can_send_now(uint16_t goep_cid); 88 89 /** 90 * @brief Get Opcode from last created request, needed for parsing of OBEX response packet 91 * @param gope_cid 92 * @return opcode 93 */ 94 uint8_t goep_client_get_request_opcode(uint16_t goep_cid); 95 96 /** 97 * @brief Set Connection ID used for newly created requests 98 * @param gope_cid 99 */ 100 void goep_client_set_connection_id(uint16_t goep_cid, uint32_t connection_id); 101 102 /** 103 * @brief Start Connect request 104 * @param gope_cid 105 * @param obex_version_number 106 * @param flags 107 * @param maximum_obex_packet_length 108 */ 109 void goep_client_create_connect_request(uint16_t goep_cid, uint8_t obex_version_number, uint8_t flags, uint16_t maximum_obex_packet_length); 110 111 /** 112 * @brief Start Get request 113 * @param gope_cid 114 */ 115 void goep_client_create_get_request(uint16_t goep_cid); 116 117 /** 118 * @brief Start Set Path request 119 * @param gope_cid 120 */ 121 void goep_client_create_set_path_request(uint16_t goep_cid, uint8_t flags); 122 123 // not implemented yet 124 // void goep_client_create_put(uint16_t goep_cid); 125 126 /** 127 * @brief Add name header to current request 128 * @param goep_cid 129 * @param name 130 */ 131 void goep_client_add_header_name(uint16_t goep_cid, const char * name); 132 133 /** 134 * @brief Add target header to current request 135 * @param goep_cid 136 * @param target 137 */ 138 void goep_client_add_header_target(uint16_t goep_cid, uint16_t length, const uint8_t * target); 139 140 /** 141 * @brief Add type header to current request 142 * @param goep_cid 143 * @param type 144 */ 145 void goep_client_add_header_type(uint16_t goep_cid, const char * type); 146 147 /** 148 * @brief Add count header to current request 149 * @param goep_cid 150 * @param count 151 */ 152 void goep_client_add_header_count(uint16_t goep_cid, uint32_t count); 153 154 /** 155 * @brief Add application parameters header to current request 156 * @param goep_cid 157 * @param lenght of application parameters 158 * @param daa 159 */ 160 void goep_client_add_header_application_parameters(uint16_t goep_cid, uint16_t length, uint8_t * data); 161 162 // int goep_client_add_body_static(uint16_t goep_cid, uint32_t length, uint8_t * data); 163 // int goep_client_add_body_dynamic(uint16_t goep_cid, uint32_t length, void (*data_callback)(uint32_t offset, uint8_t * buffer, uint32_t len)); 164 165 /** 166 * @brief Execute prepared request 167 * @param goep_cid 168 * @param daa 169 */ 170 int goep_client_execute(uint16_t goep_cid); 171 172 /* API_END */ 173 174 #if defined __cplusplus 175 } 176 #endif 177 #endif