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/rci_binary_buffer.h

Committer:
spastor
Date:
2013-12-03
Revision:
1:908afea5a49d
Parent:
0:1c358ea10753

File content as of revision 1:908afea5a49d:

/*
 * Copyright (c) 2013 Digi International Inc.,
 * All rights not expressly granted are reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
 * =======================================================================
 */

static void rci_set_buffer(rci_buffer_t * const dst, rci_service_buffer_t const * const src)
{
    uint8_t * const start = src->data;

    dst->start = start;
    dst->end = start + src->bytes;
    dst->current = start;
}

static size_t rci_buffer_remaining(rci_buffer_t const * const buffer)
{
    size_t const remaining_length = (size_t)(buffer->end - buffer->current);
    return remaining_length;
}

static size_t rci_buffer_used(rci_buffer_t const * const buffer)
{
    size_t const used_length = (size_t)(buffer->current - buffer->start);
    return used_length;
}

static uint8_t * rci_buffer_position(rci_buffer_t const * const buffer)
{
    return buffer->current;
}

static void rci_buffer_advance(rci_buffer_t * const buffer, size_t const amount)
{
    ASSERT((buffer->current + amount) <= buffer->end);
    buffer->current += amount;
}

static uint8_t rci_buffer_read(rci_buffer_t const * const buffer)
{
    ASSERT(rci_buffer_remaining(buffer) != 0);

    return *(buffer->current);
}

static connector_bool_t ptr_in_range(void const * const pointer, void const * const start, void const * const end)
{
    return connector_bool((pointer >= start) && (pointer <= end));
}

static connector_bool_t ptr_in_buffer(uint8_t const * const pointer, rci_buffer_t const * const buffer)
{
    return ptr_in_range(pointer, buffer->start, buffer->end);
}