Merge pull request #935 from rxt1077/issue-927

#927 add SSL notification at boot
1.2-legacy
Jm Casler 2021-11-28 19:30:29 -08:00 zatwierdzone przez GitHub
commit 757de54a4f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 31 dodań i 1 usunięć

Wyświetl plik

@ -147,6 +147,17 @@ static void drawBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int1
drawIconScreen(region, display, state, x, y); drawIconScreen(region, display, state, x, y);
} }
// Used on boot when a certificate is being created
static void drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->setFont(FONT_SMALL);
display->drawString(64 + x, y, "Creating SSL certificate");
display->setFont(FONT_SMALL);
display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait...");
}
#ifdef HAS_EINK #ifdef HAS_EINK
/// Used on eink displays while in deep sleep /// Used on eink displays while in deep sleep
static void drawSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) static void drawSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
@ -898,6 +909,16 @@ void Screen::drawDebugInfoWiFiTrampoline(OLEDDisplay *display, OLEDDisplayUiStat
screen->debugInfo.drawFrameWiFi(display, state, x, y); screen->debugInfo.drawFrameWiFi(display, state, x, y);
} }
/* show a message that the SSL cert is being built
* it is expected that this will be used during the boot phase */
void Screen::setSSLFrames()
{
DEBUG_MSG("showing SSL frames\n");
static FrameCallback sslFrames[] = {drawSSLScreen};
ui.setFrames(sslFrames, 1);
ui.update();
}
// restore our regular frame list // restore our regular frame list
void Screen::setFrames() void Screen::setFrames()
{ {

Wyświetl plik

@ -220,6 +220,9 @@ class Screen : public concurrency::OSThread
/// Used to force (super slow) eink displays to draw critical frames /// Used to force (super slow) eink displays to draw critical frames
void forceDisplay(); void forceDisplay();
/// Draws our SSL cert screen during boot (called from WebServer)
void setSSLFrames();
protected: protected:
/// Updates the UI. /// Updates the UI.
// //

Wyświetl plik

@ -1,3 +1,4 @@
#include "main.h"
#include "mesh/http/WebServer.h" #include "mesh/http/WebServer.h"
#include "NodeDB.h" #include "NodeDB.h"
#include "mesh/http/WiFiAPClient.h" #include "mesh/http/WiFiAPClient.h"
@ -77,7 +78,7 @@ static void taskCreateCert(void *parameter)
{ {
prefs.begin("MeshtasticHTTPS", false); prefs.begin("MeshtasticHTTPS", false);
// Delete the saved certs // Delete the saved certs (used in debugging)
if (0) { if (0) {
DEBUG_MSG("Deleting any saved SSL keys ...\n"); DEBUG_MSG("Deleting any saved SSL keys ...\n");
// prefs.clear(); // prefs.clear();
@ -166,11 +167,16 @@ void createSSLCert()
NULL); /* Task handle. */ NULL); /* Task handle. */
DEBUG_MSG("Waiting for SSL Cert to be generated.\n"); DEBUG_MSG("Waiting for SSL Cert to be generated.\n");
int seconds = 0;
while (!isCertReady) { while (!isCertReady) {
DEBUG_MSG("."); DEBUG_MSG(".");
delay(1000); delay(1000);
yield(); yield();
esp_task_wdt_reset(); esp_task_wdt_reset();
seconds++;
if ((seconds == 3) && screen) {
screen->setSSLFrames();
}
} }
DEBUG_MSG("SSL Cert Ready!\n"); DEBUG_MSG("SSL Cert Ready!\n");
} }