Browse Source

Fix wifi keys issues

v2
Xose Pérez 6 years ago
parent
commit
d852f2a4df
15 changed files with 10873 additions and 10845 deletions
  1. BIN
      code/espurna/data/index.all.html.gz
  2. BIN
      code/espurna/data/index.light.html.gz
  3. BIN
      code/espurna/data/index.rfbridge.html.gz
  4. BIN
      code/espurna/data/index.sensor.html.gz
  5. BIN
      code/espurna/data/index.small.html.gz
  6. +22
    -0
      code/espurna/espurna.ino
  7. +2272
    -2271
      code/espurna/static/index.all.html.gz.h
  8. +2220
    -2219
      code/espurna/static/index.light.html.gz.h
  9. +2544
    -2543
      code/espurna/static/index.rfbridge.html.gz.h
  10. +1889
    -1888
      code/espurna/static/index.sensor.html.gz.h
  11. +1855
    -1853
      code/espurna/static/index.small.html.gz.h
  12. +61
    -56
      code/espurna/wifi.ino
  13. +3
    -3
      code/espurna/ws.ino
  14. +1
    -1
      code/html/custom.js
  15. +6
    -11
      code/html/index.html

BIN
code/espurna/data/index.all.html.gz View File


BIN
code/espurna/data/index.light.html.gz View File


BIN
code/espurna/data/index.rfbridge.html.gz View File


BIN
code/espurna/data/index.sensor.html.gz View File


BIN
code/espurna/data/index.small.html.gz View File


+ 22
- 0
code/espurna/espurna.ino View File

@ -34,6 +34,23 @@ void espurnaRegisterLoop(void (*callback)()) {
_loop_callbacks.push_back(callback);
}
// -----------------------------------------------------------------------------
// GLOBAL CONFIG KEYS
// -----------------------------------------------------------------------------
#if WEB_SUPPORT
bool _espWebSocketOnReceive(const char * key, JsonVariant& value) {
if (strncmp(key, "admin", 5) == 0) return true;
if (strncmp(key, "hostname", 8) == 0) return true;
if (strncmp(key, "boardName", 9) == 0) return true;
if (strncmp(key, "loopDelay", 9) == 0) return true;
if (strncmp(key, "wtfHeap", 7) == 0) return true;
return false;
}
#endif
// -----------------------------------------------------------------------------
// BOOTING
// -----------------------------------------------------------------------------
@ -172,6 +189,11 @@ void setup() {
saveSettings();
// Global configuration settings
#if WEB_SUPPORT
wsOnReceiveRegister(_espWebSocketOnReceive);
#endif
}
void loop() {


+ 2272
- 2271
code/espurna/static/index.all.html.gz.h
File diff suppressed because it is too large
View File


+ 2220
- 2219
code/espurna/static/index.light.html.gz.h
File diff suppressed because it is too large
View File


+ 2544
- 2543
code/espurna/static/index.rfbridge.html.gz.h
File diff suppressed because it is too large
View File


+ 1889
- 1888
code/espurna/static/index.sensor.html.gz.h
File diff suppressed because it is too large
View File


+ 1855
- 1853
code/espurna/static/index.small.html.gz.h
File diff suppressed because it is too large
View File


+ 61
- 56
code/espurna/wifi.ino View File

@ -45,7 +45,7 @@ void _wifiConfigure() {
jw.enableAPFallback(true);
jw.cleanNetworks();
_wifi_ap_mode = getSetting("apmode", WIFI_AP_FALLBACK).toInt();
_wifi_ap_mode = getSetting("wifiMode", WIFI_AP_FALLBACK).toInt();
// If system is flagged unstable we do not init wifi networks
#if SYSTEM_CHECK_ENABLED
@ -57,20 +57,20 @@ void _wifiConfigure() {
int i;
for (i = 0; i< WIFI_MAX_NETWORKS; i++) {
if (getSetting("ssid" + String(i)).length() == 0) break;
if (getSetting("ip" + String(i)).length() == 0) {
if (!hasSetting("wifiName", i)) break;
if (hasSetting("wifiIP", i)) {
jw.addNetwork(
getSetting("ssid" + String(i)).c_str(),
getSetting("pass" + String(i)).c_str()
getSetting("wifiName", i, "").c_str(),
getSetting("wifiPass", i, "").c_str(),
getSetting("wifiIP", i, "").c_str(),
getSetting("wifiGW", i, "").c_str(),
getSetting("wifiMask", i, "").c_str(),
getSetting("wifiDNS", i, "").c_str()
);
} else {
jw.addNetwork(
getSetting("ssid" + String(i)).c_str(),
getSetting("pass" + String(i)).c_str(),
getSetting("ip" + String(i)).c_str(),
getSetting("gw" + String(i)).c_str(),
getSetting("mask" + String(i)).c_str(),
getSetting("dns" + String(i)).c_str()
getSetting("wifiName", i, "").c_str(),
getSetting("wifiPass", i, "").c_str()
);
}
}
@ -155,17 +155,17 @@ bool _wifiClean(unsigned char num) {
while (i < num) {
// Skip on first non-defined setting
if (!hasSetting("ssid", i)) {
delSetting("ssid", i);
if (!hasSetting("wifiName", i)) {
delSetting("wifiName", i);
break;
}
// Delete empty values
if (!hasSetting("pass", i)) delSetting("pass", i);
if (!hasSetting("ip", i)) delSetting("ip", i);
if (!hasSetting("gw", i)) delSetting("gw", i);
if (!hasSetting("mask", i)) delSetting("mask", i);
if (!hasSetting("dns", i)) delSetting("dns", i);
if (!hasSetting("wifiPass", i)) delSetting("wifiPass", i);
if (!hasSetting("wifiIP", i)) delSetting("wifiIP", i);
if (!hasSetting("wifiGW", i)) delSetting("wifiGW", i);
if (!hasSetting("wifiMask", i)) delSetting("wifiMask", i);
if (!hasSetting("wifiDNS", i)) delSetting("wifiDNS", i);
++i;
@ -173,13 +173,13 @@ bool _wifiClean(unsigned char num) {
// Delete all other settings
while (i < WIFI_MAX_NETWORKS) {
changed = hasSetting("ssid", i);
delSetting("ssid", i);
delSetting("pass", i);
delSetting("ip", i);
delSetting("gw", i);
delSetting("mask", i);
delSetting("dns", i);
changed = hasSetting("wifiName", i);
delSetting("wifiName", i);
delSetting("wifiPass", i);
delSetting("wifiIP", i);
delSetting("wifiGW", i);
delSetting("wifiMask", i);
delSetting("wifiDNS", i);
++i;
}
@ -192,23 +192,23 @@ void _wifiInject() {
if (strlen(WIFI1_SSID)) {
if (!hasSetting("ssid", 0)) {
setSetting("ssid", 0, WIFI1_SSID);
setSetting("pass", 0, WIFI1_PASS);
setSetting("ip", 0, WIFI1_IP);
setSetting("gw", 0, WIFI1_GW);
setSetting("mask", 0, WIFI1_MASK);
setSetting("dns", 0, WIFI1_DNS);
if (!hasSetting("wifiName", 0)) {
setSetting("wifiName", 0, WIFI1_SSID);
setSetting("wifiPass", 0, WIFI1_PASS);
setSetting("wifiIP", 0, WIFI1_IP);
setSetting("wifiGW", 0, WIFI1_GW);
setSetting("wifiMask", 0, WIFI1_MASK);
setSetting("wifiDNS", 0, WIFI1_DNS);
}
if (strlen(WIFI2_SSID)) {
if (!hasSetting("ssid", 1)) {
setSetting("ssid", 1, WIFI2_SSID);
setSetting("pass", 1, WIFI2_PASS);
setSetting("ip", 1, WIFI2_IP);
setSetting("gw", 1, WIFI2_GW);
setSetting("mask", 1, WIFI2_MASK);
setSetting("dns", 1, WIFI2_DNS);
if (!hasSetting("wifiName", 1)) {
setSetting("wifiName", 1, WIFI2_SSID);
setSetting("wifiPass", 1, WIFI2_PASS);
setSetting("wifiIP", 1, WIFI2_IP);
setSetting("wifiGW", 1, WIFI2_GW);
setSetting("wifiMask", 1, WIFI2_MASK);
setSetting("wifiDNS", 1, WIFI2_DNS);
}
}
@ -238,16 +238,16 @@ void _wifiCallback(justwifi_messages_t code, char * parameter) {
// Look for the same SSID
uint8_t count = 0;
while (count < WIFI_MAX_NETWORKS) {
if (!hasSetting("ssid", count)) break;
if (ssid.equals(getSetting("ssid", count, ""))) break;
if (!hasSetting("wifiName", count)) break;
if (ssid.equals(getSetting("wifiName", count, ""))) break;
count++;
}
// If we have reached the max we overwrite the first one
if (WIFI_MAX_NETWORKS == count) count = 0;
setSetting("ssid", count, ssid);
setSetting("pass", count, pass);
setSetting("wifiName", count, ssid);
setSetting("wifiPass", count, pass);
_wifi_wps_running = false;
_wifi_smartconfig_running = false;
@ -427,12 +427,6 @@ void _wifiInitCommands() {
bool _wifiWebSocketOnReceive(const char * key, JsonVariant& value) {
if (strncmp(key, "wifi", 4) == 0) return true;
if (strncmp(key, "ssid", 4) == 0) return true;
if (strncmp(key, "pass", 4) == 0) return true;
if (strncmp(key, "ip", 2) == 0) return true;
if (strncmp(key, "gw", 2) == 0) return true;
if (strncmp(key, "mask", 4) == 0) return true;
if (strncmp(key, "dns", 3) == 0) return true;
return false;
}
@ -441,14 +435,14 @@ void _wifiWebSocketOnSend(JsonObject& root) {
root["wifiScan"] = getSetting("wifiScan", WIFI_SCAN_NETWORKS).toInt() == 1;
JsonArray& wifi = root.createNestedArray("wifi");
for (byte i=0; i<WIFI_MAX_NETWORKS; i++) {
if (!hasSetting("ssid", i)) break;
if (!hasSetting("wifiName", i)) break;
JsonObject& network = wifi.createNestedObject();
network["ssid"] = getSetting("ssid", i, "");
network["pass"] = getSetting("pass", i, "");
network["ip"] = getSetting("ip", i, "");
network["gw"] = getSetting("gw", i, "");
network["mask"] = getSetting("mask", i, "");
network["dns"] = getSetting("dns", i, "");
network["wifiName"] = getSetting("wifiName", i, "");
network["wifiPass"] = getSetting("wifiPass", i, "");
network["wifiIP"] = getSetting("wifiIP", i, "");
network["wifiGW"] = getSetting("wifiGW", i, "");
network["wifiMask"] = getSetting("wifiMask", i, "");
network["wifiDNS"] = getSetting("wifiDNS", i, "");
}
}
@ -458,6 +452,16 @@ void _wifiWebSocketOnAction(uint32_t client_id, const char * action, JsonObject&
#endif
void _wifiBackwards() {
moveSettings("ssid", "wifiName");
moveSettings("pass", "wifiPass");
moveSettings("ip", "wifiIP");
moveSettings("gw", "wifiGW");
moveSettings("mask", "wifiMask");
moveSettings("dns", "wifiDNS");
moveSetting("apmode", "wifiMode");
}
// -----------------------------------------------------------------------------
// INFO
// -----------------------------------------------------------------------------
@ -594,6 +598,7 @@ void wifiSetup() {
WiFi.setSleepMode(WIFI_SLEEP_MODE);
_wifiBackwards();
_wifiInject();
_wifiConfigure();


+ 3
- 3
code/espurna/ws.ino View File

@ -303,11 +303,11 @@ bool _wsOnReceive(const char * key, JsonVariant& value) {
void _wsOnStart(JsonObject& root) {
unsigned char webMode = webMode();
unsigned char web_mode = webMode();
root["webMode"] = webMode;
root["webMode"] = web_mode;
if (WEB_MODE_NORMAL == webMode) {
if (WEB_MODE_NORMAL == web_mode) {
char chipid[7];
snprintf_P(chipid, sizeof(chipid), PSTR("%06X"), ESP.getChipId());


+ 1
- 1
code/html/custom.js View File

@ -199,7 +199,7 @@ function addValue(data, name, value) {
// These fields will always be a list of values
var is_group = [
"ssid", "pass", "gw", "mask", "ip", "dns",
"wifiName", "wifiPass", "wifiGW", "wifiMask", "wifiIP", "wifiDNS",
"schEnabled", "schSwitch","schAction","schType","schHour","schMinute","schWDs","schUTC",
"rlyBoot", "rlyPulse", "rlyTime",
"mqttGroup", "mqttGroupInv", "rlyOnDisc",


+ 6
- 11
code/html/index.html View File

@ -220,11 +220,6 @@
<div class="pure-u-1-2">Firmware version</div>
<div class="pure-u-11-24"><span class="right" name="app_version"></span></div>
<!--
<div class="pure-u-1-2">Firmware revision</div>
<div class="pure-u-11-24"><span class="right" name="app_revision"></span></div>
-->
<div class="pure-u-1-2">Firmware build date</div>
<div class="pure-u-11-24"><span class="right" name="app_build"></span></div>
@ -1243,29 +1238,29 @@
<div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Network SSID</label>
<div class="pure-u-5-6 pure-u-lg-2-3"><input name="ssid" type="text" action="reconnect" class="pure-u-23-24" value="" tabindex="0" placeholder="Network SSID" required autocomplete="false" /></div>
<div class="pure-u-5-6 pure-u-lg-2-3"><input name="wifiName" type="text" action="reconnect" class="pure-u-23-24" value="" tabindex="0" placeholder="Network SSID" required autocomplete="false" /></div>
<div class="pure-u-1-6 pure-u-lg-1-12"><button type="button" class="pure-button button-more-network pure-u-1">...</button></div>
<label class="pure-u-1 pure-u-lg-1-4 more">Password</label>
<input class="pure-u-1 pure-u-lg-3-4 more" name="pass" type="password" action="reconnect" value="" tabindex="0" autocomplete="false" />
<input class="pure-u-1 pure-u-lg-3-4 more" name="wifiPass" type="password" action="reconnect" value="" tabindex="0" autocomplete="false" />
<label class="pure-u-1 pure-u-lg-1-4 more">Static IP</label>
<input class="pure-u-1 pure-u-lg-3-4 more" name="ip" type="text" action="reconnect" value="" maxlength="15" tabindex="0" autocomplete="false" />
<input class="pure-u-1 pure-u-lg-3-4 more" name="wifiIP" type="text" action="reconnect" value="" maxlength="15" tabindex="0" autocomplete="false" />
<div class="pure-u-0 pure-u-lg-1-4 more"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint more">Leave empty for DNS negotiation</div>
<label class="pure-u-1 pure-u-lg-1-4 more">Gateway IP</label>
<input class="pure-u-1 pure-u-lg-3-4 more" name="gw" type="text" action="reconnect" value="" maxlength="15" tabindex="0" autocomplete="false" />
<input class="pure-u-1 pure-u-lg-3-4 more" name="wifiGW" type="text" action="reconnect" value="" maxlength="15" tabindex="0" autocomplete="false" />
<div class="pure-u-0 pure-u-lg-1-4 more"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint more">Set when using a static IP</div>
<label class="pure-u-1 pure-u-lg-1-4 more">Network Mask</label>
<input class="pure-u-1 pure-u-lg-3-4 more" name="mask" type="text" action="reconnect" value="255.255.255.0" maxlength="15" tabindex="0" autocomplete="false" />
<input class="pure-u-1 pure-u-lg-3-4 more" name="wifiMask" type="text" action="reconnect" value="255.255.255.0" maxlength="15" tabindex="0" autocomplete="false" />
<div class="pure-u-0 pure-u-lg-1-4 more"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint more">Usually 255.255.255.0 for /24 networks</div>
<label class="pure-u-1 pure-u-lg-1-4 more">DNS IP</label>
<input class="pure-u-1 pure-u-lg-3-4 more" name="dns" type="text" action="reconnect" value="8.8.8.8" maxlength="15" tabindex="0" autocomplete="false" />
<input class="pure-u-1 pure-u-lg-3-4 more" name="wifiDNS" type="text" action="reconnect" value="8.8.8.8" maxlength="15" tabindex="0" autocomplete="false" />
<div class="pure-u-0 pure-u-lg-1-4 more"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint more">Set the Domain Name Server IP to use when using a static IP</div>


Loading…
Cancel
Save