mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-30 10:48:06 +02:00
Merge branch 'bugfix/fix_mqtt5_flow_control' into 'master'
mqtt5: Fix flow control will increase count when send fragmented packet See merge request espressif/esp-mqtt!164
This commit is contained in:
@ -19,8 +19,7 @@ static esp_err_t esp_mqtt5_user_property_copy(mqtt5_user_property_handle_t user_
|
|||||||
void esp_mqtt5_increment_packet_counter(esp_mqtt5_client_handle_t client)
|
void esp_mqtt5_increment_packet_counter(esp_mqtt5_client_handle_t client)
|
||||||
{
|
{
|
||||||
bool msg_dup = mqtt5_get_dup(client->mqtt_state.outbound_message->data);
|
bool msg_dup = mqtt5_get_dup(client->mqtt_state.outbound_message->data);
|
||||||
int msg_qos = mqtt5_get_qos(client->mqtt_state.outbound_message->data);
|
if (msg_dup == false) {
|
||||||
if ((msg_dup == false) && (msg_qos > 0)) {
|
|
||||||
client->send_publish_packet_count ++;
|
client->send_publish_packet_count ++;
|
||||||
ESP_LOGD(TAG, "Sent (%d) qos > 0 publish packet without ack", client->send_publish_packet_count);
|
ESP_LOGD(TAG, "Sent (%d) qos > 0 publish packet without ack", client->send_publish_packet_count);
|
||||||
}
|
}
|
||||||
|
@ -943,11 +943,6 @@ static esp_err_t mqtt_write_data(esp_mqtt_client_handle_t client)
|
|||||||
esp_mqtt_client_dispatch_transport_error(client);
|
esp_mqtt_client_dispatch_transport_error(client);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
#ifdef MQTT_PROTOCOL_5
|
|
||||||
if (client->connect_info.protocol_ver == MQTT_PROTOCOL_V_5) {
|
|
||||||
esp_mqtt5_increment_packet_counter(client);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1475,10 +1470,18 @@ static esp_err_t mqtt_resend_queued(esp_mqtt_client_handle_t client, outbox_item
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if it was QoS-0 publish message
|
// check if it was QoS-0 publish message
|
||||||
if (client->mqtt_state.pending_msg_type == MQTT_MSG_TYPE_PUBLISH && client->mqtt_state.pending_publish_qos == 0) {
|
if (client->mqtt_state.pending_msg_type == MQTT_MSG_TYPE_PUBLISH) {
|
||||||
// delete all qos0 publish messages once we process them
|
if (client->mqtt_state.pending_publish_qos == 0) {
|
||||||
if (outbox_delete_item(client->outbox, item) != ESP_OK) {
|
// delete all qos0 publish messages once we process them
|
||||||
ESP_LOGE(TAG, "Failed to remove queued qos0 message from the outbox");
|
if (outbox_delete_item(client->outbox, item) != ESP_OK) {
|
||||||
|
ESP_LOGE(TAG, "Failed to remove queued qos0 message from the outbox");
|
||||||
|
}
|
||||||
|
} else if (client->mqtt_state.pending_publish_qos > 0) {
|
||||||
|
#ifdef MQTT_PROTOCOL_5
|
||||||
|
if (client->connect_info.protocol_ver == MQTT_PROTOCOL_V_5) {
|
||||||
|
esp_mqtt5_increment_packet_counter(client);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
@ -2090,6 +2093,11 @@ int esp_mqtt_client_publish(esp_mqtt_client_handle_t client, const char *topic,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (qos > 0) {
|
if (qos > 0) {
|
||||||
|
#ifdef MQTT_PROTOCOL_5
|
||||||
|
if (client->connect_info.protocol_ver == MQTT_PROTOCOL_V_5) {
|
||||||
|
esp_mqtt5_increment_packet_counter(client);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
//Tick is set after transmit to avoid retransmitting too early due slow network speed / big messages
|
//Tick is set after transmit to avoid retransmitting too early due slow network speed / big messages
|
||||||
outbox_set_tick(client->outbox, pending_msg_id, platform_tick_get_ms());
|
outbox_set_tick(client->outbox, pending_msg_id, platform_tick_get_ms());
|
||||||
outbox_set_pending(client->outbox, pending_msg_id, TRANSMITTED);
|
outbox_set_pending(client->outbox, pending_msg_id, TRANSMITTED);
|
||||||
|
Reference in New Issue
Block a user