mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
tiny->bk7231, WS ping? fix clear config
This commit is contained in:
@@ -134,7 +134,8 @@ else:
|
|||||||
deviceType = 'esp32*'
|
deviceType = 'esp32*'
|
||||||
if not 'esp32' in deviceName:
|
if not 'esp32' in deviceName:
|
||||||
deviceType = 'esp82*'
|
deviceType = 'esp82*'
|
||||||
|
if 'bk72' in deviceName:
|
||||||
|
deviceType = 'bk72*'
|
||||||
# генерируем файлы проекта на основе подготовленного профиля
|
# генерируем файлы проекта на основе подготовленного профиля
|
||||||
# заполняем конфигурационный файл прошивки параметрами из профиля
|
# заполняем конфигурационный файл прошивки параметрами из профиля
|
||||||
with open("data_svelte/settings.json", "r", encoding='utf-8') as read_file:
|
with open("data_svelte/settings.json", "r", encoding='utf-8') as read_file:
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -103,6 +103,7 @@ enum TimerTask_t {
|
|||||||
TIMES, // периодические секундные проверки
|
TIMES, // периодические секундные проверки
|
||||||
PTASK,
|
PTASK,
|
||||||
ST,
|
ST,
|
||||||
|
PiWS,
|
||||||
END
|
END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -162,6 +162,8 @@ extern Time_t _time_local;
|
|||||||
extern Time_t _time_utc;
|
extern Time_t _time_utc;
|
||||||
extern bool _time_isTrust;
|
extern bool _time_isTrust;
|
||||||
|
|
||||||
|
#define WEBSOCKETS_CLIENT_MAX 5
|
||||||
|
extern int8_t ws_clients[WEBSOCKETS_CLIENT_MAX];
|
||||||
// extern unsigned long loopPeriod;
|
// extern unsigned long loopPeriod;
|
||||||
|
|
||||||
// extern DynamicJsonDocument settingsFlashJsonDoc;
|
// extern DynamicJsonDocument settingsFlashJsonDoc;
|
||||||
|
|||||||
@@ -19,6 +19,6 @@ void periodicWsSend();
|
|||||||
|
|
||||||
void sendFileToWsByFrames(const String& filename, const String& header, const String& json, int client_id, size_t frameSize);
|
void sendFileToWsByFrames(const String& filename, const String& header, const String& json, int client_id, size_t frameSize);
|
||||||
void sendStringToWs(const String& header, String& payload, int client_id);
|
void sendStringToWs(const String& header, String& payload, int client_id);
|
||||||
|
void disconnectWSClient(uint8_t client_id);
|
||||||
void sendDeviceList(uint8_t num);
|
void sendDeviceList(uint8_t num);
|
||||||
int getNumWSClients();
|
int getNumWSClients();
|
||||||
@@ -381,14 +381,14 @@ build_src_filter =
|
|||||||
+<modules/*.cpp>
|
+<modules/*.cpp>
|
||||||
${env:esp32_16mb_fromitems.build_src_filter}
|
${env:esp32_16mb_fromitems.build_src_filter}
|
||||||
|
|
||||||
[env:tiny]
|
[env:bk7231n]
|
||||||
extra_scripts = pre:tools/lt_fsbuildscript.py
|
extra_scripts = pre:tools/lt_fsbuildscript.py
|
||||||
lib_compat_mode = off
|
lib_compat_mode = off
|
||||||
lib_deps =
|
lib_deps =
|
||||||
LT_WebSockets
|
LT_WebSockets
|
||||||
https://github.com/Mit4el/ESPAsyncUDP#master
|
https://github.com/Mit4el/ESPAsyncUDP#master
|
||||||
${common_env_data.lib_deps_external}
|
${common_env_data.lib_deps_external}
|
||||||
${env:tiny_fromitems.lib_deps}
|
${env:bk7231n_fromitems.lib_deps}
|
||||||
lib_ignore = EspSoftwareSerial, HTTPUpdate, WebSockets
|
lib_ignore = EspSoftwareSerial, HTTPUpdate, WebSockets
|
||||||
platform = https://github.com/Mit4el/libretiny#master
|
platform = https://github.com/Mit4el/libretiny#master
|
||||||
framework = arduino
|
framework = arduino
|
||||||
@@ -411,7 +411,7 @@ build_src_filter =
|
|||||||
+<classes/*.cpp>
|
+<classes/*.cpp>
|
||||||
+<utils/*.cpp>
|
+<utils/*.cpp>
|
||||||
+<modules/*.cpp>
|
+<modules/*.cpp>
|
||||||
${env:tiny_fromitems.build_src_filter}
|
${env:bk7231n_fromitems.build_src_filter}
|
||||||
|
|
||||||
[env:esp8266_1mb_ota_fromitems]
|
[env:esp8266_1mb_ota_fromitems]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
@@ -882,9 +882,8 @@ build_src_filter =
|
|||||||
+<modules/virtual/VariableColor>
|
+<modules/virtual/VariableColor>
|
||||||
+<modules/virtual/VButton>
|
+<modules/virtual/VButton>
|
||||||
|
|
||||||
[env:tiny_fromitems]
|
[env:bk7231n_fromitems]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
plerup/EspSoftwareSerial
|
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
+<modules/virtual/Cron>
|
+<modules/virtual/Cron>
|
||||||
+<modules/virtual/Loging>
|
+<modules/virtual/Loging>
|
||||||
@@ -894,10 +893,6 @@ build_src_filter =
|
|||||||
+<modules/virtual/Timer>
|
+<modules/virtual/Timer>
|
||||||
+<modules/virtual/Variable>
|
+<modules/virtual/Variable>
|
||||||
+<modules/virtual/VButton>
|
+<modules/virtual/VButton>
|
||||||
+<modules/sensors/AnalogAdc>
|
|
||||||
+<modules/sensors/BL0937>
|
+<modules/sensors/BL0937>
|
||||||
+<modules/sensors/UART>
|
+<modules/exec/TelegramLT>
|
||||||
+<modules/exec/AnalogBtn>
|
|
||||||
+<modules/exec/ButtonIn>
|
|
||||||
+<modules/exec/ButtonOut>
|
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ String prevDate = "";
|
|||||||
bool firstTimeInit = true;
|
bool firstTimeInit = true;
|
||||||
|
|
||||||
// unsigned long loopPeriod;
|
// unsigned long loopPeriod;
|
||||||
|
int8_t ws_clients[WEBSOCKETS_CLIENT_MAX];
|
||||||
bool isTimeSynch = false;
|
bool isTimeSynch = false;
|
||||||
Time_t _time_local;
|
Time_t _time_local;
|
||||||
Time_t _time_utc;
|
Time_t _time_utc;
|
||||||
|
|||||||
36
src/Main.cpp
36
src/Main.cpp
@@ -110,7 +110,7 @@ void setup() {
|
|||||||
#endif // RESTART_DEBUG_INFO
|
#endif // RESTART_DEBUG_INFO
|
||||||
// Печать или оправка отладочной информации
|
// Печать или оправка отладочной информации
|
||||||
printDebugTrace();
|
printDebugTrace();
|
||||||
//startWatchDog();
|
startWatchDog();
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println(F("--------------started----------------"));
|
Serial.println(F("--------------started----------------"));
|
||||||
|
|
||||||
@@ -157,6 +157,19 @@ void setup() {
|
|||||||
SerialPrint("i", "i2c", F("i2c pins overriding done"));
|
SerialPrint("i", "i2c", F("i2c pins overriding done"));
|
||||||
}
|
}
|
||||||
#if defined(RESTART_DEBUG_INFO) && defined(ESP32) && !defined(esp32c3m_4mb)
|
#if defined(RESTART_DEBUG_INFO) && defined(ESP32) && !defined(esp32c3m_4mb)
|
||||||
|
esp_reset_reason_t esp_reason = esp_reset_reason();
|
||||||
|
if (esp_reason == ESP_RST_UNKNOWN || esp_reason == ESP_RST_POWERON)
|
||||||
|
bootloop_panic_count = 0;
|
||||||
|
/* else if (bootloop_panic_count == 3 || bootloop_panic_count == 0 ) bootloop_panic_count = 1;
|
||||||
|
else if (bootloop_panic_count == 2) bootloop_panic_count = 3;
|
||||||
|
else if (bootloop_panic_count == 1) bootloop_panic_count = 2;
|
||||||
|
else bootloop_panic_count = 0; */
|
||||||
|
Serial.println("bootloop_panic_count " + String(bootloop_panic_count));
|
||||||
|
if (bootloop_panic_count >3 )
|
||||||
|
{
|
||||||
|
//resetSettingsFlashByPanic();
|
||||||
|
bootloop_panic_count = 0;
|
||||||
|
}
|
||||||
if (bootloop_panic_count >= 3)
|
if (bootloop_panic_count >= 3)
|
||||||
{
|
{
|
||||||
resetSettingsFlashByPanic();
|
resetSettingsFlashByPanic();
|
||||||
@@ -167,7 +180,7 @@ void setup() {
|
|||||||
SerialPrint("E", "CORE", F("CONFIG and SCENARIO reset !!!"));
|
SerialPrint("E", "CORE", F("CONFIG and SCENARIO reset !!!"));
|
||||||
bootloop_panic_count = 0;
|
bootloop_panic_count = 0;
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
#endif // RESTART_DEBUG_INFO
|
#endif // RESTART_DEBUG_INFO
|
||||||
// настраиваем микроконтроллер
|
// настраиваем микроконтроллер
|
||||||
configure("/config.json");
|
configure("/config.json");
|
||||||
@@ -254,6 +267,25 @@ void setup() {
|
|||||||
},
|
},
|
||||||
nullptr, true);
|
nullptr, true);
|
||||||
|
|
||||||
|
// ловим пинги от WS (5сек) и дисконнектим если их нет (20сек)
|
||||||
|
ts.add(
|
||||||
|
PiWS, 6000, [&](void*) {
|
||||||
|
if (isNetworkActive()) {
|
||||||
|
for (size_t i = 0; i < WEBSOCKETS_CLIENT_MAX; i++)
|
||||||
|
{
|
||||||
|
if (ws_clients[i] == 0) {
|
||||||
|
disconnectWSClient(i);
|
||||||
|
ws_clients[i]=-1;
|
||||||
|
}
|
||||||
|
if (ws_clients[i] > 0) {
|
||||||
|
ws_clients[i]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
nullptr, true);
|
||||||
|
|
||||||
// test
|
// test
|
||||||
Serial.println("-------test start--------");
|
Serial.println("-------test start--------");
|
||||||
Serial.println("--------test end---------");
|
Serial.println("--------test end---------");
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ void standWebSocketsInit() {
|
|||||||
standWebSocket.begin();
|
standWebSocket.begin();
|
||||||
standWebSocket.onEvent(webSocketEvent);
|
standWebSocket.onEvent(webSocketEvent);
|
||||||
SerialPrint("i", "WS", "WS server initialized");
|
SerialPrint("i", "WS", "WS server initialized");
|
||||||
|
for (size_t i = 0; i < WEBSOCKETS_CLIENT_MAX; i++)
|
||||||
|
{
|
||||||
|
ws_clients[i] = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length) {
|
void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length) {
|
||||||
@@ -17,6 +21,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
|
|||||||
|
|
||||||
case WStype_DISCONNECTED: {
|
case WStype_DISCONNECTED: {
|
||||||
Serial.printf("[%u] Disconnected!\n", num);
|
Serial.printf("[%u] Disconnected!\n", num);
|
||||||
|
standWebSocket.disconnect(num);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case WStype_CONNECTED: {
|
case WStype_CONNECTED: {
|
||||||
@@ -54,7 +59,11 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
|
|||||||
//----------------------------------------------------------------------//
|
//----------------------------------------------------------------------//
|
||||||
// Страница веб интерфейса dashboard
|
// Страница веб интерфейса dashboard
|
||||||
//----------------------------------------------------------------------//
|
//----------------------------------------------------------------------//
|
||||||
|
if (headerStr == "p|") {
|
||||||
|
standWebSocket.sendTXT(num, "p|");
|
||||||
|
Serial.printf("Ping client: %u\n", num);
|
||||||
|
ws_clients[num]=1;
|
||||||
|
}
|
||||||
// публикация всех виджетов
|
// публикация всех виджетов
|
||||||
if (headerStr == "/|") {
|
if (headerStr == "/|") {
|
||||||
sendFileToWsByFrames("/layout.json", "layout", "", num, WEB_SOCKETS_FRAME_SIZE);
|
sendFileToWsByFrames("/layout.json", "layout", "", num, WEB_SOCKETS_FRAME_SIZE);
|
||||||
@@ -490,7 +499,14 @@ void sendStringToWs(const String& header, String& payload, int client_id) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendDeviceList(uint8_t num) {
|
void disconnectWSClient(uint8_t client_id)
|
||||||
|
{
|
||||||
|
standWebSocket.disconnect(client_id);
|
||||||
|
Serial.printf("[WS] Client %u -disconnected\n", client_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sendDeviceList(uint8_t num)
|
||||||
|
{
|
||||||
if (jsonReadInt(settingsFlashJson, F("udps")) != 0) {
|
if (jsonReadInt(settingsFlashJson, F("udps")) != 0) {
|
||||||
// если включен автопоиск то отдаем список из оперативной памяти
|
// если включен автопоиск то отдаем список из оперативной памяти
|
||||||
SerialPrint("i", "FS", "heap list");
|
SerialPrint("i", "FS", "heap list");
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,6 +50,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ class TelegramLT : public IoTItem {
|
|||||||
if (param.size() == 1) {
|
if (param.size() == 1) {
|
||||||
String strTmp;
|
String strTmp;
|
||||||
if (param[0].isDecimal && param[0].valS == "")
|
if (param[0].isDecimal && param[0].valS == "")
|
||||||
strTmp = param[0].valD;
|
strTmp = String(param[0].valD);
|
||||||
else
|
else
|
||||||
strTmp = param[0].valS;
|
strTmp = param[0].valS;
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,6 +132,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,6 +50,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,6 +96,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,6 +88,7 @@
|
|||||||
|
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32*": [],
|
"esp32*": [],
|
||||||
"esp82*": []
|
"esp82*": [],
|
||||||
|
"bk72*": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user