Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
0.5.6
Browse files Browse the repository at this point in the history
- Added temperature offset to normalize the ESP temperature.
    Before the first launch (or upgrade to this version), keep the board without the case at room temperature for 5 minutes for the desired effect.

- As requested by @mercenaruss changed the default serial port from 4444 to 6638 (only applicable to new install)

0.5.5

- Added Zeroconf for ZHA discovery
  • Loading branch information
xyzroe committed Oct 14, 2021
1 parent 09e4963 commit 9749617
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: https://www.buymeacoffee.com/xyzroe
4 changes: 2 additions & 2 deletions src/Version.h
Original file line number Diff line number Diff line change
@@ -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

1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ struct ConfigSettingsStruct
bool mqttDiscovery;
unsigned long mqttReconnectTime;
unsigned long mqttHeartbeatTime;
int tempOffset;
};

struct InfosStruct
Expand Down
18 changes: 18 additions & 0 deletions src/etc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/etc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/html.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ const char HTTP_SERIAL[] PROGMEM =
const char HTTP_HELP[] PROGMEM =
"<h2>Help</h2>"
"<div id='main' class='col-sm-9'>"
/*
"<div id='help_btns'>"
"<a href='#' class='btn btn-primary'><i class='glyphicon glyphicon-cog'></i>Primary</a>"
"<a href='#' class='btn btn-secondary'><i class='glyphicon glyphicon-file'></i>Secondary</a>"
"<a href='#' class='btn btn-success'><i class='glyphicon glyphicon-flag'></i>Success</a>"
"<a href='#' class='btn btn-danger'><i class='glyphicon glyphicon-lock'></i>Danger</a>"
"<a href='#' class='btn btn-warning'><i class='glyphicon glyphicon-tags'></i>Warning</a>"
"</div>"
*/
"<script src='https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-loader.min.js'></script>"
"<script type='module' src='https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js'></script>"
"<zero-md src='https://raw.githubusercontent.com/xyzroe/ZigStarGW-FW/main/README.md'></zero-md>"
Expand Down
31 changes: 26 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion tools/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.5
0.5.6

0 comments on commit 9749617

Please sign in to comment.