Exemple #1
0
/**@brief Function for catering CoAP module with periodic time ticks.
*/
static void app_coap_time_tick(iot_timer_time_in_ms_t wall_clock_value)
{
    // Pass a tick to coap in order to re-transmit any pending messages.
    (void)coap_time_tick();

    // Check if any of the observers needs an update.
    static uint32_t msg_count = 0;

    if (m_led3.expire_time <= (0 + OBSERVE_NOTIFY_DELTA_MAX_AGE))
    {
        m_led3.expire_time = m_led3.max_age;

        if (msg_count % 4 == 0)
        {
            notify_all_led3_subscribers(COAP_TYPE_CON);
        }
        else
        {
            notify_all_led3_subscribers(COAP_TYPE_NON);
        }

        msg_count++;
    }
    else
    {
        m_led3.expire_time--;
    }
}
Exemple #2
0
/**@brief Function for catering CoAP module with periodic time ticks.
*/
static void app_coap_time_tick(iot_timer_time_in_ms_t wall_clock_value)
{
    (void)coap_time_tick();

    // Check if any of the observable has reached max-age timeout.
    coap_observable_t * p_observable = NULL;
    uint32_t handle;
    while (coap_observe_client_next_get(&p_observable, &handle, p_observable) == NRF_SUCCESS)
    {
        p_observable->max_age--;

        // Max age timeout
        if (p_observable->max_age == 0)
        {
            // unregister observable resource.
            uint32_t err_code = coap_observe_client_unregister(handle);
            APP_ERROR_CHECK(err_code);

            LEDS_OFF(LED_FOUR);
        }
    }
}
/**@brief Function for handling CoAP periodically time ticks.
*/
static void app_coap_time_tick(iot_timer_time_in_ms_t wall_clock_value)
{
    // Pass a tick to coap in order to re-transmit any pending messages.
    (void)coap_time_tick();
}