Skip to content

Commit b06d038

Browse files
Matthew BradburyMatthew Bradbury
Matthew Bradbury
authored and
Matthew Bradbury
committed
MQTT: Provide the message id for subscribe, unsubscribe and publish
1 parent e0fa9da commit b06d038

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

os/net/app-layer/mqtt/mqtt.c

+12
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,10 @@ mqtt_subscribe(struct mqtt_connection *conn, uint16_t *mid, char *topic,
14951495
conn->out_packet.qos = qos_level;
14961496
conn->out_packet.qos_state = MQTT_QOS_STATE_NO_ACK;
14971497

1498+
if(mid) {
1499+
*mid = conn->out_packet.mid;
1500+
}
1501+
14981502
process_post(&mqtt_process, mqtt_do_subscribe_event, conn);
14991503
return MQTT_STATUS_OK;
15001504
}
@@ -1520,6 +1524,10 @@ mqtt_unsubscribe(struct mqtt_connection *conn, uint16_t *mid, char *topic)
15201524
conn->out_packet.topic_length = strlen(topic);
15211525
conn->out_packet.qos_state = MQTT_QOS_STATE_NO_ACK;
15221526

1527+
if(mid) {
1528+
*mid = conn->out_packet.mid;
1529+
}
1530+
15231531
process_post(&mqtt_process, mqtt_do_unsubscribe_event, conn);
15241532
return MQTT_STATUS_OK;
15251533
}
@@ -1552,6 +1560,10 @@ mqtt_publish(struct mqtt_connection *conn, uint16_t *mid, char *topic,
15521560
conn->out_packet.qos = qos_level;
15531561
conn->out_packet.qos_state = MQTT_QOS_STATE_NO_ACK;
15541562

1563+
if(mid) {
1564+
*mid = conn->out_packet.mid;
1565+
}
1566+
15551567
process_post(&mqtt_process, mqtt_do_publish_event, conn);
15561568
return MQTT_STATUS_OK;
15571569
}

0 commit comments

Comments
 (0)