Wiljan Arias / WhexReefMonitor

Dependencies:   mbed-rtos EthernetInterface FatFileSystemCpp MCP23S17 SDFileSystem mbed

Fork of HTTPServerHelloWorld by Donatien Garnier

Committer:
wyunreal
Date:
Fri Jan 02 22:44:42 2015 +0000
Revision:
11:9366140ebe5f
first revision, having the http server master and slave threads communicating fine

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wyunreal 11:9366140ebe5f 1 #ifndef HTTP_SERVER_H
wyunreal 11:9366140ebe5f 2 #define HTTP_SERVER_H
wyunreal 11:9366140ebe5f 3
wyunreal 11:9366140ebe5f 4 #include "rtos.h"
wyunreal 11:9366140ebe5f 5
wyunreal 11:9366140ebe5f 6 class HttpServer {
wyunreal 11:9366140ebe5f 7 private:
wyunreal 11:9366140ebe5f 8 static const unsigned short int FAULTY_REPORTS_COUNT = 10;
wyunreal 11:9366140ebe5f 9 static const unsigned short int STATUS_CHECK_TIMEOUT_MILLIS = 50;
wyunreal 11:9366140ebe5f 10 static const unsigned short int STATUS_CHECK_NO_BLOCKING = 0;
wyunreal 11:9366140ebe5f 11 static const unsigned short int WAITING_SHUTDOWN_ATTEMPTS = 10;
wyunreal 11:9366140ebe5f 12 static const unsigned short int SHUTDOWN_TIMEOUT_MILLIS = 50;
wyunreal 11:9366140ebe5f 13
wyunreal 11:9366140ebe5f 14 enum HttpServerSignals{
wyunreal 11:9366140ebe5f 15 // rtos signals are flags, assign values with care
wyunreal 11:9366140ebe5f 16 STATUS_CHECK_SIGNAL = 1,
wyunreal 11:9366140ebe5f 17 STATUS_CHECK_ACK_SIGNAL = 2,
wyunreal 11:9366140ebe5f 18 CLOSE_SIGNAL = 4,
wyunreal 11:9366140ebe5f 19 };
wyunreal 11:9366140ebe5f 20
wyunreal 11:9366140ebe5f 21 short unsigned int slaveThreadStatusCounter;
wyunreal 11:9366140ebe5f 22 osThreadId mainThreadId;
wyunreal 11:9366140ebe5f 23 Thread* listeningThread;
wyunreal 11:9366140ebe5f 24
wyunreal 11:9366140ebe5f 25 osThreadId getMainThreadId() {return mainThreadId;}
wyunreal 11:9366140ebe5f 26 static void httpServerListeningThread(void const *serverInstance);
wyunreal 11:9366140ebe5f 27 static void handleServerAliveRequests(osThreadId mainThreadId);
wyunreal 11:9366140ebe5f 28
wyunreal 11:9366140ebe5f 29 public:
wyunreal 11:9366140ebe5f 30 HttpServer();
wyunreal 11:9366140ebe5f 31 ~HttpServer();
wyunreal 11:9366140ebe5f 32
wyunreal 11:9366140ebe5f 33 bool start();
wyunreal 11:9366140ebe5f 34 bool stop();
wyunreal 11:9366140ebe5f 35 bool restart();
wyunreal 11:9366140ebe5f 36
wyunreal 11:9366140ebe5f 37 bool isAlive();
wyunreal 11:9366140ebe5f 38 };
wyunreal 11:9366140ebe5f 39
wyunreal 11:9366140ebe5f 40 #endif