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");