Merge pull request #490 from mc-hamster/master

Update filename, cpu clock timer, add more debug info on the web server startup
This commit is contained in:
Jm Casler 2020-10-18 21:41:34 -07:00 committed by GitHub
commit 64c29c4a35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 17 deletions

View File

@ -110,8 +110,6 @@ static void drawBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int1
screen->forceDisplay(); screen->forceDisplay();
} }
static void drawFrameBluetooth(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) static void drawFrameBluetooth(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{ {
display->setTextAlignment(TEXT_ALIGN_CENTER); display->setTextAlignment(TEXT_ALIGN_CENTER);
@ -1044,8 +1042,12 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
} }
} }
if ((millis() / 1000) % 2) {
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName)); display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName));
display->drawString(x, y + FONT_HEIGHT_SMALL * 3, "PWD: " + String(wifiPsw)); } 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 */ /* Display a heartbeat pixel that blinks every time the frame is redrawn */
#ifdef SHOW_REDRAWS #ifdef SHOW_REDRAWS
@ -1101,8 +1103,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
#ifndef NO_ESP32 #ifndef NO_ESP32
// Show CPU Frequency. // Show CPU Frequency.
display->drawString(x + SCREEN_WIDTH - display->getStringWidth("CPU " + String(getCpuFrequencyMhz()) + "MHz"), display->drawString(x + SCREEN_WIDTH - display->getStringWidth("CPU " + String(getCpuFrequencyMhz()) + "MHz"),
y + FONT_HEIGHT_SMALL * 1, y + FONT_HEIGHT_SMALL * 1, "CPU " + String(getCpuFrequencyMhz()) + "MHz");
"CPU " + String(getCpuFrequencyMhz()) + "MHz");
#endif #endif
// Line 3 // Line 3

View File

@ -2,7 +2,7 @@
#include "NodeDB.h" #include "NodeDB.h"
#include "configuration.h" #include "configuration.h"
#include "main.h" #include "main.h"
#include "meshhttpStatic.h" #include "meshHttpStatic.h"
#include "meshwifi/meshwifi.h" #include "meshwifi/meshwifi.h"
#include "sleep.h" #include "sleep.h"
#include <WebServer.h> #include <WebServer.h>
@ -79,9 +79,11 @@ void handleWebResponse()
insecureServer->loop(); insecureServer->loop();
} }
// Slow down the CPU if we have not received a request within the last /*
// 2 minutes. Slow down the CPU if we have not received a request within the last few
if (millis() - timeSpeedUp >= (2 * 60 * 1000)) { seconds.
*/
if (millis() - timeSpeedUp >= (25 * 1000)) {
setCpuFrequencyMhz(80); setCpuFrequencyMhz(80);
timeSpeedUp = millis(); timeSpeedUp = millis();
} }
@ -253,12 +255,14 @@ void initWebServer()
insecureServer->addMiddleware(&middlewareSpeedUp160); insecureServer->addMiddleware(&middlewareSpeedUp160);
DEBUG_MSG("Starting Web Server...\n"); DEBUG_MSG("Starting Web Servers...\n");
secureServer->start(); secureServer->start();
insecureServer->start(); insecureServer->start();
if (secureServer->isRunning() && insecureServer->isRunning()) { if (secureServer->isRunning() && insecureServer->isRunning()) {
DEBUG_MSG("Web Server Ready\n"); DEBUG_MSG("HTTP and HTTPS Web Servers Ready! :-) \n");
isWebServerReady = 1; isWebServerReady = 1;
} else {
DEBUG_MSG("HTTP and HTTPS Web Servers Failed! ;-( \n");
} }
} }

View File

@ -7,6 +7,8 @@
- Convert to hex: - Convert to hex:
http://tomeko.net/online_tools/file_to_hex.php?lang=en http://tomeko.net/online_tools/file_to_hex.php?lang=en
- Paste into the array - Paste into the array
- Note the filesize of your .gz file and write the file
size into the length int.
*/ */

View File

@ -6,6 +6,7 @@
#include "meshwifi/meshhttp.h" #include "meshwifi/meshhttp.h"
#include "target_specific.h" #include "target_specific.h"
#include <DNSServer.h> #include <DNSServer.h>
#include <ESPmDNS.h>
#include <WiFi.h> #include <WiFi.h>
static void WiFiEvent(WiFiEvent_t event); static void WiFiEvent(WiFiEvent_t event);
@ -18,7 +19,7 @@ static WiFiServerPort *apiPort;
uint8_t wifiDisconnectReason = 0; uint8_t wifiDisconnectReason = 0;
// Stores our hostname // Stores our hostname
static char ourHost[16]; char ourHost[16];
bool isWifiAvailable() bool isWifiAvailable()
{ {
@ -63,7 +64,6 @@ void initWifi()
createSSLCert(); createSSLCert();
if (radioConfig.has_preferences) { if (radioConfig.has_preferences) {
const char *wifiName = radioConfig.preferences.wifi_ssid; const char *wifiName = radioConfig.preferences.wifi_ssid;
const char *wifiPsw = radioConfig.preferences.wifi_password; 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 } else
DEBUG_MSG("Not using WIFI\n"); DEBUG_MSG("Not using WIFI\n");
} }
static void initApiServer() static void initApiServer()
{ {
// Start API server on port 4403 // Start API server on port 4403