Example program for the ESP8266Interface running Espressif Firmware
Dependencies: ESP8266Interface NetworkSocketAPI mbed
Note
This example code assumes your ESP8266 is running the Espressif Firmware. For instructions on how to update your ESP8266 to use the correct firmware see the Firmware Update Wiki Page.
This program demonstrates how to open, close, send and recv from the ESP8266 using the Network Socket API.
Diff: main.cpp
- Revision:
- 6:751245e265f6
- Parent:
- 4:cb8a17dd6746
- Child:
- 7:6787b920b496
diff -r 455deb196c7f -r 751245e265f6 main.cpp --- a/main.cpp Mon Jun 01 15:24:51 2015 -0500 +++ b/main.cpp Wed Jun 17 20:58:21 2015 +0000 @@ -15,12 +15,11 @@ */ #include "mbed.h" -#include "WiFiInterface.h" +#include "ESP8266Interface.h" DigitalOut myled(LED1); - -WiFiInterface wifi; +ESP8266Interface wifi; // or //NetworkInterface *wifi = new WiFiInterface; @@ -37,8 +36,8 @@ puts("NetworkSocketAPI Example"); wifi.init(); - wifi.connect("apname", "phrase", NetworkInterface::NI_WPA2); - + wifi.connect("apname", "phrase", WI_WPA2); + printf("Wifi is %s\n", (wifi.isConnected() > 0) ? "Connected" : "Disconnected"); printf("IP: %s\n", wifi.getIPAddress());