Controls the central heating system and the lights.

Dependencies:   1-wire clock crypto fram log lpc1768 net web wiz mbed

web-this/radiator/web-radiator-query.c

Committer:
andrewboyson
Date:
2022-11-12
Revision:
8:8ac076ce51af
Parent:
5:3579001bea1b

File content as of revision 8:8ac076ce51af:

#include <string.h>
#include <stdlib.h>
#include "http.h"
#include "radiator.h"

void WebRadiatorQuery(char* pQuery)
{
    while (pQuery)
    {
        char* pName;
        char* pValue;
        pQuery = HttpQuerySplit(pQuery, &pName, &pValue);
        int value = HttpQueryValueAsInt(pValue);
        
        if (HttpSameStr(pName, "overridecancelminute"))
        {
            int hour   = value / 100;
            int minute = value % 100;
            RadiatorSetOverrideCancelHour  (hour);
            RadiatorSetOverrideCancelMinute(minute);
        }
        
        if (HttpSameStr(pName, "htg-chg-mode"        )) RadiatorChgWinter();
        if (HttpSameStr(pName, "htg-chg-override"    )) RadiatorChgOverride();
        if (HttpSameStr(pName, "htg-chg-hw-prot"     )) RadiatorChgHotWaterProtectOn();
        
        if (HttpSameStr(pName, "nighttemp"           )) RadiatorSetNightTemperature(value);
        if (HttpSameStr(pName, "frosttemp"           )) RadiatorSetFrostTemperature(value);
        if (HttpSameStr(pName, "hwprotecttemp"       )) RadiatorSetHotWaterProtectTemp(value);
    }
}