From a371592ad9752a789e22a9d4284424a8c1dc6a11 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 18 Oct 2020 18:07:44 -0700 Subject: [PATCH 1/4] Added instructions for David --- src/meshwifi/meshhttpStatic.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/meshwifi/meshhttpStatic.h b/src/meshwifi/meshhttpStatic.h index 673685bb5..b4645625f 100644 --- a/src/meshwifi/meshhttpStatic.h +++ b/src/meshwifi/meshhttpStatic.h @@ -7,6 +7,8 @@ - Convert to hex: http://tomeko.net/online_tools/file_to_hex.php?lang=en - Paste into the array + - Note the filesize of your .gz file and write the file + size into the length int. */ From 3061860dabaf598640d0229793c19cec72dcd9f7 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 18 Oct 2020 18:30:19 -0700 Subject: [PATCH 2/4] Update sleep timer for the CPU clock --- src/meshwifi/meshhttp.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/meshwifi/meshhttp.cpp b/src/meshwifi/meshhttp.cpp index 1d6c7cead..a63a5d8e5 100644 --- a/src/meshwifi/meshhttp.cpp +++ b/src/meshwifi/meshhttp.cpp @@ -2,7 +2,7 @@ #include "NodeDB.h" #include "configuration.h" #include "main.h" -#include "meshhttpStatic.h" +#include "meshHttpStatic.h" #include "meshwifi/meshwifi.h" #include "sleep.h" #include @@ -79,9 +79,11 @@ void handleWebResponse() insecureServer->loop(); } - // Slow down the CPU if we have not received a request within the last - // 2 minutes. - if (millis() - timeSpeedUp >= (2 * 60 * 1000)) { + /* + Slow down the CPU if we have not received a request within the last few + seconds. + */ + if (millis() - timeSpeedUp >= (25 * 1000)) { setCpuFrequencyMhz(80); timeSpeedUp = millis(); } From a16c3af30a35f7198c19aa19c07ea79a6dd25892 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 18 Oct 2020 18:44:08 -0700 Subject: [PATCH 3/4] Clarified debug message regardding the Web Server startup status. --- src/meshwifi/meshhttp.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/meshwifi/meshhttp.cpp b/src/meshwifi/meshhttp.cpp index a63a5d8e5..68493f3df 100644 --- a/src/meshwifi/meshhttp.cpp +++ b/src/meshwifi/meshhttp.cpp @@ -255,12 +255,14 @@ void initWebServer() insecureServer->addMiddleware(&middlewareSpeedUp160); - DEBUG_MSG("Starting Web Server...\n"); + DEBUG_MSG("Starting Web Servers...\n"); secureServer->start(); insecureServer->start(); if (secureServer->isRunning() && insecureServer->isRunning()) { - DEBUG_MSG("Web Server Ready\n"); + DEBUG_MSG("HTTP and HTTPS Web Servers Ready! :-) \n"); isWebServerReady = 1; + } else { + DEBUG_MSG("HTTP and HTTPS Web Servers Failed! ;-( \n"); } } From d4df3f8a7e16f8052afc9a4bf5602b565cd4801a Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 18 Oct 2020 21:39:02 -0700 Subject: [PATCH 4/4] mDNS server http://meshtastic.local --- src/graphics/Screen.cpp | 15 ++++++++------- src/meshwifi/meshwifi.cpp | 19 +++++++++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index a97e04b9e..350b27d47 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -110,8 +110,6 @@ static void drawBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int1 screen->forceDisplay(); } - - static void drawFrameBluetooth(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { display->setTextAlignment(TEXT_ALIGN_CENTER); @@ -1044,8 +1042,12 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i } } - display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName)); - display->drawString(x, y + FONT_HEIGHT_SMALL * 3, "PWD: " + String(wifiPsw)); + if ((millis() / 1000) % 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"); /* Display a heartbeat pixel that blinks every time the frame is redrawn */ #ifdef SHOW_REDRAWS @@ -1100,9 +1102,8 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat #ifndef NO_ESP32 // Show CPU Frequency. - display->drawString(x + SCREEN_WIDTH - display->getStringWidth("CPU " + String(getCpuFrequencyMhz()) + "MHz"), - y + FONT_HEIGHT_SMALL * 1, - "CPU " + String(getCpuFrequencyMhz()) + "MHz"); + display->drawString(x + SCREEN_WIDTH - display->getStringWidth("CPU " + String(getCpuFrequencyMhz()) + "MHz"), + y + FONT_HEIGHT_SMALL * 1, "CPU " + String(getCpuFrequencyMhz()) + "MHz"); #endif // Line 3 diff --git a/src/meshwifi/meshwifi.cpp b/src/meshwifi/meshwifi.cpp index 3026b13f1..a20cebede 100644 --- a/src/meshwifi/meshwifi.cpp +++ b/src/meshwifi/meshwifi.cpp @@ -6,6 +6,7 @@ #include "meshwifi/meshhttp.h" #include "target_specific.h" #include +#include #include static void WiFiEvent(WiFiEvent_t event); @@ -18,7 +19,7 @@ static WiFiServerPort *apiPort; uint8_t wifiDisconnectReason = 0; // Stores our hostname -static char ourHost[16]; +char ourHost[16]; bool isWifiAvailable() { @@ -63,7 +64,6 @@ void initWifi() createSSLCert(); - if (radioConfig.has_preferences) { const char *wifiName = radioConfig.preferences.wifi_ssid; const char *wifiPsw = radioConfig.preferences.wifi_password; @@ -117,12 +117,23 @@ void initWifi() } } } + + if (!MDNS.begin( "Meshtastic" )) { + DEBUG_MSG("Error setting up MDNS responder!\n"); + + while (1) { + delay(1000); + } + } + DEBUG_MSG("mDNS responder started\n"); + DEBUG_MSG("mDNS Host: Meshtastic.local\n"); + MDNS.addService("http", "tcp", 80); + MDNS.addService("https", "tcp", 443); + } else DEBUG_MSG("Not using WIFI\n"); } - - static void initApiServer() { // Start API server on port 4403