Example program for the BSDInterface
Dependencies: BSDInterface NetworkSocketAPI
Fork of HelloLWIPInterface by
Revision 21:979b1db5d7da, committed 2015-07-27
- Comitter:
- sarahmarshy
- Date:
- Mon Jul 27 15:18:45 2015 +0000
- Parent:
- 19:03f1da306347
- Child:
- 42:d8ea089e5606
- Commit message:
- DnsQuery and IP
Changed in this revision
ESP8266Interface.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/ESP8266Interface.lib Wed Jul 22 20:55:47 2015 +0000 +++ b/ESP8266Interface.lib Mon Jul 27 15:18:45 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/NetworkSocketAPI/code/ESP8266Interface/#312453862371 +https://developer.mbed.org/teams/NetworkSocketAPI/code/ESP8266Interface/#91c4e9d34b77
--- a/main.cpp Wed Jul 22 20:55:47 2015 +0000 +++ b/main.cpp Mon Jul 27 15:18:45 2015 +0000 @@ -31,24 +31,29 @@ char* ip; ip = wifi.getIPAddress(); if(ip!=NULL) - printf("IP Address is: %s",ip); + printf("\nIP Address is: %s\n",ip); else printf("No IP"); - SocketInterface* mySocket = wifi.allocateSocket(SOCK_UDP); + char ip_goog[20]; + wifi.getHostByName("google.com", ip_goog); + printf("Got %s\n",ip_goog); + + /* + SocketInterface* mySocket = wifi.allocateSocket(SOCK_TCP); - mySocket->setAddressPort("192.168.13.6", 7); + mySocket->setAddressPort("192.168.13.5", 7); mySocket->open(); - mySocket->send("Hello",5, 10000); - char recieved[100]; - int recv_amnt = 0; + + mySocket->send("hello",5,10000); + char recieved[6]; recieved[5] = 0; - recv_amnt = mySocket->recv(recieved, 5, 10000); + int recv_amnt = mySocket->recv(recieved, 5, 10000); printf("Recieved: %d, %s\n",recv_amnt,recieved); - mySocket->close(); + */ wifi.disconnect();