Merge branch 'ver4dev' into dev_newWeb

This commit is contained in:
Mit4el
2025-07-24 22:40:24 +03:00
committed by GitHub
10 changed files with 37 additions and 40 deletions

View File

@@ -2,7 +2,8 @@
#include "BuildTime.h"
// Версия прошивки
#define FIRMWARE_VERSION 461
#define FIRMWARE_VERSION 462
#ifdef esp8266_1mb_ota
#define FIRMWARE_NAME "esp8266_1mb_ota"
@@ -104,11 +105,19 @@ WEB_SOCKETS_FRAME_SIZE создан для того что бы не загру
#define MIN_DATETIME 1575158400
#define LEAP_YEAR(Y) (((1970 + Y) > 0) && !((1970 + Y) % 4) && (((1970 + Y) % 100) || !((1970 + Y) % 400)))
#ifdef LIBRETINY
//#define WIFI_ASYNC
#endif
#ifdef ESP32
#define WIFI_ASYNC
#endif
// задачи таскера
enum TimerTask_t {
WIFI_SCAN,
WIFI_MQTT_CONNECTION_CHECK,
#ifndef ESP8266
#ifdef WIFI_ASYNC
WIFI_CONN,
#endif
TIME,

View File

@@ -28,6 +28,8 @@ class IoTUart : public IoTItem {
protected:
#ifdef ESP8266
SoftwareSerial* _myUART;
#elif LIBRETINY
SerialClass* _myUART;
#else
Stream* _myUART;
#endif

View File

@@ -5,7 +5,7 @@
boolean isNetworkActive();
uint8_t getNumAPClients();
bool startAPMode();
#ifdef ESP8266
#ifndef WIFI_ASYNC
void routerConnect();
boolean RouterFind(std::vector<String> jArray);
#else

View File

@@ -456,7 +456,7 @@ upload_speed = 921600
monitor_speed = 115200
build_flags =
-Dbk7231n="bk7231n"
-DLT_LOGLEVEL=LT_LEVEL_DEBUG
-DLT_LOGLEVEL=LT_LEVEL_FATAL
-DLT_DEBUG_ALL=1
-DPROJECT_DATA_DIR="data_svelte"
-DLT_USE_TIME=1

View File

@@ -201,7 +201,7 @@ void setup() {
initErrorMarker(SETUPINET_ERRORMARKER);
// подключаемся к роутеру
#ifdef ESP8266
#ifndef WIFI_ASYNC
routerConnect();
#else
WiFiUtilsItit();
@@ -237,7 +237,7 @@ void setup() {
// инициализация задач переодического выполнения
periodicTasksInit();
#if defined(ESP8266)
#if !defined(WIFI_ASYNC)
// Перенесли после получения IP, так как теперь работа WiFi асинхронная
// запуск работы udp
addThisDeviceToList();
@@ -306,7 +306,7 @@ void setup() {
}
void loop() {
#if !defined(ESP8266)
#if defined(WIFI_ASYNC)
static bool udpFirstFlag = true;
// Перенесли после получения IP, так как теперь работа WiFi асинхронная
if (isNetworkActive() && udpFirstFlag) {

View File

@@ -64,6 +64,10 @@ void synchTime() {
if (sntp_enabled()) {
sntp_stop();
}
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_setservername(0, jsonReadStr(settingsFlashJson, F("ntp")).c_str());
sntp_setservername(1, "pool.ntp.org");
sntp_setservername(2, "ru.pool.ntp.org");
sntp_init();
#else

View File

@@ -143,7 +143,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
sendFileToWsByFrames("/widgets.json", "widget", "", num, WEB_SOCKETS_FRAME_SIZE);
sendFileToWsByFrames("/config.json", "config", "", num, WEB_SOCKETS_FRAME_SIZE);
sendStringToWs("settin", settingsFlashJson, num);
#ifndef ESP8266
#ifdef WIFI_ASYNC
ssidListHeapJson = "{}";
jsonWriteStr_(ssidListHeapJson, "0", "Scanning...");
#endif
@@ -161,7 +161,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
sendStringToWs("errors", errorsHeapJson, num);
// если не было создано приема данных по udp - то создадим его
addThisDeviceToList();
#ifndef ESP8266
#ifdef WIFI_ASYNC
settingsFlashJson = readFile(F("settings.json"), 4096);
settingsFlashJson.replace("\r\n", "");
Serial.println(settingsFlashJson);
@@ -183,7 +183,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
// запуск асинхронного сканирования wifi сетей при нажатии выпадающего
// списка
if (headerStr == "/scan|") {
#ifdef ESP8266
#ifndef WIFI_ASYNC
std::vector<String> jArray;
jsonReadArray(settingsFlashJson, "routerssid", jArray);
RouterFind(jArray);

View File

@@ -9,11 +9,11 @@ IoTUart::IoTUart(const String& parameters) : IoTItem(parameters) {
jsonRead(parameters, "speed", _speed);
jsonRead(parameters, "line", _line);
#ifdef ESP8266
#if defined (ESP8266)
_myUART = new SoftwareSerial(_rx, _tx);
_myUART->begin(_speed);
#endif
#ifdef ESP32
#if defined (ESP32)
if (_line >= 0) {
_myUART = new HardwareSerial(_line);
((HardwareSerial*)_myUART)->begin(_speed, SERIAL_8N1, _rx, _tx);
@@ -22,6 +22,10 @@ IoTUart::IoTUart(const String& parameters) : IoTItem(parameters) {
((SoftwareSerial*)_myUART)->begin(_speed);
}
#endif
#if defined (LIBRETINY)
_myUART = new SerialClass(_rx, _tx);
_myUART->begin((unsigned long)_speed);
#endif
}
void IoTUart::loop() {

View File

@@ -1,35 +1,13 @@
#include "ESPConfiguration.h"
void* getAPI_Cron(String subtype, String params);
void* getAPI_Loging(String subtype, String params);
void* getAPI_LogingDaily(String subtype, String params);
void* getAPI_IoTMath(String subtype, String params);
void* getAPI_owmWeather(String subtype, String params);
void* getAPI_Timer(String subtype, String params);
void* getAPI_Variable(String subtype, String params);
void* getAPI_VButton(String subtype, String params);
void* getAPI_AnalogAdc(String subtype, String params);
void* getAPI_BL0937(String subtype, String params);
void* getAPI_UART(String subtype, String params);
void* getAPI_AnalogBtn(String subtype, String params);
void* getAPI_ButtonIn(String subtype, String params);
void* getAPI_ButtonOut(String subtype, String params);
void* getAPI_BL0942(String subtype, String params);
void* getAPI(String subtype, String params) {
void* tmpAPI;
if ((tmpAPI = getAPI_Cron(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Loging(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_LogingDaily(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_IoTMath(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_owmWeather(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Timer(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_VButton(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_AnalogAdc(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_BL0937(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_UART(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_AnalogBtn(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_ButtonIn(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_BL0942(subtype, params)) != nullptr) return tmpAPI;
return nullptr;
}

View File

@@ -7,7 +7,7 @@
#define TRIESONE 20 // количество секунд ожидания подключения к одной сети из несколких
#define TRIES 30 // количество секунд ожидания подключения сети если она одна
#ifndef ESP8266
#ifdef WIFI_ASYNC
std::vector<String> _ssidList;
std::vector<String> _passwordList;
// номер сети, для перебирания в момент подключения к сетям из массива
@@ -403,7 +403,7 @@ void routerConnect()
#endif
bool startAPMode()
{
#ifndef ESP8266
#ifdef WIFI_ASYNC
wifiConnecting = false;
currentNetwork = 0;
connectionAttempts = 0;
@@ -433,7 +433,7 @@ bool startAPMode()
WIFI_SCAN, 30 * 1000,
[&](void *)
{
#ifdef ESP8266
#ifndef WIFI_ASYNC
std::vector<String> jArray;
jsonReadArray(settingsFlashJson, "routerssid", jArray);
for (int8_t i = 0; i < jArray.size(); i++)
@@ -455,7 +455,7 @@ bool startAPMode()
return true;
}
#if defined(ESP8266)
#ifndef WIFI_ASYNC
boolean RouterFind(std::vector<String> jArray)
{
bool res = false;