Keegan Hu
/
finalcar
car
Fork of warehouse by
Diff: main.cpp
- Revision:
- 7:49a823b5a935
- Parent:
- 5:9a0acd11c445
- Child:
- 8:d5e340a59c71
diff -r 629e300b6c3b -r 49a823b5a935 main.cpp --- a/main.cpp Thu Dec 07 11:55:39 2017 +0000 +++ b/main.cpp Wed Dec 13 10:09:44 2017 +0000 @@ -10,20 +10,33 @@ #include "mbed.h" #include "esp8266.h" -Serial ser2usb(PA_9, PA_10, 115200); +Serial ser2usb(PA_2, PA_3, 115200); DigitalOut LED(PD_2); +DigitalIn humansensor(PA_0); + +int test_main(void){ + Serial esp8266(PA_9, PA_10, 9600); + while(1){ + if(ser2usb.readable()) + esp8266.putc(ser2usb.getc()); + if(esp8266.readable()) + ser2usb.putc(esp8266.getc()); + } +} int main(void) { + // 选定与 esp8266 相连接的串口,WiFi 名称和密码 // 参数分别为 TX pin / RX pin / SSID / Password - Esp8266 client(PA_2, PA_3, "TSINGHUA.iCenter", "TS.icenter"); + Esp8266 client(PA_9, PA_10, "TSINGHUA.iCenter", "TS.icenter"); //声明所有的传感器,每行一个,每个由名字、单位两部分组成,最后一行必须为空指针作为结尾 //服务器收到声明后,将在网页上显示这些传感器 const char* sensors[][2] = { - "pressure", "Pa", - "temperature", "C", - "humidity", "%", + //"pressure", "Pa", +// "temperature", "C", +// "humidity", "%", + "huamn","person", NULL, NULL //最后一行以空指针作为结束标记 }; @@ -61,9 +74,10 @@ if(t.read() - last_report > 1){ // 每1s发送汇报一次传感器数据 //汇报传感器数据,两个参数分别是传感器名字和值 - client.publish_value("pressure", "100000 Pa"); - client.publish_value("temperature", "20 C"); - client.publish_value("humidity", "30 %"); + //client.publish_value("pressure", "100000 Pa"); +// client.publish_value("temperature", "20 C"); +// client.publish_value("humidity", "30 %"); + client.publish_value("huamn", "30 %"); last_report = t.read(); }