Monitor motorhome leisure battery and provide simple control of habitation

Dependencies:   net lpc1768 crypto clock web fram log

Committer:
andrewboyson
Date:
Fri Jun 10 18:32:21 2022 +0000
Revision:
10:a97a7cb7aa82
Parent:
9:d957af50fdc2
Corrected amp second count in html

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 0:b843d647695c 1 #include "http.h"
andrewboyson 0:b843d647695c 2 #include "web-pages-this.h"
andrewboyson 0:b843d647695c 3 #include "web.h"
andrewboyson 0:b843d647695c 4
andrewboyson 9:d957af50fdc2 5 #define DO_HOME_HTML DO_THIS + 0
andrewboyson 9:d957af50fdc2 6 #define DO_BATTERY_HTML DO_THIS + 1
andrewboyson 9:d957af50fdc2 7 #define DO_BATTERY_AJAX DO_THIS + 2
andrewboyson 9:d957af50fdc2 8 #define DO_BATTERY_SCRIPT DO_THIS + 3
andrewboyson 9:d957af50fdc2 9 #define DO_SYSTEM_HTML DO_THIS + 4
andrewboyson 9:d957af50fdc2 10 #define DO_SYSTEM_AJAX DO_THIS + 5
andrewboyson 9:d957af50fdc2 11 #define DO_SYSTEM_SCRIPT DO_THIS + 6
andrewboyson 0:b843d647695c 12
andrewboyson 0:b843d647695c 13 int WebServerThisDecideWhatToDo(char *pPath, char* pLastModified)
andrewboyson 0:b843d647695c 14 {
andrewboyson 0:b843d647695c 15 if (HttpSameStr(pPath, "/" )) return DO_HOME_HTML;
andrewboyson 9:d957af50fdc2 16 if (HttpSameStr(pPath, "/battery" )) return DO_BATTERY_HTML;
andrewboyson 9:d957af50fdc2 17 if (HttpSameStr(pPath, "/battery-ajax" )) return DO_BATTERY_AJAX;
andrewboyson 0:b843d647695c 18 if (HttpSameStr(pPath, "/system" )) return DO_SYSTEM_HTML;
andrewboyson 0:b843d647695c 19 if (HttpSameStr(pPath, "/system-ajax" )) return DO_SYSTEM_AJAX;
andrewboyson 0:b843d647695c 20
andrewboyson 9:d957af50fdc2 21 if (HttpSameStr(pPath, "/battery.js" )) return HttpSameDate(WebBatteryScriptDate, WebBatteryScriptTime, pLastModified) ? DO_NOT_MODIFIED : DO_BATTERY_SCRIPT;
andrewboyson 0:b843d647695c 22 if (HttpSameStr(pPath, "/system.js" )) return HttpSameDate(WebSystemScriptDate, WebSystemScriptTime, pLastModified) ? DO_NOT_MODIFIED : DO_SYSTEM_SCRIPT;
andrewboyson 0:b843d647695c 23
andrewboyson 0:b843d647695c 24 return DO_NOT_FOUND;
andrewboyson 0:b843d647695c 25 }
andrewboyson 0:b843d647695c 26
andrewboyson 0:b843d647695c 27 bool WebServerThisHandleQuery(int todo, char* pQuery)
andrewboyson 0:b843d647695c 28 {
andrewboyson 0:b843d647695c 29 switch (todo)
andrewboyson 0:b843d647695c 30 {
andrewboyson 9:d957af50fdc2 31 case DO_BATTERY_AJAX: WebBatteryQuery (pQuery); return true;
andrewboyson 9:d957af50fdc2 32 case DO_BATTERY_HTML: WebBatteryQuery (pQuery); return true;
andrewboyson 0:b843d647695c 33 case DO_SYSTEM_HTML: WebSystemQuery (pQuery); return true;
andrewboyson 0:b843d647695c 34 case DO_SYSTEM_AJAX: WebSystemQuery (pQuery); return true;
andrewboyson 0:b843d647695c 35 }
andrewboyson 0:b843d647695c 36 return false;
andrewboyson 0:b843d647695c 37 }
andrewboyson 0:b843d647695c 38 bool WebServerThisPost(int todo, int contentLength, int contentStart, int size, char* pRequestStream, uint32_t positionInRequestStream, bool* pComplete)
andrewboyson 0:b843d647695c 39 {
andrewboyson 0:b843d647695c 40 return false;
andrewboyson 0:b843d647695c 41 }
andrewboyson 0:b843d647695c 42 bool WebServerThisReply(int todo)
andrewboyson 0:b843d647695c 43 {
andrewboyson 0:b843d647695c 44 switch (todo)
andrewboyson 0:b843d647695c 45 {
andrewboyson 0:b843d647695c 46 case DO_HOME_HTML: WebHomeHtml (); return true;
andrewboyson 9:d957af50fdc2 47 case DO_BATTERY_HTML: WebBatteryHtml (); return true;
andrewboyson 9:d957af50fdc2 48 case DO_BATTERY_AJAX: WebBatteryAjax (); return true;
andrewboyson 9:d957af50fdc2 49 case DO_BATTERY_SCRIPT: WebBatteryScript (); return true;
andrewboyson 0:b843d647695c 50 case DO_SYSTEM_HTML: WebSystemHtml (); return true;
andrewboyson 0:b843d647695c 51 case DO_SYSTEM_AJAX: WebSystemAjax (); return true;
andrewboyson 0:b843d647695c 52 case DO_SYSTEM_SCRIPT: WebSystemScript (); return true;
andrewboyson 0:b843d647695c 53 }
andrewboyson 0:b843d647695c 54 return false;
andrewboyson 0:b843d647695c 55 }