Page 1 of 1

MQTT 接收信息的例子

Posted: Thu Oct 14, 2021 4:43 pm
by XiotSamuel
想問一下有沒有MQTT SUBSCRIBE topic 之後接收MESSAGE的例子?

我只找到

Code: Select all

    case MQTT_EVENT_DATA:
    {
        ESP_LOGI(TAG, "MQTT_EVENT_DATA, topic: %.*s, data: %.*s",
                 event->topic_len, event->topic, event->data_len, event->data);

        mesh_mqtt_data_t *item = mesh_mqtt_parse_data(event->topic, event->topic_len, event->data, event->data_len);

        if (item == NULL)
        {
            break;
        }

        if (xQueueSend(g_mesh_mqtt.queue, &item, 0) != pdPASS)
        {
            ESP_LOGI(TAG,"Send receive queue failed");
            MDF_FREE(item->addrs_list);
            MDF_FREE(item->data);
            MDF_FREE(item);
        }

        break;
    }
但好像不太是接收message的。

Re: MQTT 接收信息的例子

Posted: Fri Oct 15, 2021 2:21 am
by ESP_ICY
可以看下https://docs.espressif.com/projects/esp ... light=mqtt这里的介绍有没有想要的信息