Skip to content

Commit 7025cae

Browse files
mcsprRastoH
authored andcommitted
Correctly access WIFI_EVENT_MODE_CHANGE event info (esp8266#8343)
Select the specific union member struct fields. Co-authored-by: Rastislav Hričák <88608954+RastoH@users.noreply.github.com>
1 parent c0a7972 commit 7025cae

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ WiFiEventHandler ESP8266WiFiGenericClass::onSoftAPModeProbeRequestReceived(std::
203203
WiFiEventHandler ESP8266WiFiGenericClass::onWiFiModeChange(std::function<void(const WiFiEventModeChange&)> f)
204204
{
205205
WiFiEventHandler handler = std::make_shared<WiFiEventHandlerOpaque>(WIFI_EVENT_MODE_CHANGE, [f](System_Event_t* e){
206-
WiFiEventModeChange& dst = *reinterpret_cast<WiFiEventModeChange*>(&e->event_info);
206+
auto& src = e->event_info.opmode_changed;
207+
WiFiEventModeChange dst;
208+
dst.oldMode = (WiFiMode_t)src.old_opmode;
209+
dst.newMode = (WiFiMode_t)src.new_opmode;
207210
f(dst);
208211
});
209212
sCbEventList.push_back(handler);

0 commit comments

Comments
 (0)