mirror of
https://github.com/meshtastic/firmware.git
synced 2025-05-07 14:08:51 +00:00
Merge pull request #469 from mc-hamster/master
Switched to esp32_https_server from the Espressif (Issue #452) and Enable RX LNA (#466)
This commit is contained in:
commit
76b4be3b87
@ -67,6 +67,7 @@ lib_deps =
|
|||||||
https://github.com/meshtastic/RadioLib.git#8657380241bce681c33aab46598bbf13b11f876c
|
https://github.com/meshtastic/RadioLib.git#8657380241bce681c33aab46598bbf13b11f876c
|
||||||
https://github.com/meshtastic/TinyGPSPlus.git
|
https://github.com/meshtastic/TinyGPSPlus.git
|
||||||
https://github.com/meshtastic/AXP202X_Library.git#8404abb6d4b486748636bc6ad72d2a47baaf5460
|
https://github.com/meshtastic/AXP202X_Library.git#8404abb6d4b486748636bc6ad72d2a47baaf5460
|
||||||
|
https://github.com/meshtastic/esp32_https_server.git
|
||||||
Wire ; explicitly needed here because the AXP202 library forgets to add it
|
Wire ; explicitly needed here because the AXP202 library forgets to add it
|
||||||
SPI
|
SPI
|
||||||
https://github.com/geeksville/ArduinoThread.git#333ffd09b596977c217ba25da4258f588b462ac6
|
https://github.com/geeksville/ArduinoThread.git#333ffd09b596977c217ba25da4258f588b462ac6
|
||||||
|
@ -124,6 +124,7 @@ static void powerEnter()
|
|||||||
{
|
{
|
||||||
screen->setOn(true);
|
screen->setOn(true);
|
||||||
setBluetoothEnable(true);
|
setBluetoothEnable(true);
|
||||||
|
setCPUFast(true); // Set CPU to 240mhz when we're plugged in to wall power.
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onEnter()
|
static void onEnter()
|
||||||
@ -140,6 +141,7 @@ static void onEnter()
|
|||||||
service.sendNetworkPing(displayedNodeNum, true); // Refresh the currently displayed node
|
service.sendNetworkPing(displayedNodeNum, true); // Refresh the currently displayed node
|
||||||
lastPingMs = now;
|
lastPingMs = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void screenPress()
|
static void screenPress()
|
||||||
@ -157,6 +159,7 @@ State stateSERIAL(serialEnter, NULL, NULL, "SERIAL");
|
|||||||
State stateBOOT(bootEnter, NULL, NULL, "BOOT");
|
State stateBOOT(bootEnter, NULL, NULL, "BOOT");
|
||||||
State stateON(onEnter, NULL, NULL, "ON");
|
State stateON(onEnter, NULL, NULL, "ON");
|
||||||
State statePOWER(powerEnter, NULL, NULL, "POWER");
|
State statePOWER(powerEnter, NULL, NULL, "POWER");
|
||||||
|
|
||||||
Fsm powerFSM(&stateBOOT);
|
Fsm powerFSM(&stateBOOT);
|
||||||
|
|
||||||
void PowerFSM_setup()
|
void PowerFSM_setup()
|
||||||
|
@ -1039,6 +1039,12 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
|||||||
String(days) + "d " + (hours < 10 ? "0" : "") + String(hours) + ":" + (minutes < 10 ? "0" : "") +
|
String(days) + "d " + (hours < 10 ? "0" : "") + String(hours) + ":" + (minutes < 10 ? "0" : "") +
|
||||||
String(minutes) + ":" + (seconds < 10 ? "0" : "") + String(seconds));
|
String(minutes) + ":" + (seconds < 10 ? "0" : "") + String(seconds));
|
||||||
|
|
||||||
|
#ifndef NO_ESP32
|
||||||
|
// Show CPU Frequency.
|
||||||
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth("CPU " + String(getCpuFrequencyMhz()) + "MHz"), y + FONT_HEIGHT * 1,
|
||||||
|
"CPU " + String(getCpuFrequencyMhz()) + "MHz");
|
||||||
|
#endif
|
||||||
|
|
||||||
// Line 3
|
// Line 3
|
||||||
drawGPSAltitude(display, x, y + FONT_HEIGHT * 2, gpsStatus);
|
drawGPSAltitude(display, x, y + FONT_HEIGHT * 2, gpsStatus);
|
||||||
|
|
||||||
|
@ -362,6 +362,7 @@ void setup()
|
|||||||
// Initialize Wifi
|
// Initialize Wifi
|
||||||
initWifi();
|
initWifi();
|
||||||
|
|
||||||
|
|
||||||
if (!rIf)
|
if (!rIf)
|
||||||
recordCriticalError(ErrNoRadio);
|
recordCriticalError(ErrNoRadio);
|
||||||
else
|
else
|
||||||
|
@ -82,8 +82,8 @@ bool SX1262Interface::reconfigure()
|
|||||||
assert(err == ERR_NONE);
|
assert(err == ERR_NONE);
|
||||||
|
|
||||||
// Hmm - seems to lower SNR when the signal levels are high. Leaving off for now...
|
// Hmm - seems to lower SNR when the signal levels are high. Leaving off for now...
|
||||||
// err = lora.setRxGain(true);
|
err = lora.setRxGain(true);
|
||||||
// assert(err == ERR_NONE);
|
assert(err == ERR_NONE);
|
||||||
|
|
||||||
err = lora.setSyncWord(syncWord);
|
err = lora.setSyncWord(syncWord);
|
||||||
assert(err == ERR_NONE);
|
assert(err == ERR_NONE);
|
||||||
|
@ -6,29 +6,46 @@
|
|||||||
#include <WebServer.h>
|
#include <WebServer.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
|
||||||
WebServer webserver(80);
|
// Persistant Data Storage
|
||||||
|
#include <Preferences.h>
|
||||||
|
Preferences prefs;
|
||||||
|
|
||||||
// Maximum number of messages for chat history. Don't make this too big -- it'll use a
|
/*
|
||||||
// lot of memory!
|
Including the esp32_https_server library will trigger a compile time error. I've
|
||||||
const uint16_t maxMessages = 50;
|
tracked it down to a reoccurrance of this bug:
|
||||||
|
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57824
|
||||||
|
The work around is described here:
|
||||||
|
https://forums.xilinx.com/t5/Embedded-Development-Tools/Error-with-Standard-Libaries-in-Zynq/td-p/450032
|
||||||
|
|
||||||
struct message_t {
|
Long story short is we need "#undef str" before including the esp32_https_server.
|
||||||
char sender[10];
|
- Jm Casler (jm@casler.org) Oct 2020
|
||||||
char message[250];
|
*/
|
||||||
int32_t gpsLat;
|
#undef str
|
||||||
int32_t gpsLong;
|
|
||||||
uint32_t time;
|
|
||||||
bool fromMe;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct messages_t {
|
// Includes for the https server
|
||||||
message_t history[maxMessages];
|
// https://github.com/fhessel/esp32_https_server
|
||||||
};
|
#include <HTTPRequest.hpp>
|
||||||
|
#include <HTTPResponse.hpp>
|
||||||
|
#include <HTTPSServer.hpp>
|
||||||
|
#include <HTTPServer.hpp>
|
||||||
|
#include <SSLCert.hpp>
|
||||||
|
|
||||||
messages_t messages_history;
|
// The HTTPS Server comes in a separate namespace. For easier use, include it here.
|
||||||
|
using namespace httpsserver;
|
||||||
|
|
||||||
String something = "";
|
SSLCert *cert;
|
||||||
String sender = "";
|
HTTPSServer *secureServer;
|
||||||
|
HTTPServer *insecureServer;
|
||||||
|
|
||||||
|
// Declare some handler functions for the various URLs on the server
|
||||||
|
void handleStyleCSS(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleJSONChatHistoryDummy(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleHotspot(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleRoot(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handle404(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
|
||||||
|
bool isWebServerReady = 0;
|
||||||
|
bool isCertReady = 0;
|
||||||
|
|
||||||
void handleWebResponse()
|
void handleWebResponse()
|
||||||
{
|
{
|
||||||
@ -36,82 +53,196 @@ void handleWebResponse()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We're going to handle the DNS responder here so it
|
if (isWebServerReady) {
|
||||||
// will be ignored by the NRF boards.
|
// We're going to handle the DNS responder here so it
|
||||||
handleDNSResponse();
|
// will be ignored by the NRF boards.
|
||||||
|
handleDNSResponse();
|
||||||
|
|
||||||
webserver.handleClient();
|
secureServer->loop();
|
||||||
|
insecureServer->loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void taskCreateCert(void *parameter)
|
||||||
|
{
|
||||||
|
|
||||||
|
prefs.begin("MeshtasticHTTPS", false);
|
||||||
|
|
||||||
|
// Delete the saved certs
|
||||||
|
if (0) {
|
||||||
|
DEBUG_MSG("Deleting any saved SSL keys ...\n");
|
||||||
|
// prefs.clear();
|
||||||
|
prefs.remove("PK");
|
||||||
|
prefs.remove("cert");
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t pkLen = prefs.getBytesLength("PK");
|
||||||
|
size_t certLen = prefs.getBytesLength("cert");
|
||||||
|
|
||||||
|
DEBUG_MSG("Checking if we have a previously saved SSL Certificate.\n");
|
||||||
|
|
||||||
|
if (pkLen && certLen) {
|
||||||
|
DEBUG_MSG("Existing SSL Certificate found!\n");
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("Creating the certificate. This may take a while. Please wait...\n");
|
||||||
|
|
||||||
|
cert = new SSLCert();
|
||||||
|
//disableCore1WDT();
|
||||||
|
int createCertResult = createSelfSignedCert(*cert, KEYSIZE_2048, "CN=meshtastic.local,O=Meshtastic,C=US",
|
||||||
|
"20190101000000", "20300101000000");
|
||||||
|
//enableCore1WDT();
|
||||||
|
|
||||||
|
if (createCertResult != 0) {
|
||||||
|
DEBUG_MSG("Creating the certificate failed\n");
|
||||||
|
|
||||||
|
// Serial.printf("Creating the certificate failed. Error Code = 0x%02X, check SSLCert.hpp for details",
|
||||||
|
// createCertResult);
|
||||||
|
// while (true)
|
||||||
|
// delay(500);
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("Creating the certificate was successful\n");
|
||||||
|
|
||||||
|
DEBUG_MSG("Created Private Key: %d Bytes\n", cert->getPKLength());
|
||||||
|
// for (int i = 0; i < cert->getPKLength(); i++)
|
||||||
|
// Serial.print(cert->getPKData()[i], HEX);
|
||||||
|
// Serial.println();
|
||||||
|
|
||||||
|
DEBUG_MSG("Created Certificate: %d Bytes\n", cert->getCertLength());
|
||||||
|
// for (int i = 0; i < cert->getCertLength(); i++)
|
||||||
|
// Serial.print(cert->getCertData()[i], HEX);
|
||||||
|
// Serial.println();
|
||||||
|
|
||||||
|
prefs.putBytes("PK", (uint8_t *)cert->getPKData(), cert->getPKLength());
|
||||||
|
prefs.putBytes("cert", (uint8_t *)cert->getCertData(), cert->getCertLength());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isCertReady = 1;
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void createSSLCert()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (isWifiAvailable() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new process just to handle creating the cert.
|
||||||
|
// This is a workaround for Bug: https://github.com/fhessel/esp32_https_server/issues/48
|
||||||
|
// jm@casler.org (Oct 2020)
|
||||||
|
xTaskCreate(taskCreateCert, /* Task function. */
|
||||||
|
"createCert", /* String with name of task. */
|
||||||
|
16384, /* Stack size in bytes. */
|
||||||
|
NULL, /* Parameter passed as input of the task */
|
||||||
|
16, /* Priority of the task. */
|
||||||
|
NULL); /* Task handle. */
|
||||||
|
|
||||||
|
DEBUG_MSG("Waiting for SSL Cert to be generated.\n");
|
||||||
|
if (isCertReady) {
|
||||||
|
DEBUG_MSG(".\n");
|
||||||
|
delayMicroseconds(1000);
|
||||||
|
}
|
||||||
|
DEBUG_MSG("SSL Cert Ready!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void initWebServer()
|
void initWebServer()
|
||||||
{
|
{
|
||||||
webserver.onNotFound(handleNotFound);
|
DEBUG_MSG("Initializing Web Server ...\n");
|
||||||
webserver.on("/json/chat/send/channel", handleJSONChatHistory);
|
|
||||||
webserver.on("/json/chat/send/user", handleJSONChatHistory);
|
|
||||||
webserver.on("/json/chat/history/channel", handleJSONChatHistory);
|
|
||||||
webserver.on("/json/chat/history/dummy", handleJSONChatHistoryDummy);
|
|
||||||
webserver.on("/json/chat/history/user", handleJSONChatHistory);
|
|
||||||
webserver.on("/json/stats", handleJSONChatHistory);
|
|
||||||
webserver.on("/hotspot-detect.html", handleHotspot);
|
|
||||||
webserver.on("/css/style.css", handleStyleCSS);
|
|
||||||
webserver.on("/scripts/script.js", handleScriptsScriptJS);
|
|
||||||
webserver.on("/", handleRoot);
|
|
||||||
webserver.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleJSONChatHistory()
|
prefs.begin("MeshtasticHTTPS", false);
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
String out = "";
|
size_t pkLen = prefs.getBytesLength("PK");
|
||||||
out += "{\n";
|
size_t certLen = prefs.getBytesLength("cert");
|
||||||
out += " \"data\" : {\n";
|
|
||||||
out += " \"chat\" : ";
|
|
||||||
out += "[";
|
|
||||||
out += "\"" + sender + "\"";
|
|
||||||
out += ",";
|
|
||||||
out += "\"" + something + "\"";
|
|
||||||
out += "]\n";
|
|
||||||
|
|
||||||
for (i = 0; i < maxMessages; i++) {
|
DEBUG_MSG("Checking if we have a previously saved SSL Certificate.\n");
|
||||||
out += "[";
|
|
||||||
out += "\"" + String(messages_history.history[i].sender) + "\"";
|
if (pkLen && certLen) {
|
||||||
out += ",";
|
|
||||||
out += "\"" + String(messages_history.history[i].message) + "\"";
|
uint8_t *pkBuffer = new uint8_t[pkLen];
|
||||||
out += "]\n";
|
prefs.getBytes("PK", pkBuffer, pkLen);
|
||||||
|
|
||||||
|
uint8_t *certBuffer = new uint8_t[certLen];
|
||||||
|
prefs.getBytes("cert", certBuffer, certLen);
|
||||||
|
|
||||||
|
cert = new SSLCert(certBuffer, certLen, pkBuffer, pkLen);
|
||||||
|
|
||||||
|
DEBUG_MSG("Retrieved Private Key: %d Bytes\n", cert->getPKLength());
|
||||||
|
// DEBUG_MSG("Retrieved Private Key: " + String(cert->getPKLength()) + " Bytes");
|
||||||
|
// for (int i = 0; i < cert->getPKLength(); i++)
|
||||||
|
// Serial.print(cert->getPKData()[i], HEX);
|
||||||
|
// Serial.println();
|
||||||
|
|
||||||
|
DEBUG_MSG("Retrieved Certificate: %d Bytes\n", cert->getCertLength());
|
||||||
|
// for (int i = 0; i < cert->getCertLength(); i++)
|
||||||
|
// Serial.print(cert->getCertData()[i], HEX);
|
||||||
|
// Serial.println();
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("Web Server started without SSL keys! How did this happen?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
out += "\n";
|
// We can now use the new certificate to setup our server as usual.
|
||||||
out += " }\n";
|
secureServer = new HTTPSServer(cert);
|
||||||
out += "}\n";
|
insecureServer = new HTTPServer();
|
||||||
|
|
||||||
webserver.send(200, "application/json", out);
|
// For every resource available on the server, we need to create a ResourceNode
|
||||||
return;
|
// The ResourceNode links URL and HTTP method to a handler function
|
||||||
|
|
||||||
|
ResourceNode *nodeCSS = new ResourceNode("/css/style.css", "GET", &handleStyleCSS);
|
||||||
|
ResourceNode *nodeJS = new ResourceNode("/scripts/script.js", "GET", &handleJSONChatHistoryDummy);
|
||||||
|
ResourceNode *nodeHotspot = new ResourceNode("/hotspot-detect.html", "GET", &handleHotspot);
|
||||||
|
ResourceNode *nodeRoot = new ResourceNode("/", "GET", &handleRoot);
|
||||||
|
ResourceNode *node404 = new ResourceNode("", "GET", &handle404);
|
||||||
|
|
||||||
|
// Secure nodes
|
||||||
|
secureServer->registerNode(nodeCSS);
|
||||||
|
secureServer->registerNode(nodeJS);
|
||||||
|
secureServer->registerNode(nodeHotspot);
|
||||||
|
secureServer->registerNode(nodeRoot);
|
||||||
|
secureServer->setDefaultNode(node404);
|
||||||
|
|
||||||
|
// Insecure nodes
|
||||||
|
insecureServer->registerNode(nodeCSS);
|
||||||
|
insecureServer->registerNode(nodeJS);
|
||||||
|
insecureServer->registerNode(nodeHotspot);
|
||||||
|
insecureServer->registerNode(nodeRoot);
|
||||||
|
insecureServer->setDefaultNode(node404);
|
||||||
|
|
||||||
|
DEBUG_MSG("Starting Web Server...\n");
|
||||||
|
secureServer->start();
|
||||||
|
insecureServer->start();
|
||||||
|
if (secureServer->isRunning() && insecureServer->isRunning()) {
|
||||||
|
DEBUG_MSG("Web Server Ready\n");
|
||||||
|
isWebServerReady = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleNotFound()
|
void handle404(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
String message = "";
|
|
||||||
message += "File Not Found\n\n";
|
|
||||||
message += "URI: ";
|
|
||||||
message += webserver.uri();
|
|
||||||
message += "\nMethod: ";
|
|
||||||
message += (webserver.method() == HTTP_GET) ? "GET" : "POST";
|
|
||||||
message += "\nArguments: ";
|
|
||||||
message += webserver.args();
|
|
||||||
message += "\n";
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < webserver.args(); i++) {
|
// Discard request body, if we received any
|
||||||
message += " " + webserver.argName(i) + ": " + webserver.arg(i) + "\n";
|
// We do this, as this is the default node and may also server POST/PUT requests
|
||||||
}
|
req->discardRequestBody();
|
||||||
Serial.println(message);
|
|
||||||
webserver.send(404, "text/plain", message);
|
// Set the response status
|
||||||
|
res->setStatusCode(404);
|
||||||
|
res->setStatusText("Not Found");
|
||||||
|
|
||||||
|
// Set content type of the response
|
||||||
|
res->setHeader("Content-Type", "text/html");
|
||||||
|
|
||||||
|
// Write a tiny HTTP page
|
||||||
|
res->println("<!DOCTYPE html>");
|
||||||
|
res->println("<html>");
|
||||||
|
res->println("<head><title>Not Found</title></head>");
|
||||||
|
res->println("<body><h1>404 Not Found</h1><p>The requested resource was not found on this server.</p></body>");
|
||||||
|
res->println("</html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This supports the Apple Captive Network Assistant (CNA) Portal
|
This supports the Apple Captive Network Assistant (CNA) Portal
|
||||||
*/
|
*/
|
||||||
void handleHotspot()
|
void handleHotspot(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
DEBUG_MSG("Hotspot Request\n");
|
DEBUG_MSG("Hotspot Request\n");
|
||||||
|
|
||||||
@ -120,25 +251,14 @@ void handleHotspot()
|
|||||||
otherwise iOS will have trouble detecting that the connection to the SoftAP worked.
|
otherwise iOS will have trouble detecting that the connection to the SoftAP worked.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String out = "";
|
// Status code is 200 OK by default.
|
||||||
// out += "Success\n";
|
// We want to deliver a simple HTML page, so we send a corresponding content type:
|
||||||
out += "<meta http-equiv=\"refresh\" content=\"0;url=http://meshtastic.org/\" />\n";
|
res->setHeader("Content-Type", "text/html");
|
||||||
webserver.send(200, "text/html", out);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void notifyWebUI()
|
// The response implements the Print interface, so you can use it just like
|
||||||
{
|
// you would write to Serial etc.
|
||||||
DEBUG_MSG("************ Got a message! ************\n");
|
res->println("<!DOCTYPE html>");
|
||||||
MeshPacket &mp = devicestate.rx_text_message;
|
res->println("<meta http-equiv=\"refresh\" content=\"0;url=http://meshtastic.org/\" />\n");
|
||||||
NodeInfo *node = nodeDB.getNode(mp.from);
|
|
||||||
sender = (node && node->has_user) ? node->user.long_name : "???";
|
|
||||||
|
|
||||||
static char tempBuf[256]; // mesh.options says this is MeshPacket.encrypted max_size
|
|
||||||
assert(mp.decoded.which_payload == SubPacket_data_tag);
|
|
||||||
snprintf(tempBuf, sizeof(tempBuf), "%s", mp.decoded.data.payload.bytes);
|
|
||||||
|
|
||||||
something = tempBuf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -146,7 +266,7 @@ void notifyWebUI()
|
|||||||
|
|
||||||
https://tomeko.net/online_tools/cpp_text_escape.php?lang=en
|
https://tomeko.net/online_tools/cpp_text_escape.php?lang=en
|
||||||
*/
|
*/
|
||||||
void handleRoot()
|
void handleRoot(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
|
|
||||||
String out = "";
|
String out = "";
|
||||||
@ -223,11 +343,17 @@ void handleRoot()
|
|||||||
"</body>\n"
|
"</body>\n"
|
||||||
"</html>\n"
|
"</html>\n"
|
||||||
"";
|
"";
|
||||||
webserver.send(200, "text/html", out);
|
|
||||||
return;
|
// Status code is 200 OK by default.
|
||||||
|
// We want to deliver a simple HTML page, so we send a corresponding content type:
|
||||||
|
res->setHeader("Content-Type", "text/html");
|
||||||
|
|
||||||
|
// The response implements the Print interface, so you can use it just like
|
||||||
|
// you would write to Serial etc.
|
||||||
|
res->print(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleStyleCSS()
|
void handleStyleCSS(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
|
|
||||||
String out = "";
|
String out = "";
|
||||||
@ -510,11 +636,16 @@ void handleStyleCSS()
|
|||||||
" height: 0;\n"
|
" height: 0;\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
webserver.send(200, "text/css", out);
|
// Status code is 200 OK by default.
|
||||||
return;
|
// We want to deliver a simple HTML page, so we send a corresponding content type:
|
||||||
|
res->setHeader("Content-Type", "text/css");
|
||||||
|
|
||||||
|
// The response implements the Print interface, so you can use it just like
|
||||||
|
// you would write to Serial etc.
|
||||||
|
res->print(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleScriptsScriptJS()
|
void handleScriptsScriptJS(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
String out = "";
|
String out = "";
|
||||||
out += "String.prototype.toHHMMSS = function () {\n"
|
out += "String.prototype.toHHMMSS = function () {\n"
|
||||||
@ -664,11 +795,16 @@ void handleScriptsScriptJS()
|
|||||||
"//\tsetTimeout(scrollHistory(),500);\n"
|
"//\tsetTimeout(scrollHistory(),500);\n"
|
||||||
"// }";
|
"// }";
|
||||||
|
|
||||||
webserver.send(200, "text/javascript", out);
|
// Status code is 200 OK by default.
|
||||||
return;
|
// We want to deliver a simple HTML page, so we send a corresponding content type:
|
||||||
|
res->setHeader("Content-Type", "text/html");
|
||||||
|
|
||||||
|
// The response implements the Print interface, so you can use it just like
|
||||||
|
// you would write to Serial etc.
|
||||||
|
res->print(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleJSONChatHistoryDummy()
|
void handleJSONChatHistoryDummy(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
String out = "";
|
String out = "";
|
||||||
out += "{\n"
|
out += "{\n"
|
||||||
@ -788,6 +924,11 @@ void handleJSONChatHistoryDummy()
|
|||||||
"\t}\n"
|
"\t}\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
webserver.send(200, "application/json", out);
|
// Status code is 200 OK by default.
|
||||||
return;
|
// We want to deliver a simple HTML page, so we send a corresponding content type:
|
||||||
|
res->setHeader("Content-Type", "application/json");
|
||||||
|
|
||||||
|
// The response implements the Print interface, so you can use it just like
|
||||||
|
// you would write to Serial etc.
|
||||||
|
res->print(out);
|
||||||
}
|
}
|
@ -4,6 +4,8 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
void initWebServer();
|
void initWebServer();
|
||||||
|
void createSSLCert();
|
||||||
|
|
||||||
|
|
||||||
void handleNotFound();
|
void handleNotFound();
|
||||||
|
|
||||||
|
@ -29,9 +29,6 @@ bool isWifiAvailable()
|
|||||||
// strcpy(radioConfig.preferences.wifi_password, "");
|
// strcpy(radioConfig.preferences.wifi_password, "");
|
||||||
|
|
||||||
if (*wifiName && *wifiPsw) {
|
if (*wifiName && *wifiPsw) {
|
||||||
|
|
||||||
// Once every 10 seconds, try to reconnect.
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@ -64,6 +61,9 @@ void initWifi()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user