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.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
src/main.cpp@0:65cfa4873284, 2016-09-01 (annotated)
- Committer:
- jmarkel44
- Date:
- Thu Sep 01 18:57:04 2016 +0000
- Revision:
- 0:65cfa4873284
- Child:
- 1:057d8fc6cb2f
Base version (threading + messaging based on mbed 5.0);
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmarkel44 | 0:65cfa4873284 | 1 | /****************************************************************************** |
jmarkel44 | 0:65cfa4873284 | 2 | * |
jmarkel44 | 0:65cfa4873284 | 3 | * File: main.cpp |
jmarkel44 | 0:65cfa4873284 | 4 | * Desciption: main ICE driver routine |
jmarkel44 | 0:65cfa4873284 | 5 | * |
jmarkel44 | 0:65cfa4873284 | 6 | *****************************************************************************/ |
jmarkel44 | 0:65cfa4873284 | 7 | #include "mbed.h" |
jmarkel44 | 0:65cfa4873284 | 8 | #include "rtos.h" |
jmarkel44 | 0:65cfa4873284 | 9 | #include <stdio.h> |
jmarkel44 | 0:65cfa4873284 | 10 | #include "mDot.h" |
jmarkel44 | 0:65cfa4873284 | 11 | #include "global.h" |
jmarkel44 | 0:65cfa4873284 | 12 | #include "ConfigurationHandler.h" |
jmarkel44 | 0:65cfa4873284 | 13 | #include "AnalyticsLogger.h" |
jmarkel44 | 0:65cfa4873284 | 14 | #include "ModbusMaster.h" |
jmarkel44 | 0:65cfa4873284 | 15 | #include "CloudDataHandler.h" |
jmarkel44 | 0:65cfa4873284 | 16 | #include "BLEDataHandler.h" |
jmarkel44 | 0:65cfa4873284 | 17 | |
jmarkel44 | 0:65cfa4873284 | 18 | // main thread identifier (for signaling) |
jmarkel44 | 0:65cfa4873284 | 19 | osThreadId mainThreadId = NULL; |
jmarkel44 | 0:65cfa4873284 | 20 | |
jmarkel44 | 0:65cfa4873284 | 21 | int sig_continue = 0x1; |
jmarkel44 | 0:65cfa4873284 | 22 | |
jmarkel44 | 0:65cfa4873284 | 23 | // data handler to configuration hanlder mailbox |
jmarkel44 | 0:65cfa4873284 | 24 | Mail<Message_t, 16> MailBox; |
jmarkel44 | 0:65cfa4873284 | 25 | |
jmarkel44 | 0:65cfa4873284 | 26 | // local function prototypes |
jmarkel44 | 0:65cfa4873284 | 27 | static void banner(void); |
jmarkel44 | 0:65cfa4873284 | 28 | |
jmarkel44 | 0:65cfa4873284 | 29 | /***************************************************************************** |
jmarkel44 | 0:65cfa4873284 | 30 | * Function: banner() |
jmarkel44 | 0:65cfa4873284 | 31 | * Description: Display the application boot banner |
jmarkel44 | 0:65cfa4873284 | 32 | * |
jmarkel44 | 0:65cfa4873284 | 33 | * @param none |
jmarkel44 | 0:65cfa4873284 | 34 | * @return none |
jmarkel44 | 0:65cfa4873284 | 35 | *****************************************************************************/ |
jmarkel44 | 0:65cfa4873284 | 36 | static void banner( void ) |
jmarkel44 | 0:65cfa4873284 | 37 | { |
jmarkel44 | 0:65cfa4873284 | 38 | printf("\n\n\r\nWelcome to Project: ICE v0.0.1\n"); |
jmarkel44 | 0:65cfa4873284 | 39 | printf("\rThe Intelligent Connected Experience\n"); |
jmarkel44 | 0:65cfa4873284 | 40 | printf("\rCopyright 2016 Nalco Water, an Ecolab Company\n"); |
jmarkel44 | 0:65cfa4873284 | 41 | |
jmarkel44 | 0:65cfa4873284 | 42 | printf("\r\t _____ _____ ______ \n"); |
jmarkel44 | 0:65cfa4873284 | 43 | printf("\r\t |_ _| / ____| | ____|\n"); |
jmarkel44 | 0:65cfa4873284 | 44 | printf("\r\t | | | | | |__ \n"); |
jmarkel44 | 0:65cfa4873284 | 45 | printf("\r\t | | | | | __| \n"); |
jmarkel44 | 0:65cfa4873284 | 46 | printf("\r\t _| |_ | |____ | |____ \n"); |
jmarkel44 | 0:65cfa4873284 | 47 | printf("\r\t |_____| \\_____| |______|\n"); |
jmarkel44 | 0:65cfa4873284 | 48 | |
jmarkel44 | 0:65cfa4873284 | 49 | printf("\r\n\r\n\r\r\n"); |
jmarkel44 | 0:65cfa4873284 | 50 | } |
jmarkel44 | 0:65cfa4873284 | 51 | |
jmarkel44 | 0:65cfa4873284 | 52 | /***************************************************************************** |
jmarkel44 | 0:65cfa4873284 | 53 | * Function: banner() |
jmarkel44 | 0:65cfa4873284 | 54 | * Description: Display the application boot banner |
jmarkel44 | 0:65cfa4873284 | 55 | * |
jmarkel44 | 0:65cfa4873284 | 56 | * @param none |
jmarkel44 | 0:65cfa4873284 | 57 | * @return none |
jmarkel44 | 0:65cfa4873284 | 58 | *****************************************************************************/ |
jmarkel44 | 0:65cfa4873284 | 59 | int main( void ) |
jmarkel44 | 0:65cfa4873284 | 60 | { |
jmarkel44 | 0:65cfa4873284 | 61 | mDot *dot; |
jmarkel44 | 0:65cfa4873284 | 62 | |
jmarkel44 | 0:65cfa4873284 | 63 | dot = mDot::getInstance(); |
jmarkel44 | 0:65cfa4873284 | 64 | mainThreadId = osThreadGetId(); |
jmarkel44 | 0:65cfa4873284 | 65 | |
jmarkel44 | 0:65cfa4873284 | 66 | banner(); |
jmarkel44 | 0:65cfa4873284 | 67 | printf("\rMultiTech mDot library version: %s\n", dot->getId().c_str()); |
jmarkel44 | 0:65cfa4873284 | 68 | |
jmarkel44 | 0:65cfa4873284 | 69 | // start the configuration handler |
jmarkel44 | 0:65cfa4873284 | 70 | Thread ch_thread(ConfigurationHandler); |
jmarkel44 | 0:65cfa4873284 | 71 | |
jmarkel44 | 0:65cfa4873284 | 72 | // wait for the configuration handler to signal us |
jmarkel44 | 0:65cfa4873284 | 73 | osSignalWait(sig_continue, osWaitForever); |
jmarkel44 | 0:65cfa4873284 | 74 | |
jmarkel44 | 0:65cfa4873284 | 75 | printf("\r%s: continuing to initialize...\n", __func__); |
jmarkel44 | 0:65cfa4873284 | 76 | |
jmarkel44 | 0:65cfa4873284 | 77 | Thread al_thread(AnalyticsLogger); |
jmarkel44 | 0:65cfa4873284 | 78 | Thread mm_thread(ModbusMaster); |
jmarkel44 | 0:65cfa4873284 | 79 | Thread cdh_thread(CloudDataHandler); |
jmarkel44 | 0:65cfa4873284 | 80 | Thread ble_thread(BLEDataHandler); |
jmarkel44 | 0:65cfa4873284 | 81 | |
jmarkel44 | 0:65cfa4873284 | 82 | // display free memory on the heap |
jmarkel44 | 0:65cfa4873284 | 83 | __heapstats((__heapprt)fprintf,stdout); |
jmarkel44 | 0:65cfa4873284 | 84 | |
jmarkel44 | 0:65cfa4873284 | 85 | // start the command shell |
jmarkel44 | 0:65cfa4873284 | 86 | Thread::wait(2000); |
jmarkel44 | 0:65cfa4873284 | 87 | printf("\r\n"); |
jmarkel44 | 0:65cfa4873284 | 88 | ntshell_execute(&ntshell, func_read, func_write, func_cb_ntshell); |
jmarkel44 | 0:65cfa4873284 | 89 | |
jmarkel44 | 0:65cfa4873284 | 90 | //ch_thread.join(); |
jmarkel44 | 0:65cfa4873284 | 91 | for (;;) {} |
jmarkel44 | 0:65cfa4873284 | 92 | } |