espressif / esp-csi

Applications based on Wi-Fi CSI (Channel state information), such as indoor positioning, human detection
Apache License 2.0
706 stars 111 forks source link

CSI ping interval is ignored when applying MQTT publish in the CSI RX callback (AEGHB-606) #169

Open DavidKks opened 7 months ago

DavidKks commented 7 months ago

I am testing the function of transmitting CSI data to the MQTT server using the example source and ESP32-S3 board. The CSI RX callback specified in the esp_wifi_set_csi_rx_cb() method is as follows.

[app_main.c]

ESP_ERROR_CHECK(esp_wifi_set_csi_rx_cb(wifi_csi_rx_cb, s_ap_info.bssid));
...
static void wifi_csi_rx_cb(void *ctx, wifi_csi_info_t *info)
{
    char *buffer = malloc(8 * 1024);
    size_t len = 0;
...
    if (s_mqtt_connect && MQTT_PUBLISH_ENABLED)
    {
        int msg_id = esp_mqtt_client_publish(mqtt_client, "/topic/qos0", buffer, 0, 1, 0); // buffer - string format for CSI Info
        ESP_LOGI(TAG, "Published CSI data successfully, msg_id=%d", msg_id);
    }
...
}

[Configuration]

        ESP32-S3   <--------------------> Wi-fi AP <-----------------------> MQTT Broker
(CSI-Recv, MQTT client)                     (CSI-Send)
                       ----- (MQTT) ------->             ------- (MQTT) -------->

The default value for the CSI ping interval was set to 1 sec using the command line command, and it was confirmed that CSI data was printed at the set interval in thewifi_csi_rx_cb() callback. However, when MQTT publishes CSI data inside a callback, the set interval value is ignored and the callback is called very quickly and the CSI data is printed continuously at very short time intervals(maybe 50ms). I wonder why this phenomenon occurs. I don't know why the CSI ping interval setting is not effective when doing MQTT publish. Is there any relation between CSI and MQTT API in ESP-IDF internal API processing? Can anyone explain this phenomenon?