Etherios Cloud Connector very first porting for mbed. Tested in an LPC1768

Etherios Cloud Connector for Embedded v2.1.0.3 library for mbed. Early porting.

This port is centered mainly in the platform code. So it should work properly with the provided examples of send_data, device_request, data_points, RCI and firmware_update (stub implementation, not a real one... yet ;-)). Filesystem is not implemented yet, and some examples might need changes.

To run, it needs the following libraries: - mbed - mbed-rtos - EthernetInterface

Find more information (and the source code!) about Etherios Cloud Connector for Embedded here: http://www.etherios.com/products/devicecloud/support/connector and in: http://www.etherios.com

Committer:
spastor
Date:
Tue Dec 03 14:10:48 2013 +0000
Revision:
1:908afea5a49d
Parent:
0:1c358ea10753
Use internal Thread.h instead of Threads.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
spastor 0:1c358ea10753 1 /*
spastor 0:1c358ea10753 2 * Copyright (c) 2013 Digi International Inc.,
spastor 0:1c358ea10753 3 * All rights not expressly granted are reserved.
spastor 0:1c358ea10753 4 *
spastor 0:1c358ea10753 5 * This Source Code Form is subject to the terms of the Mozilla Public
spastor 0:1c358ea10753 6 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
spastor 0:1c358ea10753 7 * You can obtain one at http://mozilla.org/MPL/2.0/.
spastor 0:1c358ea10753 8 *
spastor 0:1c358ea10753 9 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
spastor 0:1c358ea10753 10 * =======================================================================
spastor 0:1c358ea10753 11 */
spastor 0:1c358ea10753 12
spastor 0:1c358ea10753 13 #ifndef CONNECTOR_API_FIRMWARE_H
spastor 0:1c358ea10753 14 #define CONNECTOR_API_FIRMWARE_H
spastor 0:1c358ea10753 15
spastor 0:1c358ea10753 16 #if (defined CONNECTOR_FIRMWARE_SERVICE)
spastor 0:1c358ea10753 17
spastor 0:1c358ea10753 18 /**
spastor 0:1c358ea10753 19 * @defgroup connector_request_id_firmware_t Firmware Request IDs
spastor 0:1c358ea10753 20 * @{
spastor 0:1c358ea10753 21 */
spastor 0:1c358ea10753 22 /**
spastor 0:1c358ea10753 23 * Firmware Facility Request ID passed to the application's callback for firmware update interface.
spastor 0:1c358ea10753 24 * The class id for this connector_request_id_firmware_t is connector_class_id_firmware.
spastor 0:1c358ea10753 25 */
spastor 0:1c358ea10753 26 typedef enum {
spastor 0:1c358ea10753 27 connector_request_id_firmware_target_count, /**< Requesting callback to return number of supported target for firmware update */
spastor 0:1c358ea10753 28 connector_request_id_firmware_info, /**< Requesting callback to return the version number,
spastor 0:1c358ea10753 29 maximum code size, description and
spastor 0:1c358ea10753 30 regular expression for firmware update image name of specific target */
spastor 0:1c358ea10753 31 connector_request_id_firmware_download_start, /**< Requesting callback to start firmware update of specific target */
spastor 0:1c358ea10753 32 connector_request_id_firmware_download_data, /**< Callback is passed with image data for firmware update. This is called for each chunk of image data */
spastor 0:1c358ea10753 33 connector_request_id_firmware_download_complete, /**< Callback is called to complete firmware update. */
spastor 0:1c358ea10753 34 connector_request_id_firmware_download_abort, /**< Requesting callback to abort firmware update */
spastor 0:1c358ea10753 35 connector_request_id_firmware_target_reset /**< Requesting callback to reset the target */
spastor 0:1c358ea10753 36 } connector_request_id_firmware_t;
spastor 0:1c358ea10753 37 /**
spastor 0:1c358ea10753 38 * @}
spastor 0:1c358ea10753 39 */
spastor 0:1c358ea10753 40
spastor 0:1c358ea10753 41
spastor 0:1c358ea10753 42 /**
spastor 0:1c358ea10753 43 * @defgroup connector_firmware_count_t Firmware Target Count
spastor 0:1c358ea10753 44 * @{
spastor 0:1c358ea10753 45 */
spastor 0:1c358ea10753 46 /**
spastor 0:1c358ea10753 47 * Firmware target count for connector_request_id_firmware_count callback which
spastor 0:1c358ea10753 48 * is called to return number of supported targets.
spastor 0:1c358ea10753 49 */
spastor 0:1c358ea10753 50 typedef struct {
spastor 0:1c358ea10753 51 uint8_t count; /**< Callback writes number of targets supported */
spastor 0:1c358ea10753 52 } connector_firmware_count_t;
spastor 0:1c358ea10753 53 /**
spastor 0:1c358ea10753 54 * @}
spastor 0:1c358ea10753 55 */
spastor 0:1c358ea10753 56
spastor 0:1c358ea10753 57 /**
spastor 0:1c358ea10753 58 * @defgroup connector_firmware_version_t Firmware Version n
spastor 0:1c358ea10753 59 * @{
spastor 0:1c358ea10753 60 */
spastor 0:1c358ea10753 61 /**
spastor 0:1c358ea10753 62 * Firmware version structure for @ref connector_request_id_firmware_info callback to return
spastor 0:1c358ea10753 63 * the firmware version about the specific target.
spastor 0:1c358ea10753 64 */
spastor 0:1c358ea10753 65 typedef struct {
spastor 0:1c358ea10753 66 uint8_t major; /**< Major number */
spastor 0:1c358ea10753 67 uint8_t minor; /**< Minor number */
spastor 0:1c358ea10753 68 uint8_t revision; /**< revision number */
spastor 0:1c358ea10753 69 uint8_t build; /**< build number */
spastor 0:1c358ea10753 70 } connector_firmware_version_t;
spastor 0:1c358ea10753 71 /**
spastor 0:1c358ea10753 72 * @}
spastor 0:1c358ea10753 73 */
spastor 0:1c358ea10753 74
spastor 0:1c358ea10753 75 /**
spastor 0:1c358ea10753 76 * @defgroup connector_firmware_info_t Firmware Information
spastor 0:1c358ea10753 77 * @{
spastor 0:1c358ea10753 78 */
spastor 0:1c358ea10753 79 /**
spastor 0:1c358ea10753 80 * Firmware information structure for @ref connector_request_id_firmware_info callback to return
spastor 0:1c358ea10753 81 * information about the specific target.
spastor 0:1c358ea10753 82 */
spastor 0:1c358ea10753 83 typedef struct {
spastor 0:1c358ea10753 84
spastor 0:1c358ea10753 85 connector_firmware_version_t version; /**< Version number of the target */
spastor 0:1c358ea10753 86 char const * description; /**< An ASCII description string of the target */
spastor 0:1c358ea10753 87 char const * filespec; /**< Regular expression for the firmware image name for the target */
spastor 0:1c358ea10753 88
spastor 0:1c358ea10753 89 unsigned int CONST target_number; /**< Target number which target the firmware information is for*/
spastor 0:1c358ea10753 90 } connector_firmware_info_t;
spastor 0:1c358ea10753 91 /**
spastor 0:1c358ea10753 92 * @}
spastor 0:1c358ea10753 93 */
spastor 0:1c358ea10753 94
spastor 0:1c358ea10753 95 /**
spastor 0:1c358ea10753 96 * @defgroup connector_firmware_status_t Firmware Status Codes
spastor 0:1c358ea10753 97 * @{
spastor 0:1c358ea10753 98 */
spastor 0:1c358ea10753 99 /**
spastor 0:1c358ea10753 100 * Firmware status codes are used for @ref connector_request_id_firmware_download_start,
spastor 0:1c358ea10753 101 * @see @ref connector_request_id_firmware_download_data and @ref connector_request_id_firmware_download_abort callbacks.
spastor 0:1c358ea10753 102 */
spastor 0:1c358ea10753 103 typedef enum {
spastor 0:1c358ea10753 104 connector_firmware_status_success, /**< No error */
spastor 0:1c358ea10753 105 connector_firmware_status_download_denied, /**< Callback denied firmware update */
spastor 0:1c358ea10753 106 connector_firmware_status_download_invalid_size, /**< Callback returns invalid size */
spastor 0:1c358ea10753 107 connector_firmware_status_download_invalid_version, /**< Callback returns invalid version */
spastor 0:1c358ea10753 108 connector_firmware_status_download_unauthenticated, /**< Device Cloud has not been authenticated */
spastor 0:1c358ea10753 109 connector_firmware_status_download_not_allowed, /**< Device Cloud is not allowed to provided updates */
spastor 0:1c358ea10753 110 connector_firmware_status_download_configured_to_reject, /**< Callback rejects firmware update */
spastor 0:1c358ea10753 111 connector_firmware_status_encountered_error, /**< Callback encountered an error that precludes the firmware update */
spastor 0:1c358ea10753 112 connector_firmware_status_user_abort, /**< User aborted firmware update */
spastor 0:1c358ea10753 113 connector_firmware_status_device_error, /**< Device or Device Cloud encountered an error in the download data */
spastor 0:1c358ea10753 114 connector_firmware_status_invalid_offset, /**< connector_request_id_firmware_download_data callback found invalid offset. */
spastor 0:1c358ea10753 115 connector_firmware_status_invalid_data, /**< connector_request_id_firmware_download_data callback found invalid data block.*/
spastor 0:1c358ea10753 116 connector_firmware_status_hardware_error /**< Callback found permanent hardware error */
spastor 0:1c358ea10753 117 } connector_firmware_status_t;
spastor 0:1c358ea10753 118 /**
spastor 0:1c358ea10753 119 * @}
spastor 0:1c358ea10753 120 */
spastor 0:1c358ea10753 121
spastor 0:1c358ea10753 122
spastor 0:1c358ea10753 123 /**
spastor 0:1c358ea10753 124 * @defgroup connector_fw_download_complete_status_t Firmware Complete Status Codes
spastor 0:1c358ea10753 125 * @{
spastor 0:1c358ea10753 126 */
spastor 0:1c358ea10753 127 /**
spastor 0:1c358ea10753 128 * Firmware Update Complete status codes are used in @see connector_firmware_download_complete callback.
spastor 0:1c358ea10753 129 */
spastor 0:1c358ea10753 130 typedef enum {
spastor 0:1c358ea10753 131 connector_firmware_download_success, /**< Callback returns this for firmware download finished successfully
spastor 0:1c358ea10753 132 and calculated checksum matched the checksum sent in the callback */
spastor 0:1c358ea10753 133 connector_firmware_download_checksum_mismatch, /**< Callback returns this for download completed successfully, but
spastor 0:1c358ea10753 134 the calculated checksum did not match the checksum sent in the callback */
spastor 0:1c358ea10753 135 connector_firmware_download_not_complete /**< Callback did not complete download successfully */
spastor 0:1c358ea10753 136 } connector_firmware_download_status_t;
spastor 0:1c358ea10753 137 /**
spastor 0:1c358ea10753 138 * @}
spastor 0:1c358ea10753 139 */
spastor 0:1c358ea10753 140
spastor 0:1c358ea10753 141
spastor 0:1c358ea10753 142 /**
spastor 0:1c358ea10753 143 * @defgroup connector_firmware_download_start_t Firmware Download Start Structure
spastor 0:1c358ea10753 144 * @{
spastor 0:1c358ea10753 145 */
spastor 0:1c358ea10753 146 /**
spastor 0:1c358ea10753 147 * Firmware download start structure for @ref connector_request_id_firmware_download_start callback which
spastor 0:1c358ea10753 148 * is called when the device is requested for firmware download.
spastor 0:1c358ea10753 149 */
spastor 0:1c358ea10753 150 typedef struct {
spastor 0:1c358ea10753 151 unsigned int CONST target_number; /**< Target number which firmware target the image data is for */
spastor 0:1c358ea10753 152
spastor 0:1c358ea10753 153 char CONST * filename; /**< Pointer to filename of the image to be downloaded */
spastor 0:1c358ea10753 154
spastor 0:1c358ea10753 155 uint32_t code_size; /**< size of the code that is ready to be sent to the target */
spastor 0:1c358ea10753 156
spastor 0:1c358ea10753 157 connector_firmware_status_t status; /**< Callback writes error status if error is encountered */
spastor 0:1c358ea10753 158
spastor 0:1c358ea10753 159 } connector_firmware_download_start_t;
spastor 0:1c358ea10753 160 /**
spastor 0:1c358ea10753 161 * @}
spastor 0:1c358ea10753 162 */
spastor 0:1c358ea10753 163
spastor 0:1c358ea10753 164
spastor 0:1c358ea10753 165 /**
spastor 0:1c358ea10753 166 * @defgroup connector_firmware_download_data_t Firmware Download Image Data Structure
spastor 0:1c358ea10753 167 * @{
spastor 0:1c358ea10753 168 */
spastor 0:1c358ea10753 169 /**
spastor 0:1c358ea10753 170 * Firmware download image data structure for connector_request_id_firmware_download_data callback which
spastor 0:1c358ea10753 171 * is called when the connector receives a block of image data for firmware download.
spastor 0:1c358ea10753 172 */
spastor 0:1c358ea10753 173 typedef struct {
spastor 0:1c358ea10753 174 unsigned int CONST target_number; /**< Target number which firmware target the image data is for */
spastor 0:1c358ea10753 175
spastor 0:1c358ea10753 176 struct {
spastor 0:1c358ea10753 177 uint32_t CONST offset; /**< Offset value where this particular block of image data fits into the download */
spastor 0:1c358ea10753 178 uint8_t const * data; /**< Pointer binary image data */
spastor 0:1c358ea10753 179 size_t CONST bytes_used; /**< Length of binary image data in bytes */
spastor 0:1c358ea10753 180 } image; /**< Image data */
spastor 0:1c358ea10753 181
spastor 0:1c358ea10753 182 connector_firmware_status_t status; /**< Callback writes error status if error is encountered */
spastor 0:1c358ea10753 183
spastor 0:1c358ea10753 184 } connector_firmware_download_data_t;
spastor 0:1c358ea10753 185 /**
spastor 0:1c358ea10753 186 * @}
spastor 0:1c358ea10753 187 */
spastor 0:1c358ea10753 188
spastor 0:1c358ea10753 189
spastor 0:1c358ea10753 190 /**
spastor 0:1c358ea10753 191 * @defgroup connector_firmware_download_complete_t Firmware Download Complete Structure
spastor 0:1c358ea10753 192 * @{
spastor 0:1c358ea10753 193 */
spastor 0:1c358ea10753 194 /**
spastor 0:1c358ea10753 195 * Firmware download complete structure containing information about firmware image data
spastor 0:1c358ea10753 196 * for connector_request_id_firmware_download_complete callback which is called when Device Cloud is done
spastor 0:1c358ea10753 197 * sending all image data.
spastor 0:1c358ea10753 198 */
spastor 0:1c358ea10753 199 typedef struct {
spastor 0:1c358ea10753 200 unsigned int CONST target_number; /**< Target number which firmware target the image data is for */
spastor 0:1c358ea10753 201
spastor 0:1c358ea10753 202 connector_firmware_download_status_t status; /**< Status code regarding the download completion */
spastor 0:1c358ea10753 203
spastor 0:1c358ea10753 204 } connector_firmware_download_complete_t;
spastor 0:1c358ea10753 205 /**
spastor 0:1c358ea10753 206 * @}
spastor 0:1c358ea10753 207 */
spastor 0:1c358ea10753 208
spastor 0:1c358ea10753 209
spastor 0:1c358ea10753 210 /**
spastor 0:1c358ea10753 211 * @defgroup connector_firmware_download_abort_t Firmware Download Abort Structure
spastor 0:1c358ea10753 212 * @{
spastor 0:1c358ea10753 213 */
spastor 0:1c358ea10753 214 /**
spastor 0:1c358ea10753 215 * Firmware download abort structure for connector_request_id_firmware_abort callback which
spastor 0:1c358ea10753 216 * is called when firmware download process is aborted.
spastor 0:1c358ea10753 217 */
spastor 0:1c358ea10753 218 typedef struct {
spastor 0:1c358ea10753 219 unsigned int CONST target_number; /**< Target number which target the firmware download is aborted */
spastor 0:1c358ea10753 220
spastor 0:1c358ea10753 221 connector_firmware_status_t CONST status; /**< Abort reason or status */
spastor 0:1c358ea10753 222 } connector_firmware_download_abort_t;
spastor 0:1c358ea10753 223 /**
spastor 0:1c358ea10753 224 * @}
spastor 0:1c358ea10753 225 */
spastor 0:1c358ea10753 226
spastor 0:1c358ea10753 227
spastor 0:1c358ea10753 228 /**
spastor 0:1c358ea10753 229 * @defgroup connector_firmware_reset_t Firmware Target Reset Structure
spastor 0:1c358ea10753 230 * @{
spastor 0:1c358ea10753 231 */
spastor 0:1c358ea10753 232 /**
spastor 0:1c358ea10753 233 * Firmware target reset structure for connector_request_id_firmware_reset callback which
spastor 0:1c358ea10753 234 * is called to reset the target.
spastor 0:1c358ea10753 235 */
spastor 0:1c358ea10753 236 typedef struct {
spastor 0:1c358ea10753 237 unsigned int CONST target_number; /**< Target number which target the firmware to reset */
spastor 0:1c358ea10753 238 } connector_firmware_reset_t;
spastor 0:1c358ea10753 239 /**
spastor 0:1c358ea10753 240 * @}
spastor 0:1c358ea10753 241 */
spastor 0:1c358ea10753 242 #endif
spastor 0:1c358ea10753 243
spastor 0:1c358ea10753 244 #if !defined _CONNECTOR_API_H
spastor 0:1c358ea10753 245 #error "Illegal inclusion of connector_api_firmware.h. You should only include connector_api.h in user code."
spastor 0:1c358ea10753 246 #endif
spastor 0:1c358ea10753 247
spastor 0:1c358ea10753 248 #else
spastor 0:1c358ea10753 249 #error "Illegal inclusion of connector_api_firmware.h. You should only include connector_api.h in user code."
spastor 0:1c358ea10753 250 #endif
spastor 0:1c358ea10753 251
spastor 0:1c358ea10753 252