Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /* 00002 * Copyright (c) 2013 Digi International Inc., 00003 * All rights not expressly granted are reserved. 00004 * 00005 * This Source Code Form is subject to the terms of the Mozilla Public 00006 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 00007 * You can obtain one at http://mozilla.org/MPL/2.0/. 00008 * 00009 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 00010 * ======================================================================= 00011 */ 00012 00013 #include "mbed.h" 00014 #include "EthernetInterface.h" 00015 00016 extern "C" { 00017 00018 #include "connector_api.h" 00019 #include "ecc_platform.h" 00020 00021 } 00022 00023 static void connector_run_thread(void const * arg) 00024 { 00025 00026 APP_DEBUG("connector_run thread starts\n"); 00027 00028 for (;;) 00029 { 00030 connector_status_t const status = connector_run((void *)arg); 00031 00032 APP_DEBUG("connector_run returns %d\n", status); 00033 00034 if (status != connector_open_error) break; 00035 } 00036 00037 00038 APP_DEBUG("connector_run thread exits\n"); 00039 00040 } 00041 00042 static void application_run_thread(void const * arg) 00043 { 00044 int status; 00045 00046 APP_DEBUG("application_run thread starts\n"); 00047 00048 status = application_run((void *)arg); 00049 00050 APP_DEBUG("application_run thread exits %d\n", status); 00051 00052 } 00053 00054 int main (void) 00055 { 00056 EthernetInterface interface; 00057 00058 connector_handle_t connector_handle; 00059 00060 set_time(0); 00061 printf("Starting Ethernet interface\n"); 00062 00063 interface.init(); 00064 interface.connect(); 00065 printf("IP Address is %s\n\r", interface.getIPAddress()); 00066 00067 APP_DEBUG("Start Cloud Connector for Embedded\n"); 00068 connector_handle = connector_init(app_connector_callback); 00069 00070 if (connector_handle == NULL) 00071 { 00072 APP_DEBUG("Unable to initialize the connector\n"); 00073 ASSERT(0); 00074 } 00075 00076 { 00077 Thread connector_thread(connector_run_thread, connector_handle, osPriorityNormal, DEFAULT_STACK_SIZE); 00078 Thread application_thread(application_run_thread, connector_handle, osPriorityNormal, DEFAULT_STACK_SIZE); 00079 DigitalOut myled(LED1); 00080 for(;;) 00081 { 00082 myled = !myled.read(); 00083 wait(0.5); 00084 } 00085 } 00086 00087 return 0; 00088 } 00089
Generated on Tue Jul 12 2022 19:18:38 by
1.7.2