18
18
#include < aws/iot/MqttClient.h>
19
19
20
20
#include < algorithm>
21
+ #include < aws/crt/UUID.h>
21
22
#include < condition_variable>
22
23
#include < iostream>
23
24
#include < mutex>
24
- #include < aws/crt/UUID.h>
25
25
26
26
using namespace Aws ::Crt;
27
27
@@ -34,7 +34,9 @@ static void s_printHelp()
34
34
" --key <path to key> --topic --ca_file <optional: path to custom ca>"
35
35
" --use_websocket --signing_region <region> --proxy_host <host> --proxy_port <port>\n\n " );
36
36
fprintf (stdout, " endpoint: the endpoint of the mqtt server not including a port\n " );
37
- fprintf (stdout, " cert: path to your client certificate in PEM format. If this is not set you must specify use_websocket\n " );
37
+ fprintf (
38
+ stdout,
39
+ " cert: path to your client certificate in PEM format. If this is not set you must specify use_websocket\n " );
38
40
fprintf (stdout, " key: path to your key in PEM format. If this is not set you must specify use_websocket\n " );
39
41
fprintf (stdout, " topic: topic to publish, subscribe to.\n " );
40
42
fprintf (stdout, " client_id: client id to use (optional)\n " );
@@ -44,9 +46,13 @@ static void s_printHelp()
44
46
" in your trust store, set this.\n " );
45
47
fprintf (stdout, " \t It's the path to a CA file in PEM format\n " );
46
48
fprintf (stdout, " use_websocket: if specified, uses a websocket over https (optional)\n " );
47
- fprintf (stdout, " signing_region: used for websocket signer it should only be specific if websockets are used. (required for websockets)\n " );
49
+ fprintf (
50
+ stdout,
51
+ " signing_region: used for websocket signer it should only be specific if websockets are used. (required for "
52
+ " websockets)\n " );
48
53
fprintf (stdout, " proxy_host: if you want to use a proxy with websockets, specify the host here (optional).\n " );
49
- fprintf (stdout, " proxy_port: defaults to 8080 is proxy_host is set. Set this to any value you'd like (optional).\n\n " );
54
+ fprintf (
55
+ stdout, " proxy_port: defaults to 8080 is proxy_host is set. Set this to any value you'd like (optional).\n\n " );
50
56
}
51
57
52
58
bool s_cmdOptionExists (char **begin, char **end, const String &option)
@@ -86,7 +92,7 @@ int main(int argc, char *argv[])
86
92
bool useWebSocket = false ;
87
93
88
94
/* ********************** Parse Arguments ***************************/
89
- if (!(s_cmdOptionExists (argv, argv + argc, " --endpoint" ) && s_cmdOptionExists (argv, argv + argc, " --topic" )))
95
+ if (!(s_cmdOptionExists (argv, argv + argc, " --endpoint" ) && s_cmdOptionExists (argv, argv + argc, " --topic" )))
90
96
{
91
97
s_printHelp ();
92
98
return 0 ;
@@ -129,7 +135,7 @@ int main(int argc, char *argv[])
129
135
130
136
if (s_cmdOptionExists (argv, argv + argc, " --proxy_port" ))
131
137
{
132
- proxyPort = atoi (s_getCmdOption (argv, argv + argc, " --proxy_port" ));
138
+ proxyPort = static_cast < uint16_t >( atoi (s_getCmdOption (argv, argv + argc, " --proxy_port" ) ));
133
139
}
134
140
}
135
141
@@ -159,8 +165,7 @@ int main(int argc, char *argv[])
159
165
160
166
if (!certificatePath.empty () && !keyPath.empty ())
161
167
{
162
- builder =
163
- Aws::Iot::MqttClientConnectionConfigBuilder (certificatePath.c_str (), keyPath.c_str ());
168
+ builder = Aws::Iot::MqttClientConnectionConfigBuilder (certificatePath.c_str (), keyPath.c_str ());
164
169
}
165
170
else if (useWebSocket)
166
171
{
@@ -279,9 +284,9 @@ int main(int argc, char *argv[])
279
284
connection->OnConnectionResumed = std::move (onResumed);
280
285
281
286
connection->SetOnMessageHandler ([](Mqtt::MqttConnection &, const String &topic, const ByteBuf &payload) {
282
- fprintf (stdout, " Generic Publish received on topic %s, payload:\n " , topic.c_str ());
283
- fwrite (payload.buffer , 1 , payload.len , stdout);
284
- fprintf (stdout, " \n " );
287
+ fprintf (stdout, " Generic Publish received on topic %s, payload:\n " , topic.c_str ());
288
+ fwrite (payload.buffer , 1 , payload.len , stdout);
289
+ fprintf (stdout, " \n " );
285
290
});
286
291
287
292
/*
0 commit comments