Browse Source

Rename terminal commands: reset.wifi to wifi.reset, reset.mqtt to mqtt.reset. Added wiki.scan

i18n
Xose Pérez 6 years ago
parent
commit
8a7b0a2021
2 changed files with 59 additions and 12 deletions
  1. +15
    -10
      code/espurna/settings.ino
  2. +44
    -2
      code/espurna/wifi.ino

+ 15
- 10
code/espurna/settings.ino View File

@ -308,6 +308,14 @@ void settingsSetup() {
});
#endif
#if MQTT_SUPPORT
Embedis::command( F("MQTT.RESET"), [](Embedis* e) {
mqttConfigure();
mqttDisconnect();
DEBUG_MSG_P(PSTR("+OK\n"));
});
#endif
#if NOFUSS_SUPPORT
Embedis::command( F("NOFUSS"), [](Embedis* e) {
DEBUG_MSG_P(PSTR("+OK\n"));
@ -337,22 +345,19 @@ void settingsSetup() {
deferredReset(100, CUSTOM_RESET_TERMINAL);
});
#if MQTT_SUPPORT
Embedis::command( F("RESET.MQTT"), [](Embedis* e) {
mqttConfigure();
mqttDisconnect();
DEBUG_MSG_P(PSTR("+OK\n"));
});
#endif
Embedis::command( F("UPTIME"), [](Embedis* e) {
DEBUG_MSG_P(PSTR("Uptime: %d seconds\n"), getUptime());
DEBUG_MSG_P(PSTR("+OK\n"));
});
Embedis::command( F("RESET.WIFI"), [](Embedis* e) {
Embedis::command( F("WIFI.RESET"), [](Embedis* e) {
wifiConfigure();
wifiDisconnect();
DEBUG_MSG_P(PSTR("+OK\n"));
});
Embedis::command( F("UPTIME"), [](Embedis* e) {
DEBUG_MSG_P(PSTR("Uptime: %d seconds\n"), getUptime());
Embedis::command( F("WIFI.SCAN"), [](Embedis* e) {
wifiScan();
DEBUG_MSG_P(PSTR("+OK\n"));
});


+ 44
- 2
code/espurna/wifi.ino View File

@ -111,8 +111,7 @@ void wifiConfigure() {
}
}
// Scan for best network only if we have more than 1 defined
jw.scanNetworks(i>1);
jw.scanNetworks(true);
}
@ -144,12 +143,55 @@ void wifiStatus() {
DEBUG_MSG_P(PSTR("[WIFI] DNS %s\n"), WiFi.dnsIP().toString().c_str());
DEBUG_MSG_P(PSTR("[WIFI] MASK %s\n"), WiFi.subnetMask().toString().c_str());
DEBUG_MSG_P(PSTR("[WIFI] HOST %s\n"), WiFi.hostname().c_str());
DEBUG_MSG_P(PSTR("[WIFI] RSSI %d\n"), WiFi.RSSI());
}
DEBUG_MSG_P(PSTR("[WIFI] ----------------------------------------------\n"));
}
void wifiScan() {
DEBUG_MSG_P(PSTR("[WIFI] Start scanning\n"));
unsigned char result = WiFi.scanNetworks();
if (result == WIFI_SCAN_FAILED) {
DEBUG_MSG_P(PSTR("[WIFI] Scan failed\n"));
} else if (result == 0) {
DEBUG_MSG_P(PSTR("[WIFI] No networks found\n"));
} else {
DEBUG_MSG_P(PSTR("[WIFI] %d networks found:\n"), result);
// Populate defined networks with scan data
for (int8_t i = 0; i < result; ++i) {
String ssid_scan;
int32_t rssi_scan;
uint8_t sec_scan;
uint8_t* BSSID_scan;
int32_t chan_scan;
bool hidden_scan;
WiFi.getNetworkInfo(i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan, hidden_scan);
DEBUG_MSG_P(PSTR("[WIFI] - BSSID: %02X:%02X:%02X:%02X:%02X:%02X SEC: %s RSSI: %3d CH: %2d SSID: %s\n"),
BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], BSSID_scan[6],
(sec_scan != ENC_TYPE_NONE ? "YES" : "NO "),
rssi_scan,
chan_scan,
(char *) ssid_scan.c_str()
);
}
}
WiFi.scanDelete();
}
bool wifiClean(unsigned char num) {
bool changed = false;


Loading…
Cancel
Save