mirror of
https://github.com/espressif/esp-mqtt.git
synced 2026-08-03 20:14:15 +02:00
fix(mqtt5): Removes incorrect reason code verification when resending pubrel
Fixes #333
This commit is contained in:
+4
-3
@@ -1178,8 +1178,9 @@ int mqtt5_msg_get_reason_code(uint8_t *buffer, size_t length)
|
||||
size_t offset = 1; // Message type
|
||||
size_t variable_len = get_variable_len(buffer, offset, length, &len_bytes);
|
||||
offset += len_bytes;
|
||||
uint8_t type = mqtt5_get_type(buffer);
|
||||
|
||||
switch (mqtt5_get_type(buffer)) {
|
||||
switch (type) {
|
||||
case MQTT_MSG_TYPE_PUBACK:
|
||||
case MQTT_MSG_TYPE_PUBREC:
|
||||
case MQTT_MSG_TYPE_PUBREL:
|
||||
@@ -1191,7 +1192,7 @@ int mqtt5_msg_get_reason_code(uint8_t *buffer, size_t length)
|
||||
offset += 2; //skip the message id
|
||||
|
||||
if (offset >= length) {
|
||||
ESP_LOGE(TAG, "Invalid control packet, reason code is absent");
|
||||
ESP_LOGE(TAG, "Invalid control packet type %d, reason code is absent", type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1209,7 +1210,7 @@ int mqtt5_msg_get_reason_code(uint8_t *buffer, size_t length)
|
||||
offset = offset + len_bytes + property_len;
|
||||
|
||||
if (offset >= length) {
|
||||
ESP_LOGE(TAG, "Invalid control packet, reason code is absent");
|
||||
ESP_LOGE(TAG, "Invalid control packet type %d, reason code is absent", type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1840,8 +1840,6 @@ static esp_err_t mqtt_resend_pubrel(esp_mqtt_client_handle_t client, outbox_item
|
||||
|
||||
if (client->mqtt_state.connection.information.protocol_ver == MQTT_PROTOCOL_V_5) {
|
||||
#ifdef MQTT_PROTOCOL_5
|
||||
ESP_LOGI(TAG, "MQTT_MSG_TYPE_PUBREC return code is %d", mqtt5_msg_get_reason_code(client->mqtt_state.in_buffer,
|
||||
client->mqtt_state.in_buffer_read_len));
|
||||
mqtt5_msg_pubrel(&client->mqtt_state.connection, client->mqtt_state.pending_msg_id);
|
||||
#endif
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user