mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-19 04:41:44 +02:00
Tidier Wifi connection messages
This commit is contained in:
@@ -211,10 +211,9 @@ namespace WebUI {
|
|||||||
void WiFiConfig::WiFiEvent(WiFiEvent_t event) {
|
void WiFiConfig::WiFiEvent(WiFiEvent_t event) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case SYSTEM_EVENT_STA_GOT_IP:
|
case SYSTEM_EVENT_STA_GOT_IP:
|
||||||
info_all("Connected with %s", WiFi.localIP().toString().c_str());
|
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||||
info_all("Disconnected");
|
info_all("WiFi Disconnected");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -239,12 +238,11 @@ namespace WebUI {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool WiFiConfig::ConnectSTA2AP() {
|
bool WiFiConfig::ConnectSTA2AP() {
|
||||||
String msg, msg_out;
|
String msg, msg_out;
|
||||||
uint8_t count = 0;
|
uint8_t count;
|
||||||
uint8_t dot = 0;
|
uint8_t dot = 0;
|
||||||
wl_status_t status = WiFi.status();
|
for (count = 0; count < 10; ++count) {
|
||||||
while (status != WL_CONNECTED && count < 40) {
|
switch (WiFi.status()) {
|
||||||
switch (status) {
|
|
||||||
case WL_NO_SSID_AVAIL:
|
case WL_NO_SSID_AVAIL:
|
||||||
info_all("No SSID");
|
info_all("No SSID");
|
||||||
return false;
|
return false;
|
||||||
@@ -252,7 +250,8 @@ namespace WebUI {
|
|||||||
info_all("Connection failed");
|
info_all("Connection failed");
|
||||||
return false;
|
return false;
|
||||||
case WL_CONNECTED:
|
case WL_CONNECTED:
|
||||||
break;
|
info_all("Connected - IP is %s", WiFi.localIP().toString().c_str());
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
if ((dot > 3) || (dot == 0)) {
|
if ((dot > 3) || (dot == 0)) {
|
||||||
dot = 0;
|
dot = 0;
|
||||||
@@ -264,11 +263,9 @@ namespace WebUI {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
info_all(msg.c_str());
|
info_all(msg.c_str());
|
||||||
COMMANDS::wait(1000);
|
COMMANDS::wait(2000);
|
||||||
count++;
|
|
||||||
status = WiFi.status();
|
|
||||||
}
|
}
|
||||||
return status == WL_CONNECTED;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -317,11 +314,7 @@ namespace WebUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (WiFi.begin(SSID.c_str(), (password.length() > 0) ? password.c_str() : NULL)) {
|
if (WiFi.begin(SSID.c_str(), (password.length() > 0) ? password.c_str() : NULL)) {
|
||||||
bool connected = ConnectSTA2AP();
|
return ConnectSTA2AP();
|
||||||
if (connected) {
|
|
||||||
info_all("STA IP %s", WiFi.localIP().toString().c_str());
|
|
||||||
}
|
|
||||||
return connected;
|
|
||||||
}
|
}
|
||||||
info_serial("Cannot connect to %s", config->_comms->_staConfig->_ssid.c_str());
|
info_serial("Cannot connect to %s", config->_comms->_staConfig->_ssid.c_str());
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user