reef monitor

Dependencies:   mbed-rtos EthernetInterface FatFileSystemCpp MCP23S17 SDFileSystem mbed

Fork of HTTPServerHelloWorld by Donatien Garnier

Committer:
wyunreal
Date:
Sat Feb 01 18:54:20 2014 +0000
Revision:
5:df012c2caf40
Parent:
4:a19825caaf41
Child:
6:b2c4687b421d
Adding a FS handler to the webserver and mounting it to the local file system

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 5:df012c2caf40 30 fileSystem = new LocalFileSystem("local");
wyunreal 5:df012c2caf40 31
wyunreal 5:df012c2caf40 32 // start the rest api server
wyunreal 5:df012c2caf40 33 restServer = new RestServer(fileSystem);
wyunreal 5:df012c2caf40 34 restServer->bind();
wyunreal 4:a19825caaf41 35 }
wyunreal 4:a19825caaf41 36
wyunreal 4:a19825caaf41 37 void Application::loop() {
wyunreal 4:a19825caaf41 38
wyunreal 4:a19825caaf41 39 }
wyunreal 4:a19825caaf41 40
wyunreal 4:a19825caaf41 41 void Application::applicationReset() {
wyunreal 4:a19825caaf41 42 wait(5);
wyunreal 4:a19825caaf41 43 mbed_reset();
wyunreal 4:a19825caaf41 44 }
wyunreal 4:a19825caaf41 45
wyunreal 4:a19825caaf41 46 Application::~Application() {
wyunreal 4:a19825caaf41 47 delete ethernetService;
wyunreal 4:a19825caaf41 48 }