mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-29 18:28:24 +02:00
mqtt_client: fix esp_mqtt_client_enqueue for len=0
Commit 372b323
(mqtt_client: Fix mqtt send long data error, 2021-12-21)
removed the length calculation from esp_mqtt_client_enqueue_priv and
added it to esp_mqtt_client_publish. However, esp_mqtt_client_enqueue
was missed. Currently calls to esp_mqtt_client_enqueue appear to send no
data, fix this by adding the length calculation to esp_mqtt_client_enqueue.
This commit is contained in:
@ -1917,6 +1917,16 @@ int esp_mqtt_client_enqueue(esp_mqtt_client_handle_t client, const char *topic,
|
|||||||
ESP_LOGE(TAG, "Client was not initialized");
|
ESP_LOGE(TAG, "Client was not initialized");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Acceptable publish messages:
|
||||||
|
data == NULL, len == 0: publish null message
|
||||||
|
data valid, len == 0: publish all data, payload len is determined from string length
|
||||||
|
data valid, len > 0: publish data with defined length
|
||||||
|
*/
|
||||||
|
if (len <= 0 && data != NULL) {
|
||||||
|
len = strlen(data);
|
||||||
|
}
|
||||||
|
|
||||||
MQTT_API_LOCK(client);
|
MQTT_API_LOCK(client);
|
||||||
int ret = mqtt_client_enqueue_priv(client, topic, data, len, qos, retain, store);
|
int ret = mqtt_client_enqueue_priv(client, topic, data, len, qos, retain, store);
|
||||||
MQTT_API_UNLOCK(client);
|
MQTT_API_UNLOCK(client);
|
||||||
|
Reference in New Issue
Block a user