BUTTON LED COMBO - ST IOT CHALLENGE 2020
Dependencies: Cayenne-MQTT-mbed mbed X_NUCLEO_IDW01M1v2 NetworkSocketAPI
Diff: main.cpp
- Revision:
- 16:80ddc2c6c23a
- Parent:
- 15:1d137afcf37c
--- a/main.cpp Fri Feb 28 02:50:38 2020 +0000 +++ b/main.cpp Mon Mar 02 13:24:14 2020 +0000 @@ -15,7 +15,7 @@ // Cayenne authentication info. This should be obtained from the Cayenne Dashboard. char* username = "4f3fbcb0-3796-11e9-ad96-c15442ccb423"; char* password = "9e099f3d9aaedd7b76ca94044c6bb488c3999e3c"; -char* clientID = "4288d2f0-a5a9-11e9-9636-f9904f7b864b"; +char* clientID = "ce34fd90-5c80-11ea-a38a-d57172a4b4d4"; SpwfSAInterface interface(D8, D2); // TX, RX MQTTNetwork<SpwfSAInterface> network(interface); @@ -50,7 +50,7 @@ MQTTTimer publishData(MQTTTimer timer, int data1, int data2){ // Publish some example data every few seconds. This should be changed to send your actual data to Cayenne. -// if (timer.expired()) { + if (timer.expired()) { int error = 0; if ((error = mqttClient.publishData(DATA_TOPIC, 1, TYPE_VOLTAGE, UNIT_DIGITAL, data1)) != CAYENNE_SUCCESS) { printf("Publish data failed, error: %d\n", error); @@ -59,8 +59,8 @@ printf("Publish data failed, error: %d\n", error); } // Restart the countdown timer for publishing data every 5 seconds. Change the timeout parameter to publish at a different interval. -// timer.countdown_ms(1500); -// } + timer.countdown_ms(3000); + } return timer; } @@ -173,8 +173,8 @@ } // Send device info. Here we just send some example values for the system info. These should be changed to use actual system data, or removed if not needed. -// mqttClient.publishData(SYS_VERSION_TOPIC, CAYENNE_NO_CHANNEL, NULL, NULL, CAYENNE_VERSION); -// mqttClient.publishData(SYS_MODEL_TOPIC, CAYENNE_NO_CHANNEL, NULL, NULL, "mbedDevice"); + mqttClient.publishData(SYS_VERSION_TOPIC, CAYENNE_NO_CHANNEL, NULL, NULL, CAYENNE_VERSION); + mqttClient.publishData(SYS_MODEL_TOPIC, CAYENNE_NO_CHANNEL, NULL, NULL, "mbedDevice"); //mqttClient.publishData(SYS_CPU_MODEL_TOPIC, CAYENNE_NO_CHANNEL, NULL, NULL, "CPU Model"); //mqttClient.publishData(SYS_CPU_SPEED_TOPIC, CAYENNE_NO_CHANNEL, NULL, NULL, "1000000000"); @@ -187,12 +187,12 @@ void loop(void) { // Start the countdown timer for publishing data every 5 seconds. Change the timeout parameter to publish at a different interval. - MQTTTimer timer(200); + MQTTTimer timer(3000); while (true) { // Yield to allow MQTT message processing. - mqttClient.yield(200); + mqttClient.yield(1000); // Check that we are still connected, if not, reconnect. if (!network.connected() || !mqttClient.connected()) {