Azure IoT common library
Dependents: STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more
platform_mbed.cpp@25:8507bf644fdf, 2017-04-21 (annotated)
- Committer:
- AzureIoTClient
- Date:
- Fri Apr 21 14:51:10 2017 -0700
- Revision:
- 25:8507bf644fdf
- Parent:
- 21:b92006c5b9ff
- Child:
- 36:678a31adedbe
1.1.13
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 | 25:8507bf644fdf | 67 | return STRING_construct("(mbed)"); |
AzureIoTClient | 25:8507bf644fdf | 68 | } |
AzureIoTClient | 25:8507bf644fdf | 69 | |
Azure.IoT Build | 0:fa2de1b79154 | 70 | void platform_deinit(void) |
Azure.IoT Build | 0:fa2de1b79154 | 71 | { |
Azure.IoT Build | 0:fa2de1b79154 | 72 | EthernetInterface::disconnect(); |
Azure.IoT Build | 0:fa2de1b79154 | 73 | } |