⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hosthf_receive.c

📁 蓝牙HANDFREE软件源代码
💻 C
字号:
#include "hosthf_private.h"
#include "handsfree.h"
#include "handsfree_types.h"

#include <string.h>


/*
    handleOpenCfm

    Send a message to the driver with version information This is
    really to assure the GUI application that the handsfree is up and
    running;
*/
void handleOpenCfm(uint16 status)
{
    MAKE_GUI_MSG(START_CFM);
    msg->hf_msg.start_cfm.version = HF_VERSION;
    msg->hf_msg.start_cfm.isPaired = status;
    hostHfPutGuiMsg((void *)msg);    
}


/*
    handlePairCfm

    Pairing has completed so inform the GUI
*/
void handlePairCfm(pairing_status_t status)
{
    /* Send a pair complete message to the GUI */
    MAKE_GUI_MSG(PAIR_CFM);
    msg->hf_msg.pair_cfm.status = status;
    hostHfPutGuiMsg((void *)msg);

    switch (status)
    {
    case HfPairingComplete:        
        break;

    case HfPairingCancelled:
        /* If currently idle go into connectable mode */
        if (HFstate.connectState == idle)
            connectReqAction();
        break;

    case HfPairingFailed:
    case HfPairingError:
    case HfPairingTimedOut:   
    default:
        /* Become connectable */
        connectReqAction();
        break;
    }
}


/*
    handleRingInd

    Ring indication, pass it to the GUI since it might want to generate
    some indicator itself
*/
void handleRingInd(uint16 ring_state)
{
    /* 
        The framework lib uses the audio stop signal to detect the ring has
        stopped playing. This has the disadvantage that a ring_nd is sent 
        whenever any tone stops playing. Only send a ring ind when its a 
        genuine ring.
    */
    if (HFstate.ringing)
    {
        MAKE_GUI_MSG(RING_IND);
        msg->hf_msg.ring_ind.state = ring_state;
        hostHfPutGuiMsg((void *)msg);
    }
}


/*
    handleVolInd

    Local volume setting has changed indication.
*/
void handleVolInd(uint8 gain)
{
    /* Tell the GUI that the volume setting has changed */
    MAKE_GUI_MSG(VOLUME_CHANGE_IND);
    msg->hf_msg.volume_change_ind.gain = gain;
    hostHfPutGuiMsg((void *)msg);
}


/*
    handleErrorInd

    Handle an error or warning indication
*/
void handleErrorInd(error_code_t this_error)
{
    MAKE_GUI_MSG(ERROR_IND);
    msg->hf_msg.error_ind.reason = this_error;
    hostHfPutGuiMsg((void *)msg);    
}


/*
    handleCallerIdInd

    Caller ID notification received, pass up to GUI so it can display it
*/
void handleCallerIdInd(uint16 length, const uint8 *caller_id)
{
    /* Send a message to the external driver app */
    MAKE_GUI_MSG_WITH_LEN(CALLER_ID_IND, length);
    msg->hf_msg.caller_id_ind.length = length;
    memcpy(msg->hf_msg.caller_id_ind.caller_id_number, caller_id, length);
    hostHfPutGuiMsg((void *)msg);
}


/*
    handleIndicatorUpdate

    The status of one or both indicators has changed
*/
void handleIndicatorUpdate(uint16 service_ind, uint16 call_ind, uint16 call_setup_ind)
{
    MAKE_GUI_MSG(INDICATOR_UPDATE_IND);
    msg->hf_msg.indicator_state_update_ind.service_ind = service_ind;
    msg->hf_msg.indicator_state_update_ind.call_ind = call_ind;
    msg->hf_msg.indicator_state_update_ind.call_setup_ind = call_setup_ind;
    hostHfPutGuiMsg((void *)msg);
}


/*
    handleVoiceDialStatusInd

    Pass up to the GUI the indicating showing the current status of 
    the voice dial function at the AG
*/
void handleVoiceDialStatusInd(uint16 st)
{
    MAKE_GUI_MSG(VOICE_DIAL_IND);
    msg->hf_msg.voice_dial_ind.status = st;
    hostHfPutGuiMsg((void *)msg);
}


/*
    handleLocalStateChange

    Local state has changed. 
*/
void handleLocalStateChange(void)
{
    MAKE_GUI_MSG(LOCAL_STATE_CHANGE_IND);
    
    switch(HFstate.connectState)
    {
    case idle:
        msg->hf_msg.local_state_change_ind.new_state = HfIdle;
        break;

    case connectingAsMaster:
        msg->hf_msg.local_state_change_ind.new_state = HfConnectingAsMaster;
        break;

    case connectingAsSlave:
        msg->hf_msg.local_state_change_ind.new_state = HfConnectingAsSlave;
        break;

    case connected:
        msg->hf_msg.local_state_change_ind.new_state = HfConnected;
        break;

    case pairing:
        msg->hf_msg.local_state_change_ind.new_state = HfPairing;
        break;

    case scoConnected:
        msg->hf_msg.local_state_change_ind.new_state = HfScoConnected;
        break;

    default:
        msg->hf_msg.local_state_change_ind.new_state = HfError;
        break;
    }    
    hostHfPutGuiMsg((void *)msg);
}



/*
    handleConnectComplete

    Service level connection has been created or torn down (or the 
    connect attempt has failed /timed out)
*/
void handleConnectComplete(void)
{
    /* Nothing to do here */    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -