Azure IoT common library

Fork of azure_c_shared_utility by Azure IoT

Committer:
wiggly
Date:
Tue Aug 22 13:22:47 2017 +0100
Revision:
33:5f2a48fc7e5b
Parent:
25:8507bf644fdf
Child:
34:651c23af382c
Initial modifications to get platform initialisation working with mbed OS 5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Azure.IoT Build 0:fa2de1b79154 1 // Copyright (c) Microsoft. All rights reserved.
Azure.IoT Build 0:fa2de1b79154 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
Azure.IoT Build 0:fa2de1b79154 3
Azure.IoT Build 0:fa2de1b79154 4 #include "azure_c_shared_utility/platform.h"
Azure.IoT Build 0:fa2de1b79154 5 #include "EthernetInterface.h"
wiggly 33:5f2a48fc7e5b 6 #include "NetworkInterface.h"
Azure.IoT Build 0:fa2de1b79154 7 #include "NTPClient.h"
AzureIoTClient 21:b92006c5b9ff 8 #include "azure_c_shared_utility/optimize_size.h"
Azure.IoT Build 0:fa2de1b79154 9 #include "azure_c_shared_utility/xio.h"
Azure.IoT Build 0:fa2de1b79154 10 #include "azure_c_shared_utility/tlsio_wolfssl.h"
Azure.IoT Build 0:fa2de1b79154 11
wiggly 33:5f2a48fc7e5b 12 int setupRealTime(NetworkInterface* net)
Azure.IoT Build 0:fa2de1b79154 13 {
wiggly 33:5f2a48fc7e5b 14 int result = 0;
Azure.IoT Build 0:fa2de1b79154 15
wiggly 33:5f2a48fc7e5b 16 NTPClient ntp(*net);
wiggly 33:5f2a48fc7e5b 17
wiggly 33:5f2a48fc7e5b 18 if (ntp.setTime("1.pool.ntp.org") != 0)
Azure.IoT Build 0:fa2de1b79154 19 {
AzureIoTClient 21:b92006c5b9ff 20 result = __FAILURE__;
Azure.IoT Build 0:fa2de1b79154 21 }
Azure.IoT Build 0:fa2de1b79154 22
Azure.IoT Build 0:fa2de1b79154 23 return result;
Azure.IoT Build 0:fa2de1b79154 24 }
Azure.IoT Build 0:fa2de1b79154 25
wiggly 33:5f2a48fc7e5b 26 int platform_init(NetworkInterface* net)
Azure.IoT Build 0:fa2de1b79154 27 {
wiggly 33:5f2a48fc7e5b 28 int result = 0;
Azure.IoT Build 0:fa2de1b79154 29
wiggly 33:5f2a48fc7e5b 30 if (setupRealTime(net) != 0)
Azure.IoT Build 0:fa2de1b79154 31 {
AzureIoTClient 21:b92006c5b9ff 32 result = __FAILURE__;
Azure.IoT Build 0:fa2de1b79154 33 }
Azure.IoT Build 0:fa2de1b79154 34
Azure.IoT Build 0:fa2de1b79154 35 return result;
Azure.IoT Build 0:fa2de1b79154 36 }
Azure.IoT Build 0:fa2de1b79154 37
Azure.IoT Build 0:fa2de1b79154 38 const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void)
Azure.IoT Build 0:fa2de1b79154 39 {
Azure.IoT Build 0:fa2de1b79154 40 return tlsio_wolfssl_get_interface_description();
Azure.IoT Build 0:fa2de1b79154 41 }
Azure.IoT Build 0:fa2de1b79154 42
AzureIoTClient 25:8507bf644fdf 43 STRING_HANDLE platform_get_platform_info(void)
AzureIoTClient 25:8507bf644fdf 44 {
AzureIoTClient 25:8507bf644fdf 45 return STRING_construct("(mbed)");
AzureIoTClient 25:8507bf644fdf 46 }
AzureIoTClient 25:8507bf644fdf 47
wiggly 33:5f2a48fc7e5b 48 void platform_deinit(void) {}