Votecontroller

Dependencies:   MQTT

Fork of PGO6_VoteController_template by Jens de hoog

Revision:
4:bb892177ce23
Parent:
3:793425387c91
Child:
5:592f4272c549
diff -r 793425387c91 -r bb892177ce23 main.cpp
--- a/main.cpp	Mon Oct 15 14:30:31 2018 +0000
+++ b/main.cpp	Mon Oct 15 14:54:25 2018 +0000
@@ -55,7 +55,6 @@
     
     network.connect(BROKER_NAME, BROKER_PORT);
     MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
-    
     data.MQTTVersion = MQTT_VERSION;
     data.clientID.cstring = "client-ruben";
     data.username.cstring = "user";
@@ -67,7 +66,9 @@
 
 void sendMessage(MQTT::Client<MQTTNetwork, Countdown>* client, char* topic, char* buf, int qos, bool retained, bool duplicate){
     MQTT::Message message;
-    message.qos = MQTT::QOS0;
+    if(qos == 0){
+        message.qos = MQTT::QOS0;
+    }
     message.retained = retained;
     message.dup = duplicate;
     message.payload = (void*)buf;
@@ -78,9 +79,11 @@
 
 int main(int argc, char* argv[])
 {
-    printf("boot");
+    printf("boot\n");
     button.fall(callback(&button1_onpressed_cb));
+    printf("here\n");
     MQQTConnect();
+    printf("connected\n");
     while(connected){
         if(!button1_busy && multiclick_state != 0){
             char* buf = "";
@@ -100,6 +103,7 @@
                     connected = false;
                     led2 = 0;
             }
+            multiclick_state = 0;
             printf("\n click %d: %s", multiclick_state, buf);
         }
     }