From 48c822653b2a923e9db45ffe64e7323545fdef33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Thu, 16 Feb 2017 00:21:15 +0100 Subject: [PATCH] Fix network clean up --- code/espurna/web.ino | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/code/espurna/web.ino b/code/espurna/web.ino index d86735c0..5e8c2fbc 100644 --- a/code/espurna/web.ino +++ b/code/espurna/web.ino @@ -244,14 +244,20 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) { #endif // Clean wifi networks - for (int i = 0; i < network; i++) { - if (getSetting("pass" + String(i)).length() > 0) delSetting("pass" + String(i)); + int i = 0; + while (i < network) { + if (getSetting("ssid" + String(i)).length() == 0) { + delSetting("ssid" + String(i)); + break; + } + if (getSetting("pass" + String(i)).length() == 0) delSetting("pass" + String(i)); if (getSetting("ip" + String(i)).length() == 0) delSetting("ip" + String(i)); if (getSetting("gw" + String(i)).length() == 0) delSetting("gw" + String(i)); if (getSetting("mask" + String(i)).length() == 0) delSetting("mask" + String(i)); if (getSetting("dns" + String(i)).length() == 0) delSetting("dns" + String(i)); + ++i; } - for (int i = network; i 0) { save = changed = true; } @@ -261,6 +267,7 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) { delSetting("gw" + String(i)); delSetting("mask" + String(i)); delSetting("dns" + String(i)); + ++i; } }