reef monitor
Dependencies: mbed-rtos EthernetInterface FatFileSystemCpp MCP23S17 SDFileSystem mbed
Fork of HTTPServerHelloWorld by
Model/Application.cpp
- Committer:
- wyunreal
- Date:
- 2014-03-02
- Revision:
- 8:3655e9a98f28
- Parent:
- 7:1fe91b525d9a
- Child:
- 10:372c882b5533
File content as of revision 8:3655e9a98f28:
#include "Application.h" #define WATCH_DOG_TIMER_TRIGGER_TIME 5 //seconds extern "C" void mbed_reset(); Application::Application() { } void Application::setup() { // WatchDog reset ? if (WatchDogTimer::systemResetReason() == SYSTEM_RESET_WATCH_DOG) { handleFaultyResetRecovery(); } // setup ethernet ethernetService = new EthernetService(); if(!ethernetService->setup()) { applicationReset(); } // set the system time from NTP ethernetService->setRtcTime(); // starting the file system localFileSystem = new LocalFileSystem("local"); sdFileSystem = new SDFileSystem(p5, p6, p7, p8, "sd"); // start the rest api server restServer = new RestServer(localFileSystem, sdFileSystem); restServer->bind(); // enable watchdog timer watchDog = new WatchDogTimer(WATCH_DOG_TIMER_TRIGGER_TIME); } void Application::handleFaultyResetRecovery() { } void Application::loop() { } void Application::run() { setup(); while(1) { loop(); watchDog->feed(); ethernetService->poll(); if (ethernetService->isLinkRestored()) { // if ethernet link is restored, application needs to be restarted applicationReset(); } watchDog->feed(); } } void Application::applicationReset() { wait(5); mbed_reset(); } Application::~Application() { delete ethernetService; }