示例#1
0
void hfp_ag_establish_audio_connection(bd_addr_t bd_addr) {
    hfp_ag_establish_service_level_connection(bd_addr);
    hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
    if (!connection) {
        log_error("HFP AG: connection doesn't exist.");
        return;
    }
    if (connection->state == HFP_AUDIO_CONNECTION_ESTABLISHED) return;
    // if (connection->remote_codecs_nr == 0) {
    //     log_error("HFP AG: codecs not exchanged, or no codecs specified in HF.");
    //     return;
    // }
    connection->trigger_codec_connection_setup = 1;
    connection->establish_audio_connection = 1;

    if (!has_codec_negotiation_feature(connection)) {
        connection->trigger_codec_connection_setup = 0;
        connection->establish_audio_connection = 0;
        return;
    }

    if (connection->state == HFP_CODECS_CONNECTION_ESTABLISHED) {
        connection->trigger_codec_connection_setup = 0;
        return;
    }
    hfp_run_for_context(connection);
}
示例#2
0
文件: hfp_ag.c 项目: yourskp/btstack
void hfp_ag_establish_audio_connection(bd_addr_t bd_addr){
    hfp_ag_establish_service_level_connection(bd_addr);
    hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);

    connection->establish_audio_connection = 0;
    if (connection->state == HFP_AUDIO_CONNECTION_ESTABLISHED) return;
    if (connection->state >= HFP_W2_DISCONNECT_SCO) return;
        
    connection->establish_audio_connection = 1;

    if (!has_codec_negotiation_feature(connection)){
        log_info("hfp_ag_establish_audio_connection - no codec negotiation feature, using defaults");
        connection->codecs_state = HFP_CODECS_EXCHANGED;
    } 

    switch (connection->codecs_state){
        case HFP_CODECS_IDLE:
        case HFP_CODECS_RECEIVED_LIST:
        case HFP_CODECS_AG_RESEND_COMMON_CODEC:
        case HFP_CODECS_ERROR:
            connection->command = HFP_CMD_AG_SEND_COMMON_CODEC;
            break;
        default:
            break;
    } 

    hfp_run_for_context(connection);
}
示例#3
0
void hfp_ag_codec_connection_setup(hfp_connection_t * connection){
    if (!connection){
        log_error("HFP AG: connection doesn't exist.");
        return;
    }
    // TODO:
    hfp_run_for_context(connection);
}
示例#4
0
static void hfp_run(){
    linked_list_iterator_t it;    
    linked_list_iterator_init(&it, hfp_get_connections());
    while (linked_list_iterator_has_next(&it)){
        hfp_connection_t * connection = (hfp_connection_t *)linked_list_iterator_next(&it);
        hfp_run_for_context(connection);
    }
}
示例#5
0
void hfp_ag_transfer_callheld_status(bd_addr_t bd_addr, hfp_callheld_status_t status){
    hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
    if (!connection){
        log_error("HFP AG: connection doesn't exist.");
        return;
    }
    if (!connection->enable_status_update_for_ag_indicators) return;
    hfp_ag_update_indicator_status(connection, (char *)"callheld", status); 
    hfp_run_for_context(connection);
}
示例#6
0
文件: hfp_ag.c 项目: yourskp/btstack
/**
 * @brief 
 */
void hfp_ag_terminate_call(void){

    linked_list_iterator_t it;    
    linked_list_iterator_init(&it, hfp_get_connections());
    while (linked_list_iterator_has_next(&it)){
        hfp_connection_t * connection = (hfp_connection_t *)linked_list_iterator_next(&it);
        hfp_ag_establish_service_level_connection(connection->remote_addr);
        connection->terminate_call = 1;
        hfp_run_for_context(connection);
    }
}
示例#7
0
文件: hfp_ag.c 项目: yourskp/btstack
/**
 * @brief 
 */
void hfp_ag_incoming_call(void){
    linked_list_iterator_t it;    
    linked_list_iterator_init(&it, hfp_get_connections());
    while (linked_list_iterator_has_next(&it)){
        hfp_connection_t * connection = (hfp_connection_t *)linked_list_iterator_next(&it);
        hfp_ag_establish_service_level_connection(connection->remote_addr);
        connection->use_in_band_ring_tone = hfp_ag_use_in_band_ring_tone;
        connection->run_call_state_machine = 1;
        hfp_run_for_context(connection);
    }
}
示例#8
0
void hfp_ag_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, hfp_cme_error_t error){
    hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
    if (!connection){
        log_error("HFP HF: connection doesn't exist.");
        return;
    }
    connection->extended_audio_gateway_error = 0;
    if (!connection->enable_extended_audio_gateway_error_report){
        return;
    }
    connection->extended_audio_gateway_error = error;
    hfp_run_for_context(connection);
}
示例#9
0
void hfp_ag_establish_audio_connection(bd_addr_t bd_addr){
    hfp_ag_establish_service_level_connection(bd_addr);
    hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
    if (!has_codec_negotiation_feature(connection)) return;
    connection->establish_audio_connection = 0;
    if (connection->state == HFP_AUDIO_CONNECTION_ESTABLISHED) return;
    if (connection->state >= HFP_W2_DISCONNECT_SCO) return;
    
    connection->establish_audio_connection = 1;
    if (connection->state < HFP_SLE_W4_EXCHANGE_COMMON_CODEC){
        connection->ag_trigger_codec_connection_setup = 1;
    }
    hfp_run_for_context(connection);
}
示例#10
0
void hfp_ag_negotiate_codecs(bd_addr_t bd_addr){
    hfp_ag_establish_service_level_connection(bd_addr);
    hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
    if (!has_codec_negotiation_feature(connection)) return;
    if (connection->remote_codecs_nr == 0) return;
    
    if (connection->state >= HFP_W2_DISCONNECT_SCO) return;
    
    if (connection->state != HFP_SLE_W2_EXCHANGE_COMMON_CODEC &&
        connection->state != HFP_SLE_W4_EXCHANGE_COMMON_CODEC){
        connection->ag_trigger_codec_connection_setup = 1;
    }

    hfp_run_for_context(connection);
}
示例#11
0
void hfp_ag_release_audio_connection(bd_addr_t bd_addr){
    hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
    hfp_release_audio_connection(connection);
    hfp_run_for_context(connection);
}
示例#12
0
void hfp_ag_release_service_level_connection(bd_addr_t bd_addr){
    printf(" hfp_ag_release_service_level_connection \n");
    hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
    hfp_release_service_level_connection(connection);
    hfp_run_for_context(connection);
}