王铭轩 仓库

Dependencies:   mbed

Fork of SBY_sw4stm32_nucleo_f103rb by w mx

Files at this revision

API Documentation at this revision

Comitter:
xmwmx
Date:
Fri Aug 03 06:22:21 2018 +0000
Parent:
2:a779f481c401
Commit message:
?????

Changed in this revision

SBY/esp8266.cpp Show annotated file Show diff for this revision Revisions of this file
SBY/main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r a779f481c401 -r 55a34662204f SBY/esp8266.cpp
--- a/SBY/esp8266.cpp	Thu Aug 02 13:02:11 2018 +0000
+++ b/SBY/esp8266.cpp	Fri Aug 03 06:22:21 2018 +0000
@@ -219,7 +219,7 @@
     
 bool Esp8266::publish_value(const char *topic, const char *data) {                      //定义类的函数
     //if (mqtt_start) {
-        ESP_CMD("m:publish('/values/'..node_name..'/%s',\"%s\",0,1)", topic, data);
+        ESP_CMD("m:publish('/values/'..node_name..'/%s',\"%s\",0,0)", topic, data);//
         wait(0.1);
     //}
     return true;
diff -r a779f481c401 -r 55a34662204f SBY/main.cpp
--- a/SBY/main.cpp	Thu Aug 02 13:02:11 2018 +0000
+++ b/SBY/main.cpp	Fri Aug 03 06:22:21 2018 +0000
@@ -98,12 +98,13 @@
             else if (strcmp(actuator_name, "dat") == 0)
             {
                 int the_command = atoi(control_value);
-                if(the_command==7)
-                {
-                    received=1;
-                    ser2usb.printf("received 7\r\n");
-                    client.publish_value("report", "received.");
-                }
+                received=1;
+                ser2usb.printf("received \r\n");
+                x[y]=the_command;
+                y++;
+                ser2usb.printf("get %s|%d\r\n",control_value,y);
+                client.publish_value("report", "received.");
+                /*
                 else
                 {
                     //received=1;
@@ -112,6 +113,7 @@
                     y++;
                     ser2usb.printf("get %s|%d\r\n",control_value,y);
                 }
+                */
             }
             /*
             ser2usb.printf("Received CMD %s %s\r\n", actuator_name, control_value);
@@ -156,17 +158,19 @@
             ser2usb.printf("ready?\r\n");
             
         }
-        if(!start&&ready)
+        if(!start&&ready&&!received)
         {
             ser2usb.printf("send start.\r\n");
             client.publish_value("report", "wait data.");
         }
         if(start)
         {
+            ser2usb.printf("starting\r\n");
             for(int i=0;x[i];i++)
             {
-                state = int(x[i]);
+                state = x[i];
                 //state = y;
+                ser2usb.printf("starting %d\r\n",state);
                 switch(state)
                 {
                     case 1:
@@ -204,7 +208,7 @@
             start=0;
             done=0;
         }
-        
+    wait(0.01);   
     }                 
 }