Azure IoT common library
Fork of azure_c_shared_utility by
platform_mbed.cpp@19:2e0811512ceb, 2017-01-28 (annotated)
- Committer:
- AzureIoTClient
- Date:
- Sat Jan 28 09:35:22 2017 -0800
- Revision:
- 19:2e0811512ceb
- Parent:
- 0:fa2de1b79154
- Child:
- 21:b92006c5b9ff
1.1.6
Who changed what in which revision?
User | Revision | Line number | New 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" |
Azure.IoT Build | 0:fa2de1b79154 | 6 | #include "NTPClient.h" |
Azure.IoT Build | 0:fa2de1b79154 | 7 | #include "azure_c_shared_utility/xio.h" |
Azure.IoT Build | 0:fa2de1b79154 | 8 | #include "azure_c_shared_utility/tlsio_wolfssl.h" |
Azure.IoT Build | 0:fa2de1b79154 | 9 | |
Azure.IoT Build | 0:fa2de1b79154 | 10 | int setupRealTime(void) |
Azure.IoT Build | 0:fa2de1b79154 | 11 | { |
Azure.IoT Build | 0:fa2de1b79154 | 12 | int result; |
Azure.IoT Build | 0:fa2de1b79154 | 13 | |
Azure.IoT Build | 0:fa2de1b79154 | 14 | if (EthernetInterface::connect()) |
Azure.IoT Build | 0:fa2de1b79154 | 15 | { |
Azure.IoT Build | 0:fa2de1b79154 | 16 | result = __LINE__; |
Azure.IoT Build | 0:fa2de1b79154 | 17 | } |
Azure.IoT Build | 0:fa2de1b79154 | 18 | else |
Azure.IoT Build | 0:fa2de1b79154 | 19 | { |
Azure.IoT Build | 0:fa2de1b79154 | 20 | NTPClient ntp; |
Azure.IoT Build | 0:fa2de1b79154 | 21 | if (ntp.setTime("0.pool.ntp.org") != 0) |
Azure.IoT Build | 0:fa2de1b79154 | 22 | { |
Azure.IoT Build | 0:fa2de1b79154 | 23 | result = __LINE__; |
Azure.IoT Build | 0:fa2de1b79154 | 24 | } |
Azure.IoT Build | 0:fa2de1b79154 | 25 | else |
Azure.IoT Build | 0:fa2de1b79154 | 26 | { |
Azure.IoT Build | 0:fa2de1b79154 | 27 | result = 0; |
Azure.IoT Build | 0:fa2de1b79154 | 28 | } |
Azure.IoT Build | 0:fa2de1b79154 | 29 | EthernetInterface::disconnect(); |
Azure.IoT Build | 0:fa2de1b79154 | 30 | } |
Azure.IoT Build | 0:fa2de1b79154 | 31 | |
Azure.IoT Build | 0:fa2de1b79154 | 32 | return result; |
Azure.IoT Build | 0:fa2de1b79154 | 33 | } |
Azure.IoT Build | 0:fa2de1b79154 | 34 | |
Azure.IoT Build | 0:fa2de1b79154 | 35 | int platform_init(void) |
Azure.IoT Build | 0:fa2de1b79154 | 36 | { |
Azure.IoT Build | 0:fa2de1b79154 | 37 | int result; |
Azure.IoT Build | 0:fa2de1b79154 | 38 | |
Azure.IoT Build | 0:fa2de1b79154 | 39 | if (EthernetInterface::init()) |
Azure.IoT Build | 0:fa2de1b79154 | 40 | { |
Azure.IoT Build | 0:fa2de1b79154 | 41 | result = __LINE__; |
Azure.IoT Build | 0:fa2de1b79154 | 42 | } |
Azure.IoT Build | 0:fa2de1b79154 | 43 | else if (setupRealTime() != 0) |
Azure.IoT Build | 0:fa2de1b79154 | 44 | { |
Azure.IoT Build | 0:fa2de1b79154 | 45 | result = __LINE__; |
Azure.IoT Build | 0:fa2de1b79154 | 46 | } |
Azure.IoT Build | 0:fa2de1b79154 | 47 | else if (EthernetInterface::connect()) |
Azure.IoT Build | 0:fa2de1b79154 | 48 | { |
Azure.IoT Build | 0:fa2de1b79154 | 49 | result = __LINE__; |
Azure.IoT Build | 0:fa2de1b79154 | 50 | } |
Azure.IoT Build | 0:fa2de1b79154 | 51 | else |
Azure.IoT Build | 0:fa2de1b79154 | 52 | { |
Azure.IoT Build | 0:fa2de1b79154 | 53 | result = 0; |
Azure.IoT Build | 0:fa2de1b79154 | 54 | } |
Azure.IoT Build | 0:fa2de1b79154 | 55 | |
Azure.IoT Build | 0:fa2de1b79154 | 56 | return result; |
Azure.IoT Build | 0:fa2de1b79154 | 57 | } |
Azure.IoT Build | 0:fa2de1b79154 | 58 | |
Azure.IoT Build | 0:fa2de1b79154 | 59 | const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void) |
Azure.IoT Build | 0:fa2de1b79154 | 60 | { |
Azure.IoT Build | 0:fa2de1b79154 | 61 | return tlsio_wolfssl_get_interface_description(); |
Azure.IoT Build | 0:fa2de1b79154 | 62 | } |
Azure.IoT Build | 0:fa2de1b79154 | 63 | |
Azure.IoT Build | 0:fa2de1b79154 | 64 | void platform_deinit(void) |
Azure.IoT Build | 0:fa2de1b79154 | 65 | { |
Azure.IoT Build | 0:fa2de1b79154 | 66 | EthernetInterface::disconnect(); |
Azure.IoT Build | 0:fa2de1b79154 | 67 | } |