mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-20 04:01:14 +00:00
#669 Add restart counter
This commit is contained in:
parent
fc2862bd16
commit
4f4cdf4f9e
@ -7,9 +7,10 @@
|
|||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include <Preferences.h>
|
||||||
|
#include <driver/rtc_io.h>
|
||||||
#include <nvs.h>
|
#include <nvs.h>
|
||||||
#include <nvs_flash.h>
|
#include <nvs_flash.h>
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
|
|
||||||
void getMacAddr(uint8_t *dmac)
|
void getMacAddr(uint8_t *dmac)
|
||||||
{
|
{
|
||||||
@ -45,6 +46,18 @@ void esp32Setup()
|
|||||||
DEBUG_MSG("NVS: UsedEntries %d, FreeEntries %d, AllEntries %d\n", nvs_stats.used_entries, nvs_stats.free_entries,
|
DEBUG_MSG("NVS: UsedEntries %d, FreeEntries %d, AllEntries %d\n", nvs_stats.used_entries, nvs_stats.free_entries,
|
||||||
nvs_stats.total_entries);
|
nvs_stats.total_entries);
|
||||||
|
|
||||||
|
DEBUG_MSG("Setup Preferences in Flash Storage\n");
|
||||||
|
|
||||||
|
// Create object to store our persistant data
|
||||||
|
Preferences preferences;
|
||||||
|
preferences.begin("meshtastic", false);
|
||||||
|
|
||||||
|
uint32_t rebootCounter = preferences.getUInt("rebootCounter", 0);
|
||||||
|
rebootCounter++;
|
||||||
|
preferences.putUInt("rebootCounter", rebootCounter);
|
||||||
|
preferences.end();
|
||||||
|
DEBUG_MSG("Number of Device Reboots: %d\n", rebootCounter);
|
||||||
|
|
||||||
// enableModemSleep();
|
// enableModemSleep();
|
||||||
|
|
||||||
// Since we are turning on watchdogs rather late in the release schedule, we really don't want to catch any
|
// Since we are turning on watchdogs rather late in the release schedule, we really don't want to catch any
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "PowerFSM.h"
|
#include "PowerFSM.h"
|
||||||
|
#include "RadioLibInterface.h"
|
||||||
#include "airtime.h"
|
#include "airtime.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mesh/http/ContentHelper.h"
|
#include "mesh/http/ContentHelper.h"
|
||||||
@ -10,8 +11,8 @@
|
|||||||
#include <HTTPBodyParser.hpp>
|
#include <HTTPBodyParser.hpp>
|
||||||
#include <HTTPMultipartBodyParser.hpp>
|
#include <HTTPMultipartBodyParser.hpp>
|
||||||
#include <HTTPURLEncodedBodyParser.hpp>
|
#include <HTTPURLEncodedBodyParser.hpp>
|
||||||
|
#include <Preferences.h>
|
||||||
#include <SPIFFS.h>
|
#include <SPIFFS.h>
|
||||||
#include "RadioLibInterface.h"
|
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
@ -836,6 +837,11 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
|
|||||||
ResourceParameters *params = req->getParams();
|
ResourceParameters *params = req->getParams();
|
||||||
std::string content;
|
std::string content;
|
||||||
|
|
||||||
|
Preferences preferences;
|
||||||
|
preferences.begin("meshtastic", false);
|
||||||
|
|
||||||
|
uint32_t rebootCounter = preferences.getUInt("rebootCounter", 0);
|
||||||
|
|
||||||
if (!params->getQueryParameter("content", content)) {
|
if (!params->getQueryParameter("content", content)) {
|
||||||
content = "json";
|
content = "json";
|
||||||
}
|
}
|
||||||
@ -934,6 +940,10 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
|
|||||||
res->printf("\"is_charging\": %s\n", BoolToString(powerStatus->getIsCharging()));
|
res->printf("\"is_charging\": %s\n", BoolToString(powerStatus->getIsCharging()));
|
||||||
res->println("},");
|
res->println("},");
|
||||||
|
|
||||||
|
res->println("\"device\": {");
|
||||||
|
res->printf("\"reboot_counter\": %d\n", rebootCounter);
|
||||||
|
res->println("},");
|
||||||
|
|
||||||
res->println("\"radio\": {");
|
res->println("\"radio\": {");
|
||||||
res->printf("\"frequecy\": %f,\n", RadioLibInterface::instance->getFreq());
|
res->printf("\"frequecy\": %f,\n", RadioLibInterface::instance->getFreq());
|
||||||
res->printf("\"lora_channel\": %d\n", RadioLibInterface::instance->getChannelNum());
|
res->printf("\"lora_channel\": %d\n", RadioLibInterface::instance->getChannelNum());
|
||||||
@ -941,8 +951,6 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
|
|||||||
|
|
||||||
res->println("},");
|
res->println("},");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
res->println("\"status\": \"ok\"");
|
res->println("\"status\": \"ok\"");
|
||||||
res->println("}");
|
res->println("}");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user