How to pass "name" from void arg

kiralikbeyin
Posts: 3
Joined: Wed Dec 09, 2015 5:10 pm

How to pass "name" from void arg

Postby kiralikbeyin » Mon Jan 25, 2021 8:46 am

How can i get "name" in callback function?

Code: Select all

esp_timer_handle_t oneshot_timer;
static void oneshot_timer_callback(void* arg)
{
  //printf("%s\n",(char*)arg ); NEED NAME FROM ARG ----- .name = "one-shot-name"
    int64_t time_since_boot = esp_timer_get_time();
    ESP_LOGI(TAG_TIMER, "One-shot timer called, time since boot: %lld us", time_since_boot);
    ESP_ERROR_CHECK(esp_timer_delete(oneshot_timer));
}

void myfunc.... {
    const esp_timer_create_args_t oneshot_timer_args = {
          .callback = &oneshot_timer_callback,
          .arg = (void*) oneshot_timer,
          .name = "one-shot-name"
  };
  ESP_ERROR_CHECK(esp_timer_create(&oneshot_timer_args, &oneshot_timer));
  ESP_ERROR_CHECK(esp_timer_start_once(oneshot_timer, 5000000));
  ESP_LOGI(TAG_TIMER, "Started timers, time since boot: %lld us", esp_timer_get_time());
}

https://github.com/espressif/esp-idf/bl ... ple_main.c

Who is online

Users browsing this forum: No registered users and 108 guests