Event Loop Base issues
Posted: Wed Oct 02, 2024 4:20 pm
Hi,
I've been trying to implement the Event Loop Library. Posting and registering events using a hardcoded static string works fine.
When the string is dynamic and identical to the base it fails to trigger.
I'm registering an event using:
And posting it with an hardcoded string works:
When I change the base to a char* variable containing "COMMANDBASE1" it fails:
This string is from UART so I cannot make it hardcoded.
With a hack and a lookup table I can trigger the event again:
How do I convert a char* to esp_event_base_t as the esp_event_post function only seems to work with hardcoded strings?
I've been trying to implement the Event Loop Library. Posting and registering events using a hardcoded static string works fine.
When the string is dynamic and identical to the base it fails to trigger.
I'm registering an event using:
Code: Select all
esp_event_handler_instance_register("COMMANDBASE1", 0, commandfunction, NULL, NULL);
Code: Select all
esp_event_post("COMMANDBASE1", 0, NULL, 0, portMAX_DELAY)
This string is from UART so I cannot make it hardcoded.
Code: Select all
esp_event_post(basevar, 0, NULL, 0, portMAX_DELAY)
Code: Select all
inline esp_event_base_t filterEvents(char* eventBase)
{
if(strcmp(eventBase, "COMMANDBASE1") == 0)
{
return (esp_event_base_t)"COMMANDBASE1";
}
return (esp_event_base_t)"UNKNOWN";
}
esp_event_post(filterEvents(basevar),0, NULL, 0, portMAX_DELAY)