Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DnsQuery ESP8266Interface NetworkSocketAPI mbed
Fork of HelloESP8266Interface by
Revision 2:7283ce112304, committed 2015-05-14
- Comitter:
- sam_grove
- Date:
- Thu May 14 07:28:56 2015 +0000
- Parent:
- 1:6db1940a7f76
- Child:
- 3:95de30d399d8
- Commit message:
- Updates to main. Create example network setup and teardown
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed May 13 20:17:01 2015 +0000
+++ b/main.cpp Thu May 14 07:28:56 2015 +0000
@@ -15,15 +15,38 @@
*/
#include "mbed.h"
+#include "WiFiInterface.h"
DigitalOut myled(LED1);
+
+WiFiInterface 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", WPA2);
+
+ 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 = 1;
- wait(0.2);
- myled = 0;
- wait(0.2);
+ myled = !myled;
}
}
