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 13:34:02 2013 +0000
Revision:
0:1c358ea10753
First commit

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 #if (defined connector_request_id_remote_config_configurations)
spastor 0:1c358ea10753 14 static connector_remote_config_data_t connector_rci_config_data = {
spastor 0:1c358ea10753 15 NULL, NULL, connector_rci_error_COUNT, 0
spastor 0:1c358ea10753 16 };
spastor 0:1c358ea10753 17
spastor 0:1c358ea10753 18 #else
spastor 0:1c358ea10753 19 typedef struct {
spastor 0:1c358ea10753 20 connector_remote_group_table_t const * group_table;
spastor 0:1c358ea10753 21 char const * const * error_table;
spastor 0:1c358ea10753 22 unsigned int global_error_count;
spastor 0:1c358ea10753 23 uint32_t firmware_target_zero_version;
spastor 0:1c358ea10753 24 } connector_remote_config_data_t;
spastor 0:1c358ea10753 25
spastor 0:1c358ea10753 26 static connector_remote_config_data_t const connector_rci_config_data = {
spastor 0:1c358ea10753 27 connector_group_table,
spastor 0:1c358ea10753 28 #if defined RCI_PARSER_USES_ERROR_DESCRIPTIONS
spastor 0:1c358ea10753 29 connector_rci_errors,
spastor 0:1c358ea10753 30 #else
spastor 0:1c358ea10753 31 NULL,
spastor 0:1c358ea10753 32 #endif
spastor 0:1c358ea10753 33 connector_global_error_COUNT,
spastor 0:1c358ea10753 34 FIRMWARE_TARGET_ZERO_VERSION
spastor 0:1c358ea10753 35 };
spastor 0:1c358ea10753 36 #endif
spastor 0:1c358ea10753 37
spastor 0:1c358ea10753 38 #define BINARY_RCI_FIELD_LOWER_ID_MASK UINT32_C(0x3F)
spastor 0:1c358ea10753 39 #define BINARY_RCI_FIELD_MIDDLE_ID_MASK UINT32_C(0x380)
spastor 0:1c358ea10753 40 #define BINARY_RCI_FIELD_MIDDLE_BIT_ID_MASK UINT32_C(0x800)
spastor 0:1c358ea10753 41 #define BINARY_RCI_FIELD_UPPER_ID_MASK (~UINT32_C(0x1FFF))
spastor 0:1c358ea10753 42
spastor 0:1c358ea10753 43
spastor 0:1c358ea10753 44 static unsigned int decode_element_id(uint32_t const value)
spastor 0:1c358ea10753 45 {
spastor 0:1c358ea10753 46 unsigned int id;
spastor 0:1c358ea10753 47
spastor 0:1c358ea10753 48 id = (value & BINARY_RCI_FIELD_LOWER_ID_MASK);
spastor 0:1c358ea10753 49 id |= ((value & BINARY_RCI_FIELD_MIDDLE_ID_MASK) >> 1);
spastor 0:1c358ea10753 50 id |= ((value & BINARY_RCI_FIELD_MIDDLE_BIT_ID_MASK) >> 2);
spastor 0:1c358ea10753 51 id |= ((value & BINARY_RCI_FIELD_UPPER_ID_MASK) >> 3);
spastor 0:1c358ea10753 52
spastor 0:1c358ea10753 53 return id;
spastor 0:1c358ea10753 54 }
spastor 0:1c358ea10753 55
spastor 0:1c358ea10753 56 static uint32_t encode_element_id(unsigned int const id)
spastor 0:1c358ea10753 57 {
spastor 0:1c358ea10753 58
spastor 0:1c358ea10753 59 uint32_t value;
spastor 0:1c358ea10753 60
spastor 0:1c358ea10753 61 value = (id & BINARY_RCI_FIELD_LOWER_ID_MASK);
spastor 0:1c358ea10753 62 value |= ((id << 1) & BINARY_RCI_FIELD_MIDDLE_ID_MASK);
spastor 0:1c358ea10753 63 value |= ((id << 2) & BINARY_RCI_FIELD_MIDDLE_BIT_ID_MASK);
spastor 0:1c358ea10753 64 value |= ((id << 3) & BINARY_RCI_FIELD_UPPER_ID_MASK);
spastor 0:1c358ea10753 65
spastor 0:1c358ea10753 66 return value;
spastor 0:1c358ea10753 67 }
spastor 0:1c358ea10753 68
spastor 0:1c358ea10753 69
spastor 0:1c358ea10753 70 #define BINARY_RCI_GROUP_ID_LOWER_BIT_MASK UINT32_C(0x03F) /* [5:0] */
spastor 0:1c358ea10753 71 #define BINARY_RCI_GROUP_ID_MIDDLE_BIT_MASK UINT32_C(0xF80) /* [11:7] */
spastor 0:1c358ea10753 72 #define BINARY_RCI_GROUP_ID_UPPER_BIT_MASK ~(UINT32_C(0x1FF)) /* [:13] */
spastor 0:1c358ea10753 73
spastor 0:1c358ea10753 74 static unsigned int decode_group_id(uint32_t const group_id)
spastor 0:1c358ea10753 75 {
spastor 0:1c358ea10753 76
spastor 0:1c358ea10753 77 unsigned int id = 0;
spastor 0:1c358ea10753 78
spastor 0:1c358ea10753 79 id = (group_id & BINARY_RCI_GROUP_ID_LOWER_BIT_MASK);
spastor 0:1c358ea10753 80 id |= ((group_id & BINARY_RCI_GROUP_ID_MIDDLE_BIT_MASK) >> 1);
spastor 0:1c358ea10753 81 id |= ((group_id & BINARY_RCI_GROUP_ID_UPPER_BIT_MASK) >> 2);
spastor 0:1c358ea10753 82
spastor 0:1c358ea10753 83 return id;
spastor 0:1c358ea10753 84 }
spastor 0:1c358ea10753 85
spastor 0:1c358ea10753 86 static uint32_t encode_group_id(unsigned int const group_id)
spastor 0:1c358ea10753 87 {
spastor 0:1c358ea10753 88 uint32_t id;
spastor 0:1c358ea10753 89
spastor 0:1c358ea10753 90 id = (group_id & BINARY_RCI_GROUP_ID_LOWER_BIT_MASK);
spastor 0:1c358ea10753 91 id |= ((group_id << 1) & BINARY_RCI_GROUP_ID_MIDDLE_BIT_MASK);
spastor 0:1c358ea10753 92 id |= ((group_id << 2) & BINARY_RCI_GROUP_ID_UPPER_BIT_MASK);
spastor 0:1c358ea10753 93
spastor 0:1c358ea10753 94 return id;
spastor 0:1c358ea10753 95 }
spastor 0:1c358ea10753 96
spastor 0:1c358ea10753 97