This commit is contained in:
@@ -51,15 +51,15 @@ void wifi_task(void* parameter)
|
||||
if (prefs.getString(ssid_key, "") == "" || failed_connection_attempts > 5) {
|
||||
wifi_data.link = false;
|
||||
if (failed_connection_attempts > 5) {
|
||||
LOG(ELOG_LEVEL_DEBUG, "Failed to connect to currently saved SSID, starting SoftAP");
|
||||
LOG(ELOG_LEVEL_WARNING, "Failed to connect to currently saved SSID, starting SoftAP");
|
||||
} else {
|
||||
LOG(ELOG_LEVEL_DEBUG, "No SSID saved, starting SoftAP");
|
||||
LOG(ELOG_LEVEL_WARNING, "No SSID saved, starting SoftAP");
|
||||
}
|
||||
|
||||
String ap_ssid = get_hostname(Wireless);
|
||||
WiFi.softAP(ap_ssid.c_str(), "");
|
||||
|
||||
LOG(ELOG_LEVEL_DEBUG, "[WIFI_TASK] Waiting for SSID now...");
|
||||
LOG(ELOG_LEVEL_DEBUG, "Waiting for SSID now...");
|
||||
|
||||
String old_ssid = prefs.getString(ssid_key, "xxx");
|
||||
while (prefs.getString(ssid_key, "") == "" || prefs.getString(ssid_key, "") == old_ssid) {
|
||||
@@ -74,16 +74,16 @@ void wifi_task(void* parameter)
|
||||
wifi_data.link = true;
|
||||
wifi_data.network_name = WiFi.SSID();
|
||||
wifi_data.ip_address = WiFi.localIP().toString();
|
||||
|
||||
LOG(ELOG_LEVEL_DEBUG, "RSSI: %F, IP Address, %s, SSID: %s", float(WiFi.RSSI()), WiFi.localIP().toString(), prefs.getString(ssid_key, "NOSSID"));
|
||||
Serial.println(WiFi.localIP());
|
||||
delay(5000);
|
||||
LOG(ELOG_LEVEL_DEBUG, "WIFI connected; RSSI: %F, IP Address, %s, SSID: %s", float(WiFi.RSSI()), WiFi.localIP().toString(), prefs.getString(ssid_key, "NOSSID"));
|
||||
delay(1000 * 60);
|
||||
} else {
|
||||
LOG(ELOG_LEVEL_DEBUG, "Connecting to %s using password %s", prefs.getString(ssid_key, ""), prefs.getString(wifi_password_key, ""));
|
||||
String ssid = prefs.getString(ssid_key, "");
|
||||
String password = prefs.getString(wifi_password_key, "");
|
||||
LOG(ELOG_LEVEL_DEBUG, "Connecting to %s...", ssid);
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
WiFi.begin(prefs.getString(ssid_key, "").c_str(), prefs.getString(wifi_password_key, "").c_str());
|
||||
WiFi.begin(ssid, password);
|
||||
failed_connection_attempts++;
|
||||
LOG(ELOG_LEVEL_WARNING, "Failed to connect, retrying...");
|
||||
delay(5000);
|
||||
}
|
||||
}
|
||||
@@ -100,6 +100,12 @@ void ethernet_task(void* parameter)
|
||||
ethernet_data.rssi = ETH.linkSpeed();
|
||||
ethernet_data.ip_address = ETH.localIP().toString();
|
||||
LOG(ELOG_LEVEL_DEBUG, "Ethernet RSSI: %F, IP Address, %s, LINK: %s", float(ethernet_data.rssi), ETH.localIP().toString(), String(ethernet_data.link));
|
||||
|
||||
if (ETH.linkUp() && !ETH.isDefault() && ETH.localIP().toString() != "0.0.0.0") {
|
||||
LOG(ELOG_LEVEL_DEBUG, "Ethernet is up, setting to default");
|
||||
ETH.setDefault();
|
||||
}
|
||||
|
||||
delay(60 * 1000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user