xref: /btstack/src/classic/hfp_hf.h (revision 9b1c3b4d7d0a803905c88f4526948289db492cfd)
13deb3ec6SMatthias Ringwald /*
23deb3ec6SMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
33deb3ec6SMatthias Ringwald  *
43deb3ec6SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
53deb3ec6SMatthias Ringwald  * modification, are permitted provided that the following conditions
63deb3ec6SMatthias Ringwald  * are met:
73deb3ec6SMatthias Ringwald  *
83deb3ec6SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
93deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
103deb3ec6SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
113deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
123deb3ec6SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
133deb3ec6SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
143deb3ec6SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
153deb3ec6SMatthias Ringwald  *    from this software without specific prior written permission.
163deb3ec6SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
173deb3ec6SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
183deb3ec6SMatthias Ringwald  *    monetary gain.
193deb3ec6SMatthias Ringwald  *
203deb3ec6SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
213deb3ec6SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
223deb3ec6SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
233deb3ec6SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
243deb3ec6SMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
253deb3ec6SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
263deb3ec6SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
273deb3ec6SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
283deb3ec6SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
293deb3ec6SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
303deb3ec6SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
313deb3ec6SMatthias Ringwald  * SUCH DAMAGE.
323deb3ec6SMatthias Ringwald  *
333deb3ec6SMatthias Ringwald  * Please inquire about commercial licensing options at
343deb3ec6SMatthias Ringwald  * [email protected]
353deb3ec6SMatthias Ringwald  *
363deb3ec6SMatthias Ringwald  */
373deb3ec6SMatthias Ringwald 
383deb3ec6SMatthias Ringwald // *****************************************************************************
393deb3ec6SMatthias Ringwald //
403deb3ec6SMatthias Ringwald //  Minimal setup for HFP Hands-Free (HF) unit (!! UNDER DEVELOPMENT !!)
413deb3ec6SMatthias Ringwald //
423deb3ec6SMatthias Ringwald // *****************************************************************************
433deb3ec6SMatthias Ringwald 
443deb3ec6SMatthias Ringwald 
453deb3ec6SMatthias Ringwald #ifndef btstack_hfp_hf_h
463deb3ec6SMatthias Ringwald #define btstack_hfp_hf_h
473deb3ec6SMatthias Ringwald 
483deb3ec6SMatthias Ringwald #include "hci.h"
493edc84c5SMatthias Ringwald #include "classic/sdp_query_rfcomm.h"
503edc84c5SMatthias Ringwald #include "classic/hfp.h"
513deb3ec6SMatthias Ringwald 
523deb3ec6SMatthias Ringwald #if defined __cplusplus
533deb3ec6SMatthias Ringwald extern "C" {
543deb3ec6SMatthias Ringwald #endif
553deb3ec6SMatthias Ringwald 
563deb3ec6SMatthias Ringwald /* API_START */
573deb3ec6SMatthias Ringwald 
583deb3ec6SMatthias Ringwald 
593deb3ec6SMatthias Ringwald /**
603deb3ec6SMatthias Ringwald  * @brief Create HFP Hands-Free (HF) SDP service record.
613deb3ec6SMatthias Ringwald  */
62*9b1c3b4dSMatthias Ringwald void hfp_hf_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name, uint16_t supported_features);
633deb3ec6SMatthias Ringwald 
643deb3ec6SMatthias Ringwald /**
653deb3ec6SMatthias Ringwald  * @brief Intialize HFP Hands-Free (HF) device.
663deb3ec6SMatthias Ringwald  * TODO:  move optional params into setters
673deb3ec6SMatthias Ringwald  */
683deb3ec6SMatthias Ringwald void hfp_hf_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, uint16_t * indicators, int indicators_nr, uint32_t indicators_status);
693deb3ec6SMatthias Ringwald void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr);
703deb3ec6SMatthias Ringwald 
713deb3ec6SMatthias Ringwald /**
723deb3ec6SMatthias Ringwald  * @brief Register callback for the HFP Hands-Free (HF) client.
733deb3ec6SMatthias Ringwald  */
743deb3ec6SMatthias Ringwald void hfp_hf_register_packet_handler(hfp_callback_t callback);
753deb3ec6SMatthias Ringwald 
763deb3ec6SMatthias Ringwald /**
773deb3ec6SMatthias Ringwald  * @brief Establish RFCOMM connection, and perform service level connection agreement:
783deb3ec6SMatthias Ringwald  * - exchange of supported features
793deb3ec6SMatthias Ringwald  * - retrieve Audio Gateway (AG) indicators and their status
803deb3ec6SMatthias Ringwald  * - enable indicator status update in the AG
813deb3ec6SMatthias Ringwald  * - notify the AG about its own available codecs, if possible
823deb3ec6SMatthias Ringwald  * - retrieve the AG information describing the call hold and multiparty services, if possible
833deb3ec6SMatthias Ringwald  * - retrieve which HF indicators are enabled on the AG, if possible
843deb3ec6SMatthias Ringwald  */
853deb3ec6SMatthias Ringwald void hfp_hf_establish_service_level_connection(bd_addr_t bd_addr);
863deb3ec6SMatthias Ringwald 
873deb3ec6SMatthias Ringwald 
883deb3ec6SMatthias Ringwald /**
893deb3ec6SMatthias Ringwald  * @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
903deb3ec6SMatthias Ringwald  * TODO: trigger release of the audio connection
913deb3ec6SMatthias Ringwald  */
923deb3ec6SMatthias Ringwald void hfp_hf_release_service_level_connection(bd_addr_t bd_addr);
933deb3ec6SMatthias Ringwald 
943deb3ec6SMatthias Ringwald /**
953deb3ec6SMatthias Ringwald  * @brief Deactivate/reactivate status update for all indicators in the AG.
963deb3ec6SMatthias Ringwald  */
973deb3ec6SMatthias Ringwald void hfp_hf_enable_status_update_for_all_ag_indicators(bd_addr_t bd_addr, uint8_t enable);
983deb3ec6SMatthias Ringwald 
993deb3ec6SMatthias Ringwald /**
1003deb3ec6SMatthias Ringwald  * @brief Deactivate/reactivate status update for the individual indicators in the AG using bitmap.
1013deb3ec6SMatthias Ringwald  */
1023deb3ec6SMatthias Ringwald void hfp_hf_enable_status_update_for_individual_ag_indicators(bd_addr_t bd_addr, uint32_t indicators_status_bitmap);
1033deb3ec6SMatthias Ringwald 
1043deb3ec6SMatthias Ringwald 
1053deb3ec6SMatthias Ringwald /**
1063deb3ec6SMatthias Ringwald  * @brief Find out the name of the currently selected Network operator by AG.
1073deb3ec6SMatthias Ringwald  * The name is restricted to max 16 characters.
1083deb3ec6SMatthias Ringwald  */
1093deb3ec6SMatthias Ringwald void hfp_hf_query_operator_selection(bd_addr_t bd_addr);
1103deb3ec6SMatthias Ringwald 
1113deb3ec6SMatthias Ringwald /**
1123deb3ec6SMatthias Ringwald  * @brief Enable/disable Extended Audio Gateway Error result codes in the AG.
1133deb3ec6SMatthias Ringwald  * Whenever there is an error relating to the functionality of the AG as a
1143deb3ec6SMatthias Ringwald  * result of AT command, the AG shall send +CME ERROR:
1153deb3ec6SMatthias Ringwald  * - +CME ERROR: 0  - AG failure
1163deb3ec6SMatthias Ringwald  * - +CME ERROR: 1  - no connection to phone
1173deb3ec6SMatthias Ringwald  * - +CME ERROR: 3  - operation not allowed
1183deb3ec6SMatthias Ringwald  * - +CME ERROR: 4  - operation not supported
1193deb3ec6SMatthias Ringwald  * - +CME ERROR: 5  - PH-SIM PIN required
1203deb3ec6SMatthias Ringwald  * - +CME ERROR: 10 - SIM not inserted
1213deb3ec6SMatthias Ringwald  * - +CME ERROR: 11 - SIM PIN required
1223deb3ec6SMatthias Ringwald  * - +CME ERROR: 12 - SIM PUK required
1233deb3ec6SMatthias Ringwald  * - +CME ERROR: 13 - SIM failure
1243deb3ec6SMatthias Ringwald  * - +CME ERROR: 14 - SIM busy
1253deb3ec6SMatthias Ringwald  * - +CME ERROR: 16 - incorrect password
1263deb3ec6SMatthias Ringwald  * - +CME ERROR: 17 - SIM PIN2 required
1273deb3ec6SMatthias Ringwald  * - +CME ERROR: 18 - SIM PUK2 required
1283deb3ec6SMatthias Ringwald  * - +CME ERROR: 20 - memory full
1293deb3ec6SMatthias Ringwald  * - +CME ERROR: 21 - invalid index
1303deb3ec6SMatthias Ringwald  * - +CME ERROR: 23 - memory failure
1313deb3ec6SMatthias Ringwald  * - +CME ERROR: 24 - text string too long
1323deb3ec6SMatthias Ringwald  * - +CME ERROR: 25 - invalid characters in text string
1333deb3ec6SMatthias Ringwald  * - +CME ERROR: 26 - dial string too long
1343deb3ec6SMatthias Ringwald  * - +CME ERROR: 27 - invalid characters in dial string
1353deb3ec6SMatthias Ringwald  * - +CME ERROR: 30 - no network service
1363deb3ec6SMatthias Ringwald  * - +CME ERROR: 31 - network Timeout.
1373deb3ec6SMatthias Ringwald  * - +CME ERROR: 32 - network not allowed – Emergency calls only
1383deb3ec6SMatthias Ringwald  */
1393deb3ec6SMatthias Ringwald void hfp_hf_enable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, uint8_t enable);
1403deb3ec6SMatthias Ringwald 
1413deb3ec6SMatthias Ringwald /**
1423deb3ec6SMatthias Ringwald  * @brief
1433deb3ec6SMatthias Ringwald  */
1443deb3ec6SMatthias Ringwald void hfp_hf_establish_audio_connection(bd_addr_t bd_addr);
1453deb3ec6SMatthias Ringwald 
1463deb3ec6SMatthias Ringwald /**
1473deb3ec6SMatthias Ringwald  * @brief
1483deb3ec6SMatthias Ringwald  */
1493deb3ec6SMatthias Ringwald void hfp_hf_release_audio_connection(bd_addr_t bd_addr);
1503deb3ec6SMatthias Ringwald 
1513deb3ec6SMatthias Ringwald 
1523deb3ec6SMatthias Ringwald /* API_END */
1533deb3ec6SMatthias Ringwald 
1543deb3ec6SMatthias Ringwald #if defined __cplusplus
1553deb3ec6SMatthias Ringwald }
1563deb3ec6SMatthias Ringwald #endif
1573deb3ec6SMatthias Ringwald 
1583deb3ec6SMatthias Ringwald #endif