Duy_new_test_Water_Monitor
Fork of Cloud_IBM_MbedOS by
Revision 2:e3846f091b6b, committed 2017-12-01
- Comitter:
- mapellil
- Date:
- Fri Dec 01 11:05:04 2017 +0100
- Parent:
- 1:731b764fb26f
- Child:
- 3:e1f6c5af437e
- Commit message:
- Added registered device (no TLS)
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed_app.json | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 27 16:17:37 2017 +0100
+++ b/main.cpp Fri Dec 01 11:05:04 2017 +0100
@@ -36,7 +36,7 @@
#define ORG_QUICKSTART // comment to connect to play.internetofthings.ibmcloud.com
//#define SUBSCRIBE // uncomment to subscribe to broker msgs (not to be used with IBM broker)
-//#define X_NUCLEO_NFC01A1_PRESENT // uncomment to add NFC support
+#define X_NUCLEO_NFC01A1_PRESENT // uncomment to add NFC support
#define MQTT_MAX_PACKET_SIZE 400
#define MQTT_MAX_PAYLOAD_SIZE 300
@@ -48,10 +48,10 @@
#define AUTH_TOKEN ""
#define DEFAULT_TYPE_NAME "iotsample-mbed-Nucleo"
#else // not def ORG_QUICKSTART
-#define ORG "play" // connect to play.internetofthings.ibmcloud.com/ For a registered connection, replace with your org
-#define ID "" // For a registered connection, replace with your id
-#define AUTH_TOKEN ""// For a registered connection, replace with your auth-token
-#define DEFAULT_TYPE_NAME "sensor"
+#define ORG MQTT_ORG_ID // connect to ORG.internetofthings.ibmcloud.com/ For a registered connection, replace with your org
+#define ID MQTT_DEVICE_ID // For a registered connection is your device id
+#define AUTH_TOKEN MQTT_DEVICE_PASSWORD // For a registered connection is a device auth-token
+#define DEFAULT_TYPE_NAME MQTT_DEVICE_TYPE // For a registered connection is device type
#endif
#define TYPE DEFAULT_TYPE_NAME // For a registered connection, replace with your type
@@ -104,7 +104,7 @@
// Construct clientId - d:org:type:id
char clientId[strlen(org) + strlen(type) + strlen(id) + 5];
sprintf(clientId, "d:%s:%s:%s", org, type, id);
- sprintf(subscription_url, "%s.%s/#/device/%s/sensor/", org, "internetofthings.ibmcloud.com",id);
+ sprintf(subscription_url, "%s.%s/#/device/%s/%s/", org, "internetofthings.ibmcloud.com", id, DEFAULT_TYPE_NAME);
// Network debug statements
LOG("=====================================\n\r");
@@ -141,6 +141,7 @@
{
data.username.cstring = "use-token-auth";
data.password.cstring = auth_token;
+ printf ("AutToken: %s\n\r", auth_token);
}
if ((rc = client->connect(data)) != 0) {
printf("rc from MQTT connect is %d\r\n", rc);
--- a/mbed_app.json Mon Nov 27 16:17:37 2017 +0100
+++ b/mbed_app.json Fri Dec 01 11:05:04 2017 +0100
@@ -5,10 +5,10 @@
"value": "WIFI_IDW0XX1"
},
"wifi-ssid": {
- "value": "\"ssid\""
+ "value": "\"SSID\""
},
"wifi-password": {
- "value": "\"passw\""
+ "value": "\"wifipassw\""
},
"wifi-tx": {
"help": "TX pin for serial connection to external device",
@@ -21,10 +21,12 @@
},
"macros": [ "MQTT_BROKER_URL=\".messaging.internetofthings.ibmcloud.com\"",
"MQTT_CLIENT_ID=\"g:pvko17:<your DEVICE_ID_TYPE>:<your DEVICE_ID>\"",
+ "MQTT_ORG_ID=\"93ygbc\"",
"MQTT_USERNAME=\"use-token-auth\"",
- "MQTT_PASSWORD=\"<your DEVICE_ID>\"",
+ "MQTT_DEVICE_PASSWORD=\"devpassw\"",
"MQTT_TOPIC=\"iot-2/evt/status/fmt/json\"",
- "MQTT_SENSOR_ID=\"<mmddyyyy>\"",
+ "MQTT_DEVICE_ID=\"licio\"",
+ "MQTT_DEVICE_TYPE=\"envsens\"",
"MQTT_KEEPALIVE 10",
"MQTT_PORT 1883",
"MQTT_TLS_PORT 8883"],
