/**
 * handle timeout cases
 *
 * @param [in] h timer module handle
 * @param [out] reset true if MMGR should reset the modem
 * @param [out] start_mdm_off true if MMGR should start the modem shutdown
 * @param [out] finalize_mdm_off true if MMGR should finalize the modem shutdown
 * @param [out] cd_err true if MMGR should restart cd IPC
 * @param [out] cancel_flashing flashing thread timeout. cancel the operation
 * @param [out] stop_mcdr stop mcdr thread.
 *
 * @return E_ERR_SUCCESS if successful
 */
e_mmgr_errors_t timer_event(timer_handle_t *h, bool *reset,
                            bool *start_mdm_off, bool *finalize_mdm_off,
                            bool *cd_err, bool *cancel_flashing,
                            bool *stop_mcdr)
{
    struct timespec cur;
    mmgr_timer_t *t = (mmgr_timer_t *)h;
    bool handled = false;

    ASSERT(t != NULL);
    ASSERT(reset != NULL);
    ASSERT(start_mdm_off != NULL);
    ASSERT(finalize_mdm_off != NULL);
    ASSERT(cd_err != NULL);
    ASSERT(stop_mcdr != NULL);

    *reset = false;
    *start_mdm_off = false;
    *finalize_mdm_off = false;
    *cd_err = false;
    *stop_mcdr = false;

    clock_gettime(CLOCK_BOOTTIME, &cur);

    if (timer_is_elapsed(t, E_TIMER_COLD_RESET_ACK, &cur)) {
        handled = true;
        clients_has_ack_cold(t->clients, E_PRINT);
        timer_stop(h, E_TIMER_COLD_RESET_ACK);
        *reset = true;
    }

    if (timer_is_elapsed(t, E_TIMER_MODEM_SHUTDOWN_ACK, &cur)) {
        handled = true;
        clients_has_ack_shtdwn(t->clients, E_PRINT);
        timer_stop(h, E_TIMER_MODEM_SHUTDOWN_ACK);
        *reset = true;
        *start_mdm_off = true;
    }

    if (timer_is_elapsed(t, E_TIMER_WAIT_FOR_IPC_READY, &cur)) {
        mmgr_cli_fw_update_result_t result = { .id = E_MODEM_FW_READY_TIMEOUT };
        static const char *const msg = "IPC READY not received";

        LOG_DEBUG("%s. Force modem reset", msg);
        clients_inform_all(t->clients, E_MMGR_RESPONSE_MODEM_FW_RESULT,
                           &result);
        static const char *const ev_type = "TFT_ERROR_IPC";
        mmgr_cli_tft_event_data_t data[] = { { strlen(msg), msg } };
        mmgr_cli_tft_event_t ev = { E_EVENT_ERROR,
                                    strlen(ev_type), ev_type,
                                    MMGR_CLI_TFT_AP_LOG_MASK,
                                    1, data };
        clients_inform_all(t->clients, E_MMGR_NOTIFY_TFT_EVENT, &ev);

        handled = true;
        timer_stop(h, E_TIMER_WAIT_FOR_IPC_READY);
        *reset = true;
    }
Beispiel #2
0
void display_info_timer(void*)
{
    char lcd_text_buf[33];

    if(try_to_connect == 1)
    {
        Fl::repeat_timeout(0.1, &display_info_timer);
        return;
    }

    if(display_info == SENT_DATA)
    {
        sprintf(lcd_text_buf, "stream sent\n%0.2lfMB",
                kbytes_sent / 1024);
        print_lcd(lcd_text_buf, strlen(lcd_text_buf), 0, 1);
    }

    if(display_info == STREAM_TIME && timer_is_elapsed(&stream_timer))
    {
        sprintf(lcd_text_buf, "stream time\n%s",
                timer_get_time_str(&stream_timer));
        print_lcd(lcd_text_buf, strlen(lcd_text_buf), 0, 1);
    }

    if(display_info == REC_TIME && timer_is_elapsed(&rec_timer))
    {
        sprintf(lcd_text_buf, "record time\n%s",
                timer_get_time_str(&rec_timer));
        print_lcd(lcd_text_buf, strlen(lcd_text_buf), 0, 1);
    }

    if(display_info == REC_DATA)
    {
        sprintf(lcd_text_buf, "record size\n%0.2lfMB",
                kbytes_written / 1024);
        print_lcd(lcd_text_buf, strlen(lcd_text_buf), 0, 1);
    }

    Fl::repeat_timeout(0.1, &display_info_timer);
}