MQTT 接收信息的例子

XiotSamuel
Posts: 53
Joined: Sun Aug 29, 2021 1:50 pm

MQTT 接收信息的例子

Postby XiotSamuel » Thu Oct 14, 2021 4:43 pm

想問一下有沒有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的。

ESP_ICY
Posts: 404
Joined: Mon Aug 23, 2021 11:10 am

Re: MQTT 接收信息的例子

Postby ESP_ICY » Fri Oct 15, 2021 2:21 am

可以看下https://docs.espressif.com/projects/esp ... light=mqtt这里的介绍有没有想要的信息

Who is online

Users browsing this forum: No registered users and 63 guests