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
private/ei_packet.h@0:1c358ea10753, 2013-12-03 (annotated)
- Committer:
- spastor
- Date:
- Tue Dec 03 13:34:02 2013 +0000
- Revision:
- 0:1c358ea10753
First commit
Who changed what in which revision?
User | Revision | Line number | New 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 | #ifndef _EI_PACKET_H |
spastor | 0:1c358ea10753 | 13 | #define _EI_PACKET_H |
spastor | 0:1c358ea10753 | 14 | |
spastor | 0:1c358ea10753 | 15 | #define field_glue(left, right) left ## _ ## right |
spastor | 0:1c358ea10753 | 16 | #define field_name(record, field) field_glue(record,field) |
spastor | 0:1c358ea10753 | 17 | #define field_data(name, data) field_glue(name, data) |
spastor | 0:1c358ea10753 | 18 | |
spastor | 0:1c358ea10753 | 19 | #define field_named_data(record, field, data) field_data(field_name(record, field), data) |
spastor | 0:1c358ea10753 | 20 | |
spastor | 0:1c358ea10753 | 21 | #define field_allocate(name, type) field_data(name, offset), \ |
spastor | 0:1c358ea10753 | 22 | field_data(name, size) = (sizeof(type)), \ |
spastor | 0:1c358ea10753 | 23 | field_data(name, next) = (field_data(name, offset) + field_data(name, size) - 1) |
spastor | 0:1c358ea10753 | 24 | |
spastor | 0:1c358ea10753 | 25 | #define field_define(record, field, type) field_allocate(field_name(record, field), type) |
spastor | 0:1c358ea10753 | 26 | |
spastor | 0:1c358ea10753 | 27 | #define field_allocate_array(name, bytes) field_data(name, offset), \ |
spastor | 0:1c358ea10753 | 28 | field_data(name, size) = (bytes), \ |
spastor | 0:1c358ea10753 | 29 | field_data(name, next) = (field_data(name, offset) + field_data(name, size) - 1) |
spastor | 0:1c358ea10753 | 30 | |
spastor | 0:1c358ea10753 | 31 | #define field_define_array(record, field, count) field_allocate_array(field_name(record, field), count) |
spastor | 0:1c358ea10753 | 32 | |
spastor | 0:1c358ea10753 | 33 | #define record_end(name) field_data(name, bytes) |
spastor | 0:1c358ea10753 | 34 | |
spastor | 0:1c358ea10753 | 35 | #define record_bytes(name) field_data(name, bytes) |
spastor | 0:1c358ea10753 | 36 | |
spastor | 0:1c358ea10753 | 37 | #if (defined CONNECTOR_HAS_64_BIT_INTEGERS) |
spastor | 0:1c358ea10753 | 38 | #define message_store_be64(record, field, value) \ |
spastor | 0:1c358ea10753 | 39 | do { \ |
spastor | 0:1c358ea10753 | 40 | ASSERT(field_named_data(record, field, size) == sizeof (uint64_t)); \ |
spastor | 0:1c358ea10753 | 41 | StoreBE64(record + field_named_data(record, field, offset), (value)); \ |
spastor | 0:1c358ea10753 | 42 | } while (0) |
spastor | 0:1c358ea10753 | 43 | #endif |
spastor | 0:1c358ea10753 | 44 | |
spastor | 0:1c358ea10753 | 45 | #define message_store_be32(record, field, value) \ |
spastor | 0:1c358ea10753 | 46 | do { \ |
spastor | 0:1c358ea10753 | 47 | ASSERT(field_named_data(record, field, size) == sizeof (uint32_t)); \ |
spastor | 0:1c358ea10753 | 48 | StoreBE32(record + field_named_data(record, field, offset), (value)); \ |
spastor | 0:1c358ea10753 | 49 | } while (0) |
spastor | 0:1c358ea10753 | 50 | |
spastor | 0:1c358ea10753 | 51 | #define message_store_be16(record, field, value) \ |
spastor | 0:1c358ea10753 | 52 | do { \ |
spastor | 0:1c358ea10753 | 53 | ASSERT(field_named_data(record, field, size) == sizeof (uint16_t)); \ |
spastor | 0:1c358ea10753 | 54 | StoreBE16(record + field_named_data(record, field, offset), (value)); \ |
spastor | 0:1c358ea10753 | 55 | } while (0) |
spastor | 0:1c358ea10753 | 56 | |
spastor | 0:1c358ea10753 | 57 | #define message_store_u8(record, field, value) \ |
spastor | 0:1c358ea10753 | 58 | do { \ |
spastor | 0:1c358ea10753 | 59 | ASSERT(field_named_data(record, field, size) == sizeof (uint8_t)); \ |
spastor | 0:1c358ea10753 | 60 | *(record + field_named_data(record, field, offset)) = (value); \ |
spastor | 0:1c358ea10753 | 61 | } while (0) |
spastor | 0:1c358ea10753 | 62 | |
spastor | 0:1c358ea10753 | 63 | #define message_store_array(record, field, value, array) \ |
spastor | 0:1c358ea10753 | 64 | do { \ |
spastor | 0:1c358ea10753 | 65 | ASSERT(field_named_data(record, field, size) == array); \ |
spastor | 0:1c358ea10753 | 66 | memcpy((record + field_named_data(record, field, offset)), (value), array); \ |
spastor | 0:1c358ea10753 | 67 | } while (0) |
spastor | 0:1c358ea10753 | 68 | |
spastor | 0:1c358ea10753 | 69 | #if (defined CONNECTOR_DEBUG) |
spastor | 0:1c358ea10753 | 70 | #define message_load_be32(record, field) (ASSERT(field_named_data(record, field, size) == sizeof (uint32_t)), LoadBE32(record + field_named_data(record, field, offset))) |
spastor | 0:1c358ea10753 | 71 | #define message_load_be16(record, field) (ASSERT(field_named_data(record, field, size) == sizeof (uint16_t)), LoadBE16(record + field_named_data(record, field, offset))) |
spastor | 0:1c358ea10753 | 72 | #define message_load_u8(record, field) (ASSERT(field_named_data(record, field, size) == sizeof (uint8_t)), *(record + field_named_data(record, field, offset))) |
spastor | 0:1c358ea10753 | 73 | #else |
spastor | 0:1c358ea10753 | 74 | #define message_load_be32(record, field) LoadBE32(record + field_named_data(record, field, offset)) |
spastor | 0:1c358ea10753 | 75 | #define message_load_be16(record, field) LoadBE16(record + field_named_data(record, field, offset)) |
spastor | 0:1c358ea10753 | 76 | #define message_load_u8(record, field) *(record + field_named_data(record, field, offset)) |
spastor | 0:1c358ea10753 | 77 | #endif |
spastor | 0:1c358ea10753 | 78 | |
spastor | 0:1c358ea10753 | 79 | #define PACKET_EDP_PROTOCOL_SIZE ((size_t)record_bytes(edp_protocol)) |
spastor | 0:1c358ea10753 | 80 | #define PACKET_EDP_HEADER_SIZE ((size_t)record_bytes(edp_header)) |
spastor | 0:1c358ea10753 | 81 | #define PACKET_EDP_FACILITY_SIZE (PACKET_EDP_PROTOCOL_SIZE + PACKET_EDP_HEADER_SIZE) |
spastor | 0:1c358ea10753 | 82 | |
spastor | 0:1c358ea10753 | 83 | /* private definitions */ |
spastor | 0:1c358ea10753 | 84 | enum edp_header { |
spastor | 0:1c358ea10753 | 85 | field_define(edp_header, type, uint16_t), |
spastor | 0:1c358ea10753 | 86 | field_define(edp_header, length, uint16_t), |
spastor | 0:1c358ea10753 | 87 | record_end(edp_header) |
spastor | 0:1c358ea10753 | 88 | }; |
spastor | 0:1c358ea10753 | 89 | |
spastor | 0:1c358ea10753 | 90 | enum edp_protocol { |
spastor | 0:1c358ea10753 | 91 | field_define(edp_protocol, sec_coding, uint8_t), |
spastor | 0:1c358ea10753 | 92 | field_define(edp_protocol, payload, uint8_t), |
spastor | 0:1c358ea10753 | 93 | field_define(edp_protocol, facility, uint16_t), |
spastor | 0:1c358ea10753 | 94 | record_end(edp_protocol) |
spastor | 0:1c358ea10753 | 95 | }; |
spastor | 0:1c358ea10753 | 96 | |
spastor | 0:1c358ea10753 | 97 | |
spastor | 0:1c358ea10753 | 98 | #endif |
spastor | 0:1c358ea10753 | 99 |