рабочая версия с файлообменом

This commit is contained in:
Dmitry Borisenko
2022-01-25 20:59:37 +01:00
parent 719929445a
commit 3353194e2f
3 changed files with 11 additions and 258 deletions

File diff suppressed because one or more lines are too long

View File

@@ -110,261 +110,5 @@
"descr": "Температура", "descr": "Температура",
"pin": 0, "pin": 0,
"int": 15 "int": 15
},
{
"type": "Variable",
"subtype": "ButtonOut",
"id": "btn1",
"widget": "toggle",
"page": "Кнопки",
"descr": "Освещение",
"gpio": 13,
"inv": false
},
{
"type": "Variable",
"subtype": "PwmOut",
"id": "pwm1",
"widget": "range",
"page": "Регуляторы",
"descr": "Освещение",
"gpio": 14,
"inv": false
},
{
"type": "Reading",
"subtype": "ButtonIn",
"id": "btn",
"widget": "toggle",
"page": "Кнопки",
"descr": "Освещение",
"gpio": 12,
"inv": false
},
{
"type": "Reading",
"subtype": "OutputValue",
"id": "txt",
"widget": "anydataRed",
"page": "Предупреждения",
"descr": "Статус"
},
{
"type": "Reading",
"subtype": "InputValue",
"id": "txt",
"widget": "inputDgt",
"page": "Лимиты",
"descr": "Порог"
},
{
"type": "Reading",
"subtype": "Bme280",
"id": "t",
"widget": "anydataTmp",
"page": "Сенсоры",
"descr": "Температура"
},
{
"type": "Reading",
"subtype": "Bme280",
"id": "p",
"widget": "anydataMm",
"page": "Сенсоры",
"descr": "Давление"
},
{
"type": "Reading",
"subtype": "Bme280",
"id": "h",
"widget": "anydataHum",
"page": "Сенсоры",
"descr": "Влажность",
"int": 10,
"addr": "0x78"
},
{
"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",
"subtype": "ButtonOut",
"id": "btn1",
"widget": "toggle",
"page": "Кнопки",
"descr": "Освещение",
"gpio": 13,
"inv": false
},
{
"type": "Variable",
"subtype": "PwmOut",
"id": "pwm1",
"widget": "range",
"page": "Регуляторы",
"descr": "Освещение",
"gpio": 14,
"inv": false
},
{
"type": "Reading",
"subtype": "ButtonIn",
"id": "btn",
"widget": "toggle",
"page": "Кнопки",
"descr": "Освещение",
"gpio": 12,
"inv": false
},
{
"type": "Reading",
"subtype": "OutputValue",
"id": "txt",
"widget": "anydataRed",
"page": "Предупреждения",
"descr": "Статус"
},
{
"type": "Reading",
"subtype": "InputValue",
"id": "txt",
"widget": "inputDgt",
"page": "Лимиты",
"descr": "Порог"
},
{
"type": "Reading",
"subtype": "Bme280",
"id": "t",
"widget": "anydataTmp",
"page": "Сенсоры",
"descr": "Температура"
},
{
"type": "Reading",
"subtype": "Bme280",
"id": "p",
"widget": "anydataMm",
"page": "Сенсоры",
"descr": "Давление"
},
{
"type": "Reading",
"subtype": "Bme280",
"id": "h",
"widget": "anydataHum",
"page": "Сенсоры",
"descr": "Влажность",
"int": 10,
"addr": "0x78"
},
{
"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",
"subtype": "ButtonOut",
"id": "btn1",
"widget": "toggle",
"page": "Кнопки",
"descr": "Освещение",
"gpio": 13,
"inv": false
},
{
"type": "Variable",
"subtype": "PwmOut",
"id": "pwm1",
"widget": "range",
"page": "Регуляторы",
"descr": "Освещение",
"gpio": 14,
"inv": false
},
{
"type": "Reading",
"subtype": "ButtonIn",
"id": "btn",
"widget": "toggle",
"page": "Кнопки",
"descr": "Освещение",
"gpio": 12,
"inv": false
},
{
"type": "Reading",
"subtype": "OutputValue",
"id": "txt",
"widget": "anydataRed",
"page": "Предупреждения",
"descr": "Статус"
},
{
"type": "Reading",
"subtype": "InputValue",
"id": "txt",
"widget": "inputDgt",
"page": "Лимиты",
"descr": "Порог"
},
{
"type": "Reading",
"subtype": "Bme280",
"id": "t",
"widget": "anydataTmp",
"page": "Сенсоры",
"descr": "Температура"
},
{
"type": "Reading",
"subtype": "Bme280",
"id": "p",
"widget": "anydataMm",
"page": "Сенсоры",
"descr": "Давление"
},
{
"type": "Reading",
"subtype": "Bme280",
"id": "h",
"widget": "anydataHum",
"page": "Сенсоры",
"descr": "Влажность",
"int": 10,
"addr": "0x78"
} }
] ]

View File

@@ -225,7 +225,16 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
//если прилетел измененный пакет с меткой /gifnoc (config наоборот) то перепишем файл //если прилетел измененный пакет с меткой /gifnoc (config наоборот) то перепишем файл
if (payloadStr.startsWith("/gifnoc.json")) { if (payloadStr.startsWith("/gifnoc.json")) {
payloadStr.replace("/gifnoc.json", ""); payloadStr.replace("/gifnoc.json", "");
writeFile(F("config.json"), payloadStr); String path = filepath("config.json");
auto file = FileFS.open(path, "w");
if (!file) {
Serial.println("failed");
}
for (size_t i = 0; i < length; i++) {
file.print((char)payload[i]);
yield();
}
file.close();
} }
} break; } break;