examples/mqttc: Add QOS argument option
Add QOS argument option. Users can optionally change QOS to 0/1/2.
This commit is contained in:
parent
3dc64d9a26
commit
fe12ad9444
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user