Example program for the BSDInterface

Dependencies:   BSDInterface NetworkSocketAPI

Fork of HelloLWIPInterface by NetworkSocketAPI

Files at this revision

API Documentation at this revision

Comitter:
sam_grove
Date:
Mon Dec 28 06:42:51 2015 +0000
Parent:
23:9ca7d3d1a2df
Child:
25:eef7d93d9f5b
Commit message:
update example program to use NTP

Changed in this revision

DnsQuery.lib Show annotated file Show diff for this revision Revisions of this file
ESP8266Interface.lib Show annotated file Show diff for this revision Revisions of this file
NetworkSocketAPI.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/DnsQuery.lib	Thu Aug 13 15:50:46 2015 +0000
+++ b/DnsQuery.lib	Mon Dec 28 06:42:51 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/sarahmarshy/code/DnsQuery/#12d08f0f20cf
+http://developer.mbed.org/users/sarahmarshy/code/DnsQuery/#5705fdae6185
--- a/ESP8266Interface.lib	Thu Aug 13 15:50:46 2015 +0000
+++ b/ESP8266Interface.lib	Mon Dec 28 06:42:51 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/NetworkSocketAPI/code/ESP8266Interface/#6426873b21bd
+https://developer.mbed.org/teams/NetworkSocketAPI/code/ESP8266Interface/#c19f1e61063b
--- a/NetworkSocketAPI.lib	Thu Aug 13 15:50:46 2015 +0000
+++ b/NetworkSocketAPI.lib	Mon Dec 28 06:42:51 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/NetworkSocketAPI/code/NetworkSocketAPI/#412be55c4ee8
+http://developer.mbed.org/teams/NetworkSocketAPI/code/NetworkSocketAPI/#3ad72f5406bf
--- a/main.cpp	Thu Aug 13 15:50:46 2015 +0000
+++ b/main.cpp	Mon Dec 28 06:42:51 2015 +0000
@@ -25,31 +25,31 @@
 int main()
 {
     Ticker t;
-    t.attach(flash, 0.2f);
+    t.attach(flash, 0.4f);
     printf("NetworkSocketAPI Example\r\n");
 
     wifi.init();
-    wifi.connect("iotlab", "42F67YxLX4AawRdcj");
+    wifi.connect("DemoRoom", "");
     
-    char* ip;
-    ip = wifi.getIPAddress();
+    char* ip = wifi.getIPAddress();
     printf("IP Address is: %s\n", (ip) ? ip : "No IP");
     char host_ip[50];
-    wifi.getHostByName("google.com",host_ip);
-    printf("Google.com resolved to: %s\n",host_ip);
-    
+    wifi.getHostByName("time-a.nist.gov", host_ip);
+    printf("time-a.nist.gov resolved to: %s\n", host_ip);
 
     SocketInterface* mySocket = wifi.allocateSocket(SOCK_TCP);
-    char recieved[100];
+    char recieved[100] = {0};
     int recv_amnt = 0;
     
     //Sending and receiving from echo server 
-    mySocket->setAddressPort("192.168.13.8", 7);
+    mySocket->setAddressPort(host_ip, 37);
     mySocket->open();
-    mySocket->send("Hello",5, 10000);
-    recieved[5] = 0;
-    recv_amnt = mySocket->recv(recieved, 5, 10000);
-    printf("Recieved: %d, %s\n",recv_amnt, recieved);
+    //mySocket->send("xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx", 50, 10000);
+    recv_amnt = mySocket->recv(recieved, sizeof(recieved), 10000);
     mySocket->close();
     wifi.disconnect();
+    
+    printf("Recieved: %d bytes, %02x%02x%02x%02x\n", recv_amnt, recieved[0], recieved[1], recieved[2], recieved[3]);
+    printf("NetworkSocketAPI Example Finished\r\n");
+    while(1);
 }
--- a/mbed.bld	Thu Aug 13 15:50:46 2015 +0000
+++ b/mbed.bld	Mon Dec 28 06:42:51 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/b9ad9a133dc7
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c
\ No newline at end of file