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@20:653923c2f37a, 2016-09-08 (annotated)
- Committer:
- jmarkel44
- Date:
- Thu Sep 08 15:01:52 2016 +0000
- Revision:
- 20:653923c2f37a
- Parent:
- 18:9cf694a764c0
- Child:
- 21:85c69494c0ff
added cloud data handler and control task
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmarkel44 | 0:65cfa4873284 | 1 | /****************************************************************************** |
jmarkel44 | 3:8ea4db957749 | 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 "BLEDataHandler.h" |
davidjhoward | 16:7f6599312962 | 16 | #include "LoRaInit.h" |
jmarkel44 | 20:653923c2f37a | 17 | #include "ControlTask.h" |
jmarkel44 | 20:653923c2f37a | 18 | #include "CloudDataHandler.h" |
jmarkel44 | 0:65cfa4873284 | 19 | |
jmarkel44 | 0:65cfa4873284 | 20 | // main thread identifier (for signaling) |
jmarkel44 | 0:65cfa4873284 | 21 | osThreadId mainThreadId = NULL; |
jmarkel44 | 0:65cfa4873284 | 22 | int sig_continue = 0x1; |
jmarkel44 | 0:65cfa4873284 | 23 | |
jmarkel44 | 0:65cfa4873284 | 24 | // data handler to configuration hanlder mailbox |
jmarkel44 | 0:65cfa4873284 | 25 | Mail<Message_t, 16> MailBox; |
jmarkel44 | 0:65cfa4873284 | 26 | |
jmarkel44 | 0:65cfa4873284 | 27 | // local function prototypes |
jmarkel44 | 0:65cfa4873284 | 28 | static void banner(void); |
jmarkel44 | 0:65cfa4873284 | 29 | |
davidjhoward | 7:c0c03193612d | 30 | // for file system access outside of main() |
jmarkel44 | 13:c80c283f9db2 | 31 | mDot *GLOBAL_mdot; |
jmarkel44 | 13:c80c283f9db2 | 32 | |
jmarkel44 | 13:c80c283f9db2 | 33 | // store modbus register information |
jmarkel44 | 13:c80c283f9db2 | 34 | std::map<std::string,ModbusRegister> ModbusRegisterMap; |
davidjhoward | 7:c0c03193612d | 35 | |
jmarkel44 | 0:65cfa4873284 | 36 | /***************************************************************************** |
jmarkel44 | 0:65cfa4873284 | 37 | * Function: banner() |
jmarkel44 | 0:65cfa4873284 | 38 | * Description: Display the application boot banner |
jmarkel44 | 0:65cfa4873284 | 39 | * |
jmarkel44 | 0:65cfa4873284 | 40 | * @param none |
jmarkel44 | 0:65cfa4873284 | 41 | * @return none |
jmarkel44 | 0:65cfa4873284 | 42 | *****************************************************************************/ |
jmarkel44 | 0:65cfa4873284 | 43 | static void banner( void ) |
jmarkel44 | 0:65cfa4873284 | 44 | { |
jmarkel44 | 13:c80c283f9db2 | 45 | printf("\n\n\r\nWelcome to Project: ICE v0.0.2\n"); |
jmarkel44 | 0:65cfa4873284 | 46 | printf("\rThe Intelligent Connected Experience\n"); |
jmarkel44 | 0:65cfa4873284 | 47 | printf("\rCopyright 2016 Nalco Water, an Ecolab Company\n"); |
jmarkel44 | 0:65cfa4873284 | 48 | |
jmarkel44 | 0:65cfa4873284 | 49 | printf("\r\t _____ _____ ______ \n"); |
jmarkel44 | 0:65cfa4873284 | 50 | printf("\r\t |_ _| / ____| | ____|\n"); |
jmarkel44 | 0:65cfa4873284 | 51 | printf("\r\t | | | | | |__ \n"); |
jmarkel44 | 0:65cfa4873284 | 52 | printf("\r\t | | | | | __| \n"); |
jmarkel44 | 0:65cfa4873284 | 53 | printf("\r\t _| |_ | |____ | |____ \n"); |
jmarkel44 | 0:65cfa4873284 | 54 | printf("\r\t |_____| \\_____| |______|\n"); |
jmarkel44 | 0:65cfa4873284 | 55 | |
jmarkel44 | 0:65cfa4873284 | 56 | printf("\r\n\r\n\r\r\n"); |
jmarkel44 | 0:65cfa4873284 | 57 | } |
jmarkel44 | 0:65cfa4873284 | 58 | |
jmarkel44 | 0:65cfa4873284 | 59 | /***************************************************************************** |
jmarkel44 | 0:65cfa4873284 | 60 | * Function: banner() |
jmarkel44 | 0:65cfa4873284 | 61 | * Description: Display the application boot banner |
jmarkel44 | 0:65cfa4873284 | 62 | * |
jmarkel44 | 0:65cfa4873284 | 63 | * @param none |
jmarkel44 | 0:65cfa4873284 | 64 | * @return none |
jmarkel44 | 0:65cfa4873284 | 65 | *****************************************************************************/ |
jmarkel44 | 0:65cfa4873284 | 66 | int main( void ) |
jmarkel44 | 0:65cfa4873284 | 67 | { |
jmarkel44 | 0:65cfa4873284 | 68 | mDot *dot; |
davidjhoward | 16:7f6599312962 | 69 | |
jmarkel44 | 20:653923c2f37a | 70 | mDotRadioInit( &dot ); |
jmarkel44 | 20:653923c2f37a | 71 | //GLOBAL_mdot = dot = mDot::getInstance(); |
jmarkel44 | 3:8ea4db957749 | 72 | |
jmarkel44 | 13:c80c283f9db2 | 73 | // for signaling from the configuration handler |
jmarkel44 | 0:65cfa4873284 | 74 | mainThreadId = osThreadGetId(); |
jmarkel44 | 3:8ea4db957749 | 75 | |
jmarkel44 | 0:65cfa4873284 | 76 | banner(); |
jmarkel44 | 0:65cfa4873284 | 77 | printf("\rMultiTech mDot library version: %s\n", dot->getId().c_str()); |
jmarkel44 | 3:8ea4db957749 | 78 | |
jmarkel44 | 3:8ea4db957749 | 79 | // start the configuration handler |
jmarkel44 | 3:8ea4db957749 | 80 | Thread configHandler_thread(ConfigurationHandler); |
jmarkel44 | 20:653923c2f37a | 81 | Thread controlTask_thread(ControlTask); |
jmarkel44 | 3:8ea4db957749 | 82 | |
jmarkel44 | 0:65cfa4873284 | 83 | // wait for the configuration handler to signal us |
jmarkel44 | 0:65cfa4873284 | 84 | osSignalWait(sig_continue, osWaitForever); |
jmarkel44 | 3:8ea4db957749 | 85 | |
jmarkel44 | 0:65cfa4873284 | 86 | printf("\r%s: continuing to initialize...\n", __func__); |
jmarkel44 | 3:8ea4db957749 | 87 | |
jmarkel44 | 3:8ea4db957749 | 88 | Thread anaylticsLogger_thread(AnalyticsLogger); |
jmarkel44 | 3:8ea4db957749 | 89 | Thread modbusMaster_thread(ModbusMaster); |
jmarkel44 | 3:8ea4db957749 | 90 | Thread BLE_thread(BLEDataHandler); |
jmarkel44 | 20:653923c2f37a | 91 | Thread CDH_thread(CloudDataHandler); |
jmarkel44 | 3:8ea4db957749 | 92 | |
jmarkel44 | 1:057d8fc6cb2f | 93 | Thread::wait(1000); |
jmarkel44 | 3:8ea4db957749 | 94 | |
jmarkel44 | 3:8ea4db957749 | 95 | // display free memory on the heap |
jmarkel44 | 18:9cf694a764c0 | 96 | printf("\r\n"); |
jmarkel44 | 3:8ea4db957749 | 97 | __heapstats((__heapprt)fprintf,stdout); |
jmarkel44 | 3:8ea4db957749 | 98 | |
jmarkel44 | 3:8ea4db957749 | 99 | printf("\r\n"); |
jmarkel44 | 13:c80c283f9db2 | 100 | Thread::wait(1000); |
jmarkel44 | 0:65cfa4873284 | 101 | printf("\r\n"); |
jmarkel44 | 20:653923c2f37a | 102 | |
jmarkel44 | 3:8ea4db957749 | 103 | // start the command shell |
jmarkel44 | 0:65cfa4873284 | 104 | ntshell_execute(&ntshell, func_read, func_write, func_cb_ntshell); |
jmarkel44 | 20:653923c2f37a | 105 | |
jmarkel44 | 3:8ea4db957749 | 106 | } |