1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Correctly access WIFI_EVENT_MODE_CHANGE event info (#8343)

Select the specific union member struct fields.

Co-authored-by: Rastislav Hričák <88608954+RastoH@users.noreply.github.com>
This commit is contained in:
Max Prokhorov 2021-10-19 09:47:26 +03:00 committed by GitHub
parent c7c7d0518b
commit ac4af38c09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -203,7 +203,10 @@ WiFiEventHandler ESP8266WiFiGenericClass::onSoftAPModeProbeRequestReceived(std::
WiFiEventHandler ESP8266WiFiGenericClass::onWiFiModeChange(std::function<void(const WiFiEventModeChange&)> f)
{
WiFiEventHandler handler = std::make_shared<WiFiEventHandlerOpaque>(WIFI_EVENT_MODE_CHANGE, [f](System_Event_t* e){
WiFiEventModeChange& dst = *reinterpret_cast<WiFiEventModeChange*>(&e->event_info);
auto& src = e->event_info.opmode_changed;
WiFiEventModeChange dst;
dst.oldMode = (WiFiMode_t)src.old_opmode;
dst.newMode = (WiFiMode_t)src.new_opmode;
f(dst);
});
sCbEventList.push_back(handler);