Fixes for async MQTT (#9273)

This commit is contained in:
David Woodhouse 2025-06-30 19:25:54 +01:00 committed by GitHub
parent aaa7117ec9
commit 8014cbc71e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -163,12 +163,20 @@ void MQTTBackendESP32::mqtt_event_handler_(const Event &event) {
case MQTT_EVENT_CONNECTED:
ESP_LOGV(TAG, "MQTT_EVENT_CONNECTED");
this->is_connected_ = true;
#if defined(USE_MQTT_IDF_ENQUEUE)
this->last_dropped_log_time_ = 0;
xTaskNotifyGive(this->task_handle_);
#endif
this->on_connect_.call(event.session_present);
break;
case MQTT_EVENT_DISCONNECTED:
ESP_LOGV(TAG, "MQTT_EVENT_DISCONNECTED");
// TODO is there a way to get the disconnect reason?
this->is_connected_ = false;
#if defined(USE_MQTT_IDF_ENQUEUE)
this->last_dropped_log_time_ = 0;
xTaskNotifyGive(this->task_handle_);
#endif
this->on_disconnect_.call(MQTTClientDisconnectReason::TCP_DISCONNECTED);
break;

View File

@ -116,7 +116,7 @@ struct QueueElement {
class MQTTBackendESP32 final : public MQTTBackend {
public:
static const size_t MQTT_BUFFER_SIZE = 4096;
static const size_t TASK_STACK_SIZE = 2048;
static const size_t TASK_STACK_SIZE = 3072;
static const size_t TASK_STACK_SIZE_TLS = 4096; // Larger stack for TLS operations
static const ssize_t TASK_PRIORITY = 5;
static const uint8_t MQTT_QUEUE_LENGTH = 30; // 30*12 bytes = 360