![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Example program for the LWIPInterface
Dependencies: LWIPInterface NetworkSocketAPI mbed-rtos mbed
Fork of HelloESP8266Interface by
Example for the NetworkSocketAPI. Attempts to get the device's public facing IP address from ifcfg.me.
main.cpp
- Committer:
- sam_grove
- Date:
- 2015-06-17
- Revision:
- 6:751245e265f6
- Parent:
- 4:cb8a17dd6746
- Child:
- 7:6787b920b496
File content as of revision 6:751245e265f6:
/* NetworkSocketAPI Example Program * Copyright (c) 2015 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "mbed.h" #include "ESP8266Interface.h" DigitalOut myled(LED1); ESP8266Interface wifi; // or //NetworkInterface *wifi = new WiFiInterface; //TCPSocket tcp(wifi.getInstance()); // or //SocketInterface tcp = new TCPSocket(wifi->getInstance(); //UDPSocket udp(wifi.getInstance()); // or //SocketInterface udp = new UDPSocket(wifi->getInstance(); int main() { puts("NetworkSocketAPI Example"); wifi.init(); wifi.connect("apname", "phrase", WI_WPA2); printf("Wifi is %s\n", (wifi.isConnected() > 0) ? "Connected" : "Disconnected"); printf("IP: %s\n", wifi.getIPAddress()); printf("Gateway: %s\n", wifi.getGateway()); printf("Mask: %s\n", wifi.getNetworkMask()); printf("MAC: %s\n", wifi.getMACAddress()); wifi.disconnect(); while(1) { myled = !myled; } }