mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-11 02:34:29 +05:00
optimization for esp8266
This commit is contained in:
@@ -26,20 +26,22 @@ lib_deps =
|
||||
https://github.com/Laxilef/WiFiManager/archive/refs/heads/patch-1.zip
|
||||
;https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.2
|
||||
build_flags =
|
||||
-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
|
||||
-D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
||||
-D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK305
|
||||
-mtext-section-literals
|
||||
-D USE_SERIAL=0
|
||||
-D USE_TELNET=1
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
version = 1.4.0-rc.2
|
||||
version = 1.4.0-rc.3
|
||||
|
||||
; Defaults
|
||||
[esp8266_defaults]
|
||||
platform = espressif8266
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
nrwiersma/ESP8266Scheduler@^1.0
|
||||
;nrwiersma/ESP8266Scheduler@^1.0
|
||||
https://github.com/Laxilef/ESP8266Scheduler/archive/refs/heads/network_fix.zip
|
||||
lib_ignore =
|
||||
extra_scripts =
|
||||
post:tools/build.py
|
||||
|
||||
@@ -70,37 +70,52 @@ protected:
|
||||
Log.sinfoln("MQTT", F("Started"));
|
||||
|
||||
// wificlient settings
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
this->wifiClient->setSync(true);
|
||||
#endif
|
||||
|
||||
// client settings
|
||||
this->client->setClient(*this->wifiClient);
|
||||
this->client->setSocketTimeout(3);
|
||||
this->client->setKeepAlive(15);
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
this->client->setSocketTimeout(1);
|
||||
this->client->setBufferSize(768);
|
||||
#else
|
||||
this->client->setSocketTimeout(3);
|
||||
this->client->setBufferSize(1536);
|
||||
#endif
|
||||
|
||||
this->client->setCallback([this] (char* topic, uint8_t* payload, unsigned int length) {
|
||||
this->onMessage(topic, payload, length);
|
||||
});
|
||||
|
||||
// writer settings
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
this->writer->setYieldCallback([this] {
|
||||
this->delay(10);
|
||||
});
|
||||
#endif
|
||||
|
||||
this->writer->setEventPublishCallback([this] (const char* topic, size_t written, size_t length, bool result) {
|
||||
Log.straceln("MQTT", F("%s publish %u of %u bytes to topic: %s"), result ? F("Successfully") : F("Failed"), written, length, topic);
|
||||
|
||||
this->client->loop();
|
||||
this->delay(250);
|
||||
});
|
||||
this->writer->setEventFlushCallback([this] (size_t, size_t) {
|
||||
if (!this->wifiClient->getSync() && this->wifiClient->connected()) {
|
||||
this->wifiClient->flush();
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
::yield();
|
||||
#endif
|
||||
|
||||
this->client->loop();
|
||||
this->delay(250);
|
||||
});
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
this->writer->setEventFlushCallback([this] (size_t, size_t) {
|
||||
this->client->flush();
|
||||
this->wifiClient->flush();
|
||||
::yield();
|
||||
});
|
||||
#endif
|
||||
|
||||
// ha helper settings
|
||||
this->haHelper->setDevicePrefix(settings.mqtt.prefix);
|
||||
this->haHelper->setDeviceVersion(PROJECT_VERSION);
|
||||
@@ -117,9 +132,8 @@ protected:
|
||||
this->connected = false;
|
||||
this->onDisconnect();
|
||||
}
|
||||
|
||||
|
||||
if (this->wifiClient == nullptr || (!this->client->connected() && millis() - this->lastReconnectTime >= MQTT_RECONNECT_INTERVAL)) {
|
||||
Log.sinfoln("MQTT", F("Not connected, state: %d"), this->client->state());
|
||||
Log.sinfoln("MQTT", F("Connecting to %s:%u..."), settings.mqtt.server, settings.mqtt.port);
|
||||
|
||||
this->client->setServer(settings.mqtt.server, settings.mqtt.port);
|
||||
@@ -144,6 +158,9 @@ protected:
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
::yield();
|
||||
#endif
|
||||
this->client->loop();
|
||||
|
||||
// delay for publish data
|
||||
@@ -151,6 +168,10 @@ protected:
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
::yield();
|
||||
#endif
|
||||
|
||||
// publish variables and status
|
||||
if (this->newConnection || millis() - this->prevPubVarsTime > settings.mqtt.interval) {
|
||||
this->writer->publish(
|
||||
|
||||
@@ -273,6 +273,8 @@ protected:
|
||||
arpGratuitous();
|
||||
lastArpGratuitous = millis();
|
||||
}
|
||||
|
||||
::yield();
|
||||
#endif
|
||||
|
||||
wm.process();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#define PROJECT_NAME "OpenTherm Gateway"
|
||||
#define PROJECT_VERSION "1.4.0-rc.2"
|
||||
#define PROJECT_VERSION "1.4.0-rc.3"
|
||||
#define PROJECT_REPO "https://github.com/Laxilef/OTGateway"
|
||||
#define AP_SSID "OpenTherm Gateway"
|
||||
#define AP_PASSWORD "otgateway123456"
|
||||
|
||||
Reference in New Issue
Block a user