mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Debug changed
This commit is contained in:
@@ -43,7 +43,7 @@ class LineParsing {
|
|||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
//String order = sCmd.order();
|
//String order = sCmd.order();
|
||||||
//pm.info("create '" + order + "'");
|
//SerialPrint("I","module","create '" + order + "'");
|
||||||
for (int i = 1; i < 12; i++) {
|
for (int i = 1; i < 12; i++) {
|
||||||
if (i == 1) _key = sCmd.next();
|
if (i == 1) _key = sCmd.next();
|
||||||
if (i == 2) _file = sCmd.next();
|
if (i == 2) _file = sCmd.next();
|
||||||
@@ -166,7 +166,7 @@ class LineParsing {
|
|||||||
buf = readFile(getWidgetFileClass(filename), 2048);
|
buf = readFile(getWidgetFileClass(filename), 2048);
|
||||||
bool res = !(buf == "Failed" || buf == "Large");
|
bool res = !(buf == "Failed" || buf == "Large");
|
||||||
if (!res) {
|
if (!res) {
|
||||||
//pm.error("on load" + filename);
|
//SerialPrint("[E]","module","on load" + filename);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class Scenario {
|
|||||||
flag = _eventValue.toInt() <= _conditionValue.toInt();
|
flag = _eventValue.toInt() <= _conditionValue.toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag) Serial.println("[I] Scenario event: " + _condition);
|
if (flag) Serial.println("I Scenario event: " + _condition);
|
||||||
|
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
class Clock {
|
class Clock {
|
||||||
const char* MODULE = "Clock";
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Time_t _time_local;
|
Time_t _time_local;
|
||||||
@@ -71,7 +71,7 @@ class Clock {
|
|||||||
|
|
||||||
void startSync() {
|
void startSync() {
|
||||||
if (!_configured) {
|
if (!_configured) {
|
||||||
//pm.info("sync to: " + _ntp + " timezone: " + String(_timezone));
|
//SerialPrint("I","module","sync to: " + _ntp + " timezone: " + String(_timezone));
|
||||||
setupSntp();
|
setupSntp();
|
||||||
_configured = true;
|
_configured = true;
|
||||||
// лучше не ждать, проверим в следующий раз
|
// лучше не ждать, проверим в следующий раз
|
||||||
@@ -79,9 +79,9 @@ class Clock {
|
|||||||
}
|
}
|
||||||
_hasSynced = hasTimeSynced();
|
_hasSynced = hasTimeSynced();
|
||||||
if (_hasSynced) {
|
if (_hasSynced) {
|
||||||
//pm.info("synced " + getDateDotFormated() + " " + getTime());
|
//SerialPrint("I","module","synced " + getDateDotFormated() + " " + getTime());
|
||||||
} else {
|
} else {
|
||||||
//pm.error("failed to obtain");
|
//SerialPrint("[E]","module","failed to obtain");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "Utils\SysUtils.h"
|
#include "Utils\SysUtils.h"
|
||||||
#include "Utils\PrintMessage.h"
|
#include "Utils\PrintMessage.h"
|
||||||
#include "Utils\WiFiUtils.h"
|
#include "Utils\WiFiUtils.h"
|
||||||
|
#include "Utils\SerialPrint.h"
|
||||||
|
|
||||||
#include <Adafruit_BME280.h>
|
#include <Adafruit_BME280.h>
|
||||||
#include <Adafruit_BMP280.h>
|
#include <Adafruit_BMP280.h>
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef WEBSOCKET_ENABLED
|
#ifdef WEBSOCKET_ENABLED
|
||||||
extern AsyncWebSocket ws;
|
extern AsyncWebSocket ws;
|
||||||
//extern AsyncEventSource events;
|
//extern AsyncEventSource events;
|
||||||
|
|||||||
3
include/Utils/SerialPrint.h
Normal file
3
include/Utils/SerialPrint.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
void SerialPrint(String errorLevel, String module, String msg);
|
||||||
@@ -25,7 +25,7 @@ class SensorAnalogClass : public SensorConvertingClass {
|
|||||||
eventGen(key, "");
|
eventGen(key, "");
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
MqttClient::publishStatus(key, String(valueFl));
|
MqttClient::publishStatus(key, String(valueFl));
|
||||||
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
Serial.println("I sensor '" + key + "' data: " + String(valueFl));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
// eventGen(key, "");
|
// eventGen(key, "");
|
||||||
// jsonWriteStr(configLiveJson, key, String(valueFl));
|
// jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
// MqttClient::publishStatus(key, String(valueFl));
|
// MqttClient::publishStatus(key, String(valueFl));
|
||||||
// Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
// Serial.println("I sensor '" + key + "' data: " + String(valueFl));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class SensorDallasClass : public SensorConvertingClass {
|
|||||||
eventGen(key, "");
|
eventGen(key, "");
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
MqttClient::publishStatus(key, String(valueFl));
|
MqttClient::publishStatus(key, String(valueFl));
|
||||||
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
Serial.println("I sensor '" + key + "' data: " + String(valueFl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class SensorDhtClass : public SensorConvertingClass {
|
|||||||
eventGen(key, "");
|
eventGen(key, "");
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
MqttClient::publishStatus(key, String(valueFl));
|
MqttClient::publishStatus(key, String(valueFl));
|
||||||
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
Serial.println("I sensor '" + key + "' data: " + String(valueFl));
|
||||||
} else {
|
} else {
|
||||||
Serial.println("[E] sensor '" + key);
|
Serial.println("[E] sensor '" + key);
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ class SensorDhtClass : public SensorConvertingClass {
|
|||||||
eventGen(key, "");
|
eventGen(key, "");
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
MqttClient::publishStatus(key, String(valueFl));
|
MqttClient::publishStatus(key, String(valueFl));
|
||||||
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
Serial.println("I sensor '" + key + "' data: " + String(valueFl));
|
||||||
} else {
|
} else {
|
||||||
Serial.println("[E] sensor '" + key);
|
Serial.println("[E] sensor '" + key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class SensorUltrasonic : public SensorConvertingClass {
|
|||||||
eventGen(key, "");
|
eventGen(key, "");
|
||||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||||
MqttClient::publishStatus(key, String(valueFl));
|
MqttClient::publishStatus(key, String(valueFl));
|
||||||
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
|
Serial.println("I sensor '" + key + "' data: " + String(valueFl));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
extern SensorUltrasonic mySensorUltrasonic;
|
extern SensorUltrasonic mySensorUltrasonic;
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "Module/Terminal.h"
|
#include "Module/Terminal.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
|
|
||||||
static const char *MODULE = "Cmd";
|
|
||||||
|
|
||||||
void loopCmdAdd(const String &cmdStr) {
|
void loopCmdAdd(const String &cmdStr) {
|
||||||
orderBuf += cmdStr;
|
orderBuf += cmdStr;
|
||||||
@@ -45,7 +45,7 @@ void spaceCmdExecute(String &cmdStr) {
|
|||||||
void loopCmdExecute() {
|
void loopCmdExecute() {
|
||||||
if (orderBuf.length()) {
|
if (orderBuf.length()) {
|
||||||
String tmp = selectToMarker(orderBuf, ","); //выделяем первую команду rel 5 1,
|
String tmp = selectToMarker(orderBuf, ","); //выделяем первую команду rel 5 1,
|
||||||
pm.info("do: " + tmp);
|
SerialPrint("I","module","do: " + tmp);
|
||||||
sCmd.readStr(tmp); //выполняем
|
sCmd.readStr(tmp); //выполняем
|
||||||
orderBuf = deleteBeforeDelimiter(orderBuf, ","); //осекаем
|
orderBuf = deleteBeforeDelimiter(orderBuf, ","); //осекаем
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
static const char* MODULE = "I2C";
|
|
||||||
|
|
||||||
I2CScanner::I2CScanner(String& out) : BusScanner(TAG_I2C, out, 2){};
|
I2CScanner::I2CScanner(String& out) : BusScanner(TAG_I2C, out, 2){};
|
||||||
|
|
||||||
@@ -12,12 +12,12 @@ void I2CScanner::init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean I2CScanner::syncScan() {
|
boolean I2CScanner::syncScan() {
|
||||||
pm.info("scanning...");
|
SerialPrint("I","module","scanning...");
|
||||||
size_t cnt = 0;
|
size_t cnt = 0;
|
||||||
for (uint8_t i = 8; i < 120; i++) {
|
for (uint8_t i = 8; i < 120; i++) {
|
||||||
Wire.beginTransmission(i);
|
Wire.beginTransmission(i);
|
||||||
if (Wire.endTransmission() == 0) {
|
if (Wire.endTransmission() == 0) {
|
||||||
pm.info("found: " + i);
|
SerialPrint("I","module","found: " + i);
|
||||||
addResult(i, i < 119);
|
addResult(i, i < 119);
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
void sendLogData(String file, String topic);
|
void sendLogData(String file, String topic);
|
||||||
|
|
||||||
static const char* MODULE = "Log";
|
|
||||||
|
|
||||||
#ifdef LOGGING_ENABLED
|
#ifdef LOGGING_ENABLED
|
||||||
//===============================================Логирование============================================================
|
//===============================================Логирование============================================================
|
||||||
@@ -30,7 +29,7 @@ void logging() {
|
|||||||
LOG1, period_min.toInt() * 1000 * 60, [&](void*) {
|
LOG1, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||||
String tmp_buf_1 = selectFromMarkerToMarker(logging_value_names_list, ",", 0);
|
String tmp_buf_1 = selectFromMarkerToMarker(logging_value_names_list, ",", 0);
|
||||||
deleteOldDate("log." + tmp_buf_1 + ".txt", jsonReadInt(configOptionJson, tmp_buf_1 + "_c"), jsonReadStr(configLiveJson, tmp_buf_1));
|
deleteOldDate("log." + tmp_buf_1 + ".txt", jsonReadInt(configOptionJson, tmp_buf_1 + "_c"), jsonReadStr(configLiveJson, tmp_buf_1));
|
||||||
pm.info("logging for " + tmp_buf_1 + " done");
|
SerialPrint("I","module","logging for " + tmp_buf_1 + " done");
|
||||||
},
|
},
|
||||||
nullptr, false);
|
nullptr, false);
|
||||||
}
|
}
|
||||||
@@ -39,7 +38,7 @@ void logging() {
|
|||||||
LOG2, period_min.toInt() * 1000 * 60, [&](void*) {
|
LOG2, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||||
String tmp_buf_2 = selectFromMarkerToMarker(logging_value_names_list, ",", 1);
|
String tmp_buf_2 = selectFromMarkerToMarker(logging_value_names_list, ",", 1);
|
||||||
deleteOldDate("log." + tmp_buf_2 + ".txt", jsonReadInt(configOptionJson, tmp_buf_2 + "_c"), jsonReadStr(configLiveJson, tmp_buf_2));
|
deleteOldDate("log." + tmp_buf_2 + ".txt", jsonReadInt(configOptionJson, tmp_buf_2 + "_c"), jsonReadStr(configLiveJson, tmp_buf_2));
|
||||||
pm.info("logging for " + tmp_buf_2 + " done");
|
SerialPrint("I","module","logging for " + tmp_buf_2 + " done");
|
||||||
},
|
},
|
||||||
nullptr, false);
|
nullptr, false);
|
||||||
}
|
}
|
||||||
@@ -48,7 +47,7 @@ void logging() {
|
|||||||
LOG3, period_min.toInt() * 1000 * 60, [&](void*) {
|
LOG3, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||||
String tmp_buf_3 = selectFromMarkerToMarker(logging_value_names_list, ",", 2);
|
String tmp_buf_3 = selectFromMarkerToMarker(logging_value_names_list, ",", 2);
|
||||||
deleteOldDate("log." + tmp_buf_3 + ".txt", jsonReadInt(configOptionJson, tmp_buf_3 + "_c"), jsonReadStr(configLiveJson, tmp_buf_3));
|
deleteOldDate("log." + tmp_buf_3 + ".txt", jsonReadInt(configOptionJson, tmp_buf_3 + "_c"), jsonReadStr(configLiveJson, tmp_buf_3));
|
||||||
pm.info("logging for " + tmp_buf_3 + " done");
|
SerialPrint("I","module","logging for " + tmp_buf_3 + " done");
|
||||||
},
|
},
|
||||||
nullptr, false);
|
nullptr, false);
|
||||||
}
|
}
|
||||||
@@ -57,7 +56,7 @@ void logging() {
|
|||||||
LOG4, period_min.toInt() * 1000 * 60, [&](void*) {
|
LOG4, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||||
String tmp_buf_4 = selectFromMarkerToMarker(logging_value_names_list, ",", 3);
|
String tmp_buf_4 = selectFromMarkerToMarker(logging_value_names_list, ",", 3);
|
||||||
deleteOldDate("log." + tmp_buf_4 + ".txt", jsonReadInt(configOptionJson, tmp_buf_4 + "_c"), jsonReadStr(configLiveJson, tmp_buf_4));
|
deleteOldDate("log." + tmp_buf_4 + ".txt", jsonReadInt(configOptionJson, tmp_buf_4 + "_c"), jsonReadStr(configLiveJson, tmp_buf_4));
|
||||||
pm.info("logging for " + tmp_buf_4 + " done");
|
SerialPrint("I","module","logging for " + tmp_buf_4 + " done");
|
||||||
},
|
},
|
||||||
nullptr, false);
|
nullptr, false);
|
||||||
}
|
}
|
||||||
@@ -66,7 +65,7 @@ void logging() {
|
|||||||
LOG5, period_min.toInt() * 1000 * 60, [&](void*) {
|
LOG5, period_min.toInt() * 1000 * 60, [&](void*) {
|
||||||
String tmp_buf_5 = selectFromMarkerToMarker(logging_value_names_list, ",", 4);
|
String tmp_buf_5 = selectFromMarkerToMarker(logging_value_names_list, ",", 4);
|
||||||
deleteOldDate("log." + tmp_buf_5 + ".txt", jsonReadInt(configOptionJson, tmp_buf_5 + "_c"), jsonReadStr(configLiveJson, tmp_buf_5));
|
deleteOldDate("log." + tmp_buf_5 + ".txt", jsonReadInt(configOptionJson, tmp_buf_5 + "_c"), jsonReadStr(configLiveJson, tmp_buf_5));
|
||||||
pm.info("logging for " + tmp_buf_5 + " done");
|
SerialPrint("I","module","logging for " + tmp_buf_5 + " done");
|
||||||
},
|
},
|
||||||
nullptr, false);
|
nullptr, false);
|
||||||
}
|
}
|
||||||
@@ -79,7 +78,7 @@ void deleteOldDate(const String filename, size_t max_lines_cnt, String payload)
|
|||||||
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");
|
||||||
|
|
||||||
pm.info("log " + filename + " (" + String(lines_cnt, DEC) + ")");
|
SerialPrint("I","module","log " + filename + " (" + String(lines_cnt, DEC) + ")");
|
||||||
|
|
||||||
if ((lines_cnt > max_lines_cnt + 1) || !lines_cnt) {
|
if ((lines_cnt > max_lines_cnt + 1) || !lines_cnt) {
|
||||||
removeFile(filename);
|
removeFile(filename);
|
||||||
@@ -136,7 +135,7 @@ void sendLogData(String file, String topic) {
|
|||||||
value = "";
|
value = "";
|
||||||
log_date = "";
|
log_date = "";
|
||||||
json_array = "{\"status\":[" + json_array + "]}";
|
json_array = "{\"status\":[" + json_array + "]}";
|
||||||
pm.info(json_array);
|
SerialPrint("I","module",json_array);
|
||||||
|
|
||||||
MqttClient::publishChart(topic, json_array);
|
MqttClient::publishChart(topic, json_array);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Init.h"
|
#include "Init.h"
|
||||||
|
|
||||||
static const char* MODULE = "Mqtt";
|
|
||||||
|
|
||||||
namespace MqttClient {
|
namespace MqttClient {
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ void init() {
|
|||||||
if (isNetworkActive()) {
|
if (isNetworkActive()) {
|
||||||
if (mqtt.connected()) {
|
if (mqtt.connected()) {
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
pm.info("OK");
|
SerialPrint("I","module","OK");
|
||||||
setLedStatus(LED_OFF);
|
setLedStatus(LED_OFF);
|
||||||
connected = true;
|
connected = true;
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ void init() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
pm.error("connection lost");
|
SerialPrint("[E]","module","connection lost");
|
||||||
connected = false;
|
connected = false;
|
||||||
}
|
}
|
||||||
ts.remove(WIFI_MQTT_CONNECTION_CHECK);
|
ts.remove(WIFI_MQTT_CONNECTION_CHECK);
|
||||||
@@ -57,7 +57,7 @@ void init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void disconnect() {
|
void disconnect() {
|
||||||
pm.info("disconnect");
|
SerialPrint("I","module","disconnect");
|
||||||
mqtt.disconnect();
|
mqtt.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void subscribe() {
|
void subscribe() {
|
||||||
pm.info("subscribe");
|
SerialPrint("I","module","subscribe");
|
||||||
mqtt.subscribe(mqttPrefix.c_str());
|
mqtt.subscribe(mqttPrefix.c_str());
|
||||||
mqtt.subscribe((mqttRootDevice + "/+/control").c_str());
|
mqtt.subscribe((mqttRootDevice + "/+/control").c_str());
|
||||||
mqtt.subscribe((mqttRootDevice + "/order").c_str());
|
mqtt.subscribe((mqttRootDevice + "/order").c_str());
|
||||||
@@ -84,11 +84,11 @@ void subscribe() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean connect() {
|
boolean connect() {
|
||||||
pm.info("connect");
|
SerialPrint("I","module","connect");
|
||||||
|
|
||||||
String addr = jsonReadStr(configSetupJson, "mqttServer");
|
String addr = jsonReadStr(configSetupJson, "mqttServer");
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
pm.error("no broker address");
|
SerialPrint("[E]","module","no broker address");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,20 +100,20 @@ boolean connect() {
|
|||||||
mqttPrefix = jsonReadStr(configSetupJson, "mqttPrefix");
|
mqttPrefix = jsonReadStr(configSetupJson, "mqttPrefix");
|
||||||
mqttRootDevice = mqttPrefix + "/" + chipId;
|
mqttRootDevice = mqttPrefix + "/" + chipId;
|
||||||
|
|
||||||
pm.info("broker " + addr + ":" + String(port, DEC));
|
SerialPrint("I","module","broker " + addr + ":" + String(port, DEC));
|
||||||
pm.info("topic " + mqttRootDevice);
|
SerialPrint("I","module","topic " + mqttRootDevice);
|
||||||
|
|
||||||
setLedStatus(LED_FAST);
|
setLedStatus(LED_FAST);
|
||||||
mqtt.setServer(addr.c_str(), port);
|
mqtt.setServer(addr.c_str(), port);
|
||||||
bool res = false;
|
bool res = false;
|
||||||
if (!mqtt.connected()) {
|
if (!mqtt.connected()) {
|
||||||
if (mqtt.connect(chipId.c_str(), user.c_str(), pass.c_str())) {
|
if (mqtt.connect(chipId.c_str(), user.c_str(), pass.c_str())) {
|
||||||
pm.info("connected");
|
SerialPrint("I","module","connected");
|
||||||
setLedStatus(LED_OFF);
|
setLedStatus(LED_OFF);
|
||||||
subscribe();
|
subscribe();
|
||||||
res = true;
|
res = true;
|
||||||
} else {
|
} else {
|
||||||
pm.error("could't connect, retry in " + String(MQTT_RECONNECT_INTERVAL / 1000) + "s");
|
SerialPrint("[E]","module","could't connect, retry in " + String(MQTT_RECONNECT_INTERVAL / 1000) + "s");
|
||||||
setLedStatus(LED_FAST);
|
setLedStatus(LED_FAST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ boolean connect() {
|
|||||||
void handleSubscribedUpdates(char* topic, uint8_t* payload, size_t length) {
|
void handleSubscribedUpdates(char* topic, uint8_t* payload, size_t length) {
|
||||||
String topicStr = String(topic);
|
String topicStr = String(topic);
|
||||||
|
|
||||||
pm.info(topicStr);
|
SerialPrint("I","module",topicStr);
|
||||||
|
|
||||||
String payloadStr;
|
String payloadStr;
|
||||||
|
|
||||||
@@ -132,10 +132,10 @@ void handleSubscribedUpdates(char* topic, uint8_t* payload, size_t length) {
|
|||||||
payloadStr += (char)payload[i];
|
payloadStr += (char)payload[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
pm.info(payloadStr);
|
SerialPrint("I","module",payloadStr);
|
||||||
|
|
||||||
if (payloadStr.startsWith("HELLO")) {
|
if (payloadStr.startsWith("HELLO")) {
|
||||||
pm.info("Full update");
|
SerialPrint("I","module","Full update");
|
||||||
publishWidgets();
|
publishWidgets();
|
||||||
publishState();
|
publishState();
|
||||||
#ifdef LOGGING_ENABLED
|
#ifdef LOGGING_ENABLED
|
||||||
@@ -184,7 +184,7 @@ boolean publish(const String& topic, const String& data) {
|
|||||||
boolean publishData(const String& topic, const String& data) {
|
boolean publishData(const String& topic, const String& data) {
|
||||||
String path = mqttRootDevice + "/" + topic;
|
String path = mqttRootDevice + "/" + topic;
|
||||||
if (!publish(path, data)) {
|
if (!publish(path, data)) {
|
||||||
pm.error("on publish data");
|
SerialPrint("[E]","module","on publish data");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -193,7 +193,7 @@ boolean publishData(const String& topic, const String& data) {
|
|||||||
boolean publishChart(const String& topic, const String& data) {
|
boolean publishChart(const String& topic, const String& data) {
|
||||||
String path = mqttRootDevice + "/" + topic + "/status";
|
String path = mqttRootDevice + "/" + topic + "/status";
|
||||||
if (!publish(path, data)) {
|
if (!publish(path, data)) {
|
||||||
pm.error("on publish chart");
|
SerialPrint("[E]","module","on publish chart");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -235,7 +235,7 @@ void publishWidgets() {
|
|||||||
Serial.println("[V] " + line);
|
Serial.println("[V] " + line);
|
||||||
psn_1 = psn_2 + 1;
|
psn_1 = psn_2 + 1;
|
||||||
} while (psn_2 + 2 < all_widgets.length());
|
} while (psn_2 + 2 < all_widgets.length());
|
||||||
getMemoryLoad("[I] after send all widgets");
|
getMemoryLoad("I after send all widgets");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -244,12 +244,12 @@ void publishWidgets() {
|
|||||||
void publishWidgets() {
|
void publishWidgets() {
|
||||||
auto file = seekFile("layout.txt");
|
auto file = seekFile("layout.txt");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
pm.error("no file layout.txt");
|
SerialPrint("[E]","module","no file layout.txt");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (file.available()) {
|
while (file.available()) {
|
||||||
String payload = file.readStringUntil('\n');
|
String payload = file.readStringUntil('\n');
|
||||||
pm.info("widgets: " + payload);
|
SerialPrint("I","module","widgets: " + payload);
|
||||||
publishData("config", payload);
|
publishData("config", payload);
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ void pushControl() {
|
|||||||
const char* logServer = "api.pushingbox.com";
|
const char* logServer = "api.pushingbox.com";
|
||||||
String deviceId = jsonReadStr(configSetupJson, "pushingbox_id");
|
String deviceId = jsonReadStr(configSetupJson, "pushingbox_id");
|
||||||
|
|
||||||
Serial.println("- starting client");
|
//Serial.println("- starting client");
|
||||||
|
|
||||||
WiFiClient client_push;
|
WiFiClient client_push;
|
||||||
|
|
||||||
Serial.println("- connecting to pushing server: " + String(logServer));
|
//Serial.println("- connecting to pushing server: " + String(logServer));
|
||||||
if (!client_push.connect(logServer, 80)) {
|
if (!client_push.connect(logServer, 80)) {
|
||||||
Serial.println("- not connected");
|
//Serial.println("- not connected");
|
||||||
} else {
|
} else {
|
||||||
Serial.println("- succesfully connected");
|
//Serial.println("- succesfully connected");
|
||||||
|
|
||||||
String postStr = "devid=";
|
String postStr = "devid=";
|
||||||
postStr += String(deviceId);
|
postStr += String(deviceId);
|
||||||
@@ -44,7 +44,7 @@ void pushControl() {
|
|||||||
|
|
||||||
postStr += "\r\n\r\n";
|
postStr += "\r\n\r\n";
|
||||||
|
|
||||||
Serial.println("- sending data...");
|
//Serial.println("- sending data...");
|
||||||
|
|
||||||
client_push.print(F("POST /pushingbox HTTP/1.1\n"));
|
client_push.print(F("POST /pushingbox HTTP/1.1\n"));
|
||||||
client_push.print(F("Host: api.pushingbox.com\n"));
|
client_push.print(F("Host: api.pushingbox.com\n"));
|
||||||
@@ -56,5 +56,5 @@ void pushControl() {
|
|||||||
client_push.print(postStr);
|
client_push.print(postStr);
|
||||||
}
|
}
|
||||||
client_push.stop();
|
client_push.stop();
|
||||||
Serial.println("- stopping the client");
|
//Serial.println("- stopping the client");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ void asyncUdpInit() {
|
|||||||
Serial.print(data);
|
Serial.print(data);
|
||||||
if (udpPacketValidation(data)) {
|
if (udpPacketValidation(data)) {
|
||||||
udpPacketParse(data);
|
udpPacketParse(data);
|
||||||
Serial.println("', Packet valid");
|
//Serial.println("', Packet valid");
|
||||||
} else {
|
} else {
|
||||||
Serial.println("', Packet invalid");
|
//Serial.println("', Packet invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
//reply to the client
|
//reply to the client
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Class/ScenarioClass.h"
|
#include "Class/ScenarioClass.h"
|
||||||
|
|
||||||
static const char* MODULE = "Scen";
|
|
||||||
|
|
||||||
boolean isScenarioEnabled() {
|
boolean isScenarioEnabled() {
|
||||||
return jsonReadBool(configSetupJson, "scen") && eventBuf != "";
|
return jsonReadBool(configSetupJson, "scen") && eventBuf != "";
|
||||||
@@ -58,7 +58,7 @@ void loopScenario() {
|
|||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
scenBlok = deleteBeforeDelimiter(scenBlok, "\n"); // удаляем строку самого сценария оставляя только команды
|
scenBlok = deleteBeforeDelimiter(scenBlok, "\n"); // удаляем строку самого сценария оставляя только команды
|
||||||
pm.info("do: " + scenBlok);
|
SerialPrint("I","module","do: " + scenBlok);
|
||||||
spaceCmdExecute(scenBlok); // выполняем все команды
|
spaceCmdExecute(scenBlok); // выполняем все команды
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
// //eventGen(dhtT_value_name, "");
|
// //eventGen(dhtT_value_name, "");
|
||||||
// //jsonWriteStr(configLiveJson, dhtT_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, dhtT_value_name, String(value));
|
||||||
// //MqttClient::publishStatus(dhtT_value_name, String(value));
|
// //MqttClient::publishStatus(dhtT_value_name, String(value));
|
||||||
// //Serial.println("[I] sensor '" + dhtT_value_name + "' data: " + String(value));
|
// //Serial.println("I sensor '" + dhtT_value_name + "' data: " + String(value));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
// //eventGen(dhtH_value_name, "");
|
// //eventGen(dhtH_value_name, "");
|
||||||
// //jsonWriteStr(configLiveJson, dhtH_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, dhtH_value_name, String(value));
|
||||||
// //MqttClient::publishStatus(dhtH_value_name, String(value));
|
// //MqttClient::publishStatus(dhtH_value_name, String(value));
|
||||||
// //Serial.println("[I] sensor '" + dhtH_value_name + "' data: " + String(value));
|
// //Serial.println("I sensor '" + dhtH_value_name + "' data: " + String(value));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
// eventGen("dhtPerception", "");
|
// eventGen("dhtPerception", "");
|
||||||
// MqttClient::publishStatus("dhtPerception", final_line);
|
// MqttClient::publishStatus("dhtPerception", final_line);
|
||||||
// if (mqtt.connected()) {
|
// if (mqtt.connected()) {
|
||||||
// Serial.println("[I] sensor 'dhtPerception' data: " + final_line);
|
// Serial.println("I sensor 'dhtPerception' data: " + final_line);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
// jsonWriteStr(configLiveJson, "dhtComfort", final_line);
|
// jsonWriteStr(configLiveJson, "dhtComfort", final_line);
|
||||||
// eventGen("dhtComfort", "");
|
// eventGen("dhtComfort", "");
|
||||||
// MqttClient::publishStatus("dhtComfort", final_line);
|
// MqttClient::publishStatus("dhtComfort", final_line);
|
||||||
// Serial.println("[I] sensor 'dhtComfort' send date " + final_line);
|
// Serial.println("I sensor 'dhtComfort' send date " + final_line);
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
@@ -236,7 +236,7 @@
|
|||||||
// jsonWriteInt(configLiveJson, "dhtDewpoint", value);
|
// jsonWriteInt(configLiveJson, "dhtDewpoint", value);
|
||||||
// eventGen("dhtDewpoint", "");
|
// eventGen("dhtDewpoint", "");
|
||||||
// MqttClient::publishStatus("dhtDewpoint", String(value));
|
// MqttClient::publishStatus("dhtDewpoint", String(value));
|
||||||
// Serial.println("[I] sensor 'dhtDewpoint' data: " + String(value));
|
// Serial.println("I sensor 'dhtDewpoint' data: " + String(value));
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//#endif
|
//#endif
|
||||||
@@ -272,7 +272,7 @@
|
|||||||
// //jsonWriteStr(configLiveJson, bmp280T_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, bmp280T_value_name, String(value));
|
||||||
// //eventGen(bmp280T_value_name, "");
|
// //eventGen(bmp280T_value_name, "");
|
||||||
// //MqttClient::publishStatus(bmp280T_value_name, String(value));
|
// //MqttClient::publishStatus(bmp280T_value_name, String(value));
|
||||||
// //Serial.println("[I] sensor '" + bmp280T_value_name + "' data: " + String(value));
|
// //Serial.println("I sensor '" + bmp280T_value_name + "' data: " + String(value));
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
////bmp280P press1 0x76 Давление#bmp280 Датчики any-data 2
|
////bmp280P press1 0x76 Давление#bmp280 Датчики any-data 2
|
||||||
@@ -304,7 +304,7 @@
|
|||||||
// //jsonWriteStr(configLiveJson, bmp280P_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, bmp280P_value_name, String(value));
|
||||||
// //eventGen(bmp280P_value_name, "");
|
// //eventGen(bmp280P_value_name, "");
|
||||||
// //MqttClient::publishStatus(bmp280P_value_name, String(value));
|
// //MqttClient::publishStatus(bmp280P_value_name, String(value));
|
||||||
// //Serial.println("[I] sensor '" + bmp280P_value_name + "' data: " + String(value));
|
// //Serial.println("I sensor '" + bmp280P_value_name + "' data: " + String(value));
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
////=========================================================================================================================================
|
////=========================================================================================================================================
|
||||||
@@ -329,7 +329,7 @@
|
|||||||
// //jsonWriteStr(configLiveJson, bme280T_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, bme280T_value_name, String(value));
|
||||||
// //eventGen(bme280T_value_name, "");
|
// //eventGen(bme280T_value_name, "");
|
||||||
// //MqttClient::publishStatus(bme280T_value_name, String(value));
|
// //MqttClient::publishStatus(bme280T_value_name, String(value));
|
||||||
// //Serial.println("[I] sensor '" + bme280T_value_name + "' data: " + String(value));
|
// //Serial.println("I sensor '" + bme280T_value_name + "' data: " + String(value));
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
////bme280P pres1 0x76 Давление#bmp280 Датчики any-data 1
|
////bme280P pres1 0x76 Давление#bmp280 Датчики any-data 1
|
||||||
@@ -353,7 +353,7 @@
|
|||||||
// //jsonWriteStr(configLiveJson, bme280P_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, bme280P_value_name, String(value));
|
||||||
// //eventGen(bme280P_value_name, "");
|
// //eventGen(bme280P_value_name, "");
|
||||||
// //MqttClient::publishStatus(bme280P_value_name, String(value));
|
// //MqttClient::publishStatus(bme280P_value_name, String(value));
|
||||||
// //Serial.println("[I] sensor '" + bme280P_value_name + "' data: " + String(value));
|
// //Serial.println("I sensor '" + bme280P_value_name + "' data: " + String(value));
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
////bme280H hum1 0x76 Влажность#bmp280 Датчики any-data 1
|
////bme280H hum1 0x76 Влажность#bmp280 Датчики any-data 1
|
||||||
@@ -376,7 +376,7 @@
|
|||||||
// //jsonWriteStr(configLiveJson, bme280H_value_name, String(value));
|
// //jsonWriteStr(configLiveJson, bme280H_value_name, String(value));
|
||||||
// //eventGen(bme280H_value_name, "");
|
// //eventGen(bme280H_value_name, "");
|
||||||
// //MqttClient::publishStatus(bme280H_value_name, String(value));
|
// //MqttClient::publishStatus(bme280H_value_name, String(value));
|
||||||
// //Serial.println("[I] sensor '" + bme280H_value_name + "' data: " + String(value));
|
// //Serial.println("I sensor '" + bme280H_value_name + "' data: " + String(value));
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
////bme280A altit1 0x76 Высота#bmp280 Датчики any-data 1
|
////bme280A altit1 0x76 Высота#bmp280 Датчики any-data 1
|
||||||
@@ -401,5 +401,5 @@
|
|||||||
//
|
//
|
||||||
// //MqttClient::publishStatus(bme280A_value_name, String(value));
|
// //MqttClient::publishStatus(bme280A_value_name, String(value));
|
||||||
//
|
//
|
||||||
// //Serial.println("[I] sensor '" + bme280A_value_name + "' data: " + String(value));
|
// //Serial.println("I sensor '" + bme280A_value_name + "' data: " + String(value));
|
||||||
//}
|
//}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ void Timer_countdown_init() {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
do {
|
do {
|
||||||
String timer = selectFromMarkerToMarker(old_line, ",", i);
|
String timer = selectFromMarkerToMarker(old_line, ",", i);
|
||||||
Serial.print("timer no " + String(i) + ": ");
|
//Serial.print("timer no " + String(i) + ": ");
|
||||||
Serial.println(timer);
|
//Serial.println(timer);
|
||||||
if (timer == "not found" || timer == "") return;
|
if (timer == "not found" || timer == "") return;
|
||||||
int number = selectToMarker(timer, ":").toInt();
|
int number = selectToMarker(timer, ":").toInt();
|
||||||
int time = readTimer(number);
|
int time = readTimer(number);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "ESP8266.h"
|
#include "ESP8266.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
static const char* MODULE = "Update";
|
|
||||||
static const char* check_update_url PROGMEM = "http://91.204.228.124:1100/update/%s/version.txt";
|
static const char* check_update_url PROGMEM = "http://91.204.228.124:1100/update/%s/version.txt";
|
||||||
|
|
||||||
void upgradeInit() {
|
void upgradeInit() {
|
||||||
@@ -23,7 +23,7 @@ void upgradeInit() {
|
|||||||
if (isNetworkActive()) {
|
if (isNetworkActive()) {
|
||||||
getLastVersion();
|
getLastVersion();
|
||||||
if (lastVersion.length()) {
|
if (lastVersion.length()) {
|
||||||
pm.info("available: " + lastVersion);
|
SerialPrint("I","module","available: " + lastVersion);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ void upgrade_firmware() {
|
|||||||
configBackup = readFile(String(DEVICE_CONFIG_FILE), 4096);
|
configBackup = readFile(String(DEVICE_CONFIG_FILE), 4096);
|
||||||
setupBackup = configSetupJson;
|
setupBackup = configSetupJson;
|
||||||
|
|
||||||
pm.info("update data");
|
SerialPrint("I","module","update data");
|
||||||
WiFiClient wifiClient;
|
WiFiClient wifiClient;
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
ESPhttpUpdate.rebootOnUpdate(false);
|
ESPhttpUpdate.rebootOnUpdate(false);
|
||||||
@@ -68,22 +68,22 @@ void upgrade_firmware() {
|
|||||||
|
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
pm.info("done!");
|
SerialPrint("I","module","done!");
|
||||||
} else {
|
} else {
|
||||||
pm.error("on data");
|
SerialPrint("[E]","module","on data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("update firmware");
|
//Serial.println("update firmware");
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
ret = ESPhttpUpdate.update(wifiClient, F("http://91.204.228.124:1100/update/esp8266/esp32-esp8266_iot-manager_modules_firmware.ino.bin"));
|
ret = ESPhttpUpdate.update(wifiClient, F("http://91.204.228.124:1100/update/esp8266/esp32-esp8266_iot-manager_modules_firmware.ino.bin"));
|
||||||
#else
|
#else
|
||||||
ret = httpUpdate.update(client_for_upgrade, "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.ino.bin");
|
ret = httpUpdate.update(client_for_upgrade, "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.ino.bin");
|
||||||
#endif
|
#endif
|
||||||
if (ret == HTTP_UPDATE_OK) {
|
if (ret == HTTP_UPDATE_OK) {
|
||||||
pm.info("done! restart...");
|
SerialPrint("I","module","done! restart...");
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
} else {
|
} else {
|
||||||
pm.error("on firmware");
|
SerialPrint("[E]","module","on firmware");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "Utils/FileUtils.h"
|
#include "Utils/FileUtils.h"
|
||||||
#include "Utils/PrintMessage.h"
|
#include "Utils/PrintMessage.h"
|
||||||
|
|
||||||
static const char* MODULE = "FS";
|
|
||||||
|
|
||||||
const String filepath(const String& filename) {
|
const String filepath(const String& filename) {
|
||||||
return filename.startsWith("/") ? filename : "/" + filename;
|
return filename.startsWith("/") ? filename : "/" + filename;
|
||||||
@@ -9,7 +9,7 @@ const String filepath(const String& filename) {
|
|||||||
|
|
||||||
bool fileSystemInit() {
|
bool fileSystemInit() {
|
||||||
if (!LittleFS.begin()) {
|
if (!LittleFS.begin()) {
|
||||||
pm.error("init");
|
SerialPrint("[E]","module","init");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -19,10 +19,10 @@ void removeFile(const String& filename) {
|
|||||||
String path = filepath(filename);
|
String path = filepath(filename);
|
||||||
if (LittleFS.exists(path)) {
|
if (LittleFS.exists(path)) {
|
||||||
if (!LittleFS.remove(path)) {
|
if (!LittleFS.remove(path)) {
|
||||||
pm.error("remove " + path);
|
SerialPrint("[E]","module","remove " + path);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pm.info("not exist" + path);
|
SerialPrint("I","module","not exist" + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ File seekFile(const String& filename, size_t position) {
|
|||||||
String path = filepath(filename);
|
String path = filepath(filename);
|
||||||
auto file = LittleFS.open(path, "r");
|
auto file = LittleFS.open(path, "r");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
pm.error("open " + path);
|
SerialPrint("[E]","module","open " + path);
|
||||||
}
|
}
|
||||||
// поставим курсор в начало файла
|
// поставим курсор в начало файла
|
||||||
file.seek(position, SeekSet);
|
file.seek(position, SeekSet);
|
||||||
@@ -76,14 +76,14 @@ const String addFile(const String& filename, const String& str) {
|
|||||||
bool copyFile(const String& src, const String& dst, bool overwrite) {
|
bool copyFile(const String& src, const String& dst, bool overwrite) {
|
||||||
String srcPath = filepath(src);
|
String srcPath = filepath(src);
|
||||||
String dstPath = filepath(dst);
|
String dstPath = filepath(dst);
|
||||||
pm.info("copy " + srcPath + " to " + dstPath);
|
SerialPrint("I","module","copy " + srcPath + " to " + dstPath);
|
||||||
if (!LittleFS.exists(srcPath)) {
|
if (!LittleFS.exists(srcPath)) {
|
||||||
pm.error("not exist: " + srcPath);
|
SerialPrint("[E]","module","not exist: " + srcPath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (LittleFS.exists(dstPath)) {
|
if (LittleFS.exists(dstPath)) {
|
||||||
if (!overwrite) {
|
if (!overwrite) {
|
||||||
pm.error("already exist: " + dstPath);
|
SerialPrint("[E]","module","already exist: " + dstPath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LittleFS.remove(dstPath);
|
LittleFS.remove(dstPath);
|
||||||
|
|||||||
8
src/Utils/SerialPrint.cpp
Normal file
8
src/Utils/SerialPrint.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#include "Utils\SerialPrint.h"
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
|
||||||
|
void SerialPrint(String errorLevel, String module, String msg) {
|
||||||
|
Serial.println(prettyMillis(millis()) + " [" + errorLevel + "] [" + module + "] " + msg);
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Utils/PrintMessage.h"
|
#include "Utils/PrintMessage.h"
|
||||||
|
|
||||||
static const char* MODULE = "Main";
|
|
||||||
|
|
||||||
const String getUniqueId(const char* name) {
|
const String getUniqueId(const char* name) {
|
||||||
return String(name) + getMacAddress();
|
return String(name) + getMacAddress();
|
||||||
@@ -25,7 +24,7 @@ const String getChipId() {
|
|||||||
|
|
||||||
void setChipId() {
|
void setChipId() {
|
||||||
chipId = getChipId();
|
chipId = getChipId();
|
||||||
pm.info("id: " + chipId);
|
SerialPrint("I","module","id: " + chipId);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "Utils/WiFiUtils.h"
|
#include "Utils/WiFiUtils.h"
|
||||||
|
|
||||||
static const char* MODULE = "WiFi";
|
|
||||||
|
|
||||||
void startSTAMode() {
|
void startSTAMode() {
|
||||||
setLedStatus(LED_SLOW);
|
setLedStatus(LED_SLOW);
|
||||||
pm.info("STA Mode");
|
SerialPrint("I","module","STA Mode");
|
||||||
|
|
||||||
String ssid = jsonReadStr(configSetupJson, "routerssid");
|
String ssid = jsonReadStr(configSetupJson, "routerssid");
|
||||||
String passwd = jsonReadStr(configSetupJson, "routerpass");
|
String passwd = jsonReadStr(configSetupJson, "routerpass");
|
||||||
@@ -14,7 +14,7 @@ void startSTAMode() {
|
|||||||
WiFi.begin();
|
WiFi.begin();
|
||||||
} else {
|
} else {
|
||||||
if (WiFi.begin(ssid.c_str(), passwd.c_str()) == WL_CONNECT_FAILED) {
|
if (WiFi.begin(ssid.c_str(), passwd.c_str()) == WL_CONNECT_FAILED) {
|
||||||
pm.error("failed on start");
|
SerialPrint("[E]","module","failed on start");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,17 +29,17 @@ void startSTAMode() {
|
|||||||
#endif
|
#endif
|
||||||
switch (connRes) {
|
switch (connRes) {
|
||||||
case WL_NO_SSID_AVAIL: {
|
case WL_NO_SSID_AVAIL: {
|
||||||
pm.error("no network");
|
SerialPrint("[E]","module","no network");
|
||||||
keepConnecting = false;
|
keepConnecting = false;
|
||||||
} break;
|
} break;
|
||||||
case WL_CONNECTED: {
|
case WL_CONNECTED: {
|
||||||
String hostIpStr = WiFi.localIP().toString();
|
String hostIpStr = WiFi.localIP().toString();
|
||||||
pm.info("http://" + hostIpStr);
|
SerialPrint("I","module","http://" + hostIpStr);
|
||||||
jsonWriteStr(configSetupJson, "ip", hostIpStr);
|
jsonWriteStr(configSetupJson, "ip", hostIpStr);
|
||||||
keepConnecting = false;
|
keepConnecting = false;
|
||||||
} break;
|
} break;
|
||||||
case WL_CONNECT_FAILED: {
|
case WL_CONNECT_FAILED: {
|
||||||
pm.error("check credentials");
|
SerialPrint("[E]","module","check credentials");
|
||||||
jsonWriteInt(configOptionJson, "pass_status", 1);
|
jsonWriteInt(configOptionJson, "pass_status", 1);
|
||||||
keepConnecting = false;
|
keepConnecting = false;
|
||||||
} break;
|
} break;
|
||||||
@@ -52,14 +52,14 @@ void startSTAMode() {
|
|||||||
MqttClient::init();
|
MqttClient::init();
|
||||||
setLedStatus(LED_OFF);
|
setLedStatus(LED_OFF);
|
||||||
} else {
|
} else {
|
||||||
pm.error("failed: " + String(connRes, DEC));
|
SerialPrint("[E]","module","failed: " + String(connRes, DEC));
|
||||||
startAPMode();
|
startAPMode();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool startAPMode() {
|
bool startAPMode() {
|
||||||
setLedStatus(LED_ON);
|
setLedStatus(LED_ON);
|
||||||
pm.info("AP Mode");
|
SerialPrint("I","module","AP Mode");
|
||||||
|
|
||||||
String ssid = jsonReadStr(configSetupJson, "apssid");
|
String ssid = jsonReadStr(configSetupJson, "apssid");
|
||||||
String passwd = jsonReadStr(configSetupJson, "appass");
|
String passwd = jsonReadStr(configSetupJson, "appass");
|
||||||
@@ -68,14 +68,14 @@ bool startAPMode() {
|
|||||||
|
|
||||||
WiFi.softAP(ssid.c_str(), passwd.c_str());
|
WiFi.softAP(ssid.c_str(), passwd.c_str());
|
||||||
String hostIpStr = WiFi.softAPIP().toString();
|
String hostIpStr = WiFi.softAPIP().toString();
|
||||||
pm.info("Host IP: " + hostIpStr);
|
SerialPrint("I","module","Host IP: " + hostIpStr);
|
||||||
jsonWriteStr(configSetupJson, "ip", hostIpStr);
|
jsonWriteStr(configSetupJson, "ip", hostIpStr);
|
||||||
|
|
||||||
ts.add(
|
ts.add(
|
||||||
WIFI_SCAN, 10 * 1000,
|
WIFI_SCAN, 10 * 1000,
|
||||||
[&](void*) {
|
[&](void*) {
|
||||||
String sta_ssid = jsonReadStr(configSetupJson, "routerssid");
|
String sta_ssid = jsonReadStr(configSetupJson, "routerssid");
|
||||||
pm.info("scanning for " + sta_ssid);
|
SerialPrint("I","module","scanning for " + sta_ssid);
|
||||||
if (scanWiFi(sta_ssid)) {
|
if (scanWiFi(sta_ssid)) {
|
||||||
ts.remove(WIFI_SCAN);
|
ts.remove(WIFI_SCAN);
|
||||||
startSTAMode();
|
startSTAMode();
|
||||||
@@ -89,25 +89,25 @@ bool startAPMode() {
|
|||||||
boolean scanWiFi(String ssid) {
|
boolean scanWiFi(String ssid) {
|
||||||
bool res = false;
|
bool res = false;
|
||||||
int8_t n = WiFi.scanComplete();
|
int8_t n = WiFi.scanComplete();
|
||||||
pm.info("scan result: " + String(n, DEC));
|
SerialPrint("I","module","scan result: " + String(n, DEC));
|
||||||
if (n == -2) {
|
if (n == -2) {
|
||||||
// не было запущено, запускаем
|
// не было запущено, запускаем
|
||||||
pm.info("start scanning");
|
SerialPrint("I","module","start scanning");
|
||||||
// async, show_hidden
|
// async, show_hidden
|
||||||
WiFi.scanNetworks(true, false);
|
WiFi.scanNetworks(true, false);
|
||||||
} else if (n == -1) {
|
} else if (n == -1) {
|
||||||
// все еще выполняется
|
// все еще выполняется
|
||||||
pm.info("scanning in progress");
|
SerialPrint("I","module","scanning in progress");
|
||||||
} else if (n == 0) {
|
} else if (n == 0) {
|
||||||
// не найдена ни одна сеть
|
// не найдена ни одна сеть
|
||||||
pm.info("no networks found");
|
SerialPrint("I","module","no networks found");
|
||||||
WiFi.scanNetworks(true, false);
|
WiFi.scanNetworks(true, false);
|
||||||
} else if (n > 0) {
|
} else if (n > 0) {
|
||||||
for (int8_t i = 0; i < n; i++) {
|
for (int8_t i = 0; i < n; i++) {
|
||||||
if (WiFi.SSID(i) == ssid) {
|
if (WiFi.SSID(i) == ssid) {
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
pm.info((res ? "*" : "") + String(i, DEC) + ") " + WiFi.SSID(i));
|
SerialPrint("I","module",(res ? "*" : "") + String(i, DEC) + ") " + WiFi.SSID(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "ItemsList.h"
|
#include "ItemsList.h"
|
||||||
|
|
||||||
|
|
||||||
void initSt() {
|
void initSt() {
|
||||||
Serial.print("[I] [Stat] New device registation: ");
|
addNewDevice();
|
||||||
Serial.println(addNewDevice());
|
|
||||||
decide();
|
decide();
|
||||||
if (TELEMETRY_UPDATE_INTERVAL_MIN) {
|
if (TELEMETRY_UPDATE_INTERVAL_MIN) {
|
||||||
ts.add(
|
ts.add(
|
||||||
@@ -16,9 +16,7 @@ void initSt() {
|
|||||||
static bool secondTime = false;
|
static bool secondTime = false;
|
||||||
if (secondTime) plusOneHour();
|
if (secondTime) plusOneHour();
|
||||||
secondTime = true;
|
secondTime = true;
|
||||||
|
updateDeviceStatus();
|
||||||
Serial.print("[I] [Stat] Update device status: ");
|
|
||||||
Serial.println(updateDeviceStatus());
|
|
||||||
},
|
},
|
||||||
nullptr, true);
|
nullptr, true);
|
||||||
}
|
}
|
||||||
@@ -27,17 +25,17 @@ void initSt() {
|
|||||||
void decide() {
|
void decide() {
|
||||||
if ((WiFi.status() == WL_CONNECTED)) {
|
if ((WiFi.status() == WL_CONNECTED)) {
|
||||||
uint8_t cnt = getNewElementNumber("stat.txt");
|
uint8_t cnt = getNewElementNumber("stat.txt");
|
||||||
Serial.print("[I] [Stat] Total reset number: ");
|
SerialPrint("I","module","Total reset number: " + String(cnt));
|
||||||
Serial.print(cnt);
|
//Serial.print(cnt);
|
||||||
Serial.print(" ");
|
//Serial.print(" ");
|
||||||
if (cnt <= 3) {
|
if (cnt <= 3) {
|
||||||
Serial.println("(get)");
|
//Serial.println("(get)");
|
||||||
getPsn();
|
getPsn();
|
||||||
} else {
|
} else {
|
||||||
if (cnt % 5) {
|
if (cnt % 5) {
|
||||||
Serial.println("(skip)");
|
//Serial.println("(skip)");
|
||||||
} else {
|
} else {
|
||||||
Serial.println("(get)");
|
//Serial.println("(get)");
|
||||||
getPsn();
|
getPsn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,8 +51,7 @@ void getPsn() {
|
|||||||
//String city = jsonReadStr(res, "city");
|
//String city = jsonReadStr(res, "city");
|
||||||
//String country = jsonReadStr(res, "country");
|
//String country = jsonReadStr(res, "country");
|
||||||
//String region = jsonReadStr(res, "region");
|
//String region = jsonReadStr(res, "region");
|
||||||
Serial.print("[I] [Stat] Update device psn: ");
|
updateDevicePsn(lat, lon, "1000");
|
||||||
Serial.println(updateDevicePsn(lat, lon, "1000"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,6 +83,7 @@ String addNewDevice() {
|
|||||||
}
|
}
|
||||||
http.end();
|
http.end();
|
||||||
}
|
}
|
||||||
|
SerialPrint("I","module","New device registaration: " + ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +112,7 @@ String updateDevicePsn(String lat, String lon, String accur) {
|
|||||||
}
|
}
|
||||||
http.end();
|
http.end();
|
||||||
}
|
}
|
||||||
|
SerialPrint("I","module","Update device psn: " + ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,6 +141,7 @@ String updateDeviceStatus() {
|
|||||||
}
|
}
|
||||||
http.end();
|
http.end();
|
||||||
}
|
}
|
||||||
|
SerialPrint("I","module","Update device data: " + ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,8 +149,9 @@ String getUptimeTotal() {
|
|||||||
static int hrs;
|
static int hrs;
|
||||||
EEPROM.begin(512);
|
EEPROM.begin(512);
|
||||||
hrs = eeGetInt(0);
|
hrs = eeGetInt(0);
|
||||||
|
SerialPrint("I","module","Total running hrs: " + String(hrs));
|
||||||
String hrsStr = prettySeconds(hrs * 60 * 60);
|
String hrsStr = prettySeconds(hrs * 60 * 60);
|
||||||
//Serial.println(hrsStr);
|
SerialPrint("I","module","Total running hrs (f): " + hrsStr);
|
||||||
return hrsStr;
|
return hrsStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "Init.h"
|
#include "Init.h"
|
||||||
#include "Class/NotAsinc.h"
|
#include "Class/NotAsinc.h"
|
||||||
|
|
||||||
static const char* MODULE = "Web";
|
|
||||||
|
|
||||||
bool parseRequestForPreset(AsyncWebServerRequest* request, uint8_t& preset) {
|
bool parseRequestForPreset(AsyncWebServerRequest* request, uint8_t& preset) {
|
||||||
if (request->hasArg("preset")) {
|
if (request->hasArg("preset")) {
|
||||||
@@ -32,7 +32,7 @@ void web_init() {
|
|||||||
//==============================presets===========================================================================================================
|
//==============================presets===========================================================================================================
|
||||||
//uint8_t preset;
|
//uint8_t preset;
|
||||||
//if (parseRequestForPreset(request, preset)) {
|
//if (parseRequestForPreset(request, preset)) {
|
||||||
// pm.info("activate #" + String(preset, DEC));
|
// SerialPrint("I","module","activate #" + String(preset, DEC));
|
||||||
// String configFile = DEVICE_CONFIG_FILE;
|
// String configFile = DEVICE_CONFIG_FILE;
|
||||||
// String scenarioFile = DEVICE_SCENARIO_FILE;
|
// String scenarioFile = DEVICE_SCENARIO_FILE;
|
||||||
// copyFile(getConfigFile(preset, CT_CONFIG), configFile);
|
// copyFile(getConfigFile(preset, CT_CONFIG), configFile);
|
||||||
@@ -262,7 +262,7 @@ void web_init() {
|
|||||||
*/
|
*/
|
||||||
server.on("/check", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/check", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
myNotAsincActions->make(do_GETLASTVERSION);
|
myNotAsincActions->make(do_GETLASTVERSION);
|
||||||
pm.info("firmware version: " + lastVersion);
|
SerialPrint("I","module","firmware version: " + lastVersion);
|
||||||
|
|
||||||
if (!FLASH_4MB) {
|
if (!FLASH_4MB) {
|
||||||
lastVersion = "less";
|
lastVersion = "less";
|
||||||
@@ -302,7 +302,7 @@ void web_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setConfigParam(const char* param, const String& value) {
|
void setConfigParam(const char* param, const String& value) {
|
||||||
pm.info("set " + String(param) + ": " + value);
|
SerialPrint("I","module","set " + String(param) + ": " + value);
|
||||||
jsonWriteStr(configSetupJson, param, value);
|
jsonWriteStr(configSetupJson, param, value);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace HttpServer {
|
namespace HttpServer {
|
||||||
|
|
||||||
static const char *MODULE = "Http";
|
|
||||||
/* Forward declaration */
|
/* Forward declaration */
|
||||||
void initOta();
|
void initOta();
|
||||||
void initMDNS();
|
void initMDNS();
|
||||||
@@ -29,17 +29,17 @@ void init() {
|
|||||||
server.serveStatic("/", LittleFS, "/").setDefaultFile("index.htm").setAuthentication(login.c_str(), pass.c_str());
|
server.serveStatic("/", LittleFS, "/").setDefaultFile("index.htm").setAuthentication(login.c_str(), pass.c_str());
|
||||||
|
|
||||||
server.onNotFound([](AsyncWebServerRequest *request) {
|
server.onNotFound([](AsyncWebServerRequest *request) {
|
||||||
pm.error("not found:\n" + getRequestInfo(request));
|
SerialPrint("[E]","module","not found:\n" + getRequestInfo(request));
|
||||||
request->send(404);
|
request->send(404);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.onFileUpload([](AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) {
|
server.onFileUpload([](AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) {
|
||||||
// TODO
|
// TODO
|
||||||
if (!index) {
|
if (!index) {
|
||||||
pm.info("start upload " + filename);
|
SerialPrint("I","module","start upload " + filename);
|
||||||
}
|
}
|
||||||
if (final) {
|
if (final) {
|
||||||
pm.info("finish upload: " + prettyBytes(index + len));
|
SerialPrint("I","module","finish upload: " + prettyBytes(index + len));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ void init() {
|
|||||||
|
|
||||||
server.on("/cmd", HTTP_GET, [](AsyncWebServerRequest *request) {
|
server.on("/cmd", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||||
String cmdStr = request->getParam("command")->value();
|
String cmdStr = request->getParam("command")->value();
|
||||||
pm.info("do: " + cmdStr);
|
SerialPrint("I","module","do: " + cmdStr);
|
||||||
loopCmdAdd(cmdStr);
|
loopCmdAdd(cmdStr);
|
||||||
request->send(200, "text/html", "OK");
|
request->send(200, "text/html", "OK");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
static const char* MODULE = "Widget";
|
|
||||||
|
|
||||||
const String getWidgetFile(const String& name);
|
const String getWidgetFile(const String& name);
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ bool loadWidget(const String& filename, String& buf) {
|
|||||||
buf = readFile(getWidgetFile(filename), 2048);
|
buf = readFile(getWidgetFile(filename), 2048);
|
||||||
bool res = !(buf == "Failed" || buf == "Large");
|
bool res = !(buf == "Failed" || buf == "Large");
|
||||||
if (!res) {
|
if (!res) {
|
||||||
pm.error("on load" + filename);
|
SerialPrint("[E]","module","on load" + filename);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/main.cpp
33
src/main.cpp
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
void not_async_actions();
|
void not_async_actions();
|
||||||
|
|
||||||
static const char* MODULE = "Main";
|
|
||||||
|
|
||||||
Timings metric;
|
Timings metric;
|
||||||
boolean initialized = false;
|
boolean initialized = false;
|
||||||
@@ -36,57 +35,57 @@ void setup() {
|
|||||||
myNotAsincActions = new NotAsinc(do_LAST);
|
myNotAsincActions = new NotAsinc(do_LAST);
|
||||||
myScenario = new Scenario();
|
myScenario = new Scenario();
|
||||||
|
|
||||||
pm.info("FS");
|
SerialPrint("I","module","FS");
|
||||||
fileSystemInit();
|
fileSystemInit();
|
||||||
|
|
||||||
pm.info("Config");
|
SerialPrint("I","module","Config");
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
pm.info("Clock");
|
SerialPrint("I","module","Clock");
|
||||||
clock_init();
|
clock_init();
|
||||||
|
|
||||||
pm.info("Commands");
|
SerialPrint("I","module","Commands");
|
||||||
cmd_init();
|
cmd_init();
|
||||||
|
|
||||||
pm.info("Sensors");
|
SerialPrint("I","module","Sensors");
|
||||||
sensorsInit();
|
sensorsInit();
|
||||||
|
|
||||||
pm.info("Init");
|
SerialPrint("I","module","Init");
|
||||||
all_init();
|
all_init();
|
||||||
|
|
||||||
pm.info("Network");
|
SerialPrint("I","module","Network");
|
||||||
startSTAMode();
|
startSTAMode();
|
||||||
|
|
||||||
pm.info("Uptime");
|
SerialPrint("I","module","Uptime");
|
||||||
uptime_init();
|
uptime_init();
|
||||||
|
|
||||||
pm.info("Updater");
|
SerialPrint("I","module","Updater");
|
||||||
upgradeInit();
|
upgradeInit();
|
||||||
|
|
||||||
pm.info("HttpServer");
|
SerialPrint("I","module","HttpServer");
|
||||||
HttpServer::init();
|
HttpServer::init();
|
||||||
|
|
||||||
pm.info("WebAdmin");
|
SerialPrint("I","module","WebAdmin");
|
||||||
web_init();
|
web_init();
|
||||||
|
|
||||||
pm.info("InitSt");
|
SerialPrint("I","module","InitSt");
|
||||||
initSt();
|
initSt();
|
||||||
|
|
||||||
pm.info("asyncUdpInit");
|
SerialPrint("I","module","asyncUdpInit");
|
||||||
asyncUdpInit();
|
asyncUdpInit();
|
||||||
|
|
||||||
#ifdef UDP_ENABLED
|
#ifdef UDP_ENABLED
|
||||||
pm.info("Broadcast UDP");
|
SerialPrint("I","module","Broadcast UDP");
|
||||||
udpInit();
|
udpInit();
|
||||||
#endif
|
#endif
|
||||||
#ifdef SSDP_EN
|
#ifdef SSDP_EN
|
||||||
pm.info("Ssdp Init");
|
SerialPrint("I","module","Ssdp Init");
|
||||||
SsdpInit();
|
SsdpInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ts.add(
|
ts.add(
|
||||||
TEST, 1000 * 60, [&](void*) {
|
TEST, 1000 * 60, [&](void*) {
|
||||||
pm.info(printMemoryStatus());
|
SerialPrint("I","module",printMemoryStatus());
|
||||||
|
|
||||||
},
|
},
|
||||||
nullptr, true);
|
nullptr, true);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "udp_.h"
|
#include "udp_.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
static const char* MODULE = "Udp";
|
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
IPAddress udp_multicastIP(255, 255, 255, 255);
|
IPAddress udp_multicastIP(255, 255, 255, 255);
|
||||||
@@ -49,7 +48,7 @@ void udpInit() {
|
|||||||
ts.add(
|
ts.add(
|
||||||
UDP, udp_period, [&](void*) {
|
UDP, udp_period, [&](void*) {
|
||||||
if (jsonReadBool(configSetupJson, "udponoff") && isNetworkActive() && !udp_busy) {
|
if (jsonReadBool(configSetupJson, "udponoff") && isNetworkActive() && !udp_busy) {
|
||||||
pm.info("send info");
|
SerialPrint("I","module","send info");
|
||||||
String payload = "iotm;";
|
String payload = "iotm;";
|
||||||
payload += chipId;
|
payload += chipId;
|
||||||
payload += ";";
|
payload += ";";
|
||||||
@@ -85,7 +84,7 @@ void loopUdp() {
|
|||||||
char udp_packet[255];
|
char udp_packet[255];
|
||||||
remote_ip = udp.remoteIP().toString();
|
remote_ip = udp.remoteIP().toString();
|
||||||
|
|
||||||
pm.info(prettyBytes(packetSize) + " from " + remote_ip + ":" + udp.remotePort());
|
SerialPrint("I","module",prettyBytes(packetSize) + " from " + remote_ip + ":" + udp.remotePort());
|
||||||
|
|
||||||
int len = udp.read(udp_packet, 255);
|
int len = udp.read(udp_packet, 255);
|
||||||
if (len) {
|
if (len) {
|
||||||
@@ -120,7 +119,7 @@ void handleUdp_esp32() {
|
|||||||
|
|
||||||
void do_udp_data_parse() {
|
void do_udp_data_parse() {
|
||||||
if (received.indexOf("mqttServer") >= 0) {
|
if (received.indexOf("mqttServer") >= 0) {
|
||||||
pm.info("received setting");
|
SerialPrint("I","module","received setting");
|
||||||
jsonWriteStr(configSetupJson, "mqttServer", jsonReadStr(received, "mqttServer"));
|
jsonWriteStr(configSetupJson, "mqttServer", jsonReadStr(received, "mqttServer"));
|
||||||
jsonWriteInt(configSetupJson, "mqttPort", jsonReadInt(received, "mqttPort"));
|
jsonWriteInt(configSetupJson, "mqttPort", jsonReadInt(received, "mqttPort"));
|
||||||
jsonWriteStr(configSetupJson, "mqttPrefix", jsonReadStr(received, "mqttPrefix"));
|
jsonWriteStr(configSetupJson, "mqttPrefix", jsonReadStr(received, "mqttPrefix"));
|
||||||
@@ -160,7 +159,7 @@ void send_mqtt_to_udp() {
|
|||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
udp.broadcast(mqtt_data.c_str());
|
udp.broadcast(mqtt_data.c_str());
|
||||||
#endif
|
#endif
|
||||||
pm.info("sent info");
|
SerialPrint("I","module","sent info");
|
||||||
udp_busy = false;
|
udp_busy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user