You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2024/04/21 01:10:55 UTC
(nuttx-apps) branch master updated: examples/mqttc: Add QOS argument option
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new fe12ad944 examples/mqttc: Add QOS argument option
fe12ad944 is described below
commit fe12ad9444148330d474d13db432632322d9d072
Author: Andreea Luca <an...@stud.acs.upb.ro>
AuthorDate: Wed Apr 17 13:56:40 2024 -0400
examples/mqttc: Add QOS argument option
Add QOS argument option. Users can optionally
change QOS to 0/1/2.
---
examples/mqttc/mqttc_pub.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/examples/mqttc/mqttc_pub.c b/examples/mqttc/mqttc_pub.c
index c22fc569e..ac06944db 100644
--- a/examples/mqttc/mqttc_pub.c
+++ b/examples/mqttc/mqttc_pub.c
@@ -100,7 +100,7 @@ static void parsearg(int argc, FAR char *argv[],
{
int opt;
- while ((opt = getopt(argc, argv, "h:p:m:t:n:")) != ERROR)
+ while ((opt = getopt(argc, argv, "h:p:m:t:n:q:")) != ERROR)
{
switch (opt)
{
@@ -124,6 +124,21 @@ static void parsearg(int argc, FAR char *argv[],
*n = strtol(optarg, NULL, 10);
break;
+ case 'q':
+ switch (strtol(optarg, NULL, 10))
+ {
+ case '0':
+ cfg->qos = MQTT_PUBLISH_QOS_0;
+ break;
+ case '1':
+ cfg->qos = MQTT_PUBLISH_QOS_1;
+ break;
+ case '2':
+ cfg->qos = MQTT_PUBLISH_QOS_2;
+ break;
+ }
+ break;
+
default:
fprintf(stderr, "ERROR: Unrecognized option\n");
break;