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

📄 call.c

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

#include <message.h>
#include <stdlib.h>


/*
    callTransferReqAction

    Transfer audio connection from AG to HF. The HF must create the
    SCO and also connect if a connection doesn't already exist.
*/
void callTransferReqAction(uint16 pkt_type)
{
    /* TODO might be handy if we check whether there is an active call */

    /* Reset pending flag */
    HFstate.audioTransferPending = 0;

    /* check if we're connected and if not create RFCOMM before initiating SCO */
    if (HFstate.connectState == connected)
    {
        createSCO(pkt_type);
    }
    else if (HFstate.connectState == scoConnected)
    {
        hfSendDisconnectMessage(ScoLink);
    }
    else if ((HFstate.connectState == idle) ||             
             (HFstate.connectState == connectingAsSlave))
    {
        HFstate.SCOpktType = pkt_type;
        HFstate.audioTransferPending = 1;

        /* Try to create an RFCOMM connection */
        connectReqAction();
    }
    else if (HFstate.connectState == connectingAsMaster)
    {
        /* Its already trying to connect so just set the flags */ 
        HFstate.SCOpktType = pkt_type;
        HFstate.audioTransferPending = 1;
    }
    else
    {
        /* In any other mode send an error to the driver */
        handleErrorInd(HfErrorUnknownOrUnhandledState); 
    }
}


/*
    callAnswerAction

    Accept an incoming call.
*/
void callAnswerAction(void)
{
    MAKE_MSG(HANDSFREE_CALL_RESPONSE_REQ);
    msg->accept_flag = 1;
    putMsg(msg);

    /* Reset the ringing flag */
    HFstate.ringing = 0;
}


/*
    callRejectAction

    Reject an incoming call.
*/
void callRejectAction(void)
{
    MAKE_MSG(HANDSFREE_CALL_RESPONSE_REQ);
    msg->accept_flag = 0;
    putMsg(msg);   

    /* Reset the ringing flag */
    HFstate.ringing = 0;
}


/*
    hfCallerIdInd

    Caller id unsolicited result code received from the AG 
*/
void hfCallerIdInd(const HANDSFREE_CALLER_ID_IND_T *ind)
{
    /* Inform the interface */
    handleCallerIdInd(ind->length, ind->caller_id);

    /* Free the memory allocated */
    if (ind->length)
        free(ind->caller_id);
}


/*
    hfCallerIdEnableAction

    Enable or disable the AG sending us the caller id
*/
void hfCallerIdEnableAction(uint16 en)
{
    MAKE_MSG(HANDSFREE_CALLER_ID_ENABLE_REQ);
    msg->enable = en;
    putMsg(msg);
}

⌨️ 快捷键说明

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