mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-16 18:12:07 +00:00
Merge remote-tracking branch 'root/master' into dev
This commit is contained in:
commit
a7c54e4ad7
@ -95,6 +95,9 @@ build_flags =
|
|||||||
${arduino_base.build_flags} -Wall -Wextra -Isrc/esp32 -Isrc/esp32-mfix-esp32-psram-cache-issue -lnimble -std=c++11
|
${arduino_base.build_flags} -Wall -Wextra -Isrc/esp32 -Isrc/esp32-mfix-esp32-psram-cache-issue -lnimble -std=c++11
|
||||||
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||||
-DAXP_DEBUG_PORT=Serial
|
-DAXP_DEBUG_PORT=Serial
|
||||||
|
lib_deps =
|
||||||
|
${arduino_base.lib_deps}
|
||||||
|
https://github.com/meshtastic/esp32_https_server.git
|
||||||
# Hmm - this doesn't work yet
|
# Hmm - this doesn't work yet
|
||||||
# board_build.ldscript = linker/esp32.extram.bss.ld
|
# board_build.ldscript = linker/esp32.extram.bss.ld
|
||||||
lib_ignore = segger_rtt
|
lib_ignore = segger_rtt
|
||||||
@ -117,7 +120,7 @@ board_build.partitions = partition-table.csv
|
|||||||
extends = esp32_base
|
extends = esp32_base
|
||||||
board = ttgo-t-beam
|
board = ttgo-t-beam
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${arduino_base.lib_deps}
|
${esp32_base.lib_deps}
|
||||||
build_flags =
|
build_flags =
|
||||||
${esp32_base.build_flags} -D TBEAM_V10
|
${esp32_base.build_flags} -D TBEAM_V10
|
||||||
|
|
||||||
|
@ -149,6 +149,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()
|
||||||
|
@ -1098,6 +1098,13 @@ 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_SMALL * 1,
|
||||||
|
"CPU " + String(getCpuFrequencyMhz()) + "MHz");
|
||||||
|
#endif
|
||||||
|
|
||||||
// Line 3
|
// Line 3
|
||||||
drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
|
drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
|
||||||
|
|
||||||
|
@ -392,6 +392,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);
|
||||||
|
@ -3,32 +3,62 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "meshwifi/meshwifi.h"
|
#include "meshwifi/meshwifi.h"
|
||||||
|
#include "sleep.h"
|
||||||
#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;
|
||||||
|
|
||||||
|
// Our API to handle messages to and from the radio.
|
||||||
|
httpAPI webAPI;
|
||||||
|
|
||||||
|
// Declare some handler functions for the various URLs on the server
|
||||||
|
void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleStyleCSS(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleJSONChatHistoryDummy(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleHotspot(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleFavicon(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handleRoot(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
void handle404(HTTPRequest *req, HTTPResponse *res);
|
||||||
|
|
||||||
|
void middlewareSpeedUp240(HTTPRequest *req, HTTPResponse *res, std::function<void()> next);
|
||||||
|
void middlewareSpeedUp160(HTTPRequest *req, HTTPResponse *res, std::function<void()> next);
|
||||||
|
void middlewareSession(HTTPRequest *req, HTTPResponse *res, std::function<void()> next);
|
||||||
|
|
||||||
|
bool isWebServerReady = 0;
|
||||||
|
bool isCertReady = 0;
|
||||||
|
|
||||||
|
uint32_t timeSpeedUp = 0;
|
||||||
|
|
||||||
void handleWebResponse()
|
void handleWebResponse()
|
||||||
{
|
{
|
||||||
@ -36,82 +66,241 @@ 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slow down the CPU if we have not received a request within the last
|
||||||
|
// 2 minutes.
|
||||||
|
if (millis() - timeSpeedUp >= (2 * 60 * 1000)) {
|
||||||
|
setCpuFrequencyMhz(80);
|
||||||
|
timeSpeedUp = millis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 *nodeAPIv1ToRadioOptions = new ResourceNode("/api/v1/toradio", "OPTIONS", &handleAPIv1ToRadio);
|
||||||
|
ResourceNode *nodeAPIv1ToRadio = new ResourceNode("/api/v1/toradio", "PUT", &handleAPIv1ToRadio);
|
||||||
|
ResourceNode *nodeAPIv1FromRadio = new ResourceNode("/api/v1/fromradio", "GET", &handleAPIv1FromRadio);
|
||||||
|
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 *nodeFavicon = new ResourceNode("/favicon.ico", "GET", &handleFavicon);
|
||||||
|
ResourceNode *nodeRoot = new ResourceNode("/", "GET", &handleRoot);
|
||||||
|
ResourceNode *node404 = new ResourceNode("", "GET", &handle404);
|
||||||
|
|
||||||
|
// Secure nodes
|
||||||
|
secureServer->registerNode(nodeAPIv1ToRadioOptions);
|
||||||
|
secureServer->registerNode(nodeAPIv1ToRadio);
|
||||||
|
secureServer->registerNode(nodeAPIv1FromRadio);
|
||||||
|
secureServer->registerNode(nodeCSS);
|
||||||
|
secureServer->registerNode(nodeJS);
|
||||||
|
secureServer->registerNode(nodeHotspot);
|
||||||
|
secureServer->registerNode(nodeFavicon);
|
||||||
|
secureServer->registerNode(nodeRoot);
|
||||||
|
secureServer->setDefaultNode(node404);
|
||||||
|
|
||||||
|
secureServer->addMiddleware(&middlewareSpeedUp240);
|
||||||
|
|
||||||
|
// Insecure nodes
|
||||||
|
insecureServer->registerNode(nodeAPIv1ToRadioOptions);
|
||||||
|
insecureServer->registerNode(nodeAPIv1ToRadio);
|
||||||
|
insecureServer->registerNode(nodeAPIv1FromRadio);
|
||||||
|
insecureServer->registerNode(nodeCSS);
|
||||||
|
insecureServer->registerNode(nodeJS);
|
||||||
|
insecureServer->registerNode(nodeHotspot);
|
||||||
|
insecureServer->registerNode(nodeFavicon);
|
||||||
|
insecureServer->registerNode(nodeRoot);
|
||||||
|
insecureServer->setDefaultNode(node404);
|
||||||
|
|
||||||
|
insecureServer->addMiddleware(&middlewareSpeedUp160);
|
||||||
|
|
||||||
|
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 middlewareSpeedUp240(HTTPRequest *req, HTTPResponse *res, std::function<void()> next)
|
||||||
{
|
{
|
||||||
String message = "";
|
// We want to print the response status, so we need to call next() first.
|
||||||
message += "File Not Found\n\n";
|
next();
|
||||||
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++) {
|
setCpuFrequencyMhz(240);
|
||||||
message += " " + webserver.argName(i) + ": " + webserver.arg(i) + "\n";
|
timeSpeedUp = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
void middlewareSpeedUp160(HTTPRequest *req, HTTPResponse *res, std::function<void()> next)
|
||||||
|
{
|
||||||
|
// We want to print the response status, so we need to call next() first.
|
||||||
|
next();
|
||||||
|
|
||||||
|
// If the frequency is 240mhz, we have recently gotten a HTTPS request.
|
||||||
|
// In that case, leave the frequency where it is and just update the
|
||||||
|
// countdown timer (timeSpeedUp).
|
||||||
|
if (getCpuFrequencyMhz() != 240) {
|
||||||
|
setCpuFrequencyMhz(160);
|
||||||
}
|
}
|
||||||
Serial.println(message);
|
timeSpeedUp = millis();
|
||||||
webserver.send(404, "text/plain", message);
|
}
|
||||||
|
|
||||||
|
void handle404(HTTPRequest *req, HTTPResponse *res)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Discard request body, if we received any
|
||||||
|
// We do this, as this is the default node and may also server POST/PUT requests
|
||||||
|
req->discardRequestBody();
|
||||||
|
|
||||||
|
// 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 +309,103 @@ 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;
|
// The response implements the Print interface, so you can use it just like
|
||||||
|
// you would write to Serial etc.
|
||||||
|
res->println("<!DOCTYPE html>");
|
||||||
|
res->println("<meta http-equiv=\"refresh\" content=\"0;url=http://meshtastic.org/\" />\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void notifyWebUI()
|
void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
DEBUG_MSG("************ Got a message! ************\n");
|
|
||||||
MeshPacket &mp = devicestate.rx_text_message;
|
|
||||||
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
|
DEBUG_MSG("+++++++++++++++ webAPI handleAPIv1FromRadio\n");
|
||||||
assert(mp.decoded.which_payload == SubPacket_data_tag);
|
|
||||||
snprintf(tempBuf, sizeof(tempBuf), "%s", mp.decoded.data.payload.bytes);
|
|
||||||
|
|
||||||
something = tempBuf;
|
/*
|
||||||
|
For documentation, see:
|
||||||
|
https://github.com/meshtastic/Meshtastic-device/wiki/HTTP-REST-API-discussion
|
||||||
|
https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/device-api.md
|
||||||
|
|
||||||
|
Example:
|
||||||
|
http://10.10.30.198/api/v1/fromradio
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Get access to the parameters
|
||||||
|
ResourceParameters *params = req->getParams();
|
||||||
|
|
||||||
|
// std::string paramAll = "all";
|
||||||
|
std::string valueAll;
|
||||||
|
|
||||||
|
// Status code is 200 OK by default.
|
||||||
|
res->setHeader("Content-Type", "application/x-protobuf");
|
||||||
|
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
res->setHeader("Access-Control-Allow-Methods", "PUT, GET");
|
||||||
|
|
||||||
|
uint8_t txBuf[MAX_STREAM_BUF_SIZE];
|
||||||
|
uint32_t len = 1;
|
||||||
|
|
||||||
|
if (params->getQueryParameter("all", valueAll)) {
|
||||||
|
if (valueAll == "true") {
|
||||||
|
while (len) {
|
||||||
|
len = webAPI.getFromRadio(txBuf);
|
||||||
|
res->write(txBuf, len);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
len = webAPI.getFromRadio(txBuf);
|
||||||
|
res->write(txBuf, len);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
len = webAPI.getFromRadio(txBuf);
|
||||||
|
res->write(txBuf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_MSG("--------------- webAPI handleAPIv1FromRadio, len %d\n", len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res)
|
||||||
|
{
|
||||||
|
DEBUG_MSG("+++++++++++++++ webAPI handleAPIv1ToRadio\n");
|
||||||
|
|
||||||
|
/*
|
||||||
|
For documentation, see:
|
||||||
|
https://github.com/meshtastic/Meshtastic-device/wiki/HTTP-REST-API-discussion
|
||||||
|
https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/device-api.md
|
||||||
|
|
||||||
|
Example:
|
||||||
|
http://10.10.30.198/api/v1/toradio
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Status code is 200 OK by default.
|
||||||
|
|
||||||
|
if (req->getMethod() != "OPTIONS") {
|
||||||
|
res->setHeader("Content-Type", "application/x-protobuf");
|
||||||
|
} else {
|
||||||
|
res->setHeader("Content-Type", "application/x-protobuf");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
res->setHeader("Access-Control-Allow-Headers", "Content-Type");
|
||||||
|
res->setHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
res->setHeader("Access-Control-Allow-Methods", "PUT, OPTIONS");
|
||||||
|
|
||||||
|
if (req->getMethod() == "OPTIONS") {
|
||||||
|
res->setStatusCode(204);
|
||||||
|
res->print("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
byte buffer[MAX_TO_FROM_RADIO_SIZE];
|
||||||
|
size_t s = req->readBytes(buffer, MAX_TO_FROM_RADIO_SIZE);
|
||||||
|
|
||||||
|
DEBUG_MSG("Received %d bytes from PUT request\n", s);
|
||||||
|
webAPI.handleToRadio(buffer, s);
|
||||||
|
|
||||||
|
res->write(buffer, s);
|
||||||
|
DEBUG_MSG("--------------- webAPI handleAPIv1ToRadio\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -146,7 +413,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 +490,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 +783,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 +942,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 +1071,19 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleFavicon(HTTPRequest *req, HTTPResponse *res)
|
||||||
|
{
|
||||||
|
// Set Content-Type
|
||||||
|
res->setHeader("Content-Type", "image/vnd.microsoft.icon");
|
||||||
|
// Write data from header file
|
||||||
|
res->write(FAVICON_DATA, FAVICON_LENGTH);
|
||||||
}
|
}
|
@ -1,9 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "PhoneAPI.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
void initWebServer();
|
void initWebServer();
|
||||||
|
void createSSLCert();
|
||||||
|
|
||||||
void handleNotFound();
|
void handleNotFound();
|
||||||
|
|
||||||
@ -15,8 +17,133 @@ void notifyWebUI();
|
|||||||
|
|
||||||
void handleHotspot();
|
void handleHotspot();
|
||||||
|
|
||||||
|
|
||||||
void handleStyleCSS();
|
void handleStyleCSS();
|
||||||
void handleRoot();
|
void handleRoot();
|
||||||
void handleScriptsScriptJS();
|
void handleScriptsScriptJS();
|
||||||
void handleJSONChatHistoryDummy();
|
void handleJSONChatHistoryDummy();
|
||||||
|
|
||||||
|
// Binary data for the favicon
|
||||||
|
const byte FAVICON_DATA[] = {
|
||||||
|
0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x20, 0x20, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0xA8, 0x08, 0x00, 0x00, 0x16, 0x00, 0x00,
|
||||||
|
0x00, 0x28, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x84,
|
||||||
|
0xDC, 0x3D, 0x00, 0x84, 0xDC, 0x3C, 0x00, 0x85, 0xDC, 0x3F, 0x00, 0x86, 0xDD, 0x40, 0x00, 0x83, 0xDC, 0x3C, 0x00, 0x85, 0xDC,
|
||||||
|
0x3E, 0x00, 0x82, 0xDC, 0x3A, 0x00, 0x8B, 0xDE, 0x49, 0x00, 0x84, 0xDB, 0x3E, 0x00, 0x82, 0xD9, 0x3C, 0x00, 0x89, 0xDD, 0x45,
|
||||||
|
0x00, 0x83, 0xDB, 0x3C, 0x00, 0x83, 0xD8, 0x3D, 0x00, 0x81, 0xD8, 0x3A, 0x00, 0x8D, 0xE0, 0x49, 0x00, 0x88, 0xE4, 0x3F, 0x00,
|
||||||
|
0x89, 0xE9, 0x3E, 0x00, 0x84, 0xD8, 0x40, 0x00, 0x85, 0xDF, 0x3C, 0x00, 0x8E, 0xF2, 0x40, 0x00, 0x8D, 0xF6, 0x3D, 0x00, 0x90,
|
||||||
|
0xEA, 0x49, 0x00, 0x82, 0xD5, 0x3E, 0x00, 0x78, 0xC1, 0x3A, 0x00, 0x90, 0xE9, 0x4A, 0x00, 0x8E, 0xF5, 0x3D, 0x00, 0x84, 0xDD,
|
||||||
|
0x3D, 0x00, 0x91, 0xF7, 0x43, 0x00, 0x87, 0xE5, 0x3D, 0x00, 0x6C, 0xA2, 0x38, 0x00, 0x53, 0x65, 0x31, 0x00, 0x41, 0x39, 0x2E,
|
||||||
|
0x00, 0x3A, 0x27, 0x2B, 0x00, 0x34, 0x1A, 0x2A, 0x00, 0x41, 0x38, 0x2E, 0x00, 0x82, 0xD8, 0x3D, 0x00, 0x88, 0xE7, 0x3D, 0x00,
|
||||||
|
0x8E, 0xF3, 0x41, 0x00, 0x69, 0x95, 0x39, 0x00, 0x3E, 0x33, 0x2C, 0x00, 0x31, 0x11, 0x29, 0x00, 0x2E, 0x0A, 0x29, 0x00, 0x2D,
|
||||||
|
0x0B, 0x27, 0x00, 0x30, 0x10, 0x29, 0x00, 0x34, 0x18, 0x2A, 0x00, 0x3E, 0x31, 0x2C, 0x00, 0x68, 0x95, 0x39, 0x00, 0x88, 0xE7,
|
||||||
|
0x3E, 0x00, 0x82, 0xD7, 0x3C, 0x00, 0x84, 0xDD, 0x3C, 0x00, 0x8B, 0xEE, 0x3E, 0x00, 0x85, 0xDF, 0x3D, 0x00, 0x47, 0x48, 0x2E,
|
||||||
|
0x00, 0x30, 0x0F, 0x29, 0x00, 0x31, 0x13, 0x29, 0x00, 0x48, 0x4D, 0x2E, 0x00, 0x61, 0x7F, 0x39, 0x00, 0x6A, 0x9C, 0x38, 0x00,
|
||||||
|
0x75, 0xB8, 0x39, 0x00, 0x85, 0xDE, 0x3D, 0x00, 0x8C, 0xEF, 0x3E, 0x00, 0x89, 0xDE, 0x44, 0x00, 0x80, 0xD1, 0x3C, 0x00, 0x3A,
|
||||||
|
0x28, 0x2C, 0x00, 0x32, 0x16, 0x2A, 0x00, 0x33, 0x17, 0x2A, 0x00, 0x4B, 0x50, 0x30, 0x00, 0x76, 0xBA, 0x3A, 0x00, 0x8A, 0xEF,
|
||||||
|
0x3C, 0x00, 0x9A, 0xFE, 0x4D, 0x00, 0x95, 0xFF, 0x43, 0x00, 0x93, 0xFF, 0x40, 0x00, 0x4B, 0x52, 0x30, 0x00, 0x7E, 0xCE, 0x3C,
|
||||||
|
0x00, 0x87, 0xD9, 0x44, 0x00, 0x34, 0x1B, 0x2A, 0x00, 0x65, 0x90, 0x36, 0x00, 0x8E, 0xF6, 0x3D, 0x00, 0x8F, 0xF7, 0x40, 0x00,
|
||||||
|
0x8B, 0xDD, 0x48, 0x00, 0x73, 0xB1, 0x3A, 0x00, 0x66, 0x95, 0x35, 0x00, 0x66, 0x93, 0x35, 0x00, 0x35, 0x1B, 0x2A, 0x00, 0x8D,
|
||||||
|
0xE8, 0x45, 0x00, 0x82, 0xD9, 0x3B, 0x00, 0x72, 0xAA, 0x3C, 0x00, 0x95, 0xFD, 0x46, 0x00, 0x8D, 0xF0, 0x40, 0x00, 0x57, 0x70,
|
||||||
|
0x32, 0x00, 0x3C, 0x2D, 0x2C, 0x00, 0x2F, 0x0D, 0x29, 0x00, 0x81, 0xD4, 0x3D, 0x00, 0x8D, 0xF1, 0x40, 0x00, 0x94, 0xFC, 0x46,
|
||||||
|
0x00, 0x73, 0xAE, 0x3D, 0x00, 0x45, 0x44, 0x2D, 0x00, 0x94, 0xF5, 0x49, 0x00, 0x90, 0xF0, 0x45, 0x00, 0x73, 0xAF, 0x3B, 0x00,
|
||||||
|
0x38, 0x21, 0x2C, 0x00, 0x30, 0x11, 0x29, 0x00, 0x2F, 0x0F, 0x28, 0x00, 0x72, 0xAC, 0x3B, 0x00, 0x6A, 0x93, 0x3D, 0x00, 0x2E,
|
||||||
|
0x0D, 0x27, 0x00, 0x35, 0x1C, 0x2B, 0x00, 0x36, 0x20, 0x2A, 0x00, 0x5E, 0x77, 0x39, 0x00, 0x78, 0xBE, 0x3B, 0x00, 0x36, 0x21,
|
||||||
|
0x2A, 0x00, 0x71, 0xAB, 0x3B, 0x00, 0x4C, 0x54, 0x30, 0x00, 0x3D, 0x31, 0x2B, 0x00, 0x82, 0xD6, 0x3D, 0x00, 0x79, 0xC5, 0x39,
|
||||||
|
0x00, 0x9A, 0xFF, 0x4D, 0x00, 0x8A, 0xE8, 0x40, 0x00, 0x8A, 0xE7, 0x40, 0x00, 0x7A, 0xC6, 0x39, 0x00, 0x3D, 0x2E, 0x2C, 0x00,
|
||||||
|
0x81, 0xD5, 0x3D, 0x00, 0x77, 0xBC, 0x3A, 0x00, 0x31, 0x12, 0x2A, 0x00, 0x69, 0x9B, 0x37, 0x00, 0x8E, 0xF3, 0x40, 0x00, 0x83,
|
||||||
|
0xDC, 0x3B, 0x00, 0x8C, 0xF6, 0x3B, 0x00, 0x88, 0xD9, 0x45, 0x00, 0x86, 0xE1, 0x3D, 0x00, 0x85, 0xE0, 0x3D, 0x00, 0x7B, 0xC8,
|
||||||
|
0x39, 0x00, 0x36, 0x1F, 0x29, 0x00, 0x55, 0x6B, 0x32, 0x00, 0x8A, 0xEE, 0x3C, 0x00, 0x48, 0x4B, 0x2E, 0x00, 0x51, 0x61, 0x31,
|
||||||
|
0x00, 0x8C, 0xE0, 0x48, 0x00, 0x8B, 0xDE, 0x47, 0x00, 0x98, 0xEE, 0x55, 0x00, 0x5D, 0x79, 0x36, 0x00, 0x3A, 0x2A, 0x2B, 0x00,
|
||||||
|
0x3A, 0x29, 0x2B, 0x00, 0x5C, 0x78, 0x36, 0x00, 0x60, 0x7C, 0x3A, 0x00, 0x3D, 0x30, 0x2C, 0x00, 0x99, 0xFD, 0x4C, 0x00, 0x66,
|
||||||
|
0x8A, 0x3C, 0x00, 0x2D, 0x0C, 0x27, 0x00, 0x42, 0x3C, 0x2E, 0x00, 0x84, 0xDA, 0x3E, 0x00, 0x88, 0xE5, 0x3F, 0x00, 0x37, 0x22,
|
||||||
|
0x2B, 0x00, 0x2E, 0x0B, 0x28, 0x00, 0x6A, 0x9B, 0x37, 0x00, 0x72, 0xAF, 0x3A, 0x00, 0x32, 0x15, 0x29, 0x00, 0x2A, 0x00, 0x28,
|
||||||
|
0x00, 0x5B, 0x75, 0x35, 0x00, 0x89, 0xE8, 0x3D, 0x00, 0x78, 0xBF, 0x3A, 0x00, 0x73, 0xB4, 0x38, 0x00, 0x83, 0xDA, 0x3C, 0x00,
|
||||||
|
0x84, 0xDE, 0x3C, 0x00, 0x85, 0xDD, 0x3E, 0x00, 0x86, 0xDE, 0x40, 0x00, 0x84, 0xDE, 0x3B, 0x00, 0x86, 0xE2, 0x3C, 0x00, 0x85,
|
||||||
|
0xDD, 0x3F, 0x00, 0x87, 0xE2, 0x3F, 0x00, 0x87, 0xE1, 0x3E, 0x00, 0x85, 0xDE, 0x3E, 0x00, 0x89, 0xE2, 0x41, 0x00, 0x89, 0xE2,
|
||||||
|
0x43, 0x00, 0x84, 0xDC, 0x3E, 0x00, 0x83, 0xD8, 0x3E, 0x00, 0x90, 0xF6, 0x41, 0x00, 0x2B, 0x04, 0x28, 0x00, 0x8C, 0xE3, 0x47,
|
||||||
|
0x00, 0x8B, 0xDE, 0x48, 0x00, 0x8A, 0xDC, 0x47, 0x00, 0x8A, 0xDD, 0x47, 0x00, 0x8D, 0xDD, 0x4A, 0x00, 0x8A, 0xDE, 0x47, 0x00,
|
||||||
|
0x8B, 0xDD, 0x49, 0x00, 0x8B, 0xE0, 0x46, 0x00, 0x9A, 0xF2, 0x55, 0x00, 0x59, 0x70, 0x35, 0x00, 0x8F, 0xDE, 0x4F, 0x00, 0x82,
|
||||||
|
0xDC, 0x3B, 0x00, 0x82, 0xDB, 0x39, 0x00, 0x7F, 0xD7, 0x38, 0x00, 0x92, 0xF0, 0x48, 0x00, 0x33, 0x19, 0x29, 0x00, 0x87, 0xDD,
|
||||||
|
0x42, 0x00, 0x87, 0xDD, 0x41, 0x00, 0x92, 0xEC, 0x4B, 0x00, 0x78, 0xBD, 0x3C, 0x00, 0x86, 0xDD, 0x3F, 0x00, 0x81, 0xD9, 0x39,
|
||||||
|
0x00, 0x7B, 0xC4, 0x3C, 0x00, 0x34, 0x1A, 0x29, 0x00, 0x89, 0xDD, 0x44, 0x00, 0x86, 0xDC, 0x40, 0x00, 0x88, 0xDD, 0x44, 0x00,
|
||||||
|
0x87, 0xDE, 0x41, 0x00, 0x99, 0xFA, 0x4F, 0x00, 0x7B, 0xC3, 0x3E, 0x00, 0x83, 0xD7, 0x3F, 0x00, 0x8B, 0xED, 0x3E, 0x00, 0x40,
|
||||||
|
0x33, 0x2F, 0x00, 0x39, 0x27, 0x2B, 0x00, 0x81, 0xD7, 0x3B, 0x00, 0x3B, 0x2C, 0x2A, 0x00, 0x33, 0x18, 0x29, 0x00, 0x38, 0x22,
|
||||||
|
0x2B, 0x00, 0x85, 0xDA, 0x40, 0x00, 0x89, 0xEA, 0x3D, 0x00, 0x6F, 0xA9, 0x38, 0x00, 0x70, 0xAB, 0x38, 0x00, 0x85, 0xDD, 0x3D,
|
||||||
|
0x00, 0x88, 0xE1, 0x40, 0x00, 0x36, 0x1F, 0x2B, 0x00, 0x30, 0x13, 0x28, 0x00, 0x68, 0x9A, 0x36, 0x00, 0x90, 0xFB, 0x3F, 0x00,
|
||||||
|
0x8A, 0xDD, 0x46, 0x00, 0x8D, 0xE9, 0x45, 0x00, 0x5A, 0x71, 0x36, 0x00, 0x27, 0x00, 0x24, 0x00, 0x73, 0x9F, 0x45, 0x00, 0x97,
|
||||||
|
0xFE, 0x4A, 0x00, 0x86, 0xD8, 0x43, 0x00, 0x73, 0xA1, 0x45, 0x00, 0x8E, 0xDF, 0x4C, 0x00, 0x85, 0xDB, 0x40, 0x00, 0x72, 0xB5,
|
||||||
|
0x37, 0x00, 0x95, 0xF4, 0x4B, 0x00, 0x73, 0xB6, 0x37, 0x00, 0x88, 0xE9, 0x3C, 0x00, 0x8A, 0xDB, 0x48, 0x00, 0x8C, 0xDE, 0x49,
|
||||||
|
0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0xAE, 0x06, 0xF1, 0x02, 0x04, 0x04, 0x02, 0xF1, 0x06, 0xAE, 0x04, 0x03, 0x02, 0x01, 0x00, 0x01,
|
||||||
|
0x0A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0xAE, 0xC7, 0xF1, 0x02, 0x04,
|
||||||
|
0x04, 0x02, 0xF1, 0xC7, 0xAE, 0x04, 0x03, 0x02, 0x01, 0x00, 0x01, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x01, 0x02, 0x03, 0x0B, 0xAE, 0xEF, 0xF0, 0x02, 0x01, 0x01, 0x02, 0xB4, 0xEF, 0xAE, 0x0B, 0x03, 0x02, 0x01, 0x00,
|
||||||
|
0x01, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x05, 0xEB, 0xA7, 0xD1, 0xEC, 0xED, 0x96,
|
||||||
|
0x04, 0x04, 0x96, 0xED, 0xEE, 0xD1, 0xA7, 0xEB, 0x05, 0x04, 0x01, 0x04, 0xCA, 0x04, 0x01, 0x01, 0x01, 0xCA, 0xCA, 0xCA, 0xCA,
|
||||||
|
0xCA, 0xCA, 0xCA, 0xCC, 0xE2, 0x8A, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE8, 0xE7, 0xE9, 0xE5, 0xBB, 0xE3, 0x8A, 0xE2, 0xCC,
|
||||||
|
0xCA, 0xCC, 0xEA, 0xCC, 0xCA, 0xCA, 0xCA, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x08, 0xDD, 0x55, 0xDE, 0x2C, 0xDF,
|
||||||
|
0xE0, 0xE1, 0xE1, 0xE0, 0xDF, 0x2C, 0xDE, 0x55, 0xDD, 0x08, 0x04, 0x01, 0x04, 0xCA, 0x04, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x01, 0xC6, 0xD8, 0xD9, 0xAB, 0x78, 0x6A, 0x28, 0xDA, 0xDB, 0x28, 0x6A, 0x5A, 0xDC, 0xD9, 0xD8, 0xC6,
|
||||||
|
0x01, 0x00, 0x01, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x05, 0x03, 0xD4, 0xD1, 0x31,
|
||||||
|
0xD5, 0xD6, 0x98, 0xD7, 0xD6, 0xD5, 0x0B, 0x32, 0xD4, 0x03, 0x05, 0x04, 0x01, 0x04, 0xCA, 0x04, 0x01, 0x01, 0x01, 0x02, 0x02,
|
||||||
|
0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0xC3, 0xC2, 0xA4, 0xD0, 0xD1, 0xB3, 0xD2, 0xD3, 0xD3, 0xD2, 0x4F, 0x32, 0xD0, 0xA4, 0xC2,
|
||||||
|
0xC3, 0x05, 0x02, 0x05, 0xB7, 0x05, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xCB, 0xC2, 0xCC, 0x02, 0xCD,
|
||||||
|
0x79, 0xCE, 0xCF, 0xC1, 0xC1, 0xCF, 0xCE, 0x79, 0xCD, 0x02, 0xCC, 0xC2, 0xCB, 0x03, 0xCB, 0xB3, 0xCB, 0x03, 0x03, 0x03, 0x04,
|
||||||
|
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x7E, 0x05, 0xC6, 0x7E, 0x00, 0xC7, 0x15, 0xC8, 0xC9, 0xC9, 0xC8, 0x15, 0xC7, 0x00, 0x7E,
|
||||||
|
0xC6, 0x05, 0x7E, 0x04, 0x7E, 0xCA, 0x7E, 0x04, 0x04, 0x04, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0x00, 0x03, 0xC3, 0x00,
|
||||||
|
0x05, 0x55, 0xC4, 0xC5, 0xC1, 0xC1, 0xC5, 0xC4, 0x55, 0x05, 0x00, 0xC3, 0x03, 0x00, 0xAE, 0x00, 0x3D, 0x00, 0xAE, 0xAE, 0xAE,
|
||||||
|
0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0x7E, 0xBE, 0x00, 0x05, 0xBE, 0x7E, 0xBF, 0xC0, 0x5C, 0xC1, 0xC1, 0x5C, 0xC0, 0xBF, 0x7E,
|
||||||
|
0xBE, 0x05, 0x00, 0xBE, 0x7E, 0xBE, 0xC2, 0x06, 0xBD, 0xBD, 0xBD, 0xB3, 0xB3, 0xB3, 0xB4, 0xB5, 0xB3, 0xB3, 0xB5, 0xB6, 0xB6,
|
||||||
|
0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0x6B, 0x6B, 0xBB, 0xBA, 0xB9, 0xB8, 0xB7, 0xB6, 0xB6, 0xB5, 0xB3, 0xB5, 0xBC, 0xB4, 0xB3, 0xB3,
|
||||||
|
0xB3, 0x02, 0x02, 0xA8, 0xA9, 0xAA, 0xA8, 0x02, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0x8F, 0xB1, 0x71, 0x2D, 0xB1, 0x9E, 0xB0,
|
||||||
|
0xAF, 0xAE, 0xAD, 0xAC, 0xAB, 0x02, 0xA4, 0xB2, 0xAA, 0xA8, 0x02, 0x02, 0x04, 0x31, 0xA3, 0x04, 0x31, 0x82, 0x3B, 0xA3, 0xA4,
|
||||||
|
0xA5, 0xA6, 0x82, 0xA7, 0x8E, 0x20, 0x78, 0x78, 0x20, 0x8E, 0xA7, 0x82, 0xA6, 0xA5, 0xA4, 0xA3, 0x3B, 0x82, 0x3D, 0x04, 0xA3,
|
||||||
|
0x31, 0x04, 0x09, 0x9F, 0xA0, 0x21, 0x2C, 0xA1, 0x47, 0x52, 0x5B, 0x5A, 0xA2, 0x1C, 0x81, 0x8D, 0x8E, 0x91, 0x91, 0x8E, 0x8D,
|
||||||
|
0x81, 0x1C, 0xA2, 0x5A, 0x5B, 0x52, 0x47, 0xA1, 0x2C, 0x21, 0xA0, 0x9F, 0x09, 0x96, 0x97, 0x16, 0x98, 0x99, 0x9A, 0x46, 0x9B,
|
||||||
|
0x28, 0x9C, 0x6D, 0x76, 0x7D, 0x8C, 0x9D, 0x8E, 0x8E, 0x9D, 0x9E, 0x7D, 0x75, 0x6D, 0x9C, 0x65, 0x9B, 0x46, 0x39, 0x99, 0x98,
|
||||||
|
0x16, 0x97, 0x96, 0x4F, 0x89, 0x15, 0x1F, 0x69, 0x38, 0x45, 0x8A, 0x78, 0x66, 0x6C, 0x74, 0x4A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
|
||||||
|
0x8B, 0x80, 0x45, 0x90, 0x66, 0x91, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x15, 0x89, 0x4F, 0x7E, 0x0D, 0x14, 0x1E, 0x29, 0x37, 0x44,
|
||||||
|
0x14, 0x59, 0x65, 0x6B, 0x73, 0x7F, 0x80, 0x25, 0x81, 0x82, 0x25, 0x80, 0x7F, 0x83, 0x84, 0x65, 0x85, 0x4D, 0x86, 0x87, 0x29,
|
||||||
|
0x88, 0x14, 0x0D, 0x7E, 0x05, 0x0C, 0x13, 0x1D, 0x28, 0x2C, 0x43, 0x4E, 0x72, 0x64, 0x53, 0x5A, 0x73, 0x74, 0x75, 0x1C, 0x1C,
|
||||||
|
0x76, 0x74, 0x77, 0x78, 0x6A, 0x64, 0x79, 0x4E, 0x7A, 0x2C, 0x7B, 0x7C, 0x7D, 0x0C, 0x05, 0x04, 0x0B, 0x12, 0x1C, 0x27, 0x36,
|
||||||
|
0x42, 0x4D, 0x5D, 0x63, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x1A, 0x1A, 0x6D, 0x6C, 0x6E, 0x53, 0x69, 0x6F, 0x5D, 0x19, 0x70, 0x36,
|
||||||
|
0x71, 0x24, 0x12, 0x0B, 0x04, 0x03, 0x03, 0x11, 0x1B, 0x2E, 0x35, 0x41, 0x4C, 0x5E, 0x62, 0x63, 0x64, 0x65, 0x66, 0x2C, 0x5A,
|
||||||
|
0x5A, 0x2C, 0x66, 0x65, 0x64, 0x67, 0x62, 0x5E, 0x52, 0x40, 0x65, 0x68, 0x1B, 0x11, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x25,
|
||||||
|
0x34, 0x40, 0x4B, 0x56, 0x57, 0x58, 0x16, 0x59, 0x5A, 0x41, 0x5B, 0x5B, 0x41, 0x5A, 0x59, 0x5C, 0x5D, 0x5E, 0x5F, 0x21, 0x41,
|
||||||
|
0x60, 0x61, 0x05, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x09, 0x24, 0x33, 0x3F, 0x2C, 0x4B, 0x4C, 0x4D, 0x4E, 0x14, 0x4F, 0x50,
|
||||||
|
0x51, 0x51, 0x50, 0x4F, 0x14, 0x4E, 0x4D, 0x52, 0x53, 0x2C, 0x3F, 0x01, 0x54, 0x55, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x1A,
|
||||||
|
0x23, 0x32, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x47, 0x46, 0x45, 0x44, 0x43, 0x48, 0x41, 0x40, 0x3F,
|
||||||
|
0x49, 0x3C, 0x4A, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x30, 0x32, 0x33, 0x34, 0x35, 0x36, 0x2C, 0x37, 0x38,
|
||||||
|
0x39, 0x3A, 0x3A, 0x39, 0x38, 0x37, 0x2C, 0x36, 0x35, 0x34, 0x3B, 0x3C, 0x30, 0x3D, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x1A, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2C, 0x2B, 0x2A, 0x29, 0x28, 0x2D, 0x2E, 0x13,
|
||||||
|
0x2F, 0x30, 0x31, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x09, 0x02, 0x1B, 0x1C, 0x1D, 0x1E,
|
||||||
|
0x1F, 0x20, 0x21, 0x21, 0x20, 0x22, 0x1E, 0x1D, 0x1C, 0x1B, 0x02, 0x09, 0x1A, 0x01, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x17, 0x16, 0x18, 0x19, 0x13, 0x12, 0x11,
|
||||||
|
0x02, 0x01, 0x00, 0x01, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x0B, 0x0C,
|
||||||
|
0x0D, 0x0E, 0x0F, 0x10, 0x10, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x03, 0x02, 0x01, 0x00, 0x01, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04,
|
||||||
|
0x03, 0x02, 0x01, 0x00, 0x01, 0x0A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
|
// Length of the binary data
|
||||||
|
const int FAVICON_LENGTH = 2238;
|
||||||
|
|
||||||
|
class httpAPI : public PhoneAPI
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Nothing here yet
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Nothing here yet
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Nothing here yet
|
||||||
|
};
|
@ -17,7 +17,7 @@ static WiFiServerPort *apiPort;
|
|||||||
|
|
||||||
uint8_t wifiDisconnectReason = 0;
|
uint8_t wifiDisconnectReason = 0;
|
||||||
|
|
||||||
// Stores the last 4 of our hardware ID, to make finding the device for pairing easier
|
// Stores our hostname
|
||||||
static char ourHost[16];
|
static char ourHost[16];
|
||||||
|
|
||||||
bool isWifiAvailable()
|
bool isWifiAvailable()
|
||||||
@ -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