mirror of
https://github.com/esphome/esphome.git
synced 2025-01-07 19:17:43 +01:00
parent
53691d28a8
commit
39f3f795e2
@ -151,11 +151,11 @@ void MQTTBackendESP32::mqtt_event_handler_(const Event &event) {
|
|||||||
break;
|
break;
|
||||||
case MQTT_EVENT_DATA: {
|
case MQTT_EVENT_DATA: {
|
||||||
static std::string topic;
|
static std::string topic;
|
||||||
if (event.topic.length() > 0) {
|
if (!event.topic.empty()) {
|
||||||
topic = event.topic;
|
topic = event.topic;
|
||||||
}
|
}
|
||||||
ESP_LOGV(TAG, "MQTT_EVENT_DATA %s", topic.c_str());
|
ESP_LOGV(TAG, "MQTT_EVENT_DATA %s", topic.c_str());
|
||||||
this->on_message_.call(event.topic.length() > 0 ? topic.c_str() : nullptr, event.data.data(), event.data.size(),
|
this->on_message_.call(!event.topic.empty() ? topic.c_str() : nullptr, event.data.data(), event.data.size(),
|
||||||
event.current_data_offset, event.total_data_len);
|
event.current_data_offset, event.total_data_len);
|
||||||
} break;
|
} break;
|
||||||
case MQTT_EVENT_ERROR:
|
case MQTT_EVENT_ERROR:
|
||||||
@ -184,7 +184,7 @@ void MQTTBackendESP32::mqtt_event_handler(void *handler_args, esp_event_base_t b
|
|||||||
// queue event to decouple processing
|
// queue event to decouple processing
|
||||||
if (instance) {
|
if (instance) {
|
||||||
auto event = *static_cast<esp_mqtt_event_t *>(event_data);
|
auto event = *static_cast<esp_mqtt_event_t *>(event_data);
|
||||||
instance->mqtt_events_.push(Event(event));
|
instance->mqtt_events_.emplace(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user