mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
улучшения
This commit is contained in:
@@ -1,24 +1,4 @@
|
|||||||
[
|
[
|
||||||
{
|
|
||||||
"type": "Reading",
|
|
||||||
"subtype": "AnalogAdc",
|
|
||||||
"id": "t1",
|
|
||||||
"widget": "anydataDef",
|
|
||||||
"page": "Сенсоры",
|
|
||||||
"descr": "Температура",
|
|
||||||
"pin": 0,
|
|
||||||
"int": 10
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Reading",
|
|
||||||
"subtype": "AnalogAdc",
|
|
||||||
"id": "t2",
|
|
||||||
"widget": "anydataTmp",
|
|
||||||
"page": "Сенсоры",
|
|
||||||
"descr": "Температура",
|
|
||||||
"pin": 0,
|
|
||||||
"int": 15
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "Variable",
|
"type": "Variable",
|
||||||
"subtype": "ButtonOut",
|
"subtype": "ButtonOut",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "EspFileSystem.h"
|
#include "EspFileSystem.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
extern void writeFileUint8tFromBuf(const String& filename, uint8_t*& payload, size_t length, size_t headerLenth, size_t bufSize);
|
extern void writeFileUint8tByFrames(const String& filename, uint8_t*& big_buf, size_t length, size_t headerLenth, size_t frameSize);
|
||||||
extern void writeFileUint8tByByte(const String& filename, uint8_t*& payload, size_t length, size_t headerLenth);
|
extern void writeFileUint8tByByte(const String& filename, uint8_t*& payload, size_t length, size_t headerLenth);
|
||||||
extern File seekFile(const String& filename, size_t position = 0);
|
extern File seekFile(const String& filename, size_t position = 0);
|
||||||
extern const String writeFile(const String& filename, const String& str);
|
extern const String writeFile(const String& filename, const String& str);
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (headerStr == "/gifnoc") {
|
if (headerStr == "/gifnoc") {
|
||||||
writeFileUint8tFromBuf("config.json", payload, length, headerLenth, 256);
|
writeFileUint8tByFrames("config.json", payload, length, headerLenth, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
#include "Utils/FileUtils.h"
|
#include "Utils/FileUtils.h"
|
||||||
|
|
||||||
//данная функция записывает файл из длинного массива uint8_t через буфер
|
//данная функция записывает файл из буфера страницами указанного размера
|
||||||
void writeFileUint8tFromBuf(const String& filename, uint8_t*& big_buf, size_t length, size_t headerLenth, size_t bufSize) {
|
void writeFileUint8tByFrames(const String& filename, uint8_t*& big_buf, size_t length, size_t headerLenth, size_t frameSize) {
|
||||||
String path = filepath(filename);
|
String path = filepath(filename);
|
||||||
auto file = FileFS.open(path, "w");
|
auto file = FileFS.open(path, "w");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
Serial.println(F("failed write file uint8tFromBuf"));
|
Serial.println(F("failed write file uint8tByFrames"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t written{headerLenth};
|
size_t written{headerLenth};
|
||||||
while (length > written) {
|
while (length > written) {
|
||||||
size_t size = length - written;
|
size_t size = length - written;
|
||||||
if (size > bufSize) size = bufSize;
|
if (size > frameSize) size = frameSize;
|
||||||
uint8_t* p = &big_buf[written];
|
uint8_t* p = &big_buf[written];
|
||||||
size_t res = file.write(p, size);
|
size_t res = file.write(p, size);
|
||||||
if (size != res) {
|
if (size != res) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
written += res;
|
written += res;
|
||||||
|
yield();
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user