Azure IoT common library

Fork of azure_c_shared_utility by Azure IoT

Revision:
33:5f2a48fc7e5b
Parent:
25:8507bf644fdf
Child:
34:651c23af382c
--- a/platform_mbed.cpp	Tue Aug 22 11:24:58 2017 +0000
+++ b/platform_mbed.cpp	Tue Aug 22 13:22:47 2017 +0100
@@ -3,56 +3,34 @@
 
 #include "azure_c_shared_utility/platform.h"
 #include "EthernetInterface.h"
+#include "NetworkInterface.h"
 #include "NTPClient.h"
 #include "azure_c_shared_utility/optimize_size.h"
 #include "azure_c_shared_utility/xio.h"
 #include "azure_c_shared_utility/tlsio_wolfssl.h"
 
-int setupRealTime(void)
+int setupRealTime(NetworkInterface* net)
 {
-    int result;
+    int result = 0;
 
-    if (EthernetInterface::connect())
+    NTPClient ntp(*net);
+
+    if (ntp.setTime("1.pool.ntp.org") != 0)
     {
         result = __FAILURE__;
     }
-    else
-    {
-        NTPClient ntp;
-        if (ntp.setTime("0.pool.ntp.org") != 0)
-        {
-            result = __FAILURE__;
-        }
-        else
-        {
-            result = 0;
-        }
-        EthernetInterface::disconnect();
-    }
 
     return result;
 }
 
-int platform_init(void)
+int platform_init(NetworkInterface* net)
 {
-    int result;
+    int result = 0;
 
-    if (EthernetInterface::init())
+    if (setupRealTime(net) != 0)
     {
         result = __FAILURE__;
     }
-    else if (setupRealTime() != 0)
-    {
-        result = __FAILURE__;
-    } 
-    else if (EthernetInterface::connect())
-    {
-        result = __FAILURE__;
-    }
-    else
-    {
-        result = 0;
-    }
 
     return result;
 }
@@ -67,7 +45,4 @@
     return STRING_construct("(mbed)");
 }
 
-void platform_deinit(void)
-{
-    EthernetInterface::disconnect();
-}
+void platform_deinit(void) {}