Merge branch 'bugfix/fix_esp_mqtt_client_enqueue' into 'master'

mqtt_client: fix esp_mqtt_client_enqueue for len=0 (GitHub PR)

See merge request espressif/esp-mqtt!135
This commit is contained in:
David Čermák
2022-06-08 19:33:38 +08:00

View File

@ -1948,6 +1948,16 @@ int esp_mqtt_client_enqueue(esp_mqtt_client_handle_t client, const char *topic,
ESP_LOGE(TAG, "Client was not initialized");
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);
int ret = mqtt_client_enqueue_priv(client, topic, data, len, qos, retain, store);
MQTT_API_UNLOCK(client);