reef monitor

Dependencies:   mbed-rtos EthernetInterface FatFileSystemCpp MCP23S17 SDFileSystem mbed

Fork of HTTPServerHelloWorld by Donatien Garnier

Committer:
wyunreal
Date:
Sun Feb 02 16:57:24 2014 +0000
Revision:
6:b2c4687b421d
Parent:
5:df012c2caf40
Child:
7:1fe91b525d9a
Adding support for mass storage devices and making new request handlers to provide access to the webApp sources and logs

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wyunreal 4:a19825caaf41 1 #include "Application.h"
wyunreal 4:a19825caaf41 2
wyunreal 4:a19825caaf41 3 extern "C" void mbed_reset();
wyunreal 4:a19825caaf41 4
wyunreal 4:a19825caaf41 5 Application::Application() {
wyunreal 4:a19825caaf41 6 }
wyunreal 4:a19825caaf41 7
wyunreal 4:a19825caaf41 8 void Application::run() {
wyunreal 4:a19825caaf41 9 setup();
wyunreal 4:a19825caaf41 10 while(1) {
wyunreal 4:a19825caaf41 11 loop();
wyunreal 4:a19825caaf41 12 ethernetService->poll();
wyunreal 4:a19825caaf41 13 if (ethernetService->isLinkRestored()) {
wyunreal 5:df012c2caf40 14 // if ethernet link is restored, application needs to be restarted
wyunreal 4:a19825caaf41 15 applicationReset();
wyunreal 4:a19825caaf41 16 }
wyunreal 4:a19825caaf41 17 }
wyunreal 4:a19825caaf41 18 }
wyunreal 4:a19825caaf41 19
wyunreal 4:a19825caaf41 20 void Application::setup() {
wyunreal 5:df012c2caf40 21 // setup ethernet
wyunreal 4:a19825caaf41 22 ethernetService = new EthernetService();
wyunreal 4:a19825caaf41 23 if(!ethernetService->setup()) {
wyunreal 4:a19825caaf41 24 applicationReset();
wyunreal 4:a19825caaf41 25 }
wyunreal 5:df012c2caf40 26 // set the system time from NTP
wyunreal 4:a19825caaf41 27 ethernetService->setRtcTime();
wyunreal 5:df012c2caf40 28
wyunreal 5:df012c2caf40 29 // starting the file system
wyunreal 6:b2c4687b421d 30 localFileSystem = new LocalFileSystem("local");
wyunreal 6:b2c4687b421d 31 mscFileSystem = new MSCFileSystem("msc");
wyunreal 5:df012c2caf40 32
wyunreal 5:df012c2caf40 33 // start the rest api server
wyunreal 6:b2c4687b421d 34 restServer = new RestServer(localFileSystem, mscFileSystem);
wyunreal 5:df012c2caf40 35 restServer->bind();
wyunreal 4:a19825caaf41 36 }
wyunreal 4:a19825caaf41 37
wyunreal 4:a19825caaf41 38 void Application::loop() {
wyunreal 4:a19825caaf41 39
wyunreal 4:a19825caaf41 40 }
wyunreal 4:a19825caaf41 41
wyunreal 4:a19825caaf41 42 void Application::applicationReset() {
wyunreal 4:a19825caaf41 43 wait(5);
wyunreal 4:a19825caaf41 44 mbed_reset();
wyunreal 4:a19825caaf41 45 }
wyunreal 4:a19825caaf41 46
wyunreal 4:a19825caaf41 47 Application::~Application() {
wyunreal 4:a19825caaf41 48 delete ethernetService;
wyunreal 4:a19825caaf41 49 }