
to check out local tool chain for debugging purpose
Diff: main.cpp
- Revision:
- 2:67fa41d8cb21
- Parent:
- 1:e212820b1d24
- Child:
- 3:477981be79da
--- a/main.cpp Sat Oct 01 14:11:15 2016 +0000 +++ b/main.cpp Sun Nov 27 15:56:04 2016 +0000 @@ -1,18 +1,55 @@ #include "mbed.h" - +#include "ESP8266Interface.h" DigitalOut myled(LED1); DigitalIn switchInput(PTB16); +ESP8266Interface esp(D1, D0); + +Serial output(USBTX, USBRX); + + +int esp8266_init(void); + int main() { - static uint8_t led_mode=1; + + esp8266_init(); while(1) { - - //myled.write(1); - wait(200); - - myled.write(0); + } } + + +int esp8266_init(void) +{ + output.baud(115200); + + output.printf("Starting\r\n"); + NetworkInterface *network_interface = 0; + int connect_success = -1; + output.printf("\n\rUsing WiFi \r\n"); + output.printf("\n\rConnecting to WiFi..\r\n"); + connect_success = esp.connect("YEE", "YEE1235678900"); + network_interface = &esp; + + if(connect_success == 0) + { + output.printf("\n\rConnected to Network successfully\r\n"); + } + else + { + output.printf("\n\rConnection to Network Failed %d! Exiting application....\r\n", connect_success); + return 0; + } + + const char *ip_addr = network_interface->get_ip_address(); + if (ip_addr) { + output.printf("IP address %s\r\n", ip_addr); + } else { + output.printf("No IP address\r\n"); + } + + return 0; +} \ No newline at end of file