Wifi module configuration for GR_Peach
Dependencies: mbed
Wifi.cpp
- Committer:
- RahulSitaram
- Date:
- 2016-12-06
- Revision:
- 1:e5ef21ebff5f
- Parent:
- 0:7d24b78f9a5e
- Child:
- 2:19bd6403dc75
File content as of revision 1:e5ef21ebff5f:
#include "mbed.h" #include <string> DigitalOut led1(LED1); DigitalOut led2(LED2); string data; uint8_t wifi_ack; Serial pc(USBTX, USBRX); //Serial Wifi(P2_14,P2_15); Serial Wifi(P2_14, P2_15); bool i = true; bool j = false; char MSB; char LSB; void call() { // Note: you need to actually read from the serial to clear the RX interrupt data = Wifi.getc(); pc.printf("%c\n", data); // Wifi.printf("%c",data); } int main() { //pc.attach(&call); pc.baud(9600); Wifi.baud(115200); //Wifi.attach(&call); /*while(1){ //Wifi.printf("AT\n"); //pc.printf("done!\n"); if(pc.readable()) { pc.putc(pc.getc()); led1 = ~led1; } if(Wifi.readable()) { pc.putc(Wifi.getc()); led2 = ~led2; } //wifi_ack = Wifi.getc(); //pc.printf("%c\n", wifi_ack); //wait(5); }*/ while (1) { if(Wifi.readable()) // check if the esp is sending a message { while(Wifi.readable()) { // The esp has data so display its output to the serial window char c = Wifi.getc(); // read the next character. pc.putc(c); //pc.printf("%c", c); i=~i; } } if(pc.readable()) // check if the esp is sending a message { while(pc.readable()) { // The esp has data so display its output to the serial window char d = pc.getc(); // read the next character. Wifi.putc(d); //pc.printf("%c", c); j=~j; } } led1=i; led2=j; } }