liang brain
/
my_example_esp8266
8266
main.cpp@0:63af4719467f, 2017-10-11 (annotated)
- Committer:
- brainliang
- Date:
- Wed Oct 11 08:40:04 2017 +0000
- Revision:
- 0:63af4719467f
esp8266
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 | |
brainliang | 0:63af4719467f | 14 | Serial ser2usb(USBTX, USBRX); |
brainliang | 0:63af4719467f | 15 | |
brainliang | 0:63af4719467f | 16 | int main(void) { |
brainliang | 0:63af4719467f | 17 | Esp8266 client(0); |
brainliang | 0:63af4719467f | 18 | client.connect_mqtt_broker("tdxls-iot.xicp.net"); |
brainliang | 0:63af4719467f | 19 | ser2usb.printf("Initialization done.\r\n"); |
brainliang | 0:63af4719467f | 20 | |
brainliang | 0:63af4719467f | 21 | while(1) { |
brainliang | 0:63af4719467f | 22 | client.publish("/smartcar", "awesome smartcar!"); |
brainliang | 0:63af4719467f | 23 | client.publish("/smartcar", "awesome smartcar!"); |
brainliang | 0:63af4719467f | 24 | wait(1); |
brainliang | 0:63af4719467f | 25 | //char buf[32]; |
brainliang | 0:63af4719467f | 26 | //client.subscribe_poll("/icenter", buf, 32); |
brainliang | 0:63af4719467f | 27 | //ser2esp8266.attach(simple_callback, Serial::RxIrq); |
brainliang | 0:63af4719467f | 28 | //ser2usb.printf("%s\r\n", esp_paramBuf); |
brainliang | 0:63af4719467f | 29 | //ser2usb.printf("loop\r\n"); |
brainliang | 0:63af4719467f | 30 | //ser2usb.printf("haha\n"); |
brainliang | 0:63af4719467f | 31 | //while(1); |
brainliang | 0:63af4719467f | 32 | } |
brainliang | 0:63af4719467f | 33 | } |