mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-29 15:42:20 +03:00
баг wifi
This commit is contained in:
@@ -49,14 +49,12 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
|
|||||||
// connection===================================================================
|
// connection===================================================================
|
||||||
if (headerStr == "/connec") {
|
if (headerStr == "/connec") {
|
||||||
sendFileToWs("/settings.json", num, 1024);
|
sendFileToWs("/settings.json", num, 1024);
|
||||||
if (RouterFind(jsonReadStr(settingsFlashJson, F("routerssid")))) {
|
RouterFind(jsonReadStr(settingsFlashJson, F("routerssid")));
|
||||||
standWebSocket.sendTXT(num, ssidListJson);
|
standWebSocket.sendTXT(num, ssidListJson);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (headerStr == "/scan") {
|
if (headerStr == "/scan") {
|
||||||
if (RouterFind(jsonReadStr(settingsFlashJson, F("routerssid")))) {
|
RouterFind(jsonReadStr(settingsFlashJson, F("routerssid")));
|
||||||
standWebSocket.sendTXT(num, ssidListJson);
|
standWebSocket.sendTXT(num, ssidListJson);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (headerStr == "/cennoc") {
|
if (headerStr == "/cennoc") {
|
||||||
writeFileUint8tByFrames("settings.json", payload, length, headerLenth, 256);
|
writeFileUint8tByFrames("settings.json", payload, length, headerLenth, 256);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ void routerConnect() {
|
|||||||
if (WiFi.status() == WL_CONNECT_FAILED) {
|
if (WiFi.status() == WL_CONNECT_FAILED) {
|
||||||
SerialPrint("E", "WIFI", "password is not correct");
|
SerialPrint("E", "WIFI", "password is not correct");
|
||||||
tries = 1;
|
tries = 1;
|
||||||
jsonWriteInt(paramsHeapJson, "pass_status", 1);
|
jsonWriteInt(settingsFlashJson, "pass_status", 1);
|
||||||
}
|
}
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
@@ -61,21 +61,21 @@ bool startAPMode() {
|
|||||||
SerialPrint("i", "WIFI", "AP IP: " + myIP.toString());
|
SerialPrint("i", "WIFI", "AP IP: " + myIP.toString());
|
||||||
jsonWriteStr(settingsFlashJson, "ip", myIP.toString());
|
jsonWriteStr(settingsFlashJson, "ip", myIP.toString());
|
||||||
|
|
||||||
// if (jsonReadInt(paramsHeapJson, "pass_status") != 1) {
|
if (jsonReadInt(settingsFlashJson, "pass_status") != 1) {
|
||||||
ts.add(
|
ts.add(
|
||||||
WIFI_SCAN, 10 * 1000, [&](void*) {
|
WIFI_SCAN, 10 * 1000, [&](void*) {
|
||||||
String sta_ssid = jsonReadStr(settingsFlashJson, "routerssid");
|
String sta_ssid = jsonReadStr(settingsFlashJson, "routerssid");
|
||||||
|
|
||||||
SerialPrint("i", "WIFI", "scanning for " + sta_ssid);
|
SerialPrint("i", "WIFI", "scanning for " + sta_ssid);
|
||||||
|
|
||||||
if (RouterFind(sta_ssid)) {
|
if (RouterFind(sta_ssid)) {
|
||||||
ts.remove(WIFI_SCAN);
|
ts.remove(WIFI_SCAN);
|
||||||
WiFi.scanDelete();
|
WiFi.scanDelete();
|
||||||
routerConnect();
|
routerConnect();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
nullptr, true);
|
nullptr, true);
|
||||||
//}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,10 +105,11 @@ boolean RouterFind(String ssid) {
|
|||||||
}
|
}
|
||||||
// SerialPrint("i", "WIFI", (res ? "*" : "") + String(i, DEC) + ") " + WiFi.SSID(i));
|
// SerialPrint("i", "WIFI", (res ? "*" : "") + String(i, DEC) + ") " + WiFi.SSID(i));
|
||||||
jsonWriteStr_(ssidListJson, String(i), WiFi.SSID(i));
|
jsonWriteStr_(ssidListJson, String(i), WiFi.SSID(i));
|
||||||
|
|
||||||
// String(WiFi.RSSI(i)
|
// String(WiFi.RSSI(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SerialPrint("i", "WIFI", ssidListJson);
|
||||||
WiFi.scanDelete();
|
WiFi.scanDelete();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user