--- a/thermferm/server.c Sun May 25 22:37:23 2014 +0200 +++ b/thermferm/server.c Sun May 25 23:29:07 2014 +0200 @@ -39,12 +39,6 @@ #define SS_BUFSIZE 1024 #define SS_TIMEOUT 300 -unsigned char cs_mode = 'o'; /* o = Off, f = fridge, b = beer, p = profile-run */ -float cs_beerSet = 20.0; -float cs_fridgeSet = 20.0; -float cs_heatEstimator = 0.2; -float cs_coolEstimator = 5; - unsigned char cc_tempFormat = 'C'; float cc_tempSetMin = 1.0; float cc_tempSetMax = 30.0; @@ -57,11 +51,11 @@ void defaultControlSettings(void) { - cs_mode = 'o'; /* o = Off, f = fridge, b = beer, p = profile-run */ - cs_beerSet = 20.0; - cs_fridgeSet = 20.0; - cs_heatEstimator = 0.2; - cs_coolEstimator = 5; + Config.cs_mode = 'o'; /* o = Off, f = fridge, b = beer, p = profile-run */ + Config.cs_beerSet = 20.0; + Config.cs_fridgeSet = 20.0; + Config.cs_heatEstimator = 0.2; + Config.cs_coolEstimator = 5; } @@ -167,17 +161,17 @@ } srv_send(obuf); } else if (strncmp(buf, "getMode", 7) == 0) { - srv_send("%c", cs_mode); + srv_send("%c", Config.cs_mode); } else if (strncmp(buf, "getFridge", 9) == 0) { - srv_send("%.1f", cs_fridgeSet); + srv_send("%.1f", Config.cs_fridgeSet); } else if (strncmp(buf, "getBeer", 7) == 0) { - srv_send("%.1f", cs_beerSet); + srv_send("%.1f", Config.cs_beerSet); } else if (strncmp(buf, "getControlConstants", 19) == 0) { srv_send("{ \"tempFormat\":\"%c\", \"tempSetMin\":%.1f, \"tempSetMax\":%.1f, \"idleRangeH\":%.3f, \"idleRangeL\":%.3f }", cc_tempFormat, cc_tempSetMin, cc_tempSetMax, cc_idleRangeH, cc_idleRangeL ); } else if (strncmp(buf, "getControlSettings", 18) == 0) { srv_send("{ \"mode\":\"%c\", \"beerSet\":%.1f, \"fridgeSet\":%.1f, \"heatEstimator\":%.1f, \"coolEstimator\":%.1f }", - cs_mode, cs_beerSet, cs_fridgeSet, cs_heatEstimator, cs_coolEstimator); + Config.cs_mode, Config.cs_beerSet, Config.cs_fridgeSet, Config.cs_heatEstimator, Config.cs_coolEstimator); } else if (strncmp(buf, "getControlVariables", 19) == 0) { srv_send("{ \"beerDiff\":%.2f }", cv_beerDiff); } else if (strncmp(buf, "loadDefaultControlSettings", 26) == 0) { @@ -195,8 +189,8 @@ if ((cc_tempSetMin <= newtemp) && (newtemp <= cc_tempSetMax)) { syslog(LOG_NOTICE, "Beer temperature set to %.1f degrees in web interface", newtemp); srv_send("ack"); - cs_mode = 'b'; - cs_beerSet = newtemp; + Config.cs_mode = 'b'; + Config.cs_beerSet = newtemp; } else { syslog(LOG_NOTICE, "Beer temperature setting %.1f is outside of allowed range %.1f - %.1f", newtemp, cc_tempSetMin, cc_tempSetMax); srv_send("err"); @@ -215,8 +209,8 @@ if ((cc_tempSetMin <= newtemp) && (newtemp <= cc_tempSetMax)) { syslog(LOG_NOTICE, "Fridge temperature set to %.1f degrees in web interface", newtemp); srv_send("ack"); - cs_mode = 'f'; - cs_fridgeSet = newtemp; + Config.cs_mode = 'f'; + Config.cs_fridgeSet = newtemp; } else { syslog(LOG_NOTICE, "Fridge temperature setting %.1f is outside of allowed range %.1f - %.1f", newtemp, cc_tempSetMin, cc_tempSetMax); srv_send("err"); @@ -230,7 +224,7 @@ if (debug) fprintf(stdout, "temperature control disabled\n"); syslog(LOG_NOTICE, "Notification: Temperature control disabled"); - cs_mode = 'o'; + Config.cs_mode = 'o'; srv_send("ack"); } else if (strncmp(buf, "setParameters", 13) == 0) { if (debug)