Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_esp_mqtt_client_enqueue_idf4.x' into 'idf_v4.x'
Browse files Browse the repository at this point in the history
[Backport] mqtt_client: fix esp_mqtt_client_enqueue for len=0

See merge request espressif/esp-mqtt!144
  • Loading branch information
david-cermak committed Sep 14, 2022
2 parents 27eb472 + e918742 commit 60983d1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mqtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1900,6 +1900,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);
Expand Down

0 comments on commit 60983d1

Please sign in to comment.