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 <stdlib.h>
andrewboyson 0:b843d647695c 2 #include <string.h>
andrewboyson 0:b843d647695c 3 #include "http.h"
andrewboyson 9:d957af50fdc2 4 #include "comms.h"
andrewboyson 0:b843d647695c 5
andrewboyson 9:d957af50fdc2 6 void WebBatteryQuery(char* pQuery)
andrewboyson 0:b843d647695c 7 {
andrewboyson 0:b843d647695c 8 while (pQuery)
andrewboyson 0:b843d647695c 9 {
andrewboyson 0:b843d647695c 10 char* pName;
andrewboyson 0:b843d647695c 11 char* pValue;
andrewboyson 0:b843d647695c 12 pQuery = HttpQuerySplit(pQuery, &pName, &pValue);
andrewboyson 0:b843d647695c 13
andrewboyson 9:d957af50fdc2 14 if (HttpSameStr(pName, "set-battery-counted-capacity"))
andrewboyson 0:b843d647695c 15 {
andrewboyson 0:b843d647695c 16 int value = HttpQueryValueAsInt(pValue);
andrewboyson 9:d957af50fdc2 17 BatterySetCountedCapacity(value);
andrewboyson 0:b843d647695c 18 return;
andrewboyson 0:b843d647695c 19 }
andrewboyson 10:a97a7cb7aa82 20 if (HttpSameStr(pName, "set-battery-counted-capacity-amp-hours"))
andrewboyson 10:a97a7cb7aa82 21 {
andrewboyson 10:a97a7cb7aa82 22 int value = HttpQueryValueAsInt(pValue);
andrewboyson 10:a97a7cb7aa82 23 BatterySetCountedCapacity(value * 3600);
andrewboyson 10:a97a7cb7aa82 24 return;
andrewboyson 10:a97a7cb7aa82 25 }
andrewboyson 10:a97a7cb7aa82 26 if (HttpSameStr(pName, "set-battery-counted-capacity-percent"))
andrewboyson 10:a97a7cb7aa82 27 {
andrewboyson 10:a97a7cb7aa82 28 int value = HttpQueryValueAsInt(pValue);
andrewboyson 10:a97a7cb7aa82 29 BatterySetCountedCapacity(value * 36 * 280);
andrewboyson 10:a97a7cb7aa82 30 return;
andrewboyson 10:a97a7cb7aa82 31 }
andrewboyson 9:d957af50fdc2 32 if (HttpSameStr(pName, "set-battery-counted-error"))
andrewboyson 9:d957af50fdc2 33 {
andrewboyson 9:d957af50fdc2 34 int value = HttpQueryValueAsInt(pValue);
andrewboyson 9:d957af50fdc2 35 BatterySetCountedError(value);
andrewboyson 9:d957af50fdc2 36 return;
andrewboyson 9:d957af50fdc2 37 }
andrewboyson 9:d957af50fdc2 38 if (HttpSameStr(pName, "set-battery-capacity-setpoint-percent"))
andrewboyson 0:b843d647695c 39 {
andrewboyson 0:b843d647695c 40 int value = HttpQueryValueAsInt(pValue);
andrewboyson 9:d957af50fdc2 41 BatterySetCapacitySetPointPercent(value);
andrewboyson 9:d957af50fdc2 42 return;
andrewboyson 9:d957af50fdc2 43 }
andrewboyson 9:d957af50fdc2 44 if (HttpSameStr(pName, "chg-battery-charge-enabled"))
andrewboyson 9:d957af50fdc2 45 {
andrewboyson 9:d957af50fdc2 46 BatterySetChargeEnabled(!BatteryGetChargeEnabled());
andrewboyson 0:b843d647695c 47 return;
andrewboyson 0:b843d647695c 48 }
andrewboyson 9:d957af50fdc2 49 if (HttpSameStr(pName, "chg-battery-discharge-enabled"))
andrewboyson 0:b843d647695c 50 {
andrewboyson 9:d957af50fdc2 51 BatterySetDischargeEnabled(!BatteryGetDischargeEnabled());
andrewboyson 0:b843d647695c 52 return;
andrewboyson 0:b843d647695c 53 }
andrewboyson 9:d957af50fdc2 54 if (HttpSameStr(pName, "set-battery-temperature-setpoint"))
andrewboyson 0:b843d647695c 55 {
andrewboyson 9:d957af50fdc2 56 int value = HttpQueryValueAsDouble(pValue)*10;
andrewboyson 9:d957af50fdc2 57 BatterySetTemperatureSetPoint(value);
andrewboyson 9:d957af50fdc2 58 return;
andrewboyson 9:d957af50fdc2 59 }
andrewboyson 9:d957af50fdc2 60 if (HttpSameStr(pName, "chg-battery-auto-update"))
andrewboyson 9:d957af50fdc2 61 {
andrewboyson 9:d957af50fdc2 62 BatterySetCapacityAutoUpdate(!BatteryGetCapacityAutoUpdate());
andrewboyson 0:b843d647695c 63 return;
andrewboyson 0:b843d647695c 64 }
andrewboyson 0:b843d647695c 65 }
andrewboyson 0:b843d647695c 66 }