Keegan Hu
/
finalcar
car
Fork of warehouse by
main.cpp@2:b10925c474fc, 2017-11-07 (annotated)
- Committer:
- zhangyx
- Date:
- Tue Nov 07 04:09:57 2017 +0000
- Revision:
- 2:b10925c474fc
- Parent:
- 1:3b487c4813a2
- Child:
- 3:06080fa094a0
changes for IoT node
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
brainliang | 0:63af4719467f | 1 | /*----------------------------------------------------- |
brainliang | 0:63af4719467f | 2 | File Name : main.cpp |
brainliang | 0:63af4719467f | 3 | Purpose : For esp8266 mbed porting |
brainliang | 0:63af4719467f | 4 | Creation Date : 22-06-2017 |
brainliang | 0:63af4719467f | 5 | Last Modified : |
brainliang | 0:63af4719467f | 6 | Created By : Jeasine Ma [jeasinema[at]gmail[dot]com] |
brainliang | 0:63af4719467f | 7 | -----------------------------------------------------*/ |
brainliang | 0:63af4719467f | 8 | #include <cstdarg> |
brainliang | 0:63af4719467f | 9 | #include <cstring> |
brainliang | 0:63af4719467f | 10 | #include "mbed.h" |
brainliang | 0:63af4719467f | 11 | #include "esp8266.h" |
brainliang | 0:63af4719467f | 12 | |
brainliang | 0:63af4719467f | 13 | |
zhangyx | 2:b10925c474fc | 14 | |
brainliang | 0:63af4719467f | 15 | Serial ser2usb(USBTX, USBRX); |
brainliang | 0:63af4719467f | 16 | |
brainliang | 0:63af4719467f | 17 | int main(void) { |
zhangyx | 1:3b487c4813a2 | 18 | // 选定与 esp8266 相连接的串口,WiFi 名称和密码 |
zhangyx | 1:3b487c4813a2 | 19 | // 参数分别为 TX pin / RX pin / SSID / Password |
zhangyx | 1:3b487c4813a2 | 20 | Esp8266 client(PC_10, PC_11, "TSINGHUA.iCenter", "TS.icenter"); |
brainliang | 0:63af4719467f | 21 | client.connect_mqtt_broker("tdxls-iot.xicp.net"); |
brainliang | 0:63af4719467f | 22 | ser2usb.printf("Initialization done.\r\n"); |
brainliang | 0:63af4719467f | 23 | |
brainliang | 0:63af4719467f | 24 | while(1) { |
zhangyx | 2:b10925c474fc | 25 | client.publish("pressure", "12345"); |
brainliang | 0:63af4719467f | 26 | wait(1); |
brainliang | 0:63af4719467f | 27 | //char buf[32]; |
brainliang | 0:63af4719467f | 28 | //client.subscribe_poll("/icenter", buf, 32); |
brainliang | 0:63af4719467f | 29 | //ser2esp8266.attach(simple_callback, Serial::RxIrq); |
brainliang | 0:63af4719467f | 30 | //ser2usb.printf("%s\r\n", esp_paramBuf); |
brainliang | 0:63af4719467f | 31 | //ser2usb.printf("loop\r\n"); |
brainliang | 0:63af4719467f | 32 | //ser2usb.printf("haha\n"); |
brainliang | 0:63af4719467f | 33 | //while(1); |
brainliang | 0:63af4719467f | 34 | } |
brainliang | 0:63af4719467f | 35 | } |