Skip to content

Commit

Permalink
Correctly access WIFI_EVENT_MODE_CHANGE event info (#8343)
Browse files Browse the repository at this point in the history
Select the specific union member struct fields.

Co-authored-by: Rastislav Hričák <88608954+RastoH@users.noreply.github.com>
  • Loading branch information
mcspr and RastoH committed Oct 19, 2021
1 parent c7c7d05 commit ac4af38
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ac4af38

Please sign in to comment.