mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
bug fix
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#include "Utils\FileUtils.h"
|
#include "Utils\FileUtils.h"
|
||||||
#include "Utils\JsonUtils.h"
|
#include "Utils\JsonUtils.h"
|
||||||
#include "Utils\StringUtils.h"
|
#include "Utils\StringUtils.h"
|
||||||
|
#include "Utils\SysUtils.h"
|
||||||
#include "Utils\TimeUtils.h"
|
#include "Utils\TimeUtils.h"
|
||||||
|
|
||||||
//=========ПОДКЛЮЧЕНИЕ ОБЩИХ БИБЛИОТЕК===============
|
//=========ПОДКЛЮЧЕНИЕ ОБЩИХ БИБЛИОТЕК===============
|
||||||
@@ -165,6 +166,7 @@ extern void do_i2c_scanning();
|
|||||||
extern String i2c_scan();
|
extern String i2c_scan();
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
|
extern void loadConfig();
|
||||||
extern void All_init();
|
extern void All_init();
|
||||||
extern void statistics_init();
|
extern void statistics_init();
|
||||||
extern void Scenario_init();
|
extern void Scenario_init();
|
||||||
@@ -174,7 +176,7 @@ extern void up_time();
|
|||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
extern void logging();
|
extern void logging();
|
||||||
extern void deleteOldDate(String file, int seted_number_of_lines, String date_to_add);
|
extern void deleteOldDate(String filename, size_t max_lines, String date_to_add);
|
||||||
extern void clean_log_date();
|
extern void clean_log_date();
|
||||||
extern void choose_log_date_and_send();
|
extern void choose_log_date_and_send();
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,6 @@ String selectFromMarkerToMarker(String str, String found, int number);
|
|||||||
|
|
||||||
size_t itemsCount(String str, const String& separator);
|
size_t itemsCount(String str, const String& separator);
|
||||||
|
|
||||||
boolean isDigitStr(const String&);
|
boolean isDigitStr(const String&);
|
||||||
|
|
||||||
|
String prettyBytes(size_t size);
|
||||||
9
include/Utils/SysUtils.h
Normal file
9
include/Utils/SysUtils.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
const String getChipId();
|
||||||
|
|
||||||
|
void printMemoryStatus(String text = "");
|
||||||
|
|
||||||
|
String getHeapStats();
|
||||||
@@ -8,11 +8,10 @@ void handle_uptime();
|
|||||||
void handle_statistics();
|
void handle_statistics();
|
||||||
|
|
||||||
void loadConfig() {
|
void loadConfig() {
|
||||||
if (fileSystemInit()) {
|
|
||||||
configSetupJson = readFile("config.json", 4096);
|
configSetupJson = readFile("config.json", 4096);
|
||||||
configSetupJson.replace(" ", "");
|
configSetupJson.replace(" ", "");
|
||||||
configSetupJson.replace("\r\n", "");
|
configSetupJson.replace("\r\n", "");
|
||||||
}
|
|
||||||
|
|
||||||
jsonWriteStr(configSetupJson, "chipID", chipId);
|
jsonWriteStr(configSetupJson, "chipID", chipId);
|
||||||
jsonWriteStr(configSetupJson, "firmware_version", FIRMWARE_VERSION);
|
jsonWriteStr(configSetupJson, "firmware_version", FIRMWARE_VERSION);
|
||||||
|
|||||||
@@ -67,12 +67,14 @@ void logging() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=========================================Удаление стрых данных и запись новых==================================================================
|
/*
|
||||||
void deleteOldDate(const String filename, int max_lines_cnt, String date_to_add) {
|
* Удаление стрых данных и запись новых
|
||||||
|
*/
|
||||||
|
void deleteOldDate(const String filename, size_t max_lines_cnt, String date_to_add) {
|
||||||
String log_date = readFile(filename, 5120);
|
String log_date = readFile(filename, 5120);
|
||||||
size_t lines_cnt = itemsCount(log_date, "\r\n");
|
size_t lines_cnt = itemsCount(log_date, "\r\n");
|
||||||
|
|
||||||
Serial.printf("[I] log %s of %d lines\n", filename.c_str(), lines_cnt);
|
Serial.printf("[I] log %s (%d lines)\n", filename.c_str(), lines_cnt);
|
||||||
|
|
||||||
if ((lines_cnt > max_lines_cnt + 1) || !lines_cnt) {
|
if ((lines_cnt > max_lines_cnt + 1) || !lines_cnt) {
|
||||||
removeFile("/" + filename);
|
removeFile("/" + filename);
|
||||||
|
|||||||
@@ -1,24 +1,33 @@
|
|||||||
#include "Utils/FileUtils.h"
|
#include "Utils/FileUtils.h"
|
||||||
|
|
||||||
|
static const char* MODULE = "FS";
|
||||||
|
|
||||||
|
void printError(const String str) {
|
||||||
|
Serial.printf("[E] [%s] %s\n", MODULE, str.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
const String filepath(const String& filename) {
|
||||||
|
return filename.startsWith("/") ? filename : "/" + filename;
|
||||||
|
}
|
||||||
|
|
||||||
bool fileSystemInit() {
|
bool fileSystemInit() {
|
||||||
if (!LittleFS.begin()) {
|
if (!LittleFS.begin()) {
|
||||||
Serial.println("[E] LittleFS");
|
printError("init");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeFile(const String filename) {
|
void removeFile(const String filename) {
|
||||||
if (!LittleFS.remove(filename)) {
|
if (!LittleFS.remove(filepath(filename))) {
|
||||||
Serial.printf("[E] on remove %s", filename.c_str());
|
printError("remove " + filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File seekFile(const String filename, size_t position) {
|
File seekFile(const String filename, size_t position) {
|
||||||
auto file = LittleFS.open(filename, "r");
|
auto file = LittleFS.open(filepath(filename), "r");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
Serial.printf("[E] on open %s", filename.c_str());
|
printError("open " + filename);
|
||||||
}
|
}
|
||||||
// поставим курсор в начало файла
|
// поставим курсор в начало файла
|
||||||
file.seek(position, SeekSet);
|
file.seek(position, SeekSet);
|
||||||
@@ -27,7 +36,7 @@ File seekFile(const String filename, size_t position) {
|
|||||||
|
|
||||||
String readFileString(const String filename, const String to_find) {
|
String readFileString(const String filename, const String to_find) {
|
||||||
String res = "Failed";
|
String res = "Failed";
|
||||||
auto file = LittleFS.open("/" + filename, "r");
|
auto file = LittleFS.open(filepath(filename), "r");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return "Failed";
|
return "Failed";
|
||||||
}
|
}
|
||||||
@@ -39,27 +48,27 @@ String readFileString(const String filename, const String to_find) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String addFile(const String filename, const String str) {
|
String addFile(const String filename, const String str) {
|
||||||
auto file = LittleFS.open("/" + filename, "a");
|
auto file = LittleFS.open(filepath(filename), "a");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return "Failed";
|
return "Failed";
|
||||||
}
|
}
|
||||||
file.println(str);
|
file.println(str);
|
||||||
file.close();
|
file.close();
|
||||||
return "Write sucсess";
|
return "Sucсess";
|
||||||
}
|
}
|
||||||
|
|
||||||
String writeFile(const String filename, const String str) {
|
String writeFile(const String filename, const String str) {
|
||||||
auto file = LittleFS.open("/" + filename, "w");
|
auto file = LittleFS.open(filepath(filename), "w");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return "Failed";
|
return "Failed";
|
||||||
}
|
}
|
||||||
file.print(str);
|
file.print(str);
|
||||||
file.close();
|
file.close();
|
||||||
return "Write sucсess";
|
return "Sucсess";
|
||||||
}
|
}
|
||||||
|
|
||||||
String readFile(const String filename, size_t max_size) {
|
String readFile(const String filename, size_t max_size) {
|
||||||
auto file = LittleFS.open("/" + filename, "r");
|
auto file = LittleFS.open(filepath(filename), "r");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return "Failed";
|
return "Failed";
|
||||||
}
|
}
|
||||||
@@ -74,7 +83,7 @@ String readFile(const String filename, size_t max_size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String getFileSize(const String filename) {
|
String getFileSize(const String filename) {
|
||||||
auto file = LittleFS.open("/" + filename, "r");
|
auto file = LittleFS.open(filepath(filename), "r");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return "Failed";
|
return "Failed";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,3 +85,14 @@ boolean isDigitStr(const String& str) {
|
|||||||
}
|
}
|
||||||
return str.length();
|
return str.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String prettyBytes(size_t size) {
|
||||||
|
if (size < 1024)
|
||||||
|
return String(size) + "b";
|
||||||
|
else if (size < (1024 * 1024))
|
||||||
|
return String(size / 1024.0) + "kB";
|
||||||
|
else if (size < (1024 * 1024 * 1024))
|
||||||
|
return String(size / 1024.0 / 1024.0) + "MB";
|
||||||
|
else
|
||||||
|
return String(size / 1024.0 / 1024.0 / 1024.0) + "GB";
|
||||||
|
}
|
||||||
|
|||||||
181
src/Utils/SysUtils.cpp
Normal file
181
src/Utils/SysUtils.cpp
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
#include "Utils/SysUtils.h"
|
||||||
|
|
||||||
|
#include "Utils/StringUtils.h"
|
||||||
|
|
||||||
|
const String getChipId() {
|
||||||
|
String res;
|
||||||
|
#ifdef ESP32
|
||||||
|
char buf[32] = {0};
|
||||||
|
uint32_t mac = ESP.getEfuseMac();
|
||||||
|
sprintf(buf, "%0X", mac);
|
||||||
|
res = String(buf);
|
||||||
|
#endif
|
||||||
|
#ifdef ESP8266
|
||||||
|
res = String(ESP.getChipId()) + "-" + String(ESP.getFlashChipId());
|
||||||
|
#endif
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ESP8266
|
||||||
|
static uint32_t total_memory = 52864;
|
||||||
|
#endif
|
||||||
|
#ifdef ESP32
|
||||||
|
static uint32_t total_memory = 362868;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void printMemoryStatus(String text) {
|
||||||
|
uint32_t free = ESP.getFreeHeap();
|
||||||
|
uint32_t used = total_memory - free;
|
||||||
|
uint32_t memory_load = (used * 100) / total_memory;
|
||||||
|
if (text) {
|
||||||
|
Serial.print(text);
|
||||||
|
}
|
||||||
|
Serial.printf(" used: %d%% free: %s\n", memory_load, prettyBytes(free).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ESP8266
|
||||||
|
String getHeapStats() {
|
||||||
|
uint32_t free;
|
||||||
|
uint16_t max;
|
||||||
|
uint8_t frag;
|
||||||
|
ESP.getHeapStats(&free, &max, &frag);
|
||||||
|
String buf;
|
||||||
|
buf += prettyBytes(free);
|
||||||
|
buf += " ";
|
||||||
|
buf += frag;
|
||||||
|
buf += '%';
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ESP32
|
||||||
|
String getHeapStats() {
|
||||||
|
uint32_t free;
|
||||||
|
uint16_t max;
|
||||||
|
uint8_t frag;
|
||||||
|
ESP.getHeapStats(&free, &max, &frag);
|
||||||
|
String buf;
|
||||||
|
buf += prettyBytes(free);
|
||||||
|
buf += " ";
|
||||||
|
buf += frag;
|
||||||
|
buf += '%';
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//===================================================================
|
||||||
|
/*
|
||||||
|
void web_print (String text) {
|
||||||
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
|
jsonWriteStr(json, "test1", jsonReadStr(json, "test2"));
|
||||||
|
jsonWriteStr(json, "test2", jsonReadStr(json, "test3"));
|
||||||
|
jsonWriteStr(json, "test3", jsonReadStr(json, "test4"));
|
||||||
|
jsonWriteStr(json, "test4", jsonReadStr(json, "test5"));
|
||||||
|
jsonWriteStr(json, "test5", jsonReadStr(json, "test6"));
|
||||||
|
|
||||||
|
jsonWriteStr(json, "test6", GetTime() + " " + text);
|
||||||
|
|
||||||
|
ws.textAll(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//===================================================================
|
||||||
|
/*
|
||||||
|
"socket": [
|
||||||
|
"ws://{{ip}}/ws"
|
||||||
|
],
|
||||||
|
*/
|
||||||
|
//===================================================================
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"type": "h4",
|
||||||
|
"title": "('{{build2}}'=='{{firmware_version}}'?'NEW':'OLD')"
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
//===================================================================
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"type": "button",
|
||||||
|
"title": "Конфигурация устройства",
|
||||||
|
"socket": "test2",
|
||||||
|
"class": "btn btn-block btn-primary"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "h6",
|
||||||
|
"title": "{{test1}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "h6",
|
||||||
|
"title": "{{test2}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "h6",
|
||||||
|
"title": "{{test3}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "h6",
|
||||||
|
"title": "{{test4}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "h6",
|
||||||
|
"title": "{{test5}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "h6",
|
||||||
|
"title": "{{test6}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hr"
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
//===================================================================
|
||||||
|
|
||||||
|
/*
|
||||||
|
String getResetReason(uint8_t core) {
|
||||||
|
int reason = rtc_get_reset_reason(core);
|
||||||
|
switch (reason) {
|
||||||
|
case 1 : return "Power on"; break; //Vbat power on reset
|
||||||
|
case 3 : return "Software reset digital core"; break; //Software reset digital core
|
||||||
|
case 4 : return "Legacy watch dog reset digital core"; break; //Legacy watch dog reset digital core
|
||||||
|
case 5 : return "Deep Sleep reset digital core"; break; //Deep Sleep reset digital core
|
||||||
|
case 6 : return "Reset by SLC module, reset digital core"; break; //Reset by SLC module, reset digital core
|
||||||
|
case 7 : return "Timer Group0 Watch dog reset digital core"; break; //Timer Group0 Watch dog reset digital core
|
||||||
|
case 8 : return "Timer Group1 Watch dog reset digital core"; break; //Timer Group1 Watch dog reset digital core
|
||||||
|
case 9 : return "RTC Watch dog Reset digital core"; break; //
|
||||||
|
case 10 : return "Instrusion tested to reset CPU"; break;
|
||||||
|
case 11 : return "Time Group reset CPU"; break;
|
||||||
|
case 12 : return "Software reset CPU"; break;
|
||||||
|
case 13 : return "RTC Watch dog Reset CPU"; break;
|
||||||
|
case 14 : return "for APP CPU, reseted by PRO CPU"; break;
|
||||||
|
case 15 : return "Reset when the vdd voltage is not stable"; break;
|
||||||
|
case 16 : return "RTC Watch dog reset digital core and rtc module"; break;
|
||||||
|
default : return "NO_MEAN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String EspClass::getResetReason(void) {
|
||||||
|
char buff[32];
|
||||||
|
if (resetInfo.reason == REASON_DEFAULT_RST) { // normal startup by power on
|
||||||
|
strcpy_P(buff, PSTR("Power on"));
|
||||||
|
} else if (resetInfo.reason == REASON_WDT_RST) { // hardware watch dog reset
|
||||||
|
strcpy_P(buff, PSTR("Hardware Watchdog"));
|
||||||
|
} else if (resetInfo.reason == REASON_EXCEPTION_RST) { // exception reset, GPIO status won’t change
|
||||||
|
strcpy_P(buff, PSTR("Exception"));
|
||||||
|
} else if (resetInfo.reason == REASON_SOFT_WDT_RST) { // software watch dog reset, GPIO status won’t change
|
||||||
|
strcpy_P(buff, PSTR("Software Watchdog"));
|
||||||
|
} else if (resetInfo.reason == REASON_SOFT_RESTART) { // software restart ,system_restart , GPIO status won’t change
|
||||||
|
strcpy_P(buff, PSTR("Software/System restart"));
|
||||||
|
} else if (resetInfo.reason == REASON_DEEP_SLEEP_AWAKE) { // wake up from deep-sleep
|
||||||
|
strcpy_P(buff, PSTR("Deep-Sleep Wake"));
|
||||||
|
} else if (resetInfo.reason == REASON_EXT_SYS_RST) { // external system reset
|
||||||
|
strcpy_P(buff, PSTR("External System"));
|
||||||
|
} else {
|
||||||
|
strcpy_P(buff, PSTR("Unknown"));
|
||||||
|
}
|
||||||
|
return String(buff);
|
||||||
|
}
|
||||||
|
*/
|
||||||
@@ -6,12 +6,12 @@ void setup() {
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println("--------------started----------------");
|
Serial.println("--------------started----------------");
|
||||||
//Serial.setDebugOutput(true);
|
|
||||||
|
|
||||||
setChipId();
|
setChipId();
|
||||||
|
|
||||||
fileSystemInit();
|
fileSystemInit();
|
||||||
Serial.println("[V] LittleFS");
|
|
||||||
|
loadConfig();
|
||||||
|
|
||||||
CMD_init();
|
CMD_init();
|
||||||
Serial.println("[V] Commands");
|
Serial.println("[V] Commands");
|
||||||
|
|||||||
166
src/main.cpp
166
src/main.cpp
@@ -47,9 +47,14 @@ void sendCONFIG(String topik, String widgetConfig, String key, String date) {
|
|||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_blink(String satus) {
|
void setChipId() {
|
||||||
|
chipId = getChipId();
|
||||||
|
Serial.println(chipId);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#ifdef blink_pin
|
#ifdef LED_PIN
|
||||||
|
void led_blink(String satus) {
|
||||||
pinMode(LED_PIN, OUTPUT);
|
pinMode(LED_PIN, OUTPUT);
|
||||||
if (satus == "off") {
|
if (satus == "off") {
|
||||||
noTone(LED_PIN);
|
noTone(LED_PIN);
|
||||||
@@ -61,163 +66,6 @@ void led_blink(String satus) {
|
|||||||
}
|
}
|
||||||
if (satus == "slow") tone(LED_PIN, 1);
|
if (satus == "slow") tone(LED_PIN, 1);
|
||||||
if (satus == "fast") tone(LED_PIN, 20);
|
if (satus == "fast") tone(LED_PIN, 20);
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const String getChipId() {
|
|
||||||
String res;
|
|
||||||
#ifdef ESP32
|
|
||||||
char buf[32] = {0};
|
|
||||||
uint32_t mac = ESP.getEfuseMac();
|
|
||||||
sprintf(buf, "%0X", mac);
|
|
||||||
res = String(buf);
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef ESP8266
|
|
||||||
res = String(ESP.getChipId()) + "-" + String(ESP.getFlashChipId());
|
|
||||||
#endif
|
#endif
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setChipId() {
|
|
||||||
chipId = getChipId();
|
|
||||||
Serial.println(chipId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void printMemoryStatus(String text) {
|
|
||||||
#ifdef ESP8266
|
|
||||||
uint32_t all_memory = 52864;
|
|
||||||
#endif
|
|
||||||
#ifdef ESP32
|
|
||||||
uint32_t all_memory = 362868;
|
|
||||||
#endif
|
|
||||||
uint32_t memory_remain = ESP.getFreeHeap();
|
|
||||||
uint32_t memory_used = all_memory - memory_remain;
|
|
||||||
uint32_t memory_load = (memory_used * 100) / all_memory;
|
|
||||||
if (memory_load > 65) {
|
|
||||||
Serial.println("Memory low!");
|
|
||||||
}
|
|
||||||
Serial.print(text + " memory used:");
|
|
||||||
Serial.print(String(memory_load) + "%; ");
|
|
||||||
Serial.print("memory remain: ");
|
|
||||||
Serial.println(String(memory_remain) + " k bytes");
|
|
||||||
}
|
|
||||||
//esp32 full memory = 362868 k bytes
|
|
||||||
//esp8266 full memory = 52864 k bytes
|
|
||||||
|
|
||||||
//===================================================================
|
|
||||||
/*
|
|
||||||
void web_print (String text) {
|
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
|
||||||
jsonWriteStr(json, "test1", jsonReadStr(json, "test2"));
|
|
||||||
jsonWriteStr(json, "test2", jsonReadStr(json, "test3"));
|
|
||||||
jsonWriteStr(json, "test3", jsonReadStr(json, "test4"));
|
|
||||||
jsonWriteStr(json, "test4", jsonReadStr(json, "test5"));
|
|
||||||
jsonWriteStr(json, "test5", jsonReadStr(json, "test6"));
|
|
||||||
|
|
||||||
jsonWriteStr(json, "test6", GetTime() + " " + text);
|
|
||||||
|
|
||||||
ws.textAll(json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//===================================================================
|
|
||||||
/*
|
|
||||||
"socket": [
|
|
||||||
"ws://{{ip}}/ws"
|
|
||||||
],
|
|
||||||
*/
|
|
||||||
//===================================================================
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
"type": "h4",
|
|
||||||
"title": "('{{build2}}'=='{{firmware_version}}'?'NEW':'OLD')"
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
//===================================================================
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
"type": "button",
|
|
||||||
"title": "Конфигурация устройства",
|
|
||||||
"socket": "test2",
|
|
||||||
"class": "btn btn-block btn-primary"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "hr"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "h6",
|
|
||||||
"title": "{{test1}}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "h6",
|
|
||||||
"title": "{{test2}}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "h6",
|
|
||||||
"title": "{{test3}}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "h6",
|
|
||||||
"title": "{{test4}}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "h6",
|
|
||||||
"title": "{{test5}}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "h6",
|
|
||||||
"title": "{{test6}}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "hr"
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
//===================================================================
|
|
||||||
|
|
||||||
/*
|
|
||||||
String getResetReason(uint8_t core) {
|
|
||||||
int reason = rtc_get_reset_reason(core);
|
|
||||||
switch (reason) {
|
|
||||||
case 1 : return "Power on"; break; //Vbat power on reset
|
|
||||||
case 3 : return "Software reset digital core"; break; //Software reset digital core
|
|
||||||
case 4 : return "Legacy watch dog reset digital core"; break; //Legacy watch dog reset digital core
|
|
||||||
case 5 : return "Deep Sleep reset digital core"; break; //Deep Sleep reset digital core
|
|
||||||
case 6 : return "Reset by SLC module, reset digital core"; break; //Reset by SLC module, reset digital core
|
|
||||||
case 7 : return "Timer Group0 Watch dog reset digital core"; break; //Timer Group0 Watch dog reset digital core
|
|
||||||
case 8 : return "Timer Group1 Watch dog reset digital core"; break; //Timer Group1 Watch dog reset digital core
|
|
||||||
case 9 : return "RTC Watch dog Reset digital core"; break; //
|
|
||||||
case 10 : return "Instrusion tested to reset CPU"; break;
|
|
||||||
case 11 : return "Time Group reset CPU"; break;
|
|
||||||
case 12 : return "Software reset CPU"; break;
|
|
||||||
case 13 : return "RTC Watch dog Reset CPU"; break;
|
|
||||||
case 14 : return "for APP CPU, reseted by PRO CPU"; break;
|
|
||||||
case 15 : return "Reset when the vdd voltage is not stable"; break;
|
|
||||||
case 16 : return "RTC Watch dog reset digital core and rtc module"; break;
|
|
||||||
default : return "NO_MEAN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String EspClass::getResetReason(void) {
|
|
||||||
char buff[32];
|
|
||||||
if (resetInfo.reason == REASON_DEFAULT_RST) { // normal startup by power on
|
|
||||||
strcpy_P(buff, PSTR("Power on"));
|
|
||||||
} else if (resetInfo.reason == REASON_WDT_RST) { // hardware watch dog reset
|
|
||||||
strcpy_P(buff, PSTR("Hardware Watchdog"));
|
|
||||||
} else if (resetInfo.reason == REASON_EXCEPTION_RST) { // exception reset, GPIO status won’t change
|
|
||||||
strcpy_P(buff, PSTR("Exception"));
|
|
||||||
} else if (resetInfo.reason == REASON_SOFT_WDT_RST) { // software watch dog reset, GPIO status won’t change
|
|
||||||
strcpy_P(buff, PSTR("Software Watchdog"));
|
|
||||||
} else if (resetInfo.reason == REASON_SOFT_RESTART) { // software restart ,system_restart , GPIO status won’t change
|
|
||||||
strcpy_P(buff, PSTR("Software/System restart"));
|
|
||||||
} else if (resetInfo.reason == REASON_DEEP_SLEEP_AWAKE) { // wake up from deep-sleep
|
|
||||||
strcpy_P(buff, PSTR("Deep-Sleep Wake"));
|
|
||||||
} else if (resetInfo.reason == REASON_EXT_SYS_RST) { // external system reset
|
|
||||||
strcpy_P(buff, PSTR("External System"));
|
|
||||||
} else {
|
|
||||||
strcpy_P(buff, PSTR("Unknown"));
|
|
||||||
}
|
|
||||||
return String(buff);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|||||||
Reference in New Issue
Block a user