IoTKitV3 / Mbed OS MQTTPublish

Dependencies:   QEI MFRC522 HTS221 IoTKit BMP180 MQTT

Fork of MQTTPublish by smd.iotkit2.ch

Revision:
24:d2f0599798a1
Parent:
23:4d8f3061890e
Child:
25:5e982d03e7d1
--- a/main.cpp	Sun Sep 02 16:32:36 2018 +0000
+++ b/main.cpp	Mon Sep 03 18:33:01 2018 +0000
@@ -21,6 +21,11 @@
 MQTT::Message message;
 // I/O Buffer
 char buf[100];
+
+// Klassifikation 
+char cls[3][10] = { "low", "middle", "high" };
+int type = 0;
+
 // UI
 OLEDDisplay oled( PTE26, PTE0, PTE1);
 DigitalOut led1( D10 );
@@ -94,7 +99,14 @@
         hum_temp.read_id(&id);
         hum_temp.get_temperature(&temp);
         hum_temp.get_humidity(&hum);    
-        sprintf( buf, "0x%X,%2.2f,%2.1f", id, temp, hum );        
+        if  ( type == 0 )
+            temp -= 5.0f;
+        else if  ( type == 2 )
+            temp += 5.0f;
+        sprintf( buf, "0x%X,%2.2f,%2.1f,%s", id, temp, hum, cls[type] ); 
+        type++;
+        if  ( type > 2 )
+            type = 0;       
         publish( mqttNetwork, client, topicTEMP );
         
         // alert Tuer offen 
@@ -104,7 +116,7 @@
             // nur einmal Melden!, bis Reset
             if  ( alert.read() == 0 )
             {
-                sprintf( buf, "door open" );
+                sprintf( buf, "alert: hall" );
                 message.payload = (void*) buf;
                 message.payloadlen = strlen(buf)+1;
                 publish( mqttNetwork, client, topicALERT );