Skip to content

Commit

Permalink
overall enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
way5 committed Sep 27, 2023
1 parent 4e4029c commit 3b1ba88
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 48 deletions.
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ web_modules/
# Optional npm cache directory
.npm

#KiCAD
schematics/**/*-bak
schematics/**/*-backups
schematics/**/*-cache*
schematics/**/*-bak*
schematics/**/_autosave*
schematics/**/~*
schematics/**/\#auto_saved_files\#

# Custom
datasheet
tmp
Expand All @@ -121,7 +130,5 @@ web/data/**
web/temp
web/assets
web/src/temp
schematics/*backups
schematics/CAM/*backups
genssl.sh
thunder-tests/
Binary file removed schematics/sch_s2_mini_v1.0.0.pdf
Binary file not shown.
3 changes: 1 addition & 2 deletions src/flog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Project: tinyUPS #
# File Created: Monday, 6th June 2022 7:24:53 pm #
# Author: Sergey Ko #
# Last Modified: Monday, 4th September 2023 12:51:42 pm #
# Last Modified: Thursday, 7th September 2023 5:47:49 pm #
# Modified By: Sergey Ko #
# License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.txt) #
#####################################################################################
Expand Down Expand Up @@ -59,7 +59,6 @@ class fLogClass {
/**
* @brief Writes a line with [(timestamp-offset);digit[\n]] pair or just a [val;[\n]]
*
* @todo offset 2023/01/01 11:59:59 PM +0.00 = (1672574399)
* @tparam T
* @param val data to store in log
* @param timestamp if true (default) adding the timestamp
Expand Down
5 changes: 3 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# File: main.cpp #
# File Created: Monday, 22nd May 2023 3:50:32 pm #
# Author: Sergey Ko #
# Last Modified: Tuesday, 5th September 2023 1:22:51 pm #
# Last Modified: Wednesday, 27th September 2023 10:12:41 am #
# Modified By: Sergey Ko #
# License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.txt) #
#####################################################################################
Expand Down Expand Up @@ -255,6 +255,8 @@ void setSTA() {
// made using previously saved credentials.
WiFi.disconnect();
delay(100);
// beacon idle timeout
// esp_wifi_set_inactive_time();
WiFi.mode(WIFI_MODE_STA);
WiFi.setSleep(WIFI_PS_NONE);
#if WIFI_RECONNECT_METHOD == 4
Expand All @@ -270,7 +272,6 @@ void setSTA() {
*/
void setup() {
Serial.begin(SERIAL_BAUD);
delay(1000);

enableLoopWDT();

Expand Down
23 changes: 8 additions & 15 deletions src/ntpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Project: tinyUPS #
# File Created: Monday, 6th June 2022 9:34:40 pm #
# Author: Sergey Ko #
# Last Modified: Monday, 4th September 2023 12:30:24 pm #
# Last Modified: Wednesday, 27th September 2023 10:10:05 am #
# Modified By: Sergey Ko #
# License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.txt) #
#####################################################################################
Expand All @@ -21,7 +21,6 @@
* @return false if QRTC used
*/
status_t NTPClientClass::loop() {
// doing NTP sync
if (WiFi.status() == WL_CONNECTED) {
if (this->_last_update == 0 || (millis() - this->_last_update >= (config.ntpSyncInterval * 1000UL))) {
status_t s = OKAY;
Expand Down Expand Up @@ -53,17 +52,11 @@ status_t NTPClientClass::forceUpdate() {
configTime((config.ntpTimeOffset*3600UL), config.ntpDaylightOffset, config.ntpServer, config.ntpServerFB);
struct tm timeinfo;
uint8_t cntr = 0;
while(true) {
if(!getLocalTime(&timeinfo)) {
__DL("(!) failed to retrieve local time\n");
// ATTN: do not exit here, we need the _startTime to be != 0. Requires testing
} else
break;
cntr++;
if(cntr == 3) {
__DL("(!) giving up...");
break;
}
if(!getLocalTime(&timeinfo)) {
#if DEBUG == 2
__DL("(!) failed to retrieve local time\n");
#endif
return NTP_SYNC_ERR;
}
#if DEBUG == 2
__DF("%s update, tz(%i)\n", config.ntpServer, config.ntpTimeOffset);
Expand Down Expand Up @@ -98,12 +91,12 @@ void NTPClientClass::getDatetime(char *b, const char * format) {
strcpy(b, ds);
_CHBD(ds);
} else {
strcpy(b, "___");
strcpy(b, "_");
}
}

/**
* @brief Formatting current date and time for JSON API
* @brief Current timestamp to character array
*
* @param buffer
*/
Expand Down
47 changes: 22 additions & 25 deletions web/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ $.extend(tinyUPS, {
refreshLogsIntl: 15000,
refreshDashIntl: 12000,
refreshtempChartIntl: 10000,
resetCountdownIntl: 12000,
resetCountdown: 12000,
// charts
charts: {},
intls: {},
Expand Down Expand Up @@ -333,7 +333,7 @@ $.extend(tinyUPS, {
initPage: function () {
// APPLY PAGE CONTENTS
const self = this;
let lhash = location.hash;
let lhash = window.location.hash;
if (lhash !== "") {
// make corresponding objects active
$(".sidebar li.item").each(function (i) {
Expand Down Expand Up @@ -428,7 +428,7 @@ $.extend(tinyUPS, {
this.logsnmp.reload();
// hashchange
$(window).on("hashchange", (e) => {
switch (location.hash) {
switch (window.location.hash) {
case "#home":
this.getDashData();
this.logsys.reload();
Expand All @@ -440,7 +440,7 @@ $.extend(tinyUPS, {
break;
}
});
if (location.hash === "#home" || location.hash === "") this.getDashData();
if (window.location.hash === "#home" || window.location.hash === "") this.getDashData();
window.dispatchEvent(new Event("hashchange"));
// submit config
$("input[name=configsys]").on("click", function (e) {
Expand All @@ -456,19 +456,16 @@ $.extend(tinyUPS, {
self.setSecCfg();
});
// do refresh logs
if (localStorage.getItem("logarf") === "true") {
this.setRefreshLogs(localStorage.getItem("logarf"));
$("#log-aref-tg").attr("checked", true);
} else {
$("#log-aref-tg").removeAttr("checked");
}
$("#log-aref-tg").on("change", function () {
let v = $(this).prop("checked");
self.setRefreshLogs(v);
localStorage.setItem("logarf", v);
});
if (localStorage.getItem("logarf") === "true") {
this.setRefreshLogs(localStorage.getItem("logarf"));
$("#log-aref-tg").attr("checked", true);
} else {
$("#log-aref-tg").removeAttr("checked");
}
// update dashboard every refreshdashintl
this.intls["dd"] = setInterval(function () {
Expand Down Expand Up @@ -528,7 +525,7 @@ $.extend(tinyUPS, {
"//" +
window.location.hostname +
this.toggleCoolingUrl,
// url: "http://local.ims:8888/?test=33",
// url: "http://testURL/?test=33",
dataType: "json",
type: 'POST',
success: (r) => {
Expand All @@ -553,7 +550,7 @@ $.extend(tinyUPS, {
"//" +
window.location.hostname +
this.addAPIkey,
// url: "http://local.ims:8888/?test=36",
// url: "http://testURL/?test=36",
dataType: "json",
type: 'POST',
data: data,
Expand Down Expand Up @@ -626,7 +623,7 @@ $.extend(tinyUPS, {
"//" +
window.location.hostname +
this.delAPIkey,
// url: "http://local.ims:8888/?test=37",
// url: "http://testURL/?test=37",
dataType: "json",
type: 'POST',
data: { id: id },
Expand Down Expand Up @@ -1116,7 +1113,7 @@ $.extend(tinyUPS, {
"//" +
window.location.hostname +
this.infoGraphUrl,
// url: "http://local.ims:8888/?test=5",
// url: "http://testURL/?test=5",
dataType: "json",
type: 'POST',
success: (r) => {
Expand Down Expand Up @@ -1158,7 +1155,7 @@ $.extend(tinyUPS, {
"//" +
window.location.hostname +
this.dataChartUrl,
// url: "http://local.ims:8888/?test=8",
// url: "http://testURL/?test=8",
dataType: "text",
type: 'POST',
success: (r) => {
Expand Down Expand Up @@ -1244,7 +1241,7 @@ $.extend(tinyUPS, {
"//" +
window.location.hostname +
this.tempChartUrl,
// url: "http://local.ims:8888/?test=4",
// url: "http://testURL/?test=4",
dataType: "text",
type: 'POST',
success: (r) => {
Expand Down Expand Up @@ -1362,11 +1359,11 @@ $.extend(tinyUPS, {
});
$(event.currentTarget).addClass("active");
// set location.hash
location.hash = tab;
window.location.hash = tab;
});
// activate menu item by location hash
$("menu.sidebar li.item").each(function (i) {
if (location.hash === $(this).find("a").attr("href")) {
if (window.location.hash === $(this).find("a").attr("href")) {
$(this).addClass("active");
}
});
Expand All @@ -1380,7 +1377,7 @@ $.extend(tinyUPS, {
"//" +
window.location.hostname +
this.resetUrl,
// url: "http://local.ims:8888/?test=35",
// url: "http://testURL/?test=35",
dataType: "json",
type: 'POST',
success: (r) => {
Expand All @@ -1392,7 +1389,7 @@ $.extend(tinyUPS, {
);
} else {
ohSnap($.t("index.js.infoErasingConfig"), this.info);
let countdown = this.resetCountdownIntl / 1000;
let countdown = this.resetCountdown / 1000;
$(countdownEl).html(countdown);
setInterval(() => {
countdown -= 1;
Expand Down Expand Up @@ -1484,7 +1481,7 @@ $.extend(tinyUPS, {
"//" +
window.location.hostname +
this.getDashDataUrl,
// url: "http://local.ims:8888/?test=3",
// url: "http://testURL/?test=3",
dataType: "json",
type: 'POST',
success: (r) => {
Expand Down Expand Up @@ -1512,7 +1509,7 @@ $.extend(tinyUPS, {
"//" +
window.location.hostname +
this.getCfgUrl,
// url: "http://local.ims:8888/?test=7",
// url: "http://testURL/?test=7",
dataType: "json",
type: 'POST',
success: (r) => {
Expand Down Expand Up @@ -1615,9 +1612,9 @@ $.extend(tinyUPS, {
});
},
setSNMPCfg: function () {
let form = $("form[name=confsnmp]");
const form = $("form[name=confsnmp]");
// let formdata = new FormData(form[0]);
let formdata = form.serializeArray();
const formdata = form.serializeArray();
$.ajax({
url:
window.location.protocol +
Expand Down Expand Up @@ -1695,7 +1692,7 @@ class logArea {
"//" +
window.location.hostname +
this.url,
// url: "http://local.ims:8888/?test=6",
// url: "http://testURL/?test=6",
dataType: "text",
type: 'POST',
success: (r) => {
Expand Down
2 changes: 1 addition & 1 deletion web/src/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $.extend(tinyUPS, {
"//" +
window.location.hostname +
this.loginUrl,
// url: "http://local.ims:8888/?test=23",
// url: "http://testURL/?test=23",
dataType: "json",
type: 'POST',
data: formdata,
Expand Down
2 changes: 1 addition & 1 deletion web/src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ $.extend(tinyUPS, {
"//" +
window.location.hostname +
this.setupUrl,
// url: "http://local.ims:8888/?test=22",
// url: "http://testURL/?test=22",
dataType: "json",
type: 'POST',
data: formdata,
Expand Down

0 comments on commit 3b1ba88

Please sign in to comment.