|
|
@ -912,11 +912,6 @@ String AutoConnect::_token_CSS_BASE(PageArgument& args) { |
|
|
|
return String(FPSTR(_CSS_BASE)); |
|
|
|
return String(FPSTR(_CSS_BASE)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_CSS_UL(PageArgument& args) { |
|
|
|
|
|
|
|
AC_UNUSED(args); |
|
|
|
|
|
|
|
return String(FPSTR(_CSS_UL)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_CSS_ICON_LOCK(PageArgument& args) { |
|
|
|
String AutoConnect::_token_CSS_ICON_LOCK(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(FPSTR(_CSS_ICON_LOCK)); |
|
|
|
return String(FPSTR(_CSS_ICON_LOCK)); |
|
|
@ -932,9 +927,9 @@ String AutoConnect::_token_CSS_INPUT_TEXT(PageArgument& args) { |
|
|
|
return String(FPSTR(_CSS_INPUT_TEXT)); |
|
|
|
return String(FPSTR(_CSS_INPUT_TEXT)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_CSS_TABLE(PageArgument& args) { |
|
|
|
String AutoConnect::_token_CSS_LUXBAR(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(FPSTR(_CSS_TABLE)); |
|
|
|
return String(FPSTR(_CSS_LUXBAR)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_CSS_SPINNER(PageArgument& args) { |
|
|
|
String AutoConnect::_token_CSS_SPINNER(PageArgument& args) { |
|
|
@ -942,9 +937,21 @@ String AutoConnect::_token_CSS_SPINNER(PageArgument& args) { |
|
|
|
return String(FPSTR(_CSS_SPINNER)); |
|
|
|
return String(FPSTR(_CSS_SPINNER)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_HEAD(PageArgument& args) { |
|
|
|
String AutoConnect::_token_CSS_TABLE(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(FPSTR(_ELM_HTML_HEAD)); |
|
|
|
return String(FPSTR(_CSS_TABLE)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_CSS_UL(PageArgument& args) { |
|
|
|
|
|
|
|
AC_UNUSED(args); |
|
|
|
|
|
|
|
return String(FPSTR(_CSS_UL)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_MENU_AUX(PageArgument& args) { |
|
|
|
|
|
|
|
String menuItem = String(""); |
|
|
|
|
|
|
|
if (_aux) |
|
|
|
|
|
|
|
menuItem = _aux->_injectMenu(args); |
|
|
|
|
|
|
|
return menuItem; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_MENU_PRE(PageArgument& args) { |
|
|
|
String AutoConnect::_token_MENU_PRE(PageArgument& args) { |
|
|
@ -960,13 +967,6 @@ String AutoConnect::_token_MENU_PRE(PageArgument& args) { |
|
|
|
return currentMenu; |
|
|
|
return currentMenu; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_MENU_AUX(PageArgument& args) { |
|
|
|
|
|
|
|
String menuItem = String(""); |
|
|
|
|
|
|
|
if (_aux) |
|
|
|
|
|
|
|
menuItem = _aux->_injectMenu(args); |
|
|
|
|
|
|
|
return menuItem; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_MENU_POST(PageArgument& args) { |
|
|
|
String AutoConnect::_token_MENU_POST(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
String postMenu = FPSTR(_ELM_MENU_POST); |
|
|
|
String postMenu = FPSTR(_ELM_MENU_POST); |
|
|
@ -976,184 +976,115 @@ String AutoConnect::_token_MENU_POST(PageArgument& args) { |
|
|
|
return postMenu; |
|
|
|
return postMenu; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_CSS_LUXBAR(PageArgument& args) { |
|
|
|
String AutoConnect::_token_AP_MAC(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(FPSTR(_CSS_LUXBAR)); |
|
|
|
uint8_t macAddress[6]; |
|
|
|
|
|
|
|
WiFi.softAPmacAddress(macAddress); |
|
|
|
|
|
|
|
return AutoConnect::_toMACAddressString(macAddress); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_ESTAB_SSID(PageArgument& args) { |
|
|
|
String AutoConnect::_token_BOOTURI(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return (WiFi.status() == WL_CONNECTED ? WiFi.SSID() : String(F("N/A"))); |
|
|
|
return _getBootUri(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_WIFI_MODE(PageArgument& args) { |
|
|
|
String AutoConnect::_token_CHANNEL(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
PGM_P wifiMode; |
|
|
|
return String(WiFi.channel()); |
|
|
|
switch (WiFi.getMode()) { |
|
|
|
|
|
|
|
case WIFI_OFF: |
|
|
|
|
|
|
|
wifiMode = PSTR("OFF"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WIFI_STA: |
|
|
|
|
|
|
|
wifiMode = PSTR("STA"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WIFI_AP: |
|
|
|
|
|
|
|
wifiMode = PSTR("AP"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WIFI_AP_STA: |
|
|
|
|
|
|
|
wifiMode = PSTR("AP_STA"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#ifdef ARDUINO_ARCH_ESP32 |
|
|
|
|
|
|
|
case WIFI_MODE_MAX: |
|
|
|
|
|
|
|
wifiMode = PSTR("MAX"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
wifiMode = PSTR("experimental"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return String(FPSTR(wifiMode)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_WIFI_STATUS(PageArgument& args) { |
|
|
|
String AutoConnect::_token_CHIP_ID(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(WiFi.status()); |
|
|
|
return String(_getChipId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_STATION_STATUS(PageArgument& args) { |
|
|
|
String AutoConnect::_token_CONFIG_STAIP(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
PGM_P wlStatusSymbol = PSTR(""); |
|
|
|
static const char _configIPList[] PROGMEM = |
|
|
|
// const char* wlStatusSymbol ="";
|
|
|
|
"<li class=\"exp\">" |
|
|
|
PGM_P wlStatusSymbols[] = { |
|
|
|
"<label for=\"%s\">%s</label>" |
|
|
|
// static const char* wlStatusSymbols[] = {
|
|
|
|
"<input id=\"%s\" type=\"text\" name=\"%s\" value=\"%s\">" |
|
|
|
#if defined(ARDUINO_ARCH_ESP8266) |
|
|
|
"</li>"; |
|
|
|
PSTR("IDLE"), |
|
|
|
struct _reps { |
|
|
|
PSTR("CONNECTING"), |
|
|
|
PGM_P lid; |
|
|
|
PSTR("WRONG_PASSWORD"), |
|
|
|
PGM_P lbl; |
|
|
|
PSTR("NO_AP_FOUND"), |
|
|
|
} static const reps[] = { |
|
|
|
PSTR("CONNECT_FAIL"), |
|
|
|
{ PSTR(AUTOCONNECT_PARAMID_STAIP), PSTR("IP Address") }, |
|
|
|
PSTR("GOT_IP") |
|
|
|
{ PSTR(AUTOCONNECT_PARAMID_GTWAY), PSTR("Gateway") }, |
|
|
|
}; |
|
|
|
{ PSTR(AUTOCONNECT_PARAMID_NTMSK), PSTR("Netmask") }, |
|
|
|
switch (wifi_station_get_connect_status()) { |
|
|
|
{ PSTR(AUTOCONNECT_PARAMID_DNS1), PSTR("DNS1") }, |
|
|
|
case STATION_IDLE: |
|
|
|
{ PSTR(AUTOCONNECT_PARAMID_DNS2), PSTR("DNS2") } |
|
|
|
wlStatusSymbol = wlStatusSymbols[0]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case STATION_CONNECTING: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[1]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case STATION_WRONG_PASSWORD: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[2]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case STATION_NO_AP_FOUND: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[3]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case STATION_CONNECT_FAIL: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[4]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case STATION_GOT_IP: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[5]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#elif defined(ARDUINO_ARCH_ESP32) |
|
|
|
|
|
|
|
PSTR("IDLE"), |
|
|
|
|
|
|
|
PSTR("NO_SSID_AVAIL"), |
|
|
|
|
|
|
|
PSTR("SCAN_COMPLETED"), |
|
|
|
|
|
|
|
PSTR("CONNECTED"), |
|
|
|
|
|
|
|
PSTR("CONNECT_FAILED"), |
|
|
|
|
|
|
|
PSTR("CONNECTION_LOST"), |
|
|
|
|
|
|
|
PSTR("DISCONNECTED"), |
|
|
|
|
|
|
|
PSTR("NO_SHIELD") |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
switch (_rsConnect) { |
|
|
|
char liCont[600]; |
|
|
|
case WL_IDLE_STATUS: |
|
|
|
char* liBuf = liCont; |
|
|
|
wlStatusSymbol = wlStatusSymbols[0]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_NO_SSID_AVAIL: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[1]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_SCAN_COMPLETED: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[2]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_CONNECTED: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[3]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_CONNECT_FAILED: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[4]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_CONNECTION_LOST: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[5]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_DISCONNECTED: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[6]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_NO_SHIELD: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[7]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return String("(") + String(_rsConnect) + String(") ") + String(FPSTR(wlStatusSymbol)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_LOCAL_IP(PageArgument& args) { |
|
|
|
|
|
|
|
AC_UNUSED(args); |
|
|
|
|
|
|
|
return WiFi.localIP().toString(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_SOFTAP_IP(PageArgument& args) { |
|
|
|
for (uint8_t i = 0; i < 5; i++) { |
|
|
|
AC_UNUSED(args); |
|
|
|
IPAddress* ip = nullptr; |
|
|
|
return WiFi.softAPIP().toString(); |
|
|
|
if (i == 0) |
|
|
|
|
|
|
|
ip = &_apConfig.staip; |
|
|
|
|
|
|
|
else if (i == 1) |
|
|
|
|
|
|
|
ip = &_apConfig.staGateway; |
|
|
|
|
|
|
|
else if (i == 2) |
|
|
|
|
|
|
|
ip = &_apConfig.staNetmask; |
|
|
|
|
|
|
|
else if (i == 3) |
|
|
|
|
|
|
|
ip = &_apConfig.dns1; |
|
|
|
|
|
|
|
else if (i == 4) |
|
|
|
|
|
|
|
ip = &_apConfig.dns2; |
|
|
|
|
|
|
|
String ipStr = ip != nullptr ? ip->toString() : String(F("0.0.0.0")); |
|
|
|
|
|
|
|
snprintf_P(liBuf, sizeof(liCont) - (liBuf - liCont), (PGM_P)_configIPList, reps[i].lid, reps[i].lbl, reps[i].lid, reps[i].lid, ipStr.c_str()); |
|
|
|
|
|
|
|
liBuf += strlen(liBuf); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return String(liCont); |
|
|
|
String AutoConnect::_token_GATEWAY(PageArgument& args) { |
|
|
|
|
|
|
|
AC_UNUSED(args); |
|
|
|
|
|
|
|
return WiFi.gatewayIP().toString(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_NETMASK(PageArgument& args) { |
|
|
|
String AutoConnect::_token_CPU_FREQ(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return WiFi.subnetMask().toString(); |
|
|
|
return String(ESP.getCpuFreqMHz()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_AP_MAC(PageArgument& args) { |
|
|
|
String AutoConnect::_token_CURRENT_SSID(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
uint8_t macAddress[6]; |
|
|
|
char ssid_c[sizeof(station_config_t::ssid) + 1]; |
|
|
|
WiFi.softAPmacAddress(macAddress); |
|
|
|
*ssid_c = '\0'; |
|
|
|
return AutoConnect::_toMACAddressString(macAddress); |
|
|
|
strncat(ssid_c, reinterpret_cast<char*>(_credential.ssid), sizeof(ssid_c) - 1); |
|
|
|
|
|
|
|
String ssid = String(ssid_c); |
|
|
|
|
|
|
|
return ssid; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_STA_MAC(PageArgument& args) { |
|
|
|
String AutoConnect::_token_DBM(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
uint8_t macAddress[6]; |
|
|
|
int32_t dBm = WiFi.RSSI(); |
|
|
|
WiFi.macAddress(macAddress); |
|
|
|
return (dBm == 31 ? String(F("N/A")) : String(dBm)); |
|
|
|
return AutoConnect::_toMACAddressString(macAddress); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_CHANNEL(PageArgument& args) { |
|
|
|
String AutoConnect::_token_ESTAB_SSID(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(WiFi.channel()); |
|
|
|
return (WiFi.status() == WL_CONNECTED ? WiFi.SSID() : String(F("N/A"))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_DBM(PageArgument& args) { |
|
|
|
String AutoConnect::_token_FLASH_SIZE(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
int32_t dBm = WiFi.RSSI(); |
|
|
|
return String(_getFlashChipRealSize()); |
|
|
|
return (dBm == 31 ? String(F("N/A")) : String(dBm)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_CPU_FREQ(PageArgument& args) { |
|
|
|
String AutoConnect::_token_FREE_HEAP(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(ESP.getCpuFreqMHz()); |
|
|
|
return String(_freeHeapSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_FLASH_SIZE(PageArgument& args) { |
|
|
|
String AutoConnect::_token_GATEWAY(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(_getFlashChipRealSize()); |
|
|
|
return WiFi.gatewayIP().toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_CHIP_ID(PageArgument& args) { |
|
|
|
String AutoConnect::_token_HEAD(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(_getChipId()); |
|
|
|
return String(FPSTR(_ELM_HTML_HEAD)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_FREE_HEAP(PageArgument& args) { |
|
|
|
String AutoConnect::_token_HIDDEN_COUNT(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(_freeHeapSize); |
|
|
|
return String(_hiddenSSIDCount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_LIST_SSID(PageArgument& args) { |
|
|
|
String AutoConnect::_token_LIST_SSID(PageArgument& args) { |
|
|
@ -1226,53 +1157,14 @@ String AutoConnect::_token_LIST_SSID(PageArgument& args) { |
|
|
|
return ssidListStr; |
|
|
|
return ssidListStr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_SSID_COUNT(PageArgument& args) { |
|
|
|
String AutoConnect::_token_LOCAL_IP(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
|
|
|
|
return String(_scanCount); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_HIDDEN_COUNT(PageArgument& args) { |
|
|
|
|
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(_hiddenSSIDCount); |
|
|
|
return WiFi.localIP().toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_CONFIG_STAIP(PageArgument& args) { |
|
|
|
String AutoConnect::_token_NETMASK(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
static const char _configIPList[] PROGMEM = |
|
|
|
return WiFi.subnetMask().toString(); |
|
|
|
"<li class=\"exp\">" |
|
|
|
|
|
|
|
"<label for=\"%s\">%s</label>" |
|
|
|
|
|
|
|
"<input id=\"%s\" type=\"text\" name=\"%s\" value=\"%s\">" |
|
|
|
|
|
|
|
"</li>"; |
|
|
|
|
|
|
|
struct _reps { |
|
|
|
|
|
|
|
PGM_P lid; |
|
|
|
|
|
|
|
PGM_P lbl; |
|
|
|
|
|
|
|
} static const reps[] = { |
|
|
|
|
|
|
|
{ PSTR(AUTOCONNECT_PARAMID_STAIP), PSTR("IP Address") }, |
|
|
|
|
|
|
|
{ PSTR(AUTOCONNECT_PARAMID_GTWAY), PSTR("Gateway") }, |
|
|
|
|
|
|
|
{ PSTR(AUTOCONNECT_PARAMID_NTMSK), PSTR("Netmask") }, |
|
|
|
|
|
|
|
{ PSTR(AUTOCONNECT_PARAMID_DNS1), PSTR("DNS1") }, |
|
|
|
|
|
|
|
{ PSTR(AUTOCONNECT_PARAMID_DNS2), PSTR("DNS2") } |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
char liCont[600]; |
|
|
|
|
|
|
|
char* liBuf = liCont; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < 5; i++) { |
|
|
|
|
|
|
|
IPAddress* ip = nullptr; |
|
|
|
|
|
|
|
if (i == 0) |
|
|
|
|
|
|
|
ip = &_apConfig.staip; |
|
|
|
|
|
|
|
else if (i == 1) |
|
|
|
|
|
|
|
ip = &_apConfig.staGateway; |
|
|
|
|
|
|
|
else if (i == 2) |
|
|
|
|
|
|
|
ip = &_apConfig.staNetmask; |
|
|
|
|
|
|
|
else if (i == 3) |
|
|
|
|
|
|
|
ip = &_apConfig.dns1; |
|
|
|
|
|
|
|
else if (i == 4) |
|
|
|
|
|
|
|
ip = &_apConfig.dns2; |
|
|
|
|
|
|
|
String ipStr = ip != nullptr ? ip->toString() : String(F("0.0.0.0")); |
|
|
|
|
|
|
|
snprintf_P(liBuf, sizeof(liCont) - (liBuf - liCont), (PGM_P)_configIPList, reps[i].lid, reps[i].lbl, reps[i].lid, reps[i].lid, ipStr.c_str()); |
|
|
|
|
|
|
|
liBuf += strlen(liBuf); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return String(liCont); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_OPEN_SSID(PageArgument& args) { |
|
|
|
String AutoConnect::_token_OPEN_SSID(PageArgument& args) { |
|
|
@ -1318,23 +1210,131 @@ String AutoConnect::_token_OPEN_SSID(PageArgument& args) { |
|
|
|
return ssidList; |
|
|
|
return ssidList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_SOFTAP_IP(PageArgument& args) { |
|
|
|
|
|
|
|
AC_UNUSED(args); |
|
|
|
|
|
|
|
return WiFi.softAPIP().toString(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_SSID_COUNT(PageArgument& args) { |
|
|
|
|
|
|
|
AC_UNUSED(args); |
|
|
|
|
|
|
|
return String(_scanCount); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_STA_MAC(PageArgument& args) { |
|
|
|
|
|
|
|
AC_UNUSED(args); |
|
|
|
|
|
|
|
uint8_t macAddress[6]; |
|
|
|
|
|
|
|
WiFi.macAddress(macAddress); |
|
|
|
|
|
|
|
return AutoConnect::_toMACAddressString(macAddress); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_STATION_STATUS(PageArgument& args) { |
|
|
|
|
|
|
|
AC_UNUSED(args); |
|
|
|
|
|
|
|
PGM_P wlStatusSymbol = PSTR(""); |
|
|
|
|
|
|
|
// const char* wlStatusSymbol ="";
|
|
|
|
|
|
|
|
PGM_P wlStatusSymbols[] = { |
|
|
|
|
|
|
|
// static const char* wlStatusSymbols[] = {
|
|
|
|
|
|
|
|
#if defined(ARDUINO_ARCH_ESP8266) |
|
|
|
|
|
|
|
PSTR("IDLE"), |
|
|
|
|
|
|
|
PSTR("CONNECTING"), |
|
|
|
|
|
|
|
PSTR("WRONG_PASSWORD"), |
|
|
|
|
|
|
|
PSTR("NO_AP_FOUND"), |
|
|
|
|
|
|
|
PSTR("CONNECT_FAIL"), |
|
|
|
|
|
|
|
PSTR("GOT_IP") |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
switch (wifi_station_get_connect_status()) { |
|
|
|
|
|
|
|
case STATION_IDLE: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[0]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case STATION_CONNECTING: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[1]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case STATION_WRONG_PASSWORD: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[2]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case STATION_NO_AP_FOUND: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[3]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case STATION_CONNECT_FAIL: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[4]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case STATION_GOT_IP: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[5]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#elif defined(ARDUINO_ARCH_ESP32) |
|
|
|
|
|
|
|
PSTR("IDLE"), |
|
|
|
|
|
|
|
PSTR("NO_SSID_AVAIL"), |
|
|
|
|
|
|
|
PSTR("SCAN_COMPLETED"), |
|
|
|
|
|
|
|
PSTR("CONNECTED"), |
|
|
|
|
|
|
|
PSTR("CONNECT_FAILED"), |
|
|
|
|
|
|
|
PSTR("CONNECTION_LOST"), |
|
|
|
|
|
|
|
PSTR("DISCONNECTED"), |
|
|
|
|
|
|
|
PSTR("NO_SHIELD") |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
switch (_rsConnect) { |
|
|
|
|
|
|
|
case WL_IDLE_STATUS: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[0]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_NO_SSID_AVAIL: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[1]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_SCAN_COMPLETED: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[2]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_CONNECTED: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[3]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_CONNECT_FAILED: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[4]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_CONNECTION_LOST: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[5]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_DISCONNECTED: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[6]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WL_NO_SHIELD: |
|
|
|
|
|
|
|
wlStatusSymbol = wlStatusSymbols[7]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return String("(") + String(_rsConnect) + String(") ") + String(FPSTR(wlStatusSymbol)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_UPTIME(PageArgument& args) { |
|
|
|
String AutoConnect::_token_UPTIME(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return String(_apConfig.uptime); |
|
|
|
return String(_apConfig.uptime); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_BOOTURI(PageArgument& args) { |
|
|
|
String AutoConnect::_token_WIFI_MODE(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
return _getBootUri(); |
|
|
|
PGM_P wifiMode; |
|
|
|
|
|
|
|
switch (WiFi.getMode()) { |
|
|
|
|
|
|
|
case WIFI_OFF: |
|
|
|
|
|
|
|
wifiMode = PSTR("OFF"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WIFI_STA: |
|
|
|
|
|
|
|
wifiMode = PSTR("STA"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WIFI_AP: |
|
|
|
|
|
|
|
wifiMode = PSTR("AP"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WIFI_AP_STA: |
|
|
|
|
|
|
|
wifiMode = PSTR("AP_STA"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#ifdef ARDUINO_ARCH_ESP32 |
|
|
|
|
|
|
|
case WIFI_MODE_MAX: |
|
|
|
|
|
|
|
wifiMode = PSTR("MAX"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
wifiMode = PSTR("experimental"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return String(FPSTR(wifiMode)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String AutoConnect::_token_CURRENT_SSID(PageArgument& args) { |
|
|
|
String AutoConnect::_token_WIFI_STATUS(PageArgument& args) { |
|
|
|
AC_UNUSED(args); |
|
|
|
AC_UNUSED(args); |
|
|
|
char ssid_c[sizeof(station_config_t::ssid) + 1]; |
|
|
|
return String(WiFi.status()); |
|
|
|
*ssid_c = '\0'; |
|
|
|
|
|
|
|
strncat(ssid_c, reinterpret_cast<char*>(_credential.ssid), sizeof(ssid_c) - 1); |
|
|
|
|
|
|
|
String ssid = String(ssid_c); |
|
|
|
|
|
|
|
return ssid; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|