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
- Branch:
- mutualAuth
- Revision:
- 34:8f7a465c2192
- Parent:
- 29:bc323243010e
- Child:
- 35:c8fd5859a455
--- a/main.cpp Wed Apr 25 17:21:32 2018 +0900
+++ b/main.cpp Thu Jun 07 15:50:02 2018 +0900
@@ -32,9 +32,10 @@
#include "MQTTmbed.h"
#include "MQTTClient.h"
#include "MQTT_server_setting.h"
+#include "mbed-trace/mbed_trace.h"
// Number of messages received from server.
-int arrivedcount = 0;
+unsigned int arrivedcount = 0;
/*
* Callback function called when a message arrived from server.
@@ -51,12 +52,14 @@
int main(int argc, char* argv[])
{
+ mbed_trace_init();
+
NetworkInterface* network = NULL;
MQTTNetwork* mqttNetwork = NULL;
MQTT::Client<MQTTNetwork, Countdown>* mqttClient = NULL;
const float version = 0.7;
- const char* topic = "mbed-sample";
+ const char* topic = "mbed-test";
bool isSubscribed = false;
printf("HelloMQTT: version is %.2f\r\n", version);
@@ -76,7 +79,8 @@
printf("Connecting to host %s:%d ...\r\n", MQTT_SERVER_HOST_NAME, MQTT_SERVER_PORT);
{
mqttNetwork = new MQTTNetwork(network);
- int rc = mqttNetwork->connect(MQTT_SERVER_HOST_NAME, MQTT_SERVER_PORT, SSL_CA_PEM);
+ int rc = mqttNetwork->connect(MQTT_SERVER_HOST_NAME, MQTT_SERVER_PORT, SSL_CA_PEM,
+ SSL_CLIENT_CERT_PEM, SSL_CLIENT_PRIVATE_KEY_PEM);
if (rc != MQTT::SUCCESS){
printf("ERROR: rc from TCP connect is %d\r\n", rc);
goto ERROR;
