Skip to content

Commit

Permalink
Merge branch 'fix/deleted_msg_event' into 'master'
Browse files Browse the repository at this point in the history
When MQTT_REPORT_DELETED_MESSAGES, delete QOS messages with id 0

Closes IDFGH-14022 and IDFGH-14021

See merge request espressif/esp-mqtt!225
  • Loading branch information
euripedesrocha committed Nov 18, 2024
2 parents 942fd02 + ea036a5 commit cea7e95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include/mqtt_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ typedef enum esp_mqtt_event_id_t {
MQTT_EVENT_BEFORE_CONNECT, /*!< The event occurs before connecting */
MQTT_EVENT_DELETED, /*!< Notification on delete of one message from the
internal outbox, if the message couldn't have been sent
and acknowledged before expiring defined in
or acknowledged before expiring defined in
OUTBOX_EXPIRED_TIMEOUT_MS. (events are not posted upon
deletion of successfully acknowledged messages)
- This event id is posted only if
MQTT_REPORT_DELETED_MESSAGES==1
- Additional context: msg_id (id of the deleted
message).
message, always 0 for QoS = 0 messages).
*/
MQTT_USER_EVENT, /*!< Custom event used to queue tasks into mqtt event handler
All fields from the esp_mqtt_event_t type could be used to pass
Expand Down
2 changes: 1 addition & 1 deletion mqtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ static void mqtt_delete_expired_messages(esp_mqtt_client_handle_t client)
#if MQTT_REPORT_DELETED_MESSAGES
// also report the deleted items as MQTT_EVENT_DELETED events if enabled
int msg_id = 0;
while ((msg_id = outbox_delete_single_expired(client->outbox, platform_tick_get_ms(), OUTBOX_EXPIRED_TIMEOUT_MS)) > 0) {
while ((msg_id = outbox_delete_single_expired(client->outbox, platform_tick_get_ms(), OUTBOX_EXPIRED_TIMEOUT_MS)) >= 0) {
client->event.event_id = MQTT_EVENT_DELETED;
client->event.msg_id = msg_id;
if (esp_mqtt_dispatch_event(client) != ESP_OK) {
Expand Down

0 comments on commit cea7e95

Please sign in to comment.