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:
- 9:da5a230fa4f4
- Parent:
- 7:6787b920b496
- Child:
- 11:b7e531a4d661
diff -r cb6e31861ac9 -r da5a230fa4f4 main.cpp --- a/main.cpp Wed Jun 17 21:04:47 2015 +0000 +++ b/main.cpp Wed Jun 17 23:38:33 2015 +0000 @@ -44,6 +44,18 @@ printf("Gateway: %s\n", wifi.getGateway()); printf("Mask: %s\n", wifi.getNetworkMask()); printf("MAC: %s\n", wifi.getMACAddress()); + + //Endpoint google; + wifi.set_address(wifi.get_host_by_name("www.google.com")); + wifi.set_address("216.58.192.46"); + wifi.set_port(80); + + //Socket socket; + char buf[1024]; + wifi.connect(*wifi.endpoint); + wifi.recv(buf, 1024); + wifi.send(buf, sizeof(buf)); + wifi.close(*wifi.endpoint); wifi.disconnect();