Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HelloMQTT by
Diff: main.cpp
- Revision:
- 33:38e2e7bf91eb
- Parent:
- 32:16ef25cbb05c
diff -r 16ef25cbb05c -r 38e2e7bf91eb main.cpp
--- a/main.cpp Sat Apr 01 12:55:49 2017 +0000
+++ b/main.cpp Sun Apr 02 09:11:53 2017 +0800
@@ -36,9 +36,7 @@
Serial pc(USBTX, USBRX, 115200);
Thread msgSender(osPriorityNormal, DEFAULT_STACK_SIZE * 2);
-#define MQTT_USE_TLS
-#ifdef MQTT_USE_TLS
/* List of trusted root CA certificates
* currently only "letsencrypt", the CA for mbedhacks.com
*
@@ -103,7 +101,7 @@
"PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6\n"
"KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==\n"
"-----END CERTIFICATE-----";
-#endif
+
static const char * clientID = "mbed-sample";
static const char * userID = "mbedhacks";
@@ -154,20 +152,13 @@
return -1;
}
-#ifdef MQTT_USE_TLS
+
MQTTThreadedClient mqtt(network, SSL_CA_PEM);
-#else
- MQTTThreadedClient mqtt(network);
-#endif
const char* hostname = "mqtt.mbedhacks.com";
// const char* hostname = "192.168.0.7";
-#ifdef MQTT_USE_TLS
int port = 8883;
-#else
- int port = 1883;
-#endif
MQTTPacket_connectData logindata = MQTTPacket_connectData_initializer;
logindata.MQTTVersion = 3;
