forked from espressif/esp-mqtt
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:
@ -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");
|
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