WIFI

Dependencies:   mbed

Fork of SerialPassthroughcjsESP8266 by chris stevens

Committer:
mbedAustin
Date:
Mon Apr 27 21:32:55 2015 +0000
Revision:
4:ba9100d52e48
Parent:
3:0393f97fd8cf
Child:
5:96cb82af9996
esptool works! changed serial -> rawserial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 0:59bec1fd956e 1 #include "mbed.h"
mbedAustin 2:a8dcb07a1d00 2
mbedAustin 4:ba9100d52e48 3 // Program to use the mbed as a serial bridge
mbedAustin 4:ba9100d52e48 4 //
mbedAustin 4:ba9100d52e48 5 RawSerial pc(USBTX, USBRX); // tx, rx
mbedAustin 4:ba9100d52e48 6 RawSerial dev(D1, D0); // tx, rx
mbedAustin 2:a8dcb07a1d00 7
mbedAustin 4:ba9100d52e48 8 void send()
mbedAustin 2:a8dcb07a1d00 9 {
mbedAustin 4:ba9100d52e48 10 while (pc.readable()) {
mbedAustin 4:ba9100d52e48 11 dev.putc(pc.getc());
mbedAustin 0:59bec1fd956e 12 }
mbedAustin 0:59bec1fd956e 13 }
mbedAustin 4:ba9100d52e48 14
mbedAustin 4:ba9100d52e48 15 void recv()
mbedAustin 4:ba9100d52e48 16 {
mbedAustin 4:ba9100d52e48 17 pc.putc(dev.getc());
mbedAustin 4:ba9100d52e48 18 }
mbedAustin 4:ba9100d52e48 19
mbedAustin 4:ba9100d52e48 20 int main()
mbedAustin 4:ba9100d52e48 21 {
mbedAustin 4:ba9100d52e48 22 char c;
mbedAustin 4:ba9100d52e48 23
mbedAustin 4:ba9100d52e48 24 // PC serial
mbedAustin 4:ba9100d52e48 25 pc.baud(9600);
mbedAustin 4:ba9100d52e48 26 pc.attach(send, Serial::RxIrq);
mbedAustin 4:ba9100d52e48 27
mbedAustin 4:ba9100d52e48 28 // Device serial
mbedAustin 4:ba9100d52e48 29 dev.baud(9600);
mbedAustin 4:ba9100d52e48 30
mbedAustin 4:ba9100d52e48 31 wait(0.1);
mbedAustin 4:ba9100d52e48 32 dev.printf("AT+RST\r\n"); // Reset esp device
mbedAustin 4:ba9100d52e48 33 while(1) {
mbedAustin 4:ba9100d52e48 34 c = dev.getc();
mbedAustin 4:ba9100d52e48 35 pc.putc(c);
mbedAustin 4:ba9100d52e48 36 }
mbedAustin 4:ba9100d52e48 37 }