Skip to content

Commit 5bd9724

Browse files
Merge branch 'bugfix/return_on_qos0_disconnected' into 'master'
bug: Incorrect return on disconnect qos0 publish See merge request espressif/esp-mqtt!172 (cherry picked from commit fa40f44695fc4a0cde14a31a01b8a03da14dd702) 58c25577 bug: Incorrect return on disconnect qos0 publish
1 parent b2bd8e5 commit 5bd9724

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

mqtt_client.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ static esp_err_t esp_mqtt_set_ssl_transport_properties(esp_transport_list_handle
235235
/* Checks if the user supplied config values are internally consistent */
236236
static esp_err_t esp_mqtt_check_cfg_conflict(const mqtt_config_storage_t *cfg, const esp_mqtt_client_config_t *user_cfg)
237237
{
238-
if(cfg == NULL || user_cfg == NULL) {
239-
ESP_LOGE(TAG, "Invalid configuration");
240-
return ESP_ERR_INVALID_ARG;
238+
if (cfg == NULL || user_cfg == NULL) {
239+
ESP_LOGE(TAG, "Invalid configuration");
240+
return ESP_ERR_INVALID_ARG;
241241
}
242242
esp_err_t ret = ESP_OK;
243243

@@ -1124,16 +1124,16 @@ static outbox_item_handle_t mqtt_enqueue(esp_mqtt_client_handle_t client, uint8_
11241124
{
11251125
ESP_LOGD(TAG, "mqtt_enqueue id: %d, type=%d successful",
11261126
client->mqtt_state.pending_msg_id, client->mqtt_state.pending_msg_type);
1127-
outbox_message_t msg = { 0 };
1128-
msg.data = client->mqtt_state.outbound_message->data;
1129-
msg.len = client->mqtt_state.outbound_message->length;
1130-
msg.msg_id = client->mqtt_state.pending_msg_id;
1131-
msg.msg_type = client->mqtt_state.pending_msg_type;
1132-
msg.msg_qos = client->mqtt_state.pending_publish_qos;
1133-
msg.remaining_data = remaining_data;
1134-
msg.remaining_len = remaining_len;
1135-
//Copy to queue buffer
1136-
return outbox_enqueue(client->outbox, &msg, platform_tick_get_ms());
1127+
outbox_message_t msg = { 0 };
1128+
msg.data = client->mqtt_state.outbound_message->data;
1129+
msg.len = client->mqtt_state.outbound_message->length;
1130+
msg.msg_id = client->mqtt_state.pending_msg_id;
1131+
msg.msg_type = client->mqtt_state.pending_msg_type;
1132+
msg.msg_qos = client->mqtt_state.pending_publish_qos;
1133+
msg.remaining_data = remaining_data;
1134+
msg.remaining_len = remaining_len;
1135+
//Copy to queue buffer
1136+
return outbox_enqueue(client->outbox, &msg, platform_tick_get_ms());
11371137
}
11381138

11391139

@@ -2007,6 +2007,8 @@ int esp_mqtt_client_publish(esp_mqtt_client_handle_t client, const char *topic,
20072007
ESP_LOGD(TAG, "Publish: client is not connected");
20082008
if (qos > 0) {
20092009
ret = pending_msg_id;
2010+
} else {
2011+
ret = -1;
20102012
}
20112013

20122014
// delete long pending messages

0 commit comments

Comments
 (0)