Merge pull request #2224 from cesanta/qos2

fix qos=2 handling
This commit is contained in:
Sergey Lyubka 2023-05-31 12:07:10 +01:00 committed by GitHub
commit dd5f469c83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -3376,7 +3376,9 @@ static void mqtt_cb(struct mg_connection *c, int ev, void *ev_data,
uint32_t remaining_len = sizeof(id);
if (c->is_mqtt5) remaining_len += 1;
mg_mqtt_send_header(c, MQTT_CMD_PUBACK, 0, remaining_len);
mg_mqtt_send_header(
c, mm.qos == 2 ? MQTT_CMD_PUBREC : MQTT_CMD_PUBACK, 0,
remaining_len);
mg_send(c, &id, sizeof(id));
if (c->is_mqtt5) {
@ -3384,7 +3386,7 @@ static void mqtt_cb(struct mg_connection *c, int ev, void *ev_data,
mg_send(c, &zero, sizeof(zero));
}
}
mg_call(c, MG_EV_MQTT_MSG, &mm);
mg_call(c, MG_EV_MQTT_MSG, &mm); // let the app handle qos2 stuff
break;
}
}

View File

@ -449,7 +449,9 @@ static void mqtt_cb(struct mg_connection *c, int ev, void *ev_data,
uint32_t remaining_len = sizeof(id);
if (c->is_mqtt5) remaining_len += 1;
mg_mqtt_send_header(c, MQTT_CMD_PUBACK, 0, remaining_len);
mg_mqtt_send_header(
c, mm.qos == 2 ? MQTT_CMD_PUBREC : MQTT_CMD_PUBACK, 0,
remaining_len);
mg_send(c, &id, sizeof(id));
if (c->is_mqtt5) {
@ -457,7 +459,7 @@ static void mqtt_cb(struct mg_connection *c, int ev, void *ev_data,
mg_send(c, &zero, sizeof(zero));
}
}
mg_call(c, MG_EV_MQTT_MSG, &mm);
mg_call(c, MG_EV_MQTT_MSG, &mm); // let the app handle qos2 stuff
break;
}
}