Code: Select all
DEBUG_LOG("This: %p", this);
ret = esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &WiFiClient::event_handler, this);
if (ret != ESP_OK)
{
DEBUG_ERR("Unable to register event 1");
return false;
}
ret = esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &WiFiClient::event_handler, this);
if (ret != ESP_OK)
{
DEBUG_ERR("Unable to register event 2");
return false;
}
I have the following code in my handler function
Code: Select all
void WiFiClient::event_handler(void* arg, esp_event_base_t event_base, std::int32_t event_id, void* event_data)
{
[...]
if (nullptr != event_data)
{
DEBUG_LOG("Class ptr: %p", event_data);
WiFiClient* const client = reinterpret_cast<WiFiClient*>(event_data);
[...]
WifiClient.cpp: This: 0x3ffc83e4
WifiClient.cpp: Class ptr: 0x3ffd55b4
Why is the value changed? The class pointer is obviously not valid anymore.