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:
Sun Jul 26 21:55:02 2015 +0000
Parent:
19:03f1da306347
Child:
22:1d355289fc18
Commit message:
Update dependencies and example

Changed in this revision

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
--- a/ESP8266Interface.lib	Wed Jul 22 20:55:47 2015 +0000
+++ b/ESP8266Interface.lib	Sun Jul 26 21:55:02 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/NetworkSocketAPI/code/ESP8266Interface/#312453862371
+https://developer.mbed.org/teams/NetworkSocketAPI/code/ESP8266Interface/#37504440f296
--- a/NetworkSocketAPI.lib	Wed Jul 22 20:55:47 2015 +0000
+++ b/NetworkSocketAPI.lib	Sun Jul 26 21:55:02 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/NetworkSocketAPI/code/NetworkSocketAPI/#e657a90d9511
+http://developer.mbed.org/teams/NetworkSocketAPI/code/NetworkSocketAPI/#412be55c4ee8
--- a/main.cpp	Wed Jul 22 20:55:47 2015 +0000
+++ b/main.cpp	Sun Jul 26 21:55:02 2015 +0000
@@ -18,11 +18,14 @@
 #include "ESP8266Interface.h"
 
 DigitalOut myled(LED1);
+void flash(){myled = !myled;}
 
 ESP8266Interface wifi(D1, D0);
 
 int main()
-{    
+{
+    Ticker t;
+    t.attach(flash, 0.2f);
     printf("NetworkSocketAPI Example\r\n");
 
     wifi.init();
@@ -30,29 +33,19 @@
     
     char* ip;
     ip = wifi.getIPAddress();
-    if(ip!=NULL)
-        printf("IP Address is: %s",ip);
-    else
-        printf("No IP");
+    printf("IP Address is: %s\n", (ip) ? ip : "No IP");
     
     SocketInterface* mySocket = wifi.allocateSocket(SOCK_UDP);
-        
+    char recieved[100];
+    int recv_amnt = 0;
     
     mySocket->setAddressPort("192.168.13.6", 7);
-    
     mySocket->open();
     mySocket->send("Hello",5, 10000);
-    char recieved[100];
-    int recv_amnt = 0;
     recieved[5] = 0;
     recv_amnt = mySocket->recv(recieved, 5, 10000);
-    printf("Recieved: %d, %s\n",recv_amnt,recieved);
+    printf("Recieved: %d, %s\n",recv_amnt, recieved);
     
     mySocket->close();
-    
     wifi.disconnect();
-    
-    while(1) {
-        myled = !myled;
-    }
 }