Debug changed

This commit is contained in:
Dmitry Borisenko
2020-09-17 17:27:44 +03:00
parent fc91a60bab
commit 0a212e0933
30 changed files with 157 additions and 148 deletions

View File

@@ -3,7 +3,7 @@
#include "Module/Terminal.h"
#include "Errors.h"
static const char *MODULE = "Cmd";
void loopCmdAdd(const String &cmdStr) {
orderBuf += cmdStr;
@@ -45,7 +45,7 @@ void spaceCmdExecute(String &cmdStr) {
void loopCmdExecute() {
if (orderBuf.length()) {
String tmp = selectToMarker(orderBuf, ","); //выделяем первую команду rel 5 1,
pm.info("do: " + tmp);
SerialPrint("I","module","do: " + tmp);
sCmd.readStr(tmp); //выполняем
orderBuf = deleteBeforeDelimiter(orderBuf, ","); //осекаем
}

View File

@@ -3,7 +3,7 @@
#include <Wire.h>
static const char* MODULE = "I2C";
I2CScanner::I2CScanner(String& out) : BusScanner(TAG_I2C, out, 2){};
@@ -12,12 +12,12 @@ void I2CScanner::init() {
}
boolean I2CScanner::syncScan() {
pm.info("scanning...");
SerialPrint("I","module","scanning...");
size_t cnt = 0;
for (uint8_t i = 8; i < 120; i++) {
Wire.beginTransmission(i);
if (Wire.endTransmission() == 0) {
pm.info("found: " + i);
SerialPrint("I","module","found: " + i);
addResult(i, i < 119);
cnt++;
}

View File

@@ -5,7 +5,6 @@
void sendLogData(String file, String topic);
static const char* MODULE = "Log";
#ifdef LOGGING_ENABLED
//===============================================Логирование============================================================
@@ -30,7 +29,7 @@ void logging() {
LOG1, period_min.toInt() * 1000 * 60, [&](void*) {
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));
pm.info("logging for " + tmp_buf_1 + " done");
SerialPrint("I","module","logging for " + tmp_buf_1 + " done");
},
nullptr, false);
}
@@ -39,7 +38,7 @@ void logging() {
LOG2, period_min.toInt() * 1000 * 60, [&](void*) {
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));
pm.info("logging for " + tmp_buf_2 + " done");
SerialPrint("I","module","logging for " + tmp_buf_2 + " done");
},
nullptr, false);
}
@@ -48,7 +47,7 @@ void logging() {
LOG3, period_min.toInt() * 1000 * 60, [&](void*) {
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));
pm.info("logging for " + tmp_buf_3 + " done");
SerialPrint("I","module","logging for " + tmp_buf_3 + " done");
},
nullptr, false);
}
@@ -57,7 +56,7 @@ void logging() {
LOG4, period_min.toInt() * 1000 * 60, [&](void*) {
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));
pm.info("logging for " + tmp_buf_4 + " done");
SerialPrint("I","module","logging for " + tmp_buf_4 + " done");
},
nullptr, false);
}
@@ -66,7 +65,7 @@ void logging() {
LOG5, period_min.toInt() * 1000 * 60, [&](void*) {
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));
pm.info("logging for " + tmp_buf_5 + " done");
SerialPrint("I","module","logging for " + tmp_buf_5 + " done");
},
nullptr, false);
}
@@ -79,7 +78,7 @@ void deleteOldDate(const String filename, size_t max_lines_cnt, String payload)
String log_date = readFile(filename, 5120);
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) {
removeFile(filename);
@@ -136,7 +135,7 @@ void sendLogData(String file, String topic) {
value = "";
log_date = "";
json_array = "{\"status\":[" + json_array + "]}";
pm.info(json_array);
SerialPrint("I","module",json_array);
MqttClient::publishChart(topic, json_array);
}

View File

@@ -6,7 +6,7 @@
#include "Global.h"
#include "Init.h"
static const char* MODULE = "Mqtt";
namespace MqttClient {
@@ -35,7 +35,7 @@ void init() {
if (isNetworkActive()) {
if (mqtt.connected()) {
if (!connected) {
pm.info("OK");
SerialPrint("I","module","OK");
setLedStatus(LED_OFF);
connected = true;
}
@@ -45,7 +45,7 @@ void init() {
}
} else {
if (connected) {
pm.error("connection lost");
SerialPrint("[E]","module","connection lost");
connected = false;
}
ts.remove(WIFI_MQTT_CONNECTION_CHECK);
@@ -57,7 +57,7 @@ void init() {
}
void disconnect() {
pm.info("disconnect");
SerialPrint("I","module","disconnect");
mqtt.disconnect();
}
@@ -74,7 +74,7 @@ void loop() {
}
void subscribe() {
pm.info("subscribe");
SerialPrint("I","module","subscribe");
mqtt.subscribe(mqttPrefix.c_str());
mqtt.subscribe((mqttRootDevice + "/+/control").c_str());
mqtt.subscribe((mqttRootDevice + "/order").c_str());
@@ -84,11 +84,11 @@ void subscribe() {
}
boolean connect() {
pm.info("connect");
SerialPrint("I","module","connect");
String addr = jsonReadStr(configSetupJson, "mqttServer");
if (!addr) {
pm.error("no broker address");
SerialPrint("[E]","module","no broker address");
return false;
}
@@ -100,20 +100,20 @@ boolean connect() {
mqttPrefix = jsonReadStr(configSetupJson, "mqttPrefix");
mqttRootDevice = mqttPrefix + "/" + chipId;
pm.info("broker " + addr + ":" + String(port, DEC));
pm.info("topic " + mqttRootDevice);
SerialPrint("I","module","broker " + addr + ":" + String(port, DEC));
SerialPrint("I","module","topic " + mqttRootDevice);
setLedStatus(LED_FAST);
mqtt.setServer(addr.c_str(), port);
bool res = false;
if (!mqtt.connected()) {
if (mqtt.connect(chipId.c_str(), user.c_str(), pass.c_str())) {
pm.info("connected");
SerialPrint("I","module","connected");
setLedStatus(LED_OFF);
subscribe();
res = true;
} 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);
}
}
@@ -123,7 +123,7 @@ boolean connect() {
void handleSubscribedUpdates(char* topic, uint8_t* payload, size_t length) {
String topicStr = String(topic);
pm.info(topicStr);
SerialPrint("I","module",topicStr);
String payloadStr;
@@ -132,10 +132,10 @@ void handleSubscribedUpdates(char* topic, uint8_t* payload, size_t length) {
payloadStr += (char)payload[i];
}
pm.info(payloadStr);
SerialPrint("I","module",payloadStr);
if (payloadStr.startsWith("HELLO")) {
pm.info("Full update");
SerialPrint("I","module","Full update");
publishWidgets();
publishState();
#ifdef LOGGING_ENABLED
@@ -184,7 +184,7 @@ boolean publish(const String& topic, const String& data) {
boolean publishData(const String& topic, const String& data) {
String path = mqttRootDevice + "/" + topic;
if (!publish(path, data)) {
pm.error("on publish data");
SerialPrint("[E]","module","on publish data");
return false;
}
return true;
@@ -193,7 +193,7 @@ boolean publishData(const String& topic, const String& data) {
boolean publishChart(const String& topic, const String& data) {
String path = mqttRootDevice + "/" + topic + "/status";
if (!publish(path, data)) {
pm.error("on publish chart");
SerialPrint("[E]","module","on publish chart");
return false;
}
return true;
@@ -235,7 +235,7 @@ void publishWidgets() {
Serial.println("[V] " + line);
psn_1 = psn_2 + 1;
} while (psn_2 + 2 < all_widgets.length());
getMemoryLoad("[I] after send all widgets");
getMemoryLoad("I after send all widgets");
}
}
#endif
@@ -244,12 +244,12 @@ void publishWidgets() {
void publishWidgets() {
auto file = seekFile("layout.txt");
if (!file) {
pm.error("no file layout.txt");
SerialPrint("[E]","module","no file layout.txt");
return;
}
while (file.available()) {
String payload = file.readStringUntil('\n');
pm.info("widgets: " + payload);
SerialPrint("I","module","widgets: " + payload);
publishData("config", payload);
}
file.close();

View File

@@ -23,15 +23,15 @@ void pushControl() {
const char* logServer = "api.pushingbox.com";
String deviceId = jsonReadStr(configSetupJson, "pushingbox_id");
Serial.println("- starting client");
//Serial.println("- starting client");
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)) {
Serial.println("- not connected");
//Serial.println("- not connected");
} else {
Serial.println("- succesfully connected");
//Serial.println("- succesfully connected");
String postStr = "devid=";
postStr += String(deviceId);
@@ -44,7 +44,7 @@ void pushControl() {
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("Host: api.pushingbox.com\n"));
@@ -56,5 +56,5 @@ void pushControl() {
client_push.print(postStr);
}
client_push.stop();
Serial.println("- stopping the client");
//Serial.println("- stopping the client");
}

View File

@@ -35,9 +35,9 @@ void asyncUdpInit() {
Serial.print(data);
if (udpPacketValidation(data)) {
udpPacketParse(data);
Serial.println("', Packet valid");
//Serial.println("', Packet valid");
} else {
Serial.println("', Packet invalid");
//Serial.println("', Packet invalid");
}
//reply to the client

View File

@@ -2,7 +2,7 @@
#include "Global.h"
#include "Class/ScenarioClass.h"
static const char* MODULE = "Scen";
boolean isScenarioEnabled() {
return jsonReadBool(configSetupJson, "scen") && eventBuf != "";
@@ -58,7 +58,7 @@ void loopScenario() {
if (flag) {
scenBlok = deleteBeforeDelimiter(scenBlok, "\n"); // удаляем строку самого сценария оставляя только команды
pm.info("do: " + scenBlok);
SerialPrint("I","module","do: " + scenBlok);
spaceCmdExecute(scenBlok); // выполняем все команды
}
}

View File

@@ -57,7 +57,7 @@
// //eventGen(dhtT_value_name, "");
// //jsonWriteStr(configLiveJson, 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, "");
// //jsonWriteStr(configLiveJson, 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", "");
// MqttClient::publishStatus("dhtPerception", final_line);
// 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);
// eventGen("dhtComfort", "");
// 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);
// eventGen("dhtDewpoint", "");
// MqttClient::publishStatus("dhtDewpoint", String(value));
// Serial.println("[I] sensor 'dhtDewpoint' data: " + String(value));
// Serial.println("I sensor 'dhtDewpoint' data: " + String(value));
// }
//}
//#endif
@@ -272,7 +272,7 @@
// //jsonWriteStr(configLiveJson, bmp280T_value_name, String(value));
// //eventGen(bmp280T_value_name, "");
// //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
@@ -304,7 +304,7 @@
// //jsonWriteStr(configLiveJson, bmp280P_value_name, String(value));
// //eventGen(bmp280P_value_name, "");
// //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));
// //eventGen(bme280T_value_name, "");
// //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
@@ -353,7 +353,7 @@
// //jsonWriteStr(configLiveJson, bme280P_value_name, String(value));
// //eventGen(bme280P_value_name, "");
// //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
@@ -376,7 +376,7 @@
// //jsonWriteStr(configLiveJson, bme280H_value_name, String(value));
// //eventGen(bme280H_value_name, "");
// //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
@@ -401,5 +401,5 @@
//
// //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));
//}

View File

@@ -11,8 +11,8 @@ void Timer_countdown_init() {
int i = 0;
do {
String timer = selectFromMarkerToMarker(old_line, ",", i);
Serial.print("timer no " + String(i) + ": ");
Serial.println(timer);
//Serial.print("timer no " + String(i) + ": ");
//Serial.println(timer);
if (timer == "not found" || timer == "") return;
int number = selectToMarker(timer, ":").toInt();
int time = readTimer(number);

View File

@@ -4,7 +4,7 @@
#include "ESP8266.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";
void upgradeInit() {
@@ -23,7 +23,7 @@ void upgradeInit() {
if (isNetworkActive()) {
getLastVersion();
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);
setupBackup = configSetupJson;
pm.info("update data");
SerialPrint("I","module","update data");
WiFiClient wifiClient;
#ifdef ESP8266
ESPhttpUpdate.rebootOnUpdate(false);
@@ -68,22 +68,22 @@ void upgrade_firmware() {
saveConfig();
pm.info("done!");
SerialPrint("I","module","done!");
} else {
pm.error("on data");
SerialPrint("[E]","module","on data");
return;
}
Serial.println("update firmware");
//Serial.println("update firmware");
#ifdef ESP8266
ret = ESPhttpUpdate.update(wifiClient, F("http://91.204.228.124:1100/update/esp8266/esp32-esp8266_iot-manager_modules_firmware.ino.bin"));
#else
ret = httpUpdate.update(client_for_upgrade, "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.ino.bin");
#endif
if (ret == HTTP_UPDATE_OK) {
pm.info("done! restart...");
SerialPrint("I","module","done! restart...");
ESP.restart();
} else {
pm.error("on firmware");
SerialPrint("[E]","module","on firmware");
}
}

View File

@@ -1,7 +1,7 @@
#include "Utils/FileUtils.h"
#include "Utils/PrintMessage.h"
static const char* MODULE = "FS";
const String filepath(const String& filename) {
return filename.startsWith("/") ? filename : "/" + filename;
@@ -9,7 +9,7 @@ const String filepath(const String& filename) {
bool fileSystemInit() {
if (!LittleFS.begin()) {
pm.error("init");
SerialPrint("[E]","module","init");
return false;
}
return true;
@@ -19,10 +19,10 @@ void removeFile(const String& filename) {
String path = filepath(filename);
if (LittleFS.exists(path)) {
if (!LittleFS.remove(path)) {
pm.error("remove " + path);
SerialPrint("[E]","module","remove " + path);
}
} 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);
auto file = LittleFS.open(path, "r");
if (!file) {
pm.error("open " + path);
SerialPrint("[E]","module","open " + path);
}
// поставим курсор в начало файла
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) {
String srcPath = filepath(src);
String dstPath = filepath(dst);
pm.info("copy " + srcPath + " to " + dstPath);
SerialPrint("I","module","copy " + srcPath + " to " + dstPath);
if (!LittleFS.exists(srcPath)) {
pm.error("not exist: " + srcPath);
SerialPrint("[E]","module","not exist: " + srcPath);
return false;
}
if (LittleFS.exists(dstPath)) {
if (!overwrite) {
pm.error("already exist: " + dstPath);
SerialPrint("[E]","module","already exist: " + dstPath);
return false;
}
LittleFS.remove(dstPath);

View 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);
}

View File

@@ -3,7 +3,6 @@
#include "Global.h"
#include "Utils/PrintMessage.h"
static const char* MODULE = "Main";
const String getUniqueId(const char* name) {
return String(name) + getMacAddress();
@@ -25,7 +24,7 @@ const String getChipId() {
void setChipId() {
chipId = getChipId();
pm.info("id: " + chipId);
SerialPrint("I","module","id: " + chipId);
}
#ifdef ESP8266

View File

@@ -1,10 +1,10 @@
#include "Utils/WiFiUtils.h"
static const char* MODULE = "WiFi";
void startSTAMode() {
setLedStatus(LED_SLOW);
pm.info("STA Mode");
SerialPrint("I","module","STA Mode");
String ssid = jsonReadStr(configSetupJson, "routerssid");
String passwd = jsonReadStr(configSetupJson, "routerpass");
@@ -14,7 +14,7 @@ void startSTAMode() {
WiFi.begin();
} else {
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
switch (connRes) {
case WL_NO_SSID_AVAIL: {
pm.error("no network");
SerialPrint("[E]","module","no network");
keepConnecting = false;
} break;
case WL_CONNECTED: {
String hostIpStr = WiFi.localIP().toString();
pm.info("http://" + hostIpStr);
SerialPrint("I","module","http://" + hostIpStr);
jsonWriteStr(configSetupJson, "ip", hostIpStr);
keepConnecting = false;
} break;
case WL_CONNECT_FAILED: {
pm.error("check credentials");
SerialPrint("[E]","module","check credentials");
jsonWriteInt(configOptionJson, "pass_status", 1);
keepConnecting = false;
} break;
@@ -52,14 +52,14 @@ void startSTAMode() {
MqttClient::init();
setLedStatus(LED_OFF);
} else {
pm.error("failed: " + String(connRes, DEC));
SerialPrint("[E]","module","failed: " + String(connRes, DEC));
startAPMode();
};
}
bool startAPMode() {
setLedStatus(LED_ON);
pm.info("AP Mode");
SerialPrint("I","module","AP Mode");
String ssid = jsonReadStr(configSetupJson, "apssid");
String passwd = jsonReadStr(configSetupJson, "appass");
@@ -68,14 +68,14 @@ bool startAPMode() {
WiFi.softAP(ssid.c_str(), passwd.c_str());
String hostIpStr = WiFi.softAPIP().toString();
pm.info("Host IP: " + hostIpStr);
SerialPrint("I","module","Host IP: " + hostIpStr);
jsonWriteStr(configSetupJson, "ip", hostIpStr);
ts.add(
WIFI_SCAN, 10 * 1000,
[&](void*) {
String sta_ssid = jsonReadStr(configSetupJson, "routerssid");
pm.info("scanning for " + sta_ssid);
SerialPrint("I","module","scanning for " + sta_ssid);
if (scanWiFi(sta_ssid)) {
ts.remove(WIFI_SCAN);
startSTAMode();
@@ -89,25 +89,25 @@ bool startAPMode() {
boolean scanWiFi(String ssid) {
bool res = false;
int8_t n = WiFi.scanComplete();
pm.info("scan result: " + String(n, DEC));
SerialPrint("I","module","scan result: " + String(n, DEC));
if (n == -2) {
// не было запущено, запускаем
pm.info("start scanning");
SerialPrint("I","module","start scanning");
// async, show_hidden
WiFi.scanNetworks(true, false);
} else if (n == -1) {
// все еще выполняется
pm.info("scanning in progress");
SerialPrint("I","module","scanning in progress");
} else if (n == 0) {
// не найдена ни одна сеть
pm.info("no networks found");
SerialPrint("I","module","no networks found");
WiFi.scanNetworks(true, false);
} else if (n > 0) {
for (int8_t i = 0; i < n; i++) {
if (WiFi.SSID(i) == ssid) {
res = true;
}
pm.info((res ? "*" : "") + String(i, DEC) + ") " + WiFi.SSID(i));
SerialPrint("I","module",(res ? "*" : "") + String(i, DEC) + ") " + WiFi.SSID(i));
}
}
return res;

View File

@@ -6,9 +6,9 @@
#include "Global.h"
#include "ItemsList.h"
void initSt() {
Serial.print("[I] [Stat] New device registation: ");
Serial.println(addNewDevice());
addNewDevice();
decide();
if (TELEMETRY_UPDATE_INTERVAL_MIN) {
ts.add(
@@ -16,9 +16,7 @@ void initSt() {
static bool secondTime = false;
if (secondTime) plusOneHour();
secondTime = true;
Serial.print("[I] [Stat] Update device status: ");
Serial.println(updateDeviceStatus());
updateDeviceStatus();
},
nullptr, true);
}
@@ -27,17 +25,17 @@ void initSt() {
void decide() {
if ((WiFi.status() == WL_CONNECTED)) {
uint8_t cnt = getNewElementNumber("stat.txt");
Serial.print("[I] [Stat] Total reset number: ");
Serial.print(cnt);
Serial.print(" ");
SerialPrint("I","module","Total reset number: " + String(cnt));
//Serial.print(cnt);
//Serial.print(" ");
if (cnt <= 3) {
Serial.println("(get)");
//Serial.println("(get)");
getPsn();
} else {
if (cnt % 5) {
Serial.println("(skip)");
//Serial.println("(skip)");
} else {
Serial.println("(get)");
//Serial.println("(get)");
getPsn();
}
}
@@ -53,8 +51,7 @@ void getPsn() {
//String city = jsonReadStr(res, "city");
//String country = jsonReadStr(res, "country");
//String region = jsonReadStr(res, "region");
Serial.print("[I] [Stat] Update device psn: ");
Serial.println(updateDevicePsn(lat, lon, "1000"));
updateDevicePsn(lat, lon, "1000");
}
}
@@ -86,6 +83,7 @@ String addNewDevice() {
}
http.end();
}
SerialPrint("I","module","New device registaration: " + ret);
return ret;
}
@@ -114,6 +112,7 @@ String updateDevicePsn(String lat, String lon, String accur) {
}
http.end();
}
SerialPrint("I","module","Update device psn: " + ret);
return ret;
}
@@ -142,6 +141,7 @@ String updateDeviceStatus() {
}
http.end();
}
SerialPrint("I","module","Update device data: " + ret);
return ret;
}
@@ -149,8 +149,9 @@ String getUptimeTotal() {
static int hrs;
EEPROM.begin(512);
hrs = eeGetInt(0);
SerialPrint("I","module","Total running hrs: " + String(hrs));
String hrsStr = prettySeconds(hrs * 60 * 60);
//Serial.println(hrsStr);
SerialPrint("I","module","Total running hrs (f): " + hrsStr);
return hrsStr;
}

View File

@@ -4,7 +4,7 @@
#include "Init.h"
#include "Class/NotAsinc.h"
static const char* MODULE = "Web";
bool parseRequestForPreset(AsyncWebServerRequest* request, uint8_t& preset) {
if (request->hasArg("preset")) {
@@ -32,7 +32,7 @@ void web_init() {
//==============================presets===========================================================================================================
//uint8_t preset;
//if (parseRequestForPreset(request, preset)) {
// pm.info("activate #" + String(preset, DEC));
// SerialPrint("I","module","activate #" + String(preset, DEC));
// String configFile = DEVICE_CONFIG_FILE;
// String scenarioFile = DEVICE_SCENARIO_FILE;
// copyFile(getConfigFile(preset, CT_CONFIG), configFile);
@@ -262,7 +262,7 @@ void web_init() {
*/
server.on("/check", HTTP_GET, [](AsyncWebServerRequest* request) {
myNotAsincActions->make(do_GETLASTVERSION);
pm.info("firmware version: " + lastVersion);
SerialPrint("I","module","firmware version: " + lastVersion);
if (!FLASH_4MB) {
lastVersion = "less";
@@ -302,7 +302,7 @@ void web_init() {
}
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);
saveConfig();
}

View File

@@ -6,7 +6,7 @@
namespace HttpServer {
static const char *MODULE = "Http";
/* Forward declaration */
void initOta();
void initMDNS();
@@ -29,17 +29,17 @@ void init() {
server.serveStatic("/", LittleFS, "/").setDefaultFile("index.htm").setAuthentication(login.c_str(), pass.c_str());
server.onNotFound([](AsyncWebServerRequest *request) {
pm.error("not found:\n" + getRequestInfo(request));
SerialPrint("[E]","module","not found:\n" + getRequestInfo(request));
request->send(404);
});
server.onFileUpload([](AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) {
// TODO
if (!index) {
pm.info("start upload " + filename);
SerialPrint("I","module","start upload " + filename);
}
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) {
String cmdStr = request->getParam("command")->value();
pm.info("do: " + cmdStr);
SerialPrint("I","module","do: " + cmdStr);
loopCmdAdd(cmdStr);
request->send(200, "text/html", "OK");
});

View File

@@ -1,6 +1,5 @@
#include "Global.h"
static const char* MODULE = "Widget";
const String getWidgetFile(const String& name);
@@ -8,7 +7,7 @@ bool loadWidget(const String& filename, String& buf) {
buf = readFile(getWidgetFile(filename), 2048);
bool res = !(buf == "Failed" || buf == "Large");
if (!res) {
pm.error("on load" + filename);
SerialPrint("[E]","module","on load" + filename);
}
return res;
}

View File

@@ -17,7 +17,6 @@
void not_async_actions();
static const char* MODULE = "Main";
Timings metric;
boolean initialized = false;
@@ -36,57 +35,57 @@ void setup() {
myNotAsincActions = new NotAsinc(do_LAST);
myScenario = new Scenario();
pm.info("FS");
SerialPrint("I","module","FS");
fileSystemInit();
pm.info("Config");
SerialPrint("I","module","Config");
loadConfig();
pm.info("Clock");
SerialPrint("I","module","Clock");
clock_init();
pm.info("Commands");
SerialPrint("I","module","Commands");
cmd_init();
pm.info("Sensors");
SerialPrint("I","module","Sensors");
sensorsInit();
pm.info("Init");
SerialPrint("I","module","Init");
all_init();
pm.info("Network");
SerialPrint("I","module","Network");
startSTAMode();
pm.info("Uptime");
SerialPrint("I","module","Uptime");
uptime_init();
pm.info("Updater");
SerialPrint("I","module","Updater");
upgradeInit();
pm.info("HttpServer");
SerialPrint("I","module","HttpServer");
HttpServer::init();
pm.info("WebAdmin");
SerialPrint("I","module","WebAdmin");
web_init();
pm.info("InitSt");
SerialPrint("I","module","InitSt");
initSt();
pm.info("asyncUdpInit");
SerialPrint("I","module","asyncUdpInit");
asyncUdpInit();
#ifdef UDP_ENABLED
pm.info("Broadcast UDP");
SerialPrint("I","module","Broadcast UDP");
udpInit();
#endif
#ifdef SSDP_EN
pm.info("Ssdp Init");
SerialPrint("I","module","Ssdp Init");
SsdpInit();
#endif
ts.add(
TEST, 1000 * 60, [&](void*) {
pm.info(printMemoryStatus());
SerialPrint("I","module",printMemoryStatus());
},
nullptr, true);

View File

@@ -3,7 +3,6 @@
#include "udp_.h"
#include "Global.h"
static const char* MODULE = "Udp";
#ifdef ESP8266
IPAddress udp_multicastIP(255, 255, 255, 255);
@@ -49,7 +48,7 @@ void udpInit() {
ts.add(
UDP, udp_period, [&](void*) {
if (jsonReadBool(configSetupJson, "udponoff") && isNetworkActive() && !udp_busy) {
pm.info("send info");
SerialPrint("I","module","send info");
String payload = "iotm;";
payload += chipId;
payload += ";";
@@ -85,7 +84,7 @@ void loopUdp() {
char udp_packet[255];
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);
if (len) {
@@ -120,7 +119,7 @@ void handleUdp_esp32() {
void do_udp_data_parse() {
if (received.indexOf("mqttServer") >= 0) {
pm.info("received setting");
SerialPrint("I","module","received setting");
jsonWriteStr(configSetupJson, "mqttServer", jsonReadStr(received, "mqttServer"));
jsonWriteInt(configSetupJson, "mqttPort", jsonReadInt(received, "mqttPort"));
jsonWriteStr(configSetupJson, "mqttPrefix", jsonReadStr(received, "mqttPrefix"));
@@ -160,7 +159,7 @@ void send_mqtt_to_udp() {
#ifdef ESP32
udp.broadcast(mqtt_data.c_str());
#endif
pm.info("sent info");
SerialPrint("I","module","sent info");
udp_busy = false;
}