I use C++ on ESP-32. When registering a timer I have to do this:
timer_args.callback = reinterpret_cast<esp_timer_cb_t>(&SoundMixer::soundCallback);
timer_args.arg = this;
Here the timer calls soundCallback
.
And the same thing when registering a task:
xTaskCreate(reinterpret_cast<TaskFunction_t>(&SoundProviderTask::taskProviderCode), "SProvTask", stackSize, this, 10, &taskHandle);
So the method is started in a separated task.
GCC always warns me about these conversions, but it works just as planned.
Is it acceptable in production code? Is there a better way to do this?