452 исправлен баг пропадания виджетов в приложении

This commit is contained in:
IoT Manager
2023-10-07 02:01:15 +02:00
parent 57ac9738dd
commit 9eb6122fe1
6 changed files with 367 additions and 351 deletions

View File

@@ -1,7 +1,8 @@
#include "EspFileSystem.h"
#include "Global.h"
bool fileSystemInit() {
bool fileSystemInit()
{
if (!FileFS.begin()) {
SerialPrint(F("E"), F("FS"), F("Init ERROR, may be FS was not flashed"));
return false;
@@ -10,7 +11,8 @@ bool fileSystemInit() {
return true;
}
void globalVarsSync() {
void globalVarsSync()
{
settingsFlashJson = readFile(F("settings.json"), 4096);
settingsFlashJson.replace("\r\n", "");
@@ -18,44 +20,42 @@ void globalVarsSync() {
valuesFlashJson.replace("\r\n", "");
mqttPrefix = jsonReadStr(settingsFlashJson, F("mqttPrefix"));
mqttRootDevice = mqttPrefix + "/" + chipId;
jsonWriteStr_(settingsFlashJson, "root", mqttRootDevice);
jsonWriteStr_(settingsFlashJson, "id", chipId);
// jsonWriteStr_(errorsHeapJson, "errors_", ""); //метка для парсинга удалить
// jsonWriteStr_(ssidListHeapJson, "ssids_", ""); //метка для парсинга удалить
mqttRootDevice = mqttPrefix + "/" + chipId;
// это не используется - удалить в последствии
jsonWriteStr_(settingsFlashJson, "root", mqttRootDevice);
}
// к удалению. не используется
// String getParamsJson() {
// String json;
// serializeJson(*getLocalItemsAsJSON(), json);
// jsonWriteStr_(json, "params", "");
// return json;
// }
void syncSettingsFlashJson() {
void syncSettingsFlashJson()
{
writeFile(F("settings.json"), settingsFlashJson);
}
void syncValuesFlashJson() {
void syncValuesFlashJson()
{
writeFile(F("values.json"), valuesFlashJson);
}
const String getChipId() {
return String(ESP_getChipId()) + "-" + String(getFlashChipIdNew()); // + "v" + String(FIRMWARE_VERSION);
const String getChipId()
{
return String(ESP_getChipId()) + "-" + String(getFlashChipIdNew()); // + "v" + String(FIRMWARE_VERSION);
}
void setChipId() {
void setChipId()
{
chipId = getChipId();
SerialPrint("i", "System", "id: " + chipId);
}
const String getUniqueId(const char* name) {
const String getUniqueId(const char* name)
{
return String(name) + getMacAddress();
}
const String getWebVersion() {
const String getWebVersion()
{
String text = readFile("/index.html", 2000);
text = selectFromMarkerToMarker(text, "title", 1);
text = selectFromMarkerToMarker(text, " ", 2);
@@ -64,7 +64,8 @@ const String getWebVersion() {
return text;
}
uint32_t ESP_getChipId(void) {
uint32_t ESP_getChipId(void)
{
#ifdef ESP32
uint32_t id = 0;
for (uint32_t i = 0; i < 17; i = i + 8) {
@@ -78,7 +79,8 @@ uint32_t ESP_getChipId(void) {
// устарела используем новую функцию ниже
#ifndef esp32s2_4mb
uint32_t ESP_getFlashChipId(void) {
uint32_t ESP_getFlashChipId(void)
{
#ifdef ESP32
// Нет аналогичной (без доп.кода) функций в 32
// надо использовать другой id - варианты есть
@@ -92,7 +94,8 @@ uint32_t ESP_getFlashChipId(void) {
// https://github.com/espressif/arduino-esp32/issues/6945#issuecomment-1199900892
// получение flash ch id из проекта esp easy
uint32_t getFlashChipIdNew() {
uint32_t getFlashChipIdNew()
{
// Cache since size does not change
static uint32_t flashChipId = 0;
@@ -109,14 +112,15 @@ uint32_t getFlashChipIdNew() {
// esp_flash_read_id(nullptr, &flashChipId);
#elif defined(ESP8266)
flashChipId = ESP.getFlashChipId();
#endif // ifdef ESP32
#endif // ifdef ESP32
}
return flashChipId;
}
const String getMacAddress() {
const String getMacAddress()
{
uint8_t mac[6];
char buf[13] = {0};
char buf[13] = { 0 };
#if defined(ESP8266)
WiFi.macAddress(mac);
sprintf(buf, MACSTR, MAC2STR(mac));