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: Cayenne-MQTT-mbed NetworkSocketAPI X_NUCLEO_IDW01M1v2 mbed Servo
Fork of Cayenne-X-NUCLEO-IDW01M1-TMP36 by
Diff: main.cpp
- Revision:
- 7:fed254c30643
- Parent:
- 6:cec678bb15ef
- Child:
- 8:f1e261b1e25b
--- a/main.cpp Tue Aug 29 07:58:37 2017 +0000
+++ b/main.cpp Tue Aug 29 16:05:42 2017 +0000
@@ -8,7 +8,9 @@
#include "MQTTNetworkIDW01M1.h"
#include "SpwfInterface.h"
#include "BME280.hpp"
-
+#include "LED.hpp"
+//Tigger flag
+bool Flag = false;
// WiFi network info.
char* ssid = "megu megu fire";
char* wifiPassword = "66666667";
@@ -16,7 +18,7 @@
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char* username = "1f764db0-122b-11e7-b235-9359079e690e";
char* password = "0d4e9d94e7897df9af861007853ed3f906b0627d";
-char* clientID = "8ff46d80-8c81-11e7-a491-d751ec027e48";
+char* clientID = "536277d0-8cb9-11e7-9727-55550d1a07e7";
SpwfSAInterface interface(D8, D2); // TX, RX
MQTTNetwork<SpwfSAInterface> network(interface);
@@ -30,6 +32,9 @@
*/
void outputMessage(CayenneMQTT::MessageData& message)
{
+ int channel;
+ int value ;
+
switch (message.topic) {
case COMMAND_TOPIC:
printf("topic=Command");
@@ -42,15 +47,20 @@
break;
}
printf(" channel=%d", message.channel);
+ channel = message.channel;
if (message.clientID) {
printf(" clientID=%s", message.clientID);
}
if (message.type) {
printf(" type=%s", message.type);
}
+
for (size_t i = 0; i < message.valueCount; ++i) {
if (message.getValue(i)) {
printf(" value=%s", message.getValue(i));
+ /*get trigger message*/
+ value = (int)*message.getValue(i);
+ //strcpy(value,*message.getValue(i));
}
if (message.getUnit(i)) {
printf(" unit=%s", message.getUnit(i));
@@ -60,6 +70,13 @@
printf(" id=%s", message.id);
}
printf("\n");
+ printf("get channel ==%d\nget value ==%d\n",channel,value);
+ if(channel ==1 && value ==49){
+ printf("LED has been Triger\n");
+ Flag=true;
+ }else{
+ Flag=false;
+ }
}
/**
@@ -138,9 +155,14 @@
MQTTTimer timer(5000);
//TMP36 tmpSensor(A5);
BME280 bmpSensor;
+ LED led(D7);
while (true) {
+ if(Flag)
+ led.On();
+ else
+ led.Off();
// Yield to allow MQTT message processing.
mqttClient.yield(1000);
//printf("%d\n",bmpSensor->Temp_read());
