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
Revision 23:85b0a1df7d75, committed 2017-10-03
- Comitter:
- icraggs
- Date:
- Tue Oct 03 22:56:42 2017 +0000
- Parent:
- 22:f5f6c9059eed
- Commit message:
- Update client id and hostname
Changed in this revision
MQTT.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MQTT.lib Mon Sep 11 16:43:49 2017 +0200 +++ b/MQTT.lib Tue Oct 03 22:56:42 2017 +0000 @@ -1,1 +1,1 @@ -https://mbed.org/teams/mqtt/code/MQTT/#c37c8236e84a +https://os.mbed.com/users/icraggs/code/MQTT/#71ae1a773b64
--- a/main.cpp Mon Sep 11 16:43:49 2017 +0200 +++ b/main.cpp Tue Oct 03 22:56:42 2017 +0000 @@ -43,6 +43,7 @@ #endif #define MQTTCLIENT_QOS2 1 +#define MQTT_DEBUG 1 #include "easy-connect.h" #include "MQTTNetwork.h" @@ -77,7 +78,7 @@ MQTT::Client<MQTTNetwork, Countdown> client(mqttNetwork); - const char* hostname = "m2m.eclipse.org"; + const char* hostname = "iot.eclipse.org"; int port = 1883; logMessage("Connecting to %s:%d\r\n", hostname, port); int rc = mqttNetwork.connect(hostname, port); @@ -85,8 +86,10 @@ logMessage("rc from TCP connect is %d\r\n", rc); MQTTPacket_connectData data = MQTTPacket_connectData_initializer; - data.MQTTVersion = 3; - data.clientID.cstring = "mbed-sample"; + char clientid[30]; + sprintf(clientid, "mbed-sample-%d", rand()); + logMessage("Client id is %s\r\n", clientid); + data.clientID.cstring = clientid; data.username.cstring = "testuser"; data.password.cstring = "testpassword"; if ((rc = client.connect(data)) != 0)