Merge pull request #2 from obi11235/wifi_fix
fixing issue when wifi connects but no connection was requested
This commit is contained in:
commit
9fb98ee531
2 changed files with 6 additions and 1 deletions
|
@ -109,6 +109,8 @@ void wifiHandler::update_status()
|
|||
|
||||
void wifiHandler::update_credentials()
|
||||
{
|
||||
// No connection was attempted so don't try to to save the creds
|
||||
if(!this->connect_attempt) return;
|
||||
#if 0
|
||||
if (strcmp(temporary_password, wifiHandler::password) != 0 || strcmp(temporary_ssid, wifiHandler::SSID) != 0)
|
||||
{
|
||||
|
@ -138,6 +140,7 @@ void wifiHandler::update_credentials()
|
|||
preferences.end();
|
||||
}
|
||||
#endif
|
||||
this->connect_attempt = false;
|
||||
}
|
||||
|
||||
void wifiHandler::scan()
|
||||
|
@ -176,7 +179,7 @@ void wifiHandler::begin()
|
|||
//strcpy(this->password, password.c_str());
|
||||
this->SSID = ssid.c_str();
|
||||
this->password = password.c_str();
|
||||
//this->connect(std::make_shared<std::string>(std::string(this->SSID)), std::make_shared<std::string>(std::string(this->password)));
|
||||
this->connect(std::make_shared<std::string>(std::string(this->SSID)), std::make_shared<std::string>(std::string(this->password)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -200,6 +203,7 @@ void wifiHandler::onStatusUpdate(std::function<void (std::shared_ptr<wifiStatus>
|
|||
|
||||
void wifiHandler::connect(std::shared_ptr<std::string> ssid, std::shared_ptr<std::string> password)
|
||||
{
|
||||
this->connect_attempt = true;
|
||||
this->temporary_password = password;
|
||||
this->temporary_ssid = ssid;
|
||||
WiFi.begin(ssid->c_str(), password->c_str());
|
||||
|
|
|
@ -66,6 +66,7 @@ class wifiHandler: public wifiHandlerInterface {
|
|||
std::string getIP();
|
||||
wifiStatus wifi_status;
|
||||
static std::shared_ptr<wifiHandler> mInstance;
|
||||
bool connect_attempt = false;
|
||||
std::shared_ptr<std::string> temporary_password;
|
||||
std::shared_ptr<std::string> temporary_ssid;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue