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 static void rci_set_buffer(rci_buffer_t * const dst, rci_service_buffer_t const * const src)
spastor 0:1c358ea10753 14 {
spastor 0:1c358ea10753 15 uint8_t * const start = src->data;
spastor 0:1c358ea10753 16
spastor 0:1c358ea10753 17 dst->start = start;
spastor 0:1c358ea10753 18 dst->end = start + src->bytes;
spastor 0:1c358ea10753 19 dst->current = start;
spastor 0:1c358ea10753 20 }
spastor 0:1c358ea10753 21
spastor 0:1c358ea10753 22 static size_t rci_buffer_remaining(rci_buffer_t const * const buffer)
spastor 0:1c358ea10753 23 {
spastor 0:1c358ea10753 24 size_t const remaining_length = (size_t)(buffer->end - buffer->current);
spastor 0:1c358ea10753 25 return remaining_length;
spastor 0:1c358ea10753 26 }
spastor 0:1c358ea10753 27
spastor 0:1c358ea10753 28 static size_t rci_buffer_used(rci_buffer_t const * const buffer)
spastor 0:1c358ea10753 29 {
spastor 0:1c358ea10753 30 size_t const used_length = (size_t)(buffer->current - buffer->start);
spastor 0:1c358ea10753 31 return used_length;
spastor 0:1c358ea10753 32 }
spastor 0:1c358ea10753 33
spastor 0:1c358ea10753 34 static uint8_t * rci_buffer_position(rci_buffer_t const * const buffer)
spastor 0:1c358ea10753 35 {
spastor 0:1c358ea10753 36 return buffer->current;
spastor 0:1c358ea10753 37 }
spastor 0:1c358ea10753 38
spastor 0:1c358ea10753 39 static void rci_buffer_advance(rci_buffer_t * const buffer, size_t const amount)
spastor 0:1c358ea10753 40 {
spastor 0:1c358ea10753 41 ASSERT((buffer->current + amount) <= buffer->end);
spastor 0:1c358ea10753 42 buffer->current += amount;
spastor 0:1c358ea10753 43 }
spastor 0:1c358ea10753 44
spastor 0:1c358ea10753 45 static uint8_t rci_buffer_read(rci_buffer_t const * const buffer)
spastor 0:1c358ea10753 46 {
spastor 0:1c358ea10753 47 ASSERT(rci_buffer_remaining(buffer) != 0);
spastor 0:1c358ea10753 48
spastor 0:1c358ea10753 49 return *(buffer->current);
spastor 0:1c358ea10753 50 }
spastor 0:1c358ea10753 51
spastor 0:1c358ea10753 52 static connector_bool_t ptr_in_range(void const * const pointer, void const * const start, void const * const end)
spastor 0:1c358ea10753 53 {
spastor 0:1c358ea10753 54 return connector_bool((pointer >= start) && (pointer <= end));
spastor 0:1c358ea10753 55 }
spastor 0:1c358ea10753 56
spastor 0:1c358ea10753 57 static connector_bool_t ptr_in_buffer(uint8_t const * const pointer, rci_buffer_t const * const buffer)
spastor 0:1c358ea10753 58 {
spastor 0:1c358ea10753 59 return ptr_in_range(pointer, buffer->start, buffer->end);
spastor 0:1c358ea10753 60 }
spastor 0:1c358ea10753 61
spastor 0:1c358ea10753 62