Example program for the BSDInterface
Dependencies: BSDInterface NetworkSocketAPI
Fork of HelloLWIPInterface by
Revision 16:bb0a5b830dc5, committed 2015-07-17
- Comitter:
- sarahmarshy
- Date:
- Fri Jul 17 23:16:57 2015 +0000
- Parent:
- 15:e48b3c6558b1
- Child:
- 17:72de842c27b4
- Commit message:
- Test UDP socket dev and ESP8266 implementation
Changed in this revision
--- a/ATParser.lib Thu Jul 16 05:20:12 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://developer.mbed.org/teams/NetworkSocketAPI/code/ATParser/#c741e144517c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ESP8266Interface.lib Fri Jul 17 23:16:57 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/NetworkSocketAPI/code/WiFiRadioInterface/#9fc7976c7b27
--- a/NetworkSocketAPI.lib Thu Jul 16 05:20:12 2015 +0000 +++ b/NetworkSocketAPI.lib Fri Jul 17 23:16:57 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/NetworkSocketAPI/code/NetworkSocketAPI/#ab3679eb4d9d +http://developer.mbed.org/teams/NetworkSocketAPI/code/NetworkSocketAPI/#f84e69b3fdd3
--- a/WiFiRadioInterface.lib Thu Jul 16 05:20:12 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://developer.mbed.org/teams/NetworkSocketAPI/code/WiFiRadioInterface/#c3f4095337b8
--- 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();