Skip to content

Add SYSTEM_EVENT_WIFI_READY call back + WiFiMode fixes #1322

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

Merged
merged 3 commits into from
May 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions libraries/WiFi/src/WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ static bool espWiFiStart(bool persistent){
return false;
}
_esp_wifi_started = true;
system_event_t event;
event.event_id = SYSTEM_EVENT_WIFI_READY;
WiFiGenericClass::_eventCallback(nullptr, &event);

return true;
}

Expand Down Expand Up @@ -376,13 +380,22 @@ void WiFiGenericClass::persistent(bool persistent)
*/
bool WiFiGenericClass::mode(wifi_mode_t m)
{
if (!_esp_wifi_started) {
wifiLowLevelInit(_persistent);
}
wifi_mode_t cm = getMode();
if(cm == WIFI_MODE_MAX){
return false;
}
if(cm == m) {
return true;
}
if(m){
espWiFiStart(_persistent);
} else {
return espWiFiStop();
}

esp_err_t err;
err = esp_wifi_set_mode(m);
if(err){
Expand All @@ -403,6 +416,7 @@ wifi_mode_t WiFiGenericClass::getMode()
{
if(!wifiLowLevelInit(_persistent)){
return WIFI_MODE_MAX;

}
uint8_t mode;
esp_wifi_get_mode((wifi_mode_t*)&mode);
Expand Down