diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..9438ada --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: https://www.buymeacoffee.com/xyzroe diff --git a/src/Version.h b/src/Version.h index c26ee3b..de17329 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1,9 +1,9 @@ // AUTO GENERATED FILE, DO NOT EDIT #ifndef VERSION - #define VERSION "0.5.5" + #define VERSION "0.5.6" #endif #ifndef BUILD_TIMESTAMP - #define BUILD_TIMESTAMP "2021-09-29 23:40:29.613671" + #define BUILD_TIMESTAMP "2021-10-07 16:36:33.921221" #endif \ No newline at end of file diff --git a/src/config.h b/src/config.h index 3abfa81..e569abf 100644 --- a/src/config.h +++ b/src/config.h @@ -102,6 +102,7 @@ struct ConfigSettingsStruct bool mqttDiscovery; unsigned long mqttReconnectTime; unsigned long mqttHeartbeatTime; + int tempOffset; }; struct InfosStruct diff --git a/src/etc.cpp b/src/etc.cpp index 9859b23..fc69b7f 100644 --- a/src/etc.cpp +++ b/src/etc.cpp @@ -51,6 +51,24 @@ void getReadableTime(String &readableTime, unsigned long beginTime) } void getCPUtemp(String &CPUtemp) +{ + if (!ConfigSettings.enableWiFi && !ConfigSettings.emergencyWifi) + { + //DEBUG_PRINTLN(F("enable wifi to enable temp sensor ")); + WiFi.mode(WIFI_STA); + } + CPUtemp = (temprature_sens_read() - 32) / 1.8 - ConfigSettings.tempOffset; + //DEBUG_PRINT(F("CPU temp ")); + //DEBUG_PRINTLN(CPUtemp); + if (!ConfigSettings.enableWiFi && !ConfigSettings.emergencyWifi) + { + WiFi.disconnect(); + WiFi.mode(WIFI_OFF); + //DEBUG_PRINTLN(F("disable wifi")); + } +} + +void getBlankCPUtemp(String &CPUtemp) { if (!ConfigSettings.enableWiFi && !ConfigSettings.emergencyWifi) { diff --git a/src/etc.h b/src/etc.h index 5d4f45b..aaa9587 100644 --- a/src/etc.h +++ b/src/etc.h @@ -10,7 +10,7 @@ uint8_t temprature_sens_read(); uint8_t temprature_sens_read(); void getCPUtemp(String &CPUtemp); - +void getBlankCPUtemp(String &CPUtemp); //void parse_ip_address(IPAddress &ip, const char *str) void zigbeeEnableBSL(); void zigbeeRestart(); diff --git a/src/html.h b/src/html.h index 8562d1e..a93e14e 100644 --- a/src/html.h +++ b/src/html.h @@ -116,6 +116,7 @@ const char HTTP_SERIAL[] PROGMEM = const char HTTP_HELP[] PROGMEM = "

Help

" "
" + /* "
" "Primary" "Secondary" @@ -123,6 +124,7 @@ const char HTTP_HELP[] PROGMEM = "Danger" "Warning" "
" + */ "" "" "" diff --git a/src/main.cpp b/src/main.cpp index 899879e..00e7659 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -161,7 +161,12 @@ bool loadSystemVar() { DEBUG_PRINTLN(F("failed open. try to write defaults")); - String StringConfig = "{\"board\":1,\"emergencyWifi\":0}"; + String CPUtemp; + getBlankCPUtemp(CPUtemp); + int correct = CPUtemp.toInt() - 30; + String tempOffset = String(correct); + + String StringConfig = "{\"board\":1,\"emergencyWifi\":0,\"tempOffset\":" + tempOffset + "}"; DEBUG_PRINTLN(StringConfig); DynamicJsonDocument doc(1024); deserializeJson(doc, StringConfig); @@ -184,7 +189,23 @@ bool loadSystemVar() ConfigSettings.board = (int)doc["board"]; ConfigSettings.emergencyWifi = (int)doc["emergencyWifi"]; + ConfigSettings.tempOffset = (int)doc["tempOffset"]; + if (!ConfigSettings.tempOffset){ + DEBUG_PRINTLN(F("no tempOffset in system.json")); + configFile.close(); + String CPUtemp; + getBlankCPUtemp(CPUtemp); + int correct = CPUtemp.toInt() - 30; + String tempOffset = String(correct); + doc["tempOffset"] = int(tempOffset.toInt()); + + configFile = LITTLEFS.open(path, FILE_WRITE); + serializeJson(doc, configFile); + configFile.close(); + DEBUG_PRINTLN(F("saved tempOffset in system.json")); + ConfigSettings.tempOffset = int(tempOffset.toInt()); + } configFile.close(); return true; } @@ -310,7 +331,7 @@ bool loadConfigSerial() File configFile = LITTLEFS.open(path, FILE_READ); if (!configFile) { - String StringConfig = "{\"baud\":115200,\"port\":4444}"; + String StringConfig = "{\"baud\":115200,\"port\":6638}"; writeDefultConfig(path, StringConfig); } @@ -394,14 +415,14 @@ void setupWifiAP() for (int i = 0; i < AP_NameString.length(); i++) AP_NameChar[i] = AP_NameString.charAt(i); - +/* String WIFIPASSSTR = "ZigStar1"; char WIFIPASS[WIFIPASSSTR.length() + 1]; memset(WIFIPASS, 0, WIFIPASSSTR.length() + 1); for (int i = 0; i < WIFIPASSSTR.length(); i++) WIFIPASS[i] = WIFIPASSSTR.charAt(i); - - WiFi.softAP(AP_NameChar, WIFIPASS); +*/ + WiFi.softAP(AP_NameChar); //, WIFIPASS); WiFi.setSleep(false); } diff --git a/tools/version b/tools/version index 389facc..ad83b1b 100644 --- a/tools/version +++ b/tools/version @@ -1 +1 @@ -0.5.5 \ No newline at end of file +0.5.6 \ No newline at end of file