From 596144d2c70407c11f7423164350f411b8cade0a Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Mon, 21 Nov 2022 19:05:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=AF=B9?= =?UTF-8?q?=E6=AF=94=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/mqtt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main/mqtt.c b/main/mqtt.c index b94e2ed..c2ba1a8 100644 --- a/main/mqtt.c +++ b/main/mqtt.c @@ -72,15 +72,16 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, break; case MQTT_EVENT_DATA: ESP_LOGI(MQTT_TAG, "MQTT_EVENT_DATA"); - if (strcmp(event->topic, MQTT_KEY_BOARD_ONLINE)) { + if (strncmp(event->topic, MQTT_KEY_DESKTOP_ONLINE, event->topic_len) == + 0) { xEventGroupSetBits(s_mqtt_event_group, MQTT_DESKTOP_ONLINE_BIT); - ESP_LOGE(MQTT_TAG, "AAA MQTT_DESKTOP_ONLINE_BIT"); - } else if (strcmp(event->topic, MQTT_KEY_DESKTOP_COLORS)) { - ESP_LOGE(MQTT_TAG, "AAA MQTT_DESKTOP_SENDING_BIT"); + } else if (strncmp(event->topic, MQTT_KEY_DESKTOP_COLORS, + event->topic_len) == 0) { xEventGroupSetBits(s_mqtt_event_group, MQTT_DESKTOP_SENDING_BIT); + } else { + printf("TOPIC=%.*s\r\n", event->topic_len, event->topic); + printf("DATA=%.*s\r\n", event->data_len, event->data); } - printf("TOPIC=%.*s\r\n", event->topic_len, event->topic); - printf("DATA=%.*s\r\n", event->data_len, event->data); break; case MQTT_EVENT_ERROR: ESP_LOGI(MQTT_TAG, "MQTT_EVENT_ERROR");