mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-12 03:04:27 +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/Laxilef/WiFiManager/archive/refs/heads/patch-1.zip
|
||||||
;https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.2
|
;https://github.com/tzapu/WiFiManager.git#v2.0.16-rc.2
|
||||||
build_flags =
|
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
|
-mtext-section-literals
|
||||||
-D USE_SERIAL=0
|
-D USE_SERIAL=0
|
||||||
-D USE_TELNET=1
|
-D USE_TELNET=1
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
version = 1.4.0-rc.2
|
version = 1.4.0-rc.3
|
||||||
|
|
||||||
; Defaults
|
; Defaults
|
||||||
[esp8266_defaults]
|
[esp8266_defaults]
|
||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.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 =
|
lib_ignore =
|
||||||
extra_scripts =
|
extra_scripts =
|
||||||
post:tools/build.py
|
post:tools/build.py
|
||||||
|
|||||||
@@ -70,37 +70,52 @@ protected:
|
|||||||
Log.sinfoln("MQTT", F("Started"));
|
Log.sinfoln("MQTT", F("Started"));
|
||||||
|
|
||||||
// wificlient settings
|
// wificlient settings
|
||||||
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
this->wifiClient->setSync(true);
|
this->wifiClient->setSync(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
// client settings
|
// client settings
|
||||||
this->client->setClient(*this->wifiClient);
|
this->client->setClient(*this->wifiClient);
|
||||||
this->client->setSocketTimeout(3);
|
|
||||||
this->client->setKeepAlive(15);
|
this->client->setKeepAlive(15);
|
||||||
|
|
||||||
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
|
this->client->setSocketTimeout(1);
|
||||||
this->client->setBufferSize(768);
|
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->client->setCallback([this] (char* topic, uint8_t* payload, unsigned int length) {
|
||||||
this->onMessage(topic, payload, length);
|
this->onMessage(topic, payload, length);
|
||||||
});
|
});
|
||||||
|
|
||||||
// writer settings
|
// writer settings
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
this->writer->setYieldCallback([this] {
|
this->writer->setYieldCallback([this] {
|
||||||
this->delay(10);
|
this->delay(10);
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
this->writer->setEventPublishCallback([this] (const char* topic, size_t written, size_t length, bool result) {
|
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);
|
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
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
::yield();
|
::yield();
|
||||||
#endif
|
#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
|
// ha helper settings
|
||||||
this->haHelper->setDevicePrefix(settings.mqtt.prefix);
|
this->haHelper->setDevicePrefix(settings.mqtt.prefix);
|
||||||
this->haHelper->setDeviceVersion(PROJECT_VERSION);
|
this->haHelper->setDeviceVersion(PROJECT_VERSION);
|
||||||
@@ -119,7 +134,6 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->wifiClient == nullptr || (!this->client->connected() && millis() - this->lastReconnectTime >= MQTT_RECONNECT_INTERVAL)) {
|
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);
|
Log.sinfoln("MQTT", F("Connecting to %s:%u..."), settings.mqtt.server, settings.mqtt.port);
|
||||||
|
|
||||||
this->client->setServer(settings.mqtt.server, settings.mqtt.port);
|
this->client->setServer(settings.mqtt.server, settings.mqtt.port);
|
||||||
@@ -144,6 +158,9 @@ protected:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
|
::yield();
|
||||||
|
#endif
|
||||||
this->client->loop();
|
this->client->loop();
|
||||||
|
|
||||||
// delay for publish data
|
// delay for publish data
|
||||||
@@ -151,6 +168,10 @@ protected:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
|
::yield();
|
||||||
|
#endif
|
||||||
|
|
||||||
// publish variables and status
|
// publish variables and status
|
||||||
if (this->newConnection || millis() - this->prevPubVarsTime > settings.mqtt.interval) {
|
if (this->newConnection || millis() - this->prevPubVarsTime > settings.mqtt.interval) {
|
||||||
this->writer->publish(
|
this->writer->publish(
|
||||||
|
|||||||
@@ -273,6 +273,8 @@ protected:
|
|||||||
arpGratuitous();
|
arpGratuitous();
|
||||||
lastArpGratuitous = millis();
|
lastArpGratuitous = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::yield();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wm.process();
|
wm.process();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#define PROJECT_NAME "OpenTherm Gateway"
|
#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 PROJECT_REPO "https://github.com/Laxilef/OTGateway"
|
||||||
#define AP_SSID "OpenTherm Gateway"
|
#define AP_SSID "OpenTherm Gateway"
|
||||||
#define AP_PASSWORD "otgateway123456"
|
#define AP_PASSWORD "otgateway123456"
|
||||||
|
|||||||
Reference in New Issue
Block a user