From 21b3c6dd853f0cc052ebbb8ee13cf0eb1a3213f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Sun, 14 Jan 2018 23:44:32 +0100 Subject: [PATCH] Disable websocket code in wifiScan if no WEB_SUPPORT --- code/espurna/wifi.ino | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/code/espurna/wifi.ino b/code/espurna/wifi.ino index d050af08..26e3e3cd 100644 --- a/code/espurna/wifi.ino +++ b/code/espurna/wifi.ino @@ -64,15 +64,22 @@ void _wifiScan(uint32_t client_id = 0) { DEBUG_MSG_P(PSTR("[WIFI] Start scanning\n")); - String output; + #if WEB_SUPPORT + String output; + #endif + unsigned char result = WiFi.scanNetworks(); if (result == WIFI_SCAN_FAILED) { DEBUG_MSG_P(PSTR("[WIFI] Scan failed\n")); - output = String("Failed scan"); + #if WEB_SUPPORT + output = String("Failed scan"); + #endif } else if (result == 0) { DEBUG_MSG_P(PSTR("[WIFI] No networks found\n")); - output = String("No networks found"); + #if WEB_SUPPORT + output = String("No networks found"); + #endif } else { 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); - if (client_id > 0) output = output + String(buffer) + String("
"); + + #if WEB_SUPPORT + if (client_id > 0) output = output + String(buffer) + String("
"); + #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();