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: LWIPInterface NetworkSocketAPI mbed-rtos mbed
Fork of HelloESP8266Interface by
Diff: main.cpp
- Revision:
- 16:bb0a5b830dc5
- Parent:
- 15:e48b3c6558b1
- Child:
- 17:72de842c27b4
--- a/main.cpp Thu Jul 16 05:20:12 2015 +0000
+++ b/main.cpp Fri Jul 17 23:16:57 2015 +0000
@@ -15,38 +15,29 @@
*/
#include "mbed.h"
-#include "WiFiRadioInterface.h"
+#include "ESP8266Interface.h"
DigitalOut myled(LED1);
-WiFiRadioInterface wifi(D1, D0);
+ESP8266Interface wifi(D1, D0);
int main()
{
printf("NetworkSocketAPI Example\r\n");
wifi.init();
- wifi.connect("apname", "phrase", WI_WPA2);
-
- printf("Wifi is %s\r\n", (wifi.isConnected() > 0) ? "Connected" : "Disconnected");
-
- printf("IP: %s\r\n", wifi.getIPAddress());
- printf("Gateway: %s\r\n", wifi.getGateway());
- printf("Mask: %s\r\n", wifi.getNetworkMask());
- printf("MAC: %s\r\n", wifi.getMACAddress());
-
- SocketInterface* myTCPSocket = wifi.allocateSocket(SOCK_TCP);
+ wifi.connect("Buffalo-G-1280", "13808136");
+
SocketInterface* myUDPSocket = wifi.allocateSocket(SOCK_UDP);
- myTCPSocket->setAddress(myTCPSocket->getHostByName("www.google.com"));
- myTCPSocket->setAddress("216.58.192.46");
- myTCPSocket->setPort(80);
+ myUDPSocket->setAddressPort("192.168.13.5", 7);
- myTCPSocket->close();
-
- myUDPSocket->setAddress(myUDPSocket->getHostByName("www.google.com"));
- myUDPSocket->setAddress("216.58.192.46");
- myUDPSocket->setPort(80);
+ myUDPSocket->open();
+ myUDPSocket->send("Hello",5, 10000);
+ char recieved[100];
+ int recv_amnt = 0;
+ recv_amnt = myUDPSocket->recv(recieved, 5, 10000);
+ printf("Recieved: %d, %s\n",recv_amnt,recieved);
myUDPSocket->close();
