Library for inclusion of main.cpp -forked

Dependents:   df-2014-workshop-rfid-case-generator-k64f df-2014-rfid-case-gen-k64f-complete df-2014-rfid-case-gen-k64f-exercise

Fork of EndpointMain by Doug Anson

Revision:
2:55b1877a3a14
Parent:
1:8364052fbe84
Child:
3:1d8589377a86
--- a/main.cpp	Wed Sep 17 16:33:39 2014 +0000
+++ b/main.cpp	Fri Sep 26 04:34:23 2014 +0000
@@ -1,5 +1,7 @@
 /* Copyright C2014 ARM, MIT License
  *
+ * Author: Doug Anson (doug.anson@arm.com)
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
  * and associated documentation files the "Software", to deal in the Software without restriction,
  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
@@ -15,20 +17,7 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
- 
- // StatusReporter
- #include "StatusReporter.h"
-
- // appboard LCD Panel
- #if _NXP_PLATFORM
-    #include "C12832_lcd.h"
-    C12832_LCD lcd;
- #endif
- #if _UBLOX_PLATFORM
-     #include "C12832.h"
-     C12832 lcd(D11, D13, D12, D7, D10);  
- #endif
- 
+  
  // our Serial port
  #include "BufferedSerial.h"
  BufferedSerial pc(USBTX, USBRX);
@@ -41,24 +30,13 @@
  #include "HTTPClient.h"
  HTTPClient http;
  
- // HARD RESET
- extern "C" void HardFault_Handler() { NVIC_SystemReset(); }
-
- #ifdef MAC_ADDRESS
- char mac[6] = {MAC_ADDRESS};
- extern "C" void mbed_mac_address(char *s) { for(int i=0;i<6;++i) s[i] = mac[i]; }
- char fmt_mac[RESOURCE_VALUE_LEN+1];
- #endif
- 
+ // StatusReporter
+ #include "StatusReporter.h"
+  
  // Main Task...
  void mainTask(void const *v) {
     // create our object instances 
-#if _NXP_PLATFORM || _UBLOX_PLATFORM
-    ErrorHandler logger(&pc,&lcd);
-#endif
-#if _K64F_PLATFORM
-    ErrorHandler logger(&pc,NULL);
-#endif
+    Logger logger(&pc,NULL);
     
     // announce
     logger.log("ARM/DreamForce 2014 mbed Status Reporter v%s",APP_VERSION);
@@ -76,7 +54,7 @@
         logger.log("IP Address: %s",ethernet.getIPAddress());
         
         // create the StatusReporter
-        StatusReporter status_reporter(&logger,(void *)&http);
+        StatusReporter status_reporter(&http,&logger);
         
         // entering main loop
         logger.log("Entering Main Loop...\r\nScanning...");
@@ -86,7 +64,7 @@
         while(true) {
              // check and report on status updates
              status_reporter.checkAndReportOnStatus();
-          }
+        }
      }
      else {
          logger.log("No Network... Exiting...");
@@ -107,12 +85,8 @@
   
   // main entry
   int main() {
-  #if _K64F_PLATFORM
-    Thread workerTask(mainTask, NULL, osPriorityNormal, STACK_SIZE);
-    while (true) {
+     Thread workerTask(mainTask, NULL, osPriorityNormal, STACK_SIZE);
+     while (true) {
         Thread::wait(10*WAIT_TIME_MS);
-    }
-  #else
-    mainTask(NULL);
-  #endif
+     }
   }
\ No newline at end of file