Azure IoT common library
Dependents: STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more
platform_mbed.cpp@49:6bb8b9a66642, 2018-10-04 (annotated)
- Committer:
- AzureIoTClient
- Date:
- Thu Oct 04 09:17:16 2018 -0700
- Revision:
- 49:6bb8b9a66642
- Parent:
- 36:678a31adedbe
1.2.10
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" |
AzureIoTClient | 21:b92006c5b9ff | 7 | #include "azure_c_shared_utility/optimize_size.h" |
Azure.IoT Build | 0:fa2de1b79154 | 8 | #include "azure_c_shared_utility/xio.h" |
Azure.IoT Build | 0:fa2de1b79154 | 9 | #include "azure_c_shared_utility/tlsio_wolfssl.h" |
Azure.IoT Build | 0:fa2de1b79154 | 10 | |
Azure.IoT Build | 0:fa2de1b79154 | 11 | int setupRealTime(void) |
Azure.IoT Build | 0:fa2de1b79154 | 12 | { |
Azure.IoT Build | 0:fa2de1b79154 | 13 | int result; |
Azure.IoT Build | 0:fa2de1b79154 | 14 | |
Azure.IoT Build | 0:fa2de1b79154 | 15 | if (EthernetInterface::connect()) |
Azure.IoT Build | 0:fa2de1b79154 | 16 | { |
AzureIoTClient | 21:b92006c5b9ff | 17 | result = __FAILURE__; |
Azure.IoT Build | 0:fa2de1b79154 | 18 | } |
Azure.IoT Build | 0:fa2de1b79154 | 19 | else |
Azure.IoT Build | 0:fa2de1b79154 | 20 | { |
Azure.IoT Build | 0:fa2de1b79154 | 21 | NTPClient ntp; |
Azure.IoT Build | 0:fa2de1b79154 | 22 | if (ntp.setTime("0.pool.ntp.org") != 0) |
Azure.IoT Build | 0:fa2de1b79154 | 23 | { |
AzureIoTClient | 21:b92006c5b9ff | 24 | result = __FAILURE__; |
Azure.IoT Build | 0:fa2de1b79154 | 25 | } |
Azure.IoT Build | 0:fa2de1b79154 | 26 | else |
Azure.IoT Build | 0:fa2de1b79154 | 27 | { |
Azure.IoT Build | 0:fa2de1b79154 | 28 | result = 0; |
Azure.IoT Build | 0:fa2de1b79154 | 29 | } |
Azure.IoT Build | 0:fa2de1b79154 | 30 | EthernetInterface::disconnect(); |
Azure.IoT Build | 0:fa2de1b79154 | 31 | } |
Azure.IoT Build | 0:fa2de1b79154 | 32 | |
Azure.IoT Build | 0:fa2de1b79154 | 33 | return result; |
Azure.IoT Build | 0:fa2de1b79154 | 34 | } |
Azure.IoT Build | 0:fa2de1b79154 | 35 | |
Azure.IoT Build | 0:fa2de1b79154 | 36 | int platform_init(void) |
Azure.IoT Build | 0:fa2de1b79154 | 37 | { |
Azure.IoT Build | 0:fa2de1b79154 | 38 | int result; |
Azure.IoT Build | 0:fa2de1b79154 | 39 | |
Azure.IoT Build | 0:fa2de1b79154 | 40 | if (EthernetInterface::init()) |
Azure.IoT Build | 0:fa2de1b79154 | 41 | { |
AzureIoTClient | 21:b92006c5b9ff | 42 | result = __FAILURE__; |
Azure.IoT Build | 0:fa2de1b79154 | 43 | } |
Azure.IoT Build | 0:fa2de1b79154 | 44 | else if (setupRealTime() != 0) |
Azure.IoT Build | 0:fa2de1b79154 | 45 | { |
AzureIoTClient | 21:b92006c5b9ff | 46 | result = __FAILURE__; |
Azure.IoT Build | 0:fa2de1b79154 | 47 | } |
Azure.IoT Build | 0:fa2de1b79154 | 48 | else if (EthernetInterface::connect()) |
Azure.IoT Build | 0:fa2de1b79154 | 49 | { |
AzureIoTClient | 21:b92006c5b9ff | 50 | result = __FAILURE__; |
Azure.IoT Build | 0:fa2de1b79154 | 51 | } |
Azure.IoT Build | 0:fa2de1b79154 | 52 | else |
Azure.IoT Build | 0:fa2de1b79154 | 53 | { |
Azure.IoT Build | 0:fa2de1b79154 | 54 | result = 0; |
Azure.IoT Build | 0:fa2de1b79154 | 55 | } |
Azure.IoT Build | 0:fa2de1b79154 | 56 | |
Azure.IoT Build | 0:fa2de1b79154 | 57 | return result; |
Azure.IoT Build | 0:fa2de1b79154 | 58 | } |
Azure.IoT Build | 0:fa2de1b79154 | 59 | |
Azure.IoT Build | 0:fa2de1b79154 | 60 | const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void) |
Azure.IoT Build | 0:fa2de1b79154 | 61 | { |
Azure.IoT Build | 0:fa2de1b79154 | 62 | return tlsio_wolfssl_get_interface_description(); |
Azure.IoT Build | 0:fa2de1b79154 | 63 | } |
Azure.IoT Build | 0:fa2de1b79154 | 64 | |
AzureIoTClient | 25:8507bf644fdf | 65 | STRING_HANDLE platform_get_platform_info(void) |
AzureIoTClient | 25:8507bf644fdf | 66 | { |
AzureIoTClient | 36:678a31adedbe | 67 | // Expected format: "(<runtime name>; <operating system name>; <platform>)" |
AzureIoTClient | 36:678a31adedbe | 68 | |
AzureIoTClient | 36:678a31adedbe | 69 | return STRING_construct("(native; mbed; undefined)"); |
AzureIoTClient | 25:8507bf644fdf | 70 | } |
AzureIoTClient | 25:8507bf644fdf | 71 | |
Azure.IoT Build | 0:fa2de1b79154 | 72 | void platform_deinit(void) |
Azure.IoT Build | 0:fa2de1b79154 | 73 | { |
Azure.IoT Build | 0:fa2de1b79154 | 74 | EthernetInterface::disconnect(); |
Azure.IoT Build | 0:fa2de1b79154 | 75 | } |