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 // ***************************************************************************** 39 // 40 // Minimal setup for HFP Audio Gateway (AG) unit (!! UNDER DEVELOPMENT !!) 41 // 42 // ***************************************************************************** 43 44 45 #ifndef btstack_hfp_ag_h 46 #define btstack_hfp_ag_h 47 48 #include "hci.h" 49 #include "classic/sdp_query_rfcomm.h" 50 #include "classic/hfp.h" 51 52 #if defined __cplusplus 53 extern "C" { 54 #endif 55 56 /* API_START */ 57 typedef struct { 58 uint8_t type; 59 const char * number; 60 } hfp_phone_number_t; 61 62 /** 63 * @brief Create HFP Audio Gateway (AG) SDP service record. 64 */ 65 void hfp_ag_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name, uint8_t ability_to_reject_call, uint16_t supported_features);; 66 67 /** 68 * @brief Intialize HFP Audio Gateway (AG) device. 69 * TODO: move optional params into setters 70 */ 71 void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, 72 uint8_t * codecs, int codecs_nr, 73 hfp_ag_indicator_t * ag_indicators, int ag_indicators_nr, 74 hfp_generic_status_indicator_t * hf_indicators, int hf_indicators_nr, 75 const char *call_hold_services[], int call_hold_services_nr); 76 77 /** 78 * @brief Register callback for the HFP Audio Gateway (AG) client. 79 */ 80 void hfp_ag_register_packet_handler(hfp_callback_t callback); 81 82 /** 83 * @brief Establish RFCOMM connection, and perform service level connection agreement: 84 * - exchange of supported features 85 * - report Audio Gateway (AG) indicators and their status 86 * - enable indicator status update in the AG 87 * - accept the information about available codecs in the Hands-Free (HF), if sent 88 * - report own information describing the call hold and multiparty services, if possible 89 * - report which HF indicators are enabled on the AG, if possible 90 */ 91 void hfp_ag_establish_service_level_connection(bd_addr_t bd_addr); 92 93 /** 94 * @brief Release the RFCOMM channel and the audio connection between the HF and the AG. 95 * TODO: trigger release of the audio connection 96 */ 97 void hfp_ag_release_service_level_connection(bd_addr_t bd_addr); 98 99 /** 100 * @brief Report Extended Audio Gateway Error result codes in the AG. 101 * Whenever there is an error relating to the functionality of the AG as a 102 * result of AT command, the AG shall send +CME ERROR: 103 * - +CME ERROR: 0 - AG failure 104 * - +CME ERROR: 1 - no connection to phone 105 * - +CME ERROR: 3 - operation not allowed 106 * - +CME ERROR: 4 - operation not supported 107 * - +CME ERROR: 5 - PH-SIM PIN required 108 * - +CME ERROR: 10 - SIM not inserted 109 * - +CME ERROR: 11 - SIM PIN required 110 * - +CME ERROR: 12 - SIM PUK required 111 * - +CME ERROR: 13 - SIM failure 112 * - +CME ERROR: 14 - SIM busy 113 * - +CME ERROR: 16 - incorrect password 114 * - +CME ERROR: 17 - SIM PIN2 required 115 * - +CME ERROR: 18 - SIM PUK2 required 116 * - +CME ERROR: 20 - memory full 117 * - +CME ERROR: 21 - invalid index 118 * - +CME ERROR: 23 - memory failure 119 * - +CME ERROR: 24 - text string too long 120 * - +CME ERROR: 25 - invalid characters in text string 121 * - +CME ERROR: 26 - dial string too long 122 * - +CME ERROR: 27 - invalid characters in dial string 123 * - +CME ERROR: 30 - no network service 124 * - +CME ERROR: 31 - network Timeout. 125 * - +CME ERROR: 32 - network not allowed – Emergency calls only 126 */ 127 void hfp_ag_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, hfp_cme_error_t error); 128 129 /** 130 * @brief Report the change in AG's call status. 131 * Call status: 132 * - 0 = No calls (held or active) 133 * - 1 = Call is present (active or held) 134 */ 135 void hfp_ag_transfer_call_status(bd_addr_t bd_addr, hfp_call_status_t status); 136 137 /** 138 * @brief Report the change in AG's call setup status. 139 * Call setup status: 140 * - 0 = No call setup in progress 141 * - 1 = Incoming call setup in progress 142 * - 2 = Outgoing call setup in dialing state 143 * - 3 = Outgoing call setup in alerting state 144 */ 145 void hfp_ag_transfer_callsetup_status(bd_addr_t bd_addr, hfp_callsetup_status_t status); 146 147 /** 148 * @brief Report the change in AG's held call status. 149 * Held call status: 150 * - 0 = No calls held 151 * - 1 = Call is placed on hold or active/held calls are swapped 152 * - 2 = Call on hold, no active calls 153 */ 154 void hfp_ag_transfer_callheld_status(bd_addr_t bd_addr, hfp_callheld_status_t status); 155 156 /** 157 * @brief 158 */ 159 void hfp_ag_negotiate_codecs(bd_addr_t bd_addr); 160 161 /** 162 * @brief 163 */ 164 void hfp_ag_establish_audio_connection(bd_addr_t bd_addr); 165 166 /** 167 * @brief 168 */ 169 void hfp_ag_release_audio_connection(bd_addr_t bd_addr); 170 171 172 /** 173 * @brief Enable in-band ring tone 174 */ 175 void hfp_ag_set_use_in_band_ring_tone(int use_in_band_ring_tone); 176 177 /** 178 * @brief 179 */ 180 void hfp_ag_incoming_call(void); 181 182 /** 183 * @brief number is stored. 184 */ 185 void hfp_ag_set_clip(uint8_t type, const char * number); 186 187 /** 188 * @brief 189 */ 190 void hfp_ag_outgoing_call_rejected(void); 191 192 /** 193 * @brief 194 */ 195 void hfp_ag_outgoing_call_accepted(void); 196 197 /** 198 * @brief 199 */ 200 void hfp_ag_outgoing_call_ringing(void); 201 202 /** 203 * @brief 204 */ 205 void hfp_ag_outgoing_call_established(void); 206 207 /** 208 * @brief 209 */ 210 void hfp_ag_call_dropped(void); 211 212 /** 213 * @brief 214 */ 215 void hfp_ag_answer_incoming_call(void); 216 217 /** 218 * @brief 219 */ 220 void hfp_ag_join_held_call(void); 221 222 /** 223 * @brief 224 */ 225 void hfp_ag_terminate_call(void); 226 227 /* 228 * @brief 229 */ 230 void hfp_ag_set_registration_status(int status); 231 232 /* 233 * @brief 234 */ 235 void hfp_ag_set_signal_strength(int strength); 236 237 /* 238 * @brief 239 */ 240 void hfp_ag_set_roaming_status(int status); 241 242 /* 243 * @brief 244 */ 245 void hfp_ag_set_battery_level(int level); 246 247 248 /* 249 * @brief 250 */ 251 void hfp_ag_activate_voice_recognition(bd_addr_t bd_addr, int activate); 252 253 /* 254 * @brief 255 */ 256 void hfp_ag_set_microphone_gain(bd_addr_t bd_addr, int gain); 257 258 /* 259 * @brief 260 */ 261 void hfp_ag_set_speaker_gain(bd_addr_t bd_addr, int gain); 262 263 /* 264 * @brief 265 */ 266 void hfp_ag_send_phone_number_for_voice_tag(bd_addr_t bd_addr, const char * number); 267 268 /* 269 * @brief 270 */ 271 void hfp_ag_reject_phone_number_for_voice_tag(bd_addr_t bd_addr); 272 273 /* 274 * @brief 275 */ 276 void hfp_ag_send_dtmf_code_done(bd_addr_t bd_addr); 277 278 /* 279 * @brief 280 */ 281 void hfp_ag_set_subcriber_number_information(hfp_phone_number_t * numbers, int numbers_count); 282 283 /* 284 * @brief 285 */ 286 void hfp_ag_send_current_call_status(bd_addr_t bd_addr, int idx, hfp_enhanced_call_dir_t dir, 287 hfp_enhanced_call_status_t status, hfp_enhanced_call_mode_t mode, 288 hfp_enhanced_call_mpty_t mpty, uint8_t type, const char * number); 289 290 /* 291 * @brief 292 */ 293 void hfp_ag_send_current_call_status_done(bd_addr_t bd_addr); 294 295 /* 296 * @brief 297 */ 298 void hfp_ag_hold_incoming_call(void); 299 300 /* 301 * @brief 302 */ 303 void hfp_ag_accept_held_incoming_call(void); 304 305 /* 306 * @brief 307 */ 308 void hfp_ag_reject_held_incoming_call(void); 309 310 /* API_END */ 311 312 #if defined __cplusplus 313 } 314 #endif 315 316 #endif