mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
update espMqttClient, add own mqtt limit, fix queue display, 3.7.0-dev1d
This commit is contained in:
14
src/mqtt.cpp
14
src/mqtt.cpp
@@ -124,6 +124,8 @@ void Mqtt::resubscribe() {
|
||||
|
||||
// Main MQTT loop - sends out top item on publish queue
|
||||
void Mqtt::loop() {
|
||||
queuecount_ = mqttClient_->getQueue();
|
||||
|
||||
// exit if MQTT is not enabled or if there is no network connection
|
||||
if (!connected()) {
|
||||
return;
|
||||
@@ -142,7 +144,7 @@ void Mqtt::loop() {
|
||||
EMSESP::publish_sensor_values(false);
|
||||
}
|
||||
|
||||
queuecount_ = mqttClient_->getQueue();
|
||||
// wait for empty queue before sending scheduled device messages
|
||||
if (queuecount_ > 0) {
|
||||
return;
|
||||
}
|
||||
@@ -482,7 +484,7 @@ void Mqtt::on_connect() {
|
||||
|
||||
connecting_ = true;
|
||||
connectcount_++; // count # reconnects. not currently used.
|
||||
queuecount_ = 0;
|
||||
queuecount_ = mqttClient_->getQueue();
|
||||
|
||||
load_settings(); // reload MQTT settings - in case they have changes
|
||||
|
||||
@@ -590,6 +592,14 @@ bool Mqtt::queue_message(const uint8_t operation, const std::string & topic, con
|
||||
if (!mqtt_enabled_ || topic.empty()) {
|
||||
return false; // quit, not using MQTT
|
||||
}
|
||||
// check free mem
|
||||
if (ESP.getFreeHeap() < 60 * 1204) {
|
||||
if (operation == Operation::PUBLISH) {
|
||||
mqtt_message_id_++;
|
||||
mqtt_publish_fails_++;
|
||||
}
|
||||
return false; // quit, not using MQTT
|
||||
}
|
||||
|
||||
uint16_t packet_id = 0;
|
||||
char fulltopic[MQTT_TOPIC_MAX_SIZE];
|
||||
|
||||
Reference in New Issue
Block a user