ring.c

来自「蓝牙HANDFREE软件源代码」· C语言 代码 · 共 72 行

C
72
字号
#include "handsfree_private.h"
#include "handsfree.h"



#include <audio.h>
#include <stdlib.h>
#include <vm.h>

/* This is the ring tone played */
static const audio_note twilight[] =
{
    AUDIO_TEMPO(180), AUDIO_VOLUME(64), AUDIO_TIMBRE(sine),
    AUDIO_NOTE(E7, QUAVER),
    AUDIO_NOTE(F7, QUAVER),
    AUDIO_NOTE(E7, QUAVER),
    AUDIO_NOTE(C7, QUAVER),
    
    AUDIO_NOTE(E7, QUAVER),
    AUDIO_NOTE(F7, QUAVER),
    AUDIO_NOTE(E7, QUAVER),
    AUDIO_NOTE(C7, QUAVER),
    
    AUDIO_END
};



/*
    hfRingInd

    Called by the headset framework to tell us that a RING command has
    been received over RFCOMM (state = 1) or that the ring duration
    has expired (state = 0).
*/
void hfRingInd(const HS_RING_IND_T *ind)
{
    /* set the rinigng flag */
    if(ind->state)
    {
        HFstate.ringing = 1;
    }

    /* Make sure the AG isn't sending in-band ring tones */
    if(ind->state && !HFstate.inBandRingEnabled)
    {
        /* If a new ring indication received, play the ring tone */
        HFstate.AudioRingHandle = AudioPlay(twilight);
    }
    else
    {
        /* Indication that the ring tone has stopped playing */
        HFstate.AudioRingHandle = 0;
    }

    /* Inform the interface. */
    handleRingInd(ind->state);
}


/*
    hfInBandRingEnable

    AG sends an indication whether it currently has the in-band ring tone
    enabled or disabled. Handle this indication here.
*/
void hfInBandRingEnable(const HANDSFREE_IN_BAND_RING_IND_T *ind)
{
    /* Set the local state to reflect the change in in-band ring setting */
    HFstate.inBandRingEnabled = ind->enable;
}

⌨️ 快捷键说明

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