небольшие доработки

This commit is contained in:
Dmitry Borisenko
2022-01-28 00:47:13 +01:00
parent 70edd92238
commit 5ec1e59957
3 changed files with 13 additions and 6 deletions

View File

@@ -25,7 +25,7 @@ void configure(String path) {
myIoTSensor = (IoTSensor*)getAPI(subtype, jsonArrayElement); myIoTSensor = (IoTSensor*)getAPI(subtype, jsonArrayElement);
if (myIoTSensor) { if (myIoTSensor) {
iotSensors.push_back(myIoTSensor); iotSensors.push_back(myIoTSensor);
createWidget(jsonArrayElement); // createWidget(jsonArrayElement);
} }
} }
} }

View File

@@ -14,11 +14,11 @@ void standWebServerInit() {
}); });
HTTP.on("/config.json", HTTP_GET, []() { HTTP.on("/config.json", HTTP_GET, []() {
HTTP.send(200, "application/json", readFile(F("config.json"), 10000)); HTTP.send(200, "application/json", readFile(F("config.json"), 20000));
}); });
HTTP.on("/layout.json", HTTP_GET, []() { HTTP.on("/layout.json", HTTP_GET, []() {
HTTP.send(200, "application/json", readFile(F("layout.json"), 10000)); HTTP.send(200, "application/json", readFile(F("layout.json"), 20000));
}); });
HTTP.on("/restart", HTTP_GET, []() { HTTP.on("/restart", HTTP_GET, []() {
@@ -291,9 +291,10 @@ void sendFileToWs5(const char* filename, uint8_t num) {
auto file = FileFS.open(path, "r"); auto file = FileFS.open(path, "r");
if (!file) { if (!file) {
SerialPrint(F("E"), F("FS"), F("reed file error")); SerialPrint(F("E"), F("FS"), F("reed file error"));
return;
} }
size_t fileSize = file.size(); size_t fileSize = file.size();
SerialPrint(F("i"), F("WS"), "Send file '" + String(filename) + "', file size: " + String(fileSize)); SerialPrint(F("i"), F("FS"), "Send file '" + String(filename) + "', file size: " + String(fileSize));
uint8_t payload[ws_buffer + 1]; uint8_t payload[ws_buffer + 1];
int countRead = file.read(payload, sizeof(payload) - 1); int countRead = file.read(payload, sizeof(payload) - 1);
while (countRead > 0) { while (countRead > 0) {

View File

@@ -5,11 +5,17 @@ void writeFileUint8(const String& filename, uint8_t*& payload, size_t length, si
auto file = FileFS.open(path, "w"); auto file = FileFS.open(path, "w");
if (!file) { if (!file) {
Serial.println(F("failed write file uint8")); Serial.println(F("failed write file uint8"));
return;
} }
size_t every = 0;
for (size_t i = 0; i < length; i++) { for (size_t i = 0; i < length; i++) {
if (i >= headerLenth) { if (i >= headerLenth) {
every++;
file.print((char)payload[i]); file.print((char)payload[i]);
yield(); if (every > 256) {
yield();
every = 0;
}
} }
} }
file.close(); file.close();