MBED wifi code from oxford repo
Dependencies: mbed
Fork of SerialPassthroughcjsESP8266 by
main.cpp@0:59bec1fd956e, 2015-04-24 (annotated)
- Committer:
- mbedAustin
- Date:
- Fri Apr 24 15:34:17 2015 +0000
- Revision:
- 0:59bec1fd956e
- Child:
- 1:a76360ca4001
polling complete, works with ESP8266
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedAustin | 0:59bec1fd956e | 1 | #include "mbed.h" |
mbedAustin | 0:59bec1fd956e | 2 | |
mbedAustin | 0:59bec1fd956e | 3 | Serial pc(USBTX, USBRX); // computer to mbed board |
mbedAustin | 0:59bec1fd956e | 4 | Serial esp(D1, D0); // mbed board to target board |
mbedAustin | 0:59bec1fd956e | 5 | DigitalOut rst(D10); |
mbedAustin | 0:59bec1fd956e | 6 | |
mbedAustin | 0:59bec1fd956e | 7 | int |
mbedAustin | 0:59bec1fd956e | 8 | main(){ |
mbedAustin | 0:59bec1fd956e | 9 | pc.baud(9600); |
mbedAustin | 0:59bec1fd956e | 10 | esp.baud(9600); |
mbedAustin | 0:59bec1fd956e | 11 | pc.printf("\r\n########### ready ###########\r\n"); |
mbedAustin | 0:59bec1fd956e | 12 | //esp.printf("AT+RST\r\n"); |
mbedAustin | 0:59bec1fd956e | 13 | rst = 0; |
mbedAustin | 0:59bec1fd956e | 14 | wait(0.1); |
mbedAustin | 0:59bec1fd956e | 15 | rst = 1; |
mbedAustin | 0:59bec1fd956e | 16 | while(1) { |
mbedAustin | 0:59bec1fd956e | 17 | if(pc.readable()) { |
mbedAustin | 0:59bec1fd956e | 18 | char c = pc.getc(); |
mbedAustin | 0:59bec1fd956e | 19 | //pc.putc(c); // echo character back to computer for sanity |
mbedAustin | 0:59bec1fd956e | 20 | //if(c == '\r'){ |
mbedAustin | 0:59bec1fd956e | 21 | // esp.printf("\r\n"); |
mbedAustin | 0:59bec1fd956e | 22 | // } |
mbedAustin | 0:59bec1fd956e | 23 | // else{ |
mbedAustin | 0:59bec1fd956e | 24 | esp.putc(c); |
mbedAustin | 0:59bec1fd956e | 25 | // } |
mbedAustin | 0:59bec1fd956e | 26 | } |
mbedAustin | 0:59bec1fd956e | 27 | if(esp.readable()) { |
mbedAustin | 0:59bec1fd956e | 28 | char c = esp.getc(); |
mbedAustin | 0:59bec1fd956e | 29 | //if(c == '\n'){ |
mbedAustin | 0:59bec1fd956e | 30 | // pc.printf("\\n"); |
mbedAustin | 0:59bec1fd956e | 31 | // } |
mbedAustin | 0:59bec1fd956e | 32 | // if(c == '\r'){ |
mbedAustin | 0:59bec1fd956e | 33 | // pc.printf("\\r"); |
mbedAustin | 0:59bec1fd956e | 34 | // } |
mbedAustin | 0:59bec1fd956e | 35 | |
mbedAustin | 0:59bec1fd956e | 36 | pc.putc(c); |
mbedAustin | 0:59bec1fd956e | 37 | } |
mbedAustin | 0:59bec1fd956e | 38 | } |
mbedAustin | 0:59bec1fd956e | 39 | } |