示例#1
0
static void gattAdvertTimerHandler(timer_id tid)
{
    /* Based upon the timer id, stop on-going advertisements */
    if(g_btcar_data.app_tid == tid)
    {
        if(g_btcar_data.state == btcar_fast_advertising)
        {
            /* No advertisement timer for reduced power connections */
            g_btcar_data.advert_timer_value = SLOW_CONNECTION_ADVERT_TIMEOUT_VALUE;
        }

        /* Stop on-going advertisements */
        GattStopAdverts();

        g_btcar_data.app_tid = TIMER_INVALID;
    } /* Else ignore timer expiry, could be because of some race condition */
}
static void gattAdvertTimerHandler(timer_id tid)
{
    /* Based upon the timer id, stop on-going advertisements */
    if(g_hr_data.app_tid == tid)
    {
        g_hr_data.app_tid = TIMER_INVALID;

        switch(g_hr_data.state)
        {
            case app_state_fast_advertising:
            {
                if((g_hr_data.enable_white_list == TRUE))
                {
                    /* Set advertisement timer for remaining 20 seconds for
                     * fast connections with out any device in the white
                     * list.
                     */
                    g_hr_data.advert_timer_value =
                                    FAST_CONNECTION_ADVERT_TIMEOUT_VALUE -
                                    BONDED_DEVICE_ADVERT_TIMEOUT_VALUE;
                }
                else
                {
                    /* No advertisement timer for reduced power
                     * connections
                     */
                    g_hr_data.advert_timer_value =
                                SLOW_CONNECTION_ADVERT_TIMEOUT_VALUE;
                }
            }
            /* FALLTHROUGH */

            case app_state_slow_advertising:
                /* Stop on-going advertisements */
                GattStopAdverts();
            break;

            default:
                /* Ignore timer in remaining states */
            break;
        }

    }/* Else ignore timer expiry, could be because of
      * some race condition */

}