WIFI
Dependencies: mbed
Fork of SerialPassthroughcjsESP8266 by
main.cpp@1:a76360ca4001, 2015-04-24 (annotated)
- Committer:
- mbedAustin
- Date:
- Fri Apr 24 18:18:22 2015 +0000
- Revision:
- 1:a76360ca4001
- Parent:
- 0:59bec1fd956e
- Child:
- 2:a8dcb07a1d00
It works with esptool!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedAustin | 0:59bec1fd956e | 1 | #include "mbed.h" |
mbedAustin | 1:a76360ca4001 | 2 | |
mbedAustin | 1:a76360ca4001 | 3 | // Program to use the mbed as a serial bridge |
mbedAustin | 1:a76360ca4001 | 4 | // |
mbedAustin | 1:a76360ca4001 | 5 | Serial pc(USBTX, USBRX); // tx, rx |
mbedAustin | 1:a76360ca4001 | 6 | Serial dev(D1, D0); // tx, rx |
mbedAustin | 1:a76360ca4001 | 7 | |
mbedAustin | 1:a76360ca4001 | 8 | void send() { |
mbedAustin | 1:a76360ca4001 | 9 | while (pc.readable()) { |
mbedAustin | 1:a76360ca4001 | 10 | dev.putc(pc.getc()); |
mbedAustin | 0:59bec1fd956e | 11 | } |
mbedAustin | 0:59bec1fd956e | 12 | } |
mbedAustin | 1:a76360ca4001 | 13 | |
mbedAustin | 1:a76360ca4001 | 14 | void recv() { |
mbedAustin | 1:a76360ca4001 | 15 | pc.putc(dev.getc()); |
mbedAustin | 1:a76360ca4001 | 16 | } |
mbedAustin | 1:a76360ca4001 | 17 | |
mbedAustin | 1:a76360ca4001 | 18 | int main() { |
mbedAustin | 1:a76360ca4001 | 19 | char c; |
mbedAustin | 1:a76360ca4001 | 20 | |
mbedAustin | 1:a76360ca4001 | 21 | // PC serial |
mbedAustin | 1:a76360ca4001 | 22 | pc.baud(9600); |
mbedAustin | 1:a76360ca4001 | 23 | pc.attach(send, Serial::RxIrq); |
mbedAustin | 1:a76360ca4001 | 24 | |
mbedAustin | 1:a76360ca4001 | 25 | // Device serial |
mbedAustin | 1:a76360ca4001 | 26 | dev.baud(9600); // LS20031 57600 |
mbedAustin | 1:a76360ca4001 | 27 | |
mbedAustin | 1:a76360ca4001 | 28 | //dev.printf("$PMTK314,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,5*2D\r\n"); |
mbedAustin | 1:a76360ca4001 | 29 | //dev.printf("$PMTK103*30\r\n"); |
mbedAustin | 1:a76360ca4001 | 30 | wait(0.1); |
mbedAustin | 1:a76360ca4001 | 31 | dev.printf("AT+RST\r\n"); |
mbedAustin | 1:a76360ca4001 | 32 | while(1) { |
mbedAustin | 1:a76360ca4001 | 33 | |
mbedAustin | 1:a76360ca4001 | 34 | c = dev.getc(); |
mbedAustin | 1:a76360ca4001 | 35 | pc.putc(c); |
mbedAustin | 1:a76360ca4001 | 36 | |
mbedAustin | 1:a76360ca4001 | 37 | } |
mbedAustin | 1:a76360ca4001 | 38 | |
mbedAustin | 1:a76360ca4001 | 39 | } |