Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of azure_c_shared_utility by
Diff: platform_mbed.cpp
- Revision:
- 0:fa2de1b79154
- Child:
- 19:2e0811512ceb
diff -r 000000000000 -r fa2de1b79154 platform_mbed.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/platform_mbed.cpp Fri Apr 08 12:01:36 2016 -0700
@@ -0,0 +1,71 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#include <stdlib.h>
+#ifdef _CRTDBG_MAP_ALLOC
+#include <crtdbg.h>
+#endif
+#include "azure_c_shared_utility/platform.h"
+#include "EthernetInterface.h"
+#include "NTPClient.h"
+#include "azure_c_shared_utility/xio.h"
+#include "azure_c_shared_utility/tlsio_wolfssl.h"
+
+int setupRealTime(void)
+{
+ int result;
+
+ if (EthernetInterface::connect())
+ {
+ result = __LINE__;
+ }
+ else
+ {
+ NTPClient ntp;
+ if (ntp.setTime("0.pool.ntp.org") != 0)
+ {
+ result = __LINE__;
+ }
+ else
+ {
+ result = 0;
+ }
+ EthernetInterface::disconnect();
+ }
+
+ return result;
+}
+
+int platform_init(void)
+{
+ int result;
+
+ if (EthernetInterface::init())
+ {
+ result = __LINE__;
+ }
+ else if (setupRealTime() != 0)
+ {
+ result = __LINE__;
+ }
+ else if (EthernetInterface::connect())
+ {
+ result = __LINE__;
+ }
+ else
+ {
+ result = 0;
+ }
+
+ return result;
+}
+
+const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void)
+{
+ return tlsio_wolfssl_get_interface_description();
+}
+
+void platform_deinit(void)
+{
+ EthernetInterface::disconnect();
+}
