Browse Source

Disable websocket code in wifiScan if no WEB_SUPPORT

i18n
Xose Pérez 6 years ago
parent
commit
21b3c6dd85
1 changed files with 20 additions and 8 deletions
  1. +20
    -8
      code/espurna/wifi.ino

+ 20
- 8
code/espurna/wifi.ino View File

@ -64,15 +64,22 @@ void _wifiScan(uint32_t client_id = 0) {
DEBUG_MSG_P(PSTR("[WIFI] Start scanning\n")); DEBUG_MSG_P(PSTR("[WIFI] Start scanning\n"));
String output;
#if WEB_SUPPORT
String output;
#endif
unsigned char result = WiFi.scanNetworks(); unsigned char result = WiFi.scanNetworks();
if (result == WIFI_SCAN_FAILED) { if (result == WIFI_SCAN_FAILED) {
DEBUG_MSG_P(PSTR("[WIFI] Scan failed\n")); DEBUG_MSG_P(PSTR("[WIFI] Scan failed\n"));
output = String("Failed scan");
#if WEB_SUPPORT
output = String("Failed scan");
#endif
} else if (result == 0) { } else if (result == 0) {
DEBUG_MSG_P(PSTR("[WIFI] No networks found\n")); DEBUG_MSG_P(PSTR("[WIFI] No networks found\n"));
output = String("No networks found");
#if WEB_SUPPORT
output = String("No networks found");
#endif
} else { } else {
DEBUG_MSG_P(PSTR("[WIFI] %d networks found:\n"), result); DEBUG_MSG_P(PSTR("[WIFI] %d networks found:\n"), result);
@ -100,16 +107,21 @@ void _wifiScan(uint32_t client_id = 0) {
); );
DEBUG_MSG_P(PSTR("[WIFI] > %s\n"), buffer); DEBUG_MSG_P(PSTR("[WIFI] > %s\n"), buffer);
if (client_id > 0) output = output + String(buffer) + String("<br />");
#if WEB_SUPPORT
if (client_id > 0) output = output + String(buffer) + String("<br />");
#endif
} }
} }
if (client_id > 0) {
output = String("{\"scanResult\": \"") + output + String("\"}");
wsSend(client_id, output.c_str());
}
#if WEB_SUPPORT
if (client_id > 0) {
output = String("{\"scanResult\": \"") + output + String("\"}");
wsSend(client_id, output.c_str());
}
#endif
WiFi.scanDelete(); WiFi.scanDelete();


Loading…
Cancel
Save