亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pioag_receive.c

?? bluetooth audio gateway
?? C
字號:
#include "pioag_private.h"
#include "ag_types.h"
#include "ag.h"

#include <audio.h>
#include <panic.h>
#include <ps.h>
#include <stdlib.h>
#include <string.h>



static const audio_note error_beep[] =
{
    AUDIO_TEMPO(180), AUDIO_VOLUME(64), AUDIO_TIMBRE(sine),
    AUDIO_NOTE(E7, QUAVER),    
    AUDIO_NOTE(B7, QUAVER),
    
    AUDIO_NOTE(E7, QUAVER),
    AUDIO_NOTE(C7, QUAVER),

    AUDIO_END
};


/* 
    pioAgConnectionAttemptTimeout
 
    Timer function that times reconnection attempts.
*/
static Delay pioAgConnectionAttemptTimeout(TimerHandle h)
{
    /* Keep compiler happy */
    h = h;   

    /* Become connectable */
    pioAgConnectReq(PioAgSlave, PIO_AG_SLAVE_CONNECT_TIMEOUT);

    /* reset the timer handle */
    PioAgState.connectionTimerHandle = NULL_TIMER;

    return D_NEVER;
}


/*
    handleStartCfm

    Start cfm receivced from the AG
  
    This function checks to see if the FEAG is already paired to a 
    headset, if it is it attempts to connect to it. If not it prompts
    the user to enter a pin code.
*/
void handleStartCfm(void)
{
    uint16  isPaired = 0;    
        
    /* Check to see if we are currently paired to another device */    
    if (PsRetrieve(PIO_AG_PS_IS_PAIRED, &(isPaired), sizeof(isPaired)) && isPaired)
    {
        /* We are currently paired to something, register it with the security manager */        
        pioAgSmAddDevReq();                
        
        /* Now try to connect to the device we're paired with */        
        pioAgConnectReq(PioAgSlave, PIO_AG_SLAVE_CONNECT_TIMEOUT);        
    }
    else
    {
        /* 
            We are not paired to anything, clear the stored address and link key
            and get the pin code.
        */                                        
        uint16 pinlen = 0;
        uint16 *zeroBuf = (uint16*) PanicNull(calloc(32, sizeof(uint16)));
        (void) PsStore(PIO_AG_PS_PEER_ADDR, zeroBuf, sizeof(BD_ADDR_T));
        (void) PsStore(PIO_AG_PS_LINK_KEY, zeroBuf, AG_SIZE_LINK_KEY);

        if(PsRetrieve(PIO_AG_PS_PIN_LENGTH, &pinlen, 1) && pinlen)
        {
            /* 
                We have a PIN so go into pairin mode, if the user wants to enter 
                a new pin they wil perferom a reset 
            */
            pioAgInquiryReq();
        }
        else
        {
            /* No Pin stored. Get Pin Code from user */
            (void) PsStore(PIO_AG_PS_PIN_CODE, zeroBuf, MAX_PIN_LENGTH);
            (void) PsStore(PIO_AG_PS_PIN_LENGTH, zeroBuf, 1);
            
            if (pioAgResetReq())
            {
                pioAgGetPinCode();
            }
        } 
        free(zeroBuf);
    }
}


/*
    handleInquiryResultInd

    Processes the Inquiry results accordingly, since we are only looking for
    one device we can store it in the PS to indicate that a device has been found.
*/
void handleInquiryResultInd(const CM_INQUIRY_RESULT_IND_T *ind)
{       
    /* Store the address in our PS store */
    (void) PsStore(PIO_AG_PS_PEER_ADDR, &ind->inq_result.bd_addr, sizeof(BD_ADDR_T));
}


/*
    handleInquiryCompleteCfm

    Inquiry has completed. Checks the status of the inquiry confirm event 
    and processes accordingly.
*/
void handleInquiryCompleteCfm(ag_inquiry_status_t status)
{
    bd_addr_t bd_addr;

    status = status;    
    
    if (PsRetrieve(PIO_AG_PS_PEER_ADDR, &bd_addr, sizeof(bd_addr_t)) && 
        bd_addr.nap && bd_addr.uap && bd_addr.lap)
    {
        /* We found a device to pair to */
        pairReqAction(bd_addr, 1, PIO_AG_PAIRING_TIMEOUT);        
    }
    else
    {
        /* We didn't find anything so play an error beep and go idle */                
        (void) AudioPlay(error_beep);
    }
    
    PioAgState.inquiryComplete = 1;
}


/*
    handlePinReq

    Retrieve PIN code entered by the user and send to the lower layers.
*/
void handlePinReq(BD_ADDR_T addr)
{
    bd_addr_t tmp_addr;
    tmp_addr.nap = addr.nap;
    tmp_addr.uap = addr.uap;
    tmp_addr.lap = addr.lap;

    /* Send the stored Pin code */    
    pioAgPinReplyReq(tmp_addr);    
}


/*
    handleLinkKeyReq

    A request for the link key has arrived, send the stored link key back.
*/
void handleLinkKeyReq(uint16 handle)
{
    uint8 link_key[AG_SIZE_LINK_KEY];
    uint16 isValid = 0;
    memset(link_key, 0, AG_SIZE_LINK_KEY);
    
    if (PsRetrieve(PIO_AG_PS_LINK_KEY_VALID, &isValid, sizeof(uint16)) && isValid)
    {
        /* We have a valid link key, check that the handles match */
        if (handle == PioAgState.handle)
        {
            /* The handles match fetch the link key from PS and send it back */            
            (void) PsRetrieve(PIO_AG_PS_LINK_KEY, link_key, AG_SIZE_LINK_KEY);
            linkKeyResAction(1, handle, link_key);
        }
        else
        {
            /* The handle does not match, reject the request and flag an error */
            linkKeyResAction(0, handle, link_key);
        }
    }
    else
    {
        /* There is no valid link key so we have to send a reject here */
        linkKeyResAction(0, handle, link_key);
    }
}


/*
    handlePairCfm

    Process Pair Confirm accordingly, currently if the pairing fails nothing 
    happens. The state machine returns to idle so could start inquiries again.
*/
void handlePairCfm(BD_ADDR_T addr, ag_pair_status_t status, const uint8 *link_key)
{
    uint16 isPaired, isValid;           
        
    switch (status)
    {
        /* 
            If the pairing succeeded, store link key, bd addr, etc in PS
            and attempt connection
        */
    case AgPairingComplete:           
        {
            bd_addr_t tmp_addr;
            tmp_addr.nap = addr.nap;
            tmp_addr.uap = addr.uap;
            tmp_addr.lap = addr.lap;

            isPaired = 1;
            isValid = 1;
            (void) PsStore(PIO_AG_PS_LINK_KEY, link_key, AG_SIZE_LINK_KEY);
            (void) PsStore(PIO_AG_PS_IS_PAIRED, &(isPaired), 1);
            (void) PsStore(PIO_AG_PS_LINK_KEY_VALID, &(isValid), 1);
            (void) PsStore(PIO_AG_PS_PEER_ADDR, &tmp_addr, sizeof(bd_addr_t));
            
            /* Start trying to connect to the remote device */                                    
            PioAgState.connectionTimerHandle = TimerAdd(D_SEC(PIO_AG_CONNECTION_RETRY_TIMEOUT), pioAgConnectionAttemptTimeout);
        }
        break; 
        
        /* If pairing was cancelled, return to idle we must be resetting */
    case AgPairingError:
    case AgPairingCancelled:                    
    case AgPairingFailed:
    case AgPairingTimedOut: 
        (void) AudioPlay(error_beep);
        break;
        
        /* Flag an error, we got an unknown response */
    default:
        break;
    }
}


/*
    handleConnectionHandleMap

    A connection request indicator has arrived, store the device handle.
*/
void handleConnectionHandleMap(uint16 hdl, bd_addr_t addr)
{
    bd_addr_t bdAddr;
    
    (void) PsRetrieve(PIO_AG_PS_PEER_ADDR, &bdAddr, sizeof(bd_addr_t));
    
    if (bdAddr.nap == addr.nap && 
        bdAddr.uap == addr.uap && 
        bdAddr.lap == addr.lap)
    {
        /* Device address matches stored address */
        PioAgState.handle = hdl;
    }
    else
    {
        /* Device addresses do not match */
        PioAgState.handle = UNDEFINED_HANDLE;
    }
}


/*
    handleRfcommStatusInd

    An RFCOMM connection may have been established, find out and deal with it.
*/
void handleRfcommStatusInd(ag_handle_t hdl, ag_connection_status_t status, ag_profile_role_t role)
{
    /* keep the compiler happy */
    hdl = hdl;
	role = role;

    switch(status)
    {
        /* If the attempt was a success, wait for user to establish a SCO */
    case AgConnectComplete:               
        PioAgState.connectAsSlave = 0;
        break;
        
        /* If the attempt failed, flag error */
    case AgConnectDisconnect:
    case AgConnectDisconnectAbnormal:
    case AgConnectFailed:
    case AgConnectTimeout:        
        if (!agRfcommConnectedQuery())
        {
            /* If not connected, schedule another attempt to connect */
            PioAgState.connectAsSlave = 0;
            PioAgState.connectionTimerHandle = TimerAdd(D_SEC(PIO_AG_CONNECTION_RETRY_TIMEOUT), pioAgConnectionAttemptTimeout);
        }
        break;
        
        /* The attempt was cancelled - resetting or flipping connect mode */
    case AgConnectCancelled:  
        if (PioAgState.connectAsSlave)
        {
            /* If the connect as slave flag is set then try connecting as master */
            pioAgConnectReq(PioAgMaster, PIO_AG_MASTER_CONNECT_TIMEOUT);
        }
        break;
        
    default:
        /* Flag an error, we got an unknown response */
        break;
    }
}


/*
    handleButtonPressInd

    A button press has been received from the headset, this could mean
    one of two things, if there is no SCO connection then start one up.
    If there is a SCO connection, tear it down.
*/
void handleButtonPressInd(ag_handle_t hdl)
{
    if (agScoConnectedQuery())
    {
        /* Tear down SCO connection */
        agScoDisconnectReqAction(hdl);
    }
    else
    {
        /* Start a SCO Connection, packet type hard coded */
        agScoConnectReqAction(hdl, PIO_AG_HV3);
    }    
}


/*
    handleScoStatusInd

    Process the SCO connection status indicator and update state variable.
*/
void handleScoStatusInd(ag_handle_t hdl, ag_connection_status_t status, hci_connection_handle_t sco_handle)
{    
    hdl = hdl;    
    sco_handle = sco_handle;

    /* if the connection was not opened or disconnected properly beep for error */
    if (status != AgConnectComplete && status != AgConnectDisconnect)
        (void) AudioPlay(error_beep);
}


/*
    handleErrorInd

    This function handles the error events from the EAG and stores 
    the results in the PS.
*/
void handleErrorInd(ag_handle_t hdl, ag_error_code_t error_reason)
{
    /* TODO currently unused but could store this in the PS error ind keys */
    hdl = hdl;
    error_reason = error_reason;

    /* Beep to indicate an error but not for warnings */
    if (error_reason != AgWarnLocalSniffNotEnabled &&
        error_reason != AgWarnLocalParkNotEnabled &&
        error_reason != AgWarnLocalLowPwrModeNotEnabled &&
        error_reason != AgWarnRemoteDevDoesNotSupportSniffMode &&
        error_reason != AgWarnRemoteDevDoesNotSupportParkMode &&
        error_reason != AgWarnRemoteLowPwrModeNotEnabled)
        (void) AudioPlay(error_beep);    
}


/*
    handleVolumeChangeInd

    Volume indication from headset
*/
void handleVolumeChangeInd(ag_handle_t hdl, uint8 gain)
{
    /* 
        Currently this is ignored as it is not clear what to do with this 
        volume message (its an unsolicited result code informing the AG of 
        the volume settings at the headset)
    */
    hdl = hdl;
    gain = gain;
}


/*
    handleMicrophoneChangeInd

    Microphone gain indication from headset
*/
void handleMicrophoneChangeInd(ag_handle_t hdl, uint8 gain)
{
    /* 
        Currently this is ignored as it is not clear what to do with this 
        mic gain message (its an unsolicited result code informing the AG of 
        the mic gain setting at the headset)
    */
    hdl = hdl;
    gain = gain;
}

void handleCallAnsweredInd(ag_handle_t hdl, uint16 accept_flag)
{
    /* Not used by the headset profile AG so just ignore for now */
    hdl = hdl;
    accept_flag = accept_flag;
}

void handleRemoteDialReq(ag_handle_t hdl, dial_mode_t dial_what, uint16 length, const uint8 *data)
{
    /* Not used by the headset profile AG so just ignore for now */
    hdl = hdl;
    dial_what = dial_what;
    length = length;
    data = data;
}

void handleUnparsedData(ag_handle_t hdl, uint16 length, const uint8 *data)
{
    /* Just ignore data that the parser cannot cope with */
    hdl = hdl;
    length = length;
    data = data;
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区二区三区在线播放| 蜜桃91丨九色丨蝌蚪91桃色| 91精品视频网| 国产成人在线看| 首页综合国产亚洲丝袜| 国产精品国产三级国产aⅴ原创 | 视频一区二区不卡| 国产精品美女www爽爽爽| 日韩一区二区电影网| 欧美在线999| av中文字幕在线不卡| 国模少妇一区二区三区| 亚洲国产cao| 曰韩精品一区二区| 中文字幕av一区二区三区高| 日韩美女天天操| 91精品国产一区二区三区香蕉| 99久久综合狠狠综合久久| 国产一区二区在线免费观看| 日本视频免费一区| 亚洲mv在线观看| 亚洲乱码日产精品bd| 亚洲国产精品成人久久综合一区| 欧美成人艳星乳罩| 欧美不卡激情三级在线观看| 欧美日韩精品一区二区三区蜜桃 | 一区二区三区在线视频免费| 国产精品久久久久aaaa| 久久久久久麻豆| 精品福利一二区| 精品日韩成人av| 久久综合999| 久久久久久97三级| 久久日韩精品一区二区五区| 日韩欧美一级在线播放| 日韩久久久精品| 精品国产免费视频| 久久久久久久免费视频了| 欧美大片在线观看| 精品动漫一区二区三区在线观看| 精品国产乱码久久久久久蜜臀| 日韩午夜小视频| 久久综合色一综合色88| 国产肉丝袜一区二区| 亚洲国产精品成人综合色在线婷婷| 中文文精品字幕一区二区| 国产精品网曝门| 一区视频在线播放| 亚洲精品乱码久久久久久| 亚洲精品水蜜桃| 天天综合色天天综合色h| 日本人妖一区二区| 国产精品99久久久久久久女警| 国产91精品入口| 色偷偷一区二区三区| 在线视频一区二区三| 欧美久久一二三四区| 欧美xxxx老人做受| 中文字幕成人在线观看| 日韩码欧中文字| 天天爽夜夜爽夜夜爽精品视频| 免费的国产精品| 成人黄色小视频| 欧美日韩国产中文| 久久奇米777| 亚洲欧美韩国综合色| 天堂va蜜桃一区二区三区漫画版| 精品无人区卡一卡二卡三乱码免费卡 | 九九九精品视频| 国产成人小视频| 欧美性生活大片视频| 精品免费视频一区二区| 亚洲国产激情av| 亚洲成av人片一区二区| 激情综合色综合久久| 成人免费不卡视频| 欧美精品高清视频| 久久精品夜夜夜夜久久| 悠悠色在线精品| 国内久久婷婷综合| 一本大道av一区二区在线播放| 欧美美女喷水视频| 国产精品久久久久久久久免费樱桃 | 欧美一区二区三区视频免费 | 久久午夜电影网| 亚洲激情校园春色| 韩日av一区二区| 色婷婷综合五月| 久久久精品综合| 视频一区免费在线观看| 99久久免费国产| 精品人在线二区三区| 一区二区三区日韩在线观看| 韩国一区二区在线观看| 欧美色窝79yyyycom| 日本一区二区三区视频视频| 日韩国产欧美视频| 91在线观看成人| 久久美女艺术照精彩视频福利播放| 亚洲在线成人精品| 成人午夜激情在线| 精品国产91乱码一区二区三区| 亚洲精品va在线观看| 国产成人一级电影| 日韩欧美在线观看一区二区三区| 亚洲女性喷水在线观看一区| 国产成人鲁色资源国产91色综| 7777精品伊人久久久大香线蕉超级流畅| 欧美激情一二三区| 国产一区二区三区四区五区入口| 91精品中文字幕一区二区三区| 亚洲猫色日本管| 丰满少妇久久久久久久| 精品国产1区2区3区| 免费高清在线视频一区·| 欧美丰满美乳xxx高潮www| 亚洲综合小说图片| 日本丰满少妇一区二区三区| 国产视频不卡一区| 极品少妇一区二区| 日韩免费一区二区| 婷婷综合在线观看| 欧美精品一二三| 天天色 色综合| 欧美日韩亚洲综合在线 | 国产精品视频第一区| 精品一区二区精品| 日韩精品一区二区三区老鸭窝| 日产精品久久久久久久性色| 欧美精品在线观看一区二区| 天堂午夜影视日韩欧美一区二区| 欧美日韩成人激情| 日韩av一级片| 日韩欧美亚洲国产另类| 精品一区二区成人精品| 久久香蕉国产线看观看99| 国产精品白丝jk黑袜喷水| 欧美极品美女视频| 不卡av免费在线观看| 亚洲国产精品激情在线观看| 99久久精品国产毛片| 樱桃国产成人精品视频| 欧美日韩的一区二区| 奇米一区二区三区| 久久综合国产精品| 成人aa视频在线观看| 亚洲欧美日韩小说| 欧美在线短视频| 男人的天堂久久精品| 2020国产精品自拍| 99这里只有久久精品视频| 亚洲激情校园春色| 日韩一区二区三区四区| 久久99精品国产麻豆婷婷洗澡| 国产欧美一区二区精品忘忧草| 成人福利电影精品一区二区在线观看| 最新国产成人在线观看| 色婷婷精品久久二区二区蜜臀av | 卡一卡二国产精品 | 日韩精品一区二区三区在线播放| 国产一区二区三区蝌蚪| 亚洲特黄一级片| 宅男在线国产精品| 粉嫩在线一区二区三区视频| 亚洲视频在线观看一区| 欧美精品一二三四| 国产**成人网毛片九色| 亚洲激情五月婷婷| 精品免费日韩av| 色噜噜狠狠成人中文综合| 日日夜夜免费精品视频| 国产农村妇女毛片精品久久麻豆| 色婷婷国产精品| 久久电影网站中文字幕| 国产精品久久毛片| 精品视频在线免费| 国产成人免费在线观看| 亚洲成人av电影在线| 久久久www成人免费无遮挡大片 | 国产精品视频一二三区| 欧美日韩国产在线观看| 国产盗摄视频一区二区三区| 一区二区三区欧美日韩| 欧美成人一区二区| 在线视频一区二区三| 国产丶欧美丶日本不卡视频| 午夜精品国产更新| 国产精品乱子久久久久| 91精品国产综合久久国产大片| 99久久婷婷国产综合精品| 蜜臀av在线播放一区二区三区| |精品福利一区二区三区| 精品久久久影院| 欧美日韩亚洲综合在线| 成人福利视频网站| 国产一区福利在线| 日本免费在线视频不卡一不卡二| 亚洲青青青在线视频| 久久―日本道色综合久久| 51精品视频一区二区三区|