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 6:e4c690c45021, committed 2014-05-11
- Comitter:
- icraggs
- Date:
- Sun May 11 18:52:57 2014 +0000
- Parent:
- 3:7a6a899de7cc
- Child:
- 7:3de634f2d40c
- Commit message:
- Wildcard subscriptions
Changed in this revision
--- a/MQTT.lib Tue May 06 09:45:22 2014 +0000 +++ b/MQTT.lib Sun May 11 18:52:57 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/mqtt/code/MQTT/#05fc7de97d4a +http://mbed.org/teams/mqtt/code/MQTT/#8b2abe9bd814
--- a/main.cpp Tue May 06 09:45:22 2014 +0000
+++ b/main.cpp Sun May 11 18:52:57 2014 +0000
@@ -127,38 +127,30 @@
++arrivedcount;
}
-int connect(MQTT::Client<IPStack, Countdown>::connectionLostInfo* info)
-{
- char* hostname = "m2m.eclipse.org";
- int port = 1883;
- lcd.printf("Connecting to %s:%d\n", hostname, port);
- int rc = info->network->connect(hostname, port);
- lcd.printf("rc from TCP connect is %d\n", rc);
-
- MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
- data.MQTTVersion = 3;
- data.clientID.cstring = "mbed-icraggs";
- rc = info->client->connect(&data);
- lcd.printf("rc from MQTT connect is %d\n", rc);
-
- return rc;
-}
-
int main(int argc, char* argv[])
{
IPStack ipstack = IPStack();
- float version = 0.3;
+ float version = 0.42;
char* topic = "mbed-sample";
lcd.printf("Version is %f\n", version);
MQTT::Client<IPStack, Countdown> client = MQTT::Client<IPStack, Countdown>(ipstack);
- client.setConnectionLostHandler(connect);
-
- MQTT::Client<IPStack, Countdown>::connectionLostInfo info = {&client, &ipstack};
- int rc = connect(&info);
+ char* hostname = "m2m.eclipse.org";
+ int port = 1883;
+ lcd.printf("Connecting to %s:%d\n", hostname, port);
+ int rc = ipstack.connect(hostname, port);
+ if (rc != 0)
+ lcd.printf("rc from TCP connect is %d\n", rc);
+
+ MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
+ data.MQTTVersion = 3;
+ data.clientID.cstring = "mbed-icraggs";
+ rc = client.connect(&data);
+ if (rc != 0)
+ lcd.printf("rc from MQTT connect is %d\n", rc);
rc = client.subscribe(topic, MQTT::QOS1, messageArrived);
if (rc != 0)
--- a/mbed-rtos.lib Tue May 06 09:45:22 2014 +0000 +++ b/mbed-rtos.lib Sun May 11 18:52:57 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#f88660a9bed1 +http://mbed.org/users/mbed_official/code/mbed-rtos/#5dfe422a963d
