孙柏雨 仓库
Revision 1:4d8def597e29, committed 2018-07-20
- Comitter:
- xmwmx
- Date:
- Fri Jul 20 08:20:41 2018 +0000
- Parent:
- 0:7725181a2a09
- Commit message:
- first useful edition
Changed in this revision
SBY/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7725181a2a09 -r 4d8def597e29 SBY/main.cpp --- a/SBY/main.cpp Fri Jul 20 07:05:20 2018 +0000 +++ b/SBY/main.cpp Fri Jul 20 08:20:41 2018 +0000 @@ -4,6 +4,7 @@ #include "mbed.h" + Serial ser2usb(PA_2, PA_3, 115200); int state = 0; void open(int row,int col); @@ -23,7 +24,8 @@ int main() { SetUp(); - wait(0.5); + wait(2); + @@ -40,19 +42,20 @@ //声明所有的执行器,每行一个,每个由名字、参数类型两部分组成,最后一行必须为空指针作为结尾 const char* actuators[][2] = { - "openstore", "int", + "do", "int", NULL, NULL //最后一行以空指针作为结束标记 }; //ser2usb.printf("connecting...\r\n"); //连接到服务器 - client.connect_mqtt_broker("192.168.12.1", "store", sensors, actuators); + client.connect_mqtt_broker("192.168.12.1", "car", sensors, actuators); ser2usb.printf("Initialization done.\r\n"); char actuator_name[32], control_value[32]; Timer t;// 定时器用于计量发送传感器数据的时间 t.start(); - client.publish_value("openstore", "storeinit"); + client.publish_value("do", "carinit"); + while(1) { //检查有没有收到新的执行器控制指令 @@ -65,32 +68,35 @@ { case 1: open(0,0); - client.publish_value("openstore", "storefinish"); + client.publish_value("do", "carfinish"); break; case 2: open(0,1); - client.publish_value("openstore", "storefinish"); + client.publish_value("do", "carfinish"); break; case 3: open(0,2); - client.publish_value("openstore", "storefinish"); + client.publish_value("do", "carfinish"); break; case 4: open(1,0); - client.publish_value("openstore", "storefinish"); + client.publish_value("do", "carfinish"); break; case 5: open(1,1); - client.publish_value("openstore", "storefinish"); + client.publish_value("do", "carfinish"); break; case 6: - open(red[1],black[2]); - client.publish_value("openstore", "storefinish"); + open(1,2); + client.publish_value("do", "carfinish"); default: break; } } - } + } + + + } void SetUp()