From e10b82c118ad53ce0fe66000538a12221d267046 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 12 Dec 2020 19:09:58 -0800 Subject: [PATCH] #560 Partial changes --- src/graphics/Screen.cpp | 25 ++++++++++++++++--------- src/meshwifi/meshwifi.cpp | 10 +++++++--- src/meshwifi/meshwifi.h | 2 ++ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 320c0f1e2..71cad3908 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -984,7 +984,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i // The coordinates define the left starting point of the text display->setTextAlignment(TEXT_ALIGN_LEFT); - if (radioConfig.preferences.wifi_ap_mode) { + if (radioConfig.preferences.wifi_ap_mode || isSoftAPForced()) { display->drawString(x, y, String("WiFi: Software AP")); } else if (WiFi.status() != WL_CONNECTED) { display->drawString(x, y, String("WiFi: Not Connected")); @@ -1007,9 +1007,8 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i - WL_NO_SHIELD: assigned when no WiFi shield is present; */ - - if (WiFi.status() == WL_CONNECTED) { - if (radioConfig.preferences.wifi_ap_mode) { + if (WiFi.status() == WL_CONNECTED || isSoftAPForced()) { + if (radioConfig.preferences.wifi_ap_mode || isSoftAPForced()) { display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.softAPIP().toString().c_str())); } else { display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.localIP().toString().c_str())); @@ -1088,10 +1087,19 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i } } - if ((millis() / 10000) % 2) { - display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName)); + if (isSoftAPForced()) { + if ((millis() / 10000) % 2) { + display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: meshtasticAdmin"); + } else { + display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "PWD: 12345678"); + } + } else { - display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "PWD: " + String(wifiPsw)); + if ((millis() / 10000) % 2) { + display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName)); + } else { + display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "PWD: " + String(wifiPsw)); + } } display->drawString(x, y + FONT_HEIGHT_SMALL * 3, "http://meshtastic.local"); @@ -1185,8 +1193,7 @@ int Screen::handleStatusUpdate(const meshtastic::Status *arg) // DEBUG_MSG("Screen got status update %d\n", arg->getStatusType()); switch (arg->getStatusType()) { case STATUS_TYPE_NODE: - if (showingNormalScreen && - nodeStatus->getLastNumTotal() != nodeStatus->getNumTotal()) { + if (showingNormalScreen && nodeStatus->getLastNumTotal() != nodeStatus->getNumTotal()) { setFrames(); // Regen the list of screens } nodeDB.updateGUI = false; diff --git a/src/meshwifi/meshwifi.cpp b/src/meshwifi/meshwifi.cpp index 4b267399d..008d82118 100644 --- a/src/meshwifi/meshwifi.cpp +++ b/src/meshwifi/meshwifi.cpp @@ -24,10 +24,14 @@ char ourHost[16]; bool forcedSoftAP = 0; +bool isSoftAPForced() { + return forcedSoftAP; +} + bool isWifiAvailable() { // If wifi status is connected, return true regardless of the radio configuration. - if (forcedSoftAP) { + if (isSoftAPForced()) { return 1; } @@ -91,8 +95,8 @@ void initWifi(bool forceSoftAP) DEBUG_MSG("----- Forcing SoftAP\n"); - const char *softAPssid = ""; - const char *softAPpasswd = ""; + const char *softAPssid = "meshtasticAdmin"; + const char *softAPpasswd = "12345678"; IPAddress apIP(192, 168, 42, 1); WiFi.onEvent(WiFiEvent); diff --git a/src/meshwifi/meshwifi.h b/src/meshwifi/meshwifi.h index d56a44943..9e2f8ad78 100644 --- a/src/meshwifi/meshwifi.h +++ b/src/meshwifi/meshwifi.h @@ -18,5 +18,7 @@ void handleDNSResponse(); void reconnectWiFi(); +bool isSoftAPForced(); + uint8_t getWifiDisconnectReason();