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 #include "mbed.h"
spastor 0:1c358ea10753 14 #include "EthernetInterface.h"
spastor 1:908afea5a49d 15
spastor 0:1c358ea10753 16 extern "C" {
spastor 0:1c358ea10753 17
spastor 0:1c358ea10753 18 #include "connector_api.h"
spastor 0:1c358ea10753 19 #include "ecc_platform.h"
spastor 0:1c358ea10753 20
spastor 0:1c358ea10753 21 }
spastor 0:1c358ea10753 22
spastor 0:1c358ea10753 23 static void connector_run_thread(void const * arg)
spastor 0:1c358ea10753 24 {
spastor 0:1c358ea10753 25
spastor 0:1c358ea10753 26 APP_DEBUG("connector_run thread starts\n");
spastor 0:1c358ea10753 27
spastor 0:1c358ea10753 28 for (;;)
spastor 0:1c358ea10753 29 {
spastor 0:1c358ea10753 30 connector_status_t const status = connector_run((void *)arg);
spastor 0:1c358ea10753 31
spastor 0:1c358ea10753 32 APP_DEBUG("connector_run returns %d\n", status);
spastor 0:1c358ea10753 33
spastor 0:1c358ea10753 34 if (status != connector_open_error) break;
spastor 0:1c358ea10753 35 }
spastor 0:1c358ea10753 36
spastor 0:1c358ea10753 37
spastor 0:1c358ea10753 38 APP_DEBUG("connector_run thread exits\n");
spastor 0:1c358ea10753 39
spastor 0:1c358ea10753 40 }
spastor 0:1c358ea10753 41
spastor 0:1c358ea10753 42 static void application_run_thread(void const * arg)
spastor 0:1c358ea10753 43 {
spastor 0:1c358ea10753 44 int status;
spastor 0:1c358ea10753 45
spastor 0:1c358ea10753 46 APP_DEBUG("application_run thread starts\n");
spastor 0:1c358ea10753 47
spastor 0:1c358ea10753 48 status = application_run((void *)arg);
spastor 0:1c358ea10753 49
spastor 0:1c358ea10753 50 APP_DEBUG("application_run thread exits %d\n", status);
spastor 0:1c358ea10753 51
spastor 0:1c358ea10753 52 }
spastor 0:1c358ea10753 53
spastor 0:1c358ea10753 54 int main (void)
spastor 0:1c358ea10753 55 {
spastor 0:1c358ea10753 56 EthernetInterface interface;
spastor 0:1c358ea10753 57
spastor 0:1c358ea10753 58 connector_handle_t connector_handle;
spastor 0:1c358ea10753 59
spastor 0:1c358ea10753 60 set_time(0);
spastor 0:1c358ea10753 61 printf("Starting Ethernet interface\n");
spastor 0:1c358ea10753 62
spastor 0:1c358ea10753 63 interface.init();
spastor 0:1c358ea10753 64 interface.connect();
spastor 0:1c358ea10753 65 printf("IP Address is %s\n\r", interface.getIPAddress());
spastor 0:1c358ea10753 66
spastor 0:1c358ea10753 67 APP_DEBUG("Start Cloud Connector for Embedded\n");
spastor 0:1c358ea10753 68 connector_handle = connector_init(app_connector_callback);
spastor 0:1c358ea10753 69
spastor 1:908afea5a49d 70 if (connector_handle == NULL)
spastor 0:1c358ea10753 71 {
spastor 0:1c358ea10753 72 APP_DEBUG("Unable to initialize the connector\n");
spastor 1:908afea5a49d 73 ASSERT(0);
spastor 0:1c358ea10753 74 }
spastor 0:1c358ea10753 75
spastor 0:1c358ea10753 76 {
spastor 1:908afea5a49d 77 Thread connector_thread(connector_run_thread, connector_handle, osPriorityNormal, DEFAULT_STACK_SIZE);
spastor 1:908afea5a49d 78 Thread application_thread(application_run_thread, connector_handle, osPriorityNormal, DEFAULT_STACK_SIZE);
spastor 0:1c358ea10753 79 DigitalOut myled(LED1);
spastor 0:1c358ea10753 80 for(;;)
spastor 0:1c358ea10753 81 {
spastor 1:908afea5a49d 82 myled = !myled.read();
spastor 1:908afea5a49d 83 wait(0.5);
spastor 0:1c358ea10753 84 }
spastor 0:1c358ea10753 85 }
spastor 0:1c358ea10753 86
spastor 0:1c358ea10753 87 return 0;
spastor 0:1c358ea10753 88 }
spastor 0:1c358ea10753 89