Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onWiFiModeChange not working corect #8341

Closed
RastoH opened this issue Oct 16, 2021 · 4 comments · Fixed by #8343
Closed

onWiFiModeChange not working corect #8341

RastoH opened this issue Oct 16, 2021 · 4 comments · Fixed by #8343

Comments

@RastoH
Copy link
Contributor

RastoH commented Oct 16, 2021

replace:

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.opmode_changed);
        f(dst);
    });
    sCbEventList.push_back(handler);
    return handler;
}

with:

WiFiEventHandler ESP8266WiFiGenericClass::onWiFiModeChange(std::function<void(const WiFiEventModeChange&)> f)
{
    WiFiEventHandler handler = std::make_shared<WiFiEventHandlerOpaque>(WIFI_EVENT_MODE_CHANGE, [f](System_Event_t* e){
        auto& src = e->event_info.opmode_changed;
        WiFiEventModeChange dst;
        dst.oldMode = (WiFiMode)src.old_opmode;
        dst.newMode = (WiFiMode)src.new_opmode;
        f(dst);
    });
    sCbEventList.push_back(handler);
    return handler;
}
@mcspr
Copy link
Collaborator

mcspr commented Oct 16, 2021

@RastoH can you provide a small example of the issue that you patch is solving?

@RastoH
Copy link
Contributor Author

RastoH commented Oct 16, 2021

sorry, original line:

WiFiEventModeChange& dst = reinterpret_cast<WiFiEventModeChange>(&e->event_info);

handler caled, but oldMode and newMode values always 0

@mcspr
Copy link
Collaborator

mcspr commented Oct 16, 2021

@RastoH will you open a pull request or are you ok if I do that?

@RastoH
Copy link
Contributor Author

RastoH commented Oct 16, 2021

make it. thnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants