Merge pull request #645 from mc-hamster/master

#635 Added web_request_count and fixed printf of psram
This commit is contained in:
Jm Casler 2021-01-17 17:26:56 -08:00 committed by GitHub
commit 046e691d4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 9 deletions

View File

@ -80,6 +80,8 @@ bool isCertReady = 0;
uint32_t timeSpeedUp = 0; uint32_t timeSpeedUp = 0;
uint32_t numberOfRequests = 0;
// We need to specify some content-type mapping, so the resources get delivered with the // We need to specify some content-type mapping, so the resources get delivered with the
// right content type and are displayed correctly in the browser // right content type and are displayed correctly in the browser
char contentTypes[][2][32] = {{".txt", "text/plain"}, {".html", "text/html"}, char contentTypes[][2][32] = {{".txt", "text/plain"}, {".html", "text/html"},
@ -337,6 +339,8 @@ void middlewareSpeedUp240(HTTPRequest *req, HTTPResponse *res, std::function<voi
setCpuFrequencyMhz(240); setCpuFrequencyMhz(240);
timeSpeedUp = millis(); timeSpeedUp = millis();
numberOfRequests++;
} }
void middlewareSpeedUp160(HTTPRequest *req, HTTPResponse *res, std::function<void()> next) void middlewareSpeedUp160(HTTPRequest *req, HTTPResponse *res, std::function<void()> next)
@ -355,6 +359,8 @@ void middlewareSpeedUp160(HTTPRequest *req, HTTPResponse *res, std::function<voi
setCpuFrequencyMhz(160); setCpuFrequencyMhz(160);
} }
timeSpeedUp = millis(); timeSpeedUp = millis();
numberOfRequests++;
} }
void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res) void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
@ -1159,6 +1165,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
res->println("\"wifi\": {"); res->println("\"wifi\": {");
res->printf("\"web_request_count\": %d,\n", numberOfRequests);
res->println("\"rssi\": " + String(WiFi.RSSI()) + ","); res->println("\"rssi\": " + String(WiFi.RSSI()) + ",");
if (radioConfig.preferences.wifi_ap_mode || isSoftAPForced()) { if (radioConfig.preferences.wifi_ap_mode || isSoftAPForced()) {
@ -1170,13 +1177,13 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
res->println("},"); res->println("},");
res->println("\"memory\": {"); res->println("\"memory\": {");
res->printf("\"heap_total\": %u,\n", ESP.getHeapSize()); res->printf("\"heap_total\": %d,\n", ESP.getHeapSize());
res->printf("\"heap_free\": %u,\n", ESP.getFreeHeap()); res->printf("\"heap_free\": %d,\n", ESP.getFreeHeap());
res->printf("\"psram_total\": %s,\n", ESP.getPsramSize()); res->printf("\"psram_total\": %d,\n", ESP.getPsramSize());
res->printf("\"psram_free\": %s,\n", ESP.getFreePsram()); res->printf("\"psram_free\": %d,\n", ESP.getFreePsram());
res->print("\"spiffs_total\" : " + String(SPIFFS.totalBytes()) + ","); res->println("\"spiffs_total\" : " + String(SPIFFS.totalBytes()) + ",");
res->print("\"spiffs_used\" : " + String(SPIFFS.usedBytes()) + ","); res->println("\"spiffs_used\" : " + String(SPIFFS.usedBytes()) + ",");
res->print("\"spiffs_free\" : " + String(SPIFFS.totalBytes() - SPIFFS.usedBytes())); res->println("\"spiffs_free\" : " + String(SPIFFS.totalBytes() - SPIFFS.usedBytes()));
res->println("},"); res->println("},");
res->println("\"power\": {"); res->println("\"power\": {");

View File

@ -66,6 +66,17 @@ char serialStringChar[Constants_DATA_PAYLOAD_LEN];
int32_t SerialPlugin::runOnce() int32_t SerialPlugin::runOnce()
{ {
#ifndef NO_ESP32 #ifndef NO_ESP32
/*
Uncomment the preferences below if you want to use the plugin
without having to configure it from the PythonAPI or WebUI.
*/
// radioConfig.preferences.serialplugin_enabled = 1;
// radioConfig.preferences.serialplugin_rxd = 35;
// radioConfig.preferences.serialplugin_txd = 15;
// radioConfig.preferences.serialplugin_timeout = 1000;
if (radioConfig.preferences.serialplugin_enabled) { if (radioConfig.preferences.serialplugin_enabled) {
if (firstTime) { if (firstTime) {
@ -147,8 +158,8 @@ bool SerialPluginRadio::handleReceived(const MeshPacket &mp)
if (radioConfig.preferences.serialplugin_enabled) { if (radioConfig.preferences.serialplugin_enabled) {
auto &p = mp.decoded.data; auto &p = mp.decoded.data;
// DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", nodeDB.getNodeNum(), // DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n",
// mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); // nodeDB.getNodeNum(), mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes);
if (mp.from == nodeDB.getNodeNum()) { if (mp.from == nodeDB.getNodeNum()) {