Azure IoT common library
Fork of azure_c_shared_utility by
Revision 34:651c23af382c, committed 2017-08-24
- Comitter:
- wiggly
- Date:
- Thu Aug 24 14:14:15 2017 +0100
- Parent:
- 33:5f2a48fc7e5b
- Commit message:
- Pass in network stack to platform initialisation
Remove NTP setup from azure platform code
Changed in this revision
--- a/azure_c_shared_utility/platform.h Tue Aug 22 13:22:47 2017 +0100 +++ b/azure_c_shared_utility/platform.h Thu Aug 24 14:14:15 2017 +0100 @@ -19,6 +19,7 @@ MOCKABLE_FUNCTION(, const IO_INTERFACE_DESCRIPTION*, platform_get_default_tlsio); MOCKABLE_FUNCTION(, STRING_HANDLE, platform_get_platform_info); + MOCKABLE_FUNCTION(, NetworkInterface*, platform_get_network_stack); #ifdef __cplusplus } #endif /* __cplusplus */
--- a/platform_mbed.cpp Tue Aug 22 13:22:47 2017 +0100 +++ b/platform_mbed.cpp Thu Aug 24 14:14:15 2017 +0100 @@ -4,34 +4,17 @@ #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(NetworkInterface* net) -{ - int result = 0; - - NTPClient ntp(*net); - - if (ntp.setTime("1.pool.ntp.org") != 0) - { - result = __FAILURE__; - } - - return result; -} +static NetworkInterface* _platform_mbed_network; int platform_init(NetworkInterface* net) { int result = 0; - - if (setupRealTime(net) != 0) - { - result = __FAILURE__; - } - + _platform_mbed_network = net; return result; } @@ -46,3 +29,7 @@ } void platform_deinit(void) {} + +NetworkInterface* platform_get_network_stack() { + return _platform_mbed_network; +}
--- a/tcpsocketconnection_c.cpp Tue Aug 22 13:22:47 2017 +0100 +++ b/tcpsocketconnection_c.cpp Thu Aug 24 14:14:15 2017 +0100 @@ -2,10 +2,9 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. #include "mbed.h" - #include <stddef.h> - #include "azure_c_shared_utility/tcpsocketconnection_c.h" +#include "azure_c_shared_utility/platform.h" typedef struct { TCPSocket* socket; @@ -15,7 +14,7 @@ TCPSOCKETCONNECTION_HANDLE tcpsocketconnection_create(void) { TCPSOCKETCONNECTION_HANDLE_T* conn = new TCPSOCKETCONNECTION_HANDLE_T; - conn->socket = new TCPSocket(); + conn->socket = new TCPSocket(platform_get_network_stack()); conn->connected = false; return conn; }