mbed IP library over Ethernet

Dependencies:   lwip-eth Socket lwip lwip-sys

Dependents:   denki-yohou_b Network-RTOS NTPClient_HelloWorld temp_FIAP ... more

Legacy Networking Libraries

This is an mbed 2 networking library. For mbed 5, the networking libraries have been revised to better support additional network stacks and thread safety here.

Files at this revision

API Documentation at this revision

Comitter:
emilmont
Date:
Fri Aug 03 14:43:57 2012 +0000
Parent:
20:0d9ae7845bfe
Child:
22:2a797ba9babe
Commit message:
Add timeout to network initialization

Changed in this revision

EthernetInterface.cpp Show annotated file Show diff for this revision Revisions of this file
EthernetInterface.h Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface.cpp	Wed Aug 01 13:02:38 2012 +0000
+++ b/EthernetInterface.cpp	Fri Aug 03 14:43:57 2012 +0000
@@ -72,7 +72,7 @@
     return 0;
 }
 
-int EthernetInterface::connect() {
+int EthernetInterface::connect(unsigned int timeout_ms) {
     NVIC_SetPriority(ENET_IRQn, ((0x01 << 3) | 0x01));
     NVIC_EnableIRQ(ENET_IRQn);
     
@@ -82,9 +82,9 @@
         netif_set_up(&lpcNetif);
     }
     
-    netif_inited.wait();
-    
-    return 0;
+    // -1: error, 0: timeout
+    int inited = netif_inited.wait(timeout_ms);
+    return (inited > 0) ? (0) : (-1);
 }
 
 int EthernetInterface::disconnect() {
--- a/EthernetInterface.h	Wed Aug 01 13:02:38 2012 +0000
+++ b/EthernetInterface.h	Fri Aug 03 14:43:57 2012 +0000
@@ -45,9 +45,10 @@
 
   /** Connect
   * Bring the interface up, start DHCP if needed.
+  * \param   timeout_ms  timeout in ms (default: (3)s).
   * \return 0 on success, a negative number on failure
   */
-  static int connect();
+  static int connect(unsigned int timeout_ms=3000);
   
   /** Disconnect
   * Bring the interface down