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.
Dependencies: C12832_lcd ConfigFile EthernetInterface LM75B MMA7660 MQTTPacket mbed-rtos mbed
Fork of IBMIoTClientExampleForLPC1768 by
Diff: src/QuickstartClient.cpp
- Revision:
- 8:e58e10ca4352
- Parent:
- 7:2c5d0dbd7985
- Child:
- 9:cbabd85f2d5d
diff -r 2c5d0dbd7985 -r e58e10ca4352 src/QuickstartClient.cpp
--- a/src/QuickstartClient.cpp Tue Jul 01 08:22:36 2014 +0000
+++ b/src/QuickstartClient.cpp Tue Jul 01 10:08:39 2014 +0000
@@ -39,8 +39,6 @@
char value1[30];
char value2[30];
char value3[30];
- lcd.cls();
- lcd.locate(0,0);
if (cfg.read("/local/device.cfg")) {
quickstartMode = false;
@@ -130,11 +128,8 @@
//Construct client ID
string str = string("d:") + org + ":" + type + ":" + id;
- char clientId[str.size()];
+ char clientId[str.size()+1];
memcpy(clientId, str.c_str(), str.size() + 1);
- lcd.cls();
- lcd.locate(0,0);
- //lcd.printf("cleint id : %s",clientId);
//Set MQTT connect options
data.clientID.cstring = clientId;
@@ -142,12 +137,10 @@
data.cleansession = 1;
data.MQTTVersion = 3;
if (!quickstartMode) {
- data.username.cstring = "d:ibm_test:TestDevice:Device1";//clientId;
- //TODO: set mqtt password to the token in the config file it it is NOT in quickstart mode
- char authToken[token.size()+1];
+ data.username.cstring = clientId;
+ char* authToken= new char[token.size()];
memcpy(authToken, token.c_str(), token.size()+1);
- //lcd.printf("password %s",authToken);
- data.password.cstring = "M00sesRule!";//authToken;
+ data.password.cstring = authToken;
}
//Attempt MQTT connect
@@ -155,8 +148,6 @@
rc = 0;
while (rc < len) {
int rc1 = mysock.send(buf, len);
- lcd.printf(" connect rc %d\n",rc1);
- wait(3.0);
if (rc1 == -1) {
connected = false;
break;
@@ -179,9 +170,7 @@
MQTTString topicString = MQTTString_initializer;
topicString.cstring = topic;
- lcd.cls();
- lcd.locate(0,0);
- lcd.printf("inside 1");
+
//Convert payload from string to char array
char* payload = new char [thePayload.length()+1];
std::strcpy (payload, thePayload.c_str());
@@ -191,7 +180,6 @@
rc = 0;
while (rc < len) {
int rc1 = mysock.send(buf, len);
- lcd.printf(" publish rc1 %d\n",rc1);
wait(3.0);
if (rc1 == -1) {
//If return code from MQTT publish is -1, attempt reconnect
