Skip to content

Commit

Permalink
OTA, improvements and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
way5 committed Jan 9, 2024
1 parent 3b1ba88 commit 5712701
Show file tree
Hide file tree
Showing 40 changed files with 1,711 additions and 940 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,6 @@ web/temp
web/assets
web/src/temp
genssl.sh
thunder-tests/
thunder-tests/
*.bin
*.bin.gz
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ The project requires an advanced skills in electronics. It's not a plug-n-play d
- [**+ DEVELOPMENT**](#-development)
- [- DRIVERS](#--drivers)
- [- DEBUG](#--debug)
- [**+ CHANGELOG**](#-changelog)
- [**+ PHOTOS**](#-photos)
- [**+ CREDITS**](#-credits)

Expand Down Expand Up @@ -203,6 +204,14 @@ Serial monitor is used to perform the most of the tasks and to solve issues. Onc
![tinyUPS serial monitor](doc/i4.jpg)
## **+ CHANGELOG**<a id="changelog"></a>
- **fw:1.3.0 / ui:1.2.0**
1. firmware and filesystem now upgradable Over the Air
2. overal improvements on UI
3. firmware stability improvements (memory leaks, code structure, etc)
## **+ PHOTOS**<a id="photos"></a>
| ![tinyUPS PCB](./doc/e0.jpg) | ![thermistor](./doc/e1.jpg) | ![PCB](./doc/e2.jpg) | ![UPS LCD](./doc/e4.jpg) | ![UPS exterior](./doc/e5.jpg) |
Expand Down
2 changes: 1 addition & 1 deletion configure.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"ups_rated_battery_amps_max": 9,
"wifi_reconnect_method": 2
},
"version": "1.2.2"
"version": "1.3.0"
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tinyups",
"version": "1.1.3",
"version": "1.2.0",
"author": "Sergey Ko",
"license": "GPLv3",
"private": true,
Expand Down Expand Up @@ -49,7 +49,7 @@
"chartjs-adapter-luxon": "^1.3.1",
"chartjs-chart-bubblematrix": "^0.0.3",
"chartjs-plugin-zoom": "^2.0.1",
"crypto-js": "^4.1.1",
"crypto-js": "^4.2.0",
"date-fns": "^2.30.0",
"flowbite": "^1.4.7",
"flowbite-datepicker": "^1.2.2",
Expand All @@ -60,4 +60,4 @@
"luxon": "^3.3.0",
"ohsnap-tailwind": "way5/ohsnap-tailwind"
}
}
}
12 changes: 7 additions & 5 deletions partitions.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# ESP-IDF Partition Table
# ESP32 Partitions: https://github.com/espressif/arduino-esp32/blob/master/docs/source/tutorials/partition_table.rst#partition-table
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x7000,
factory, app, factory, 0x10000, 0x26A000,
storage, data, fat, 0x27A000, 0x16E000,
# ESP32 Partitions: https://github.com/espressif/arduino-esp32/blob/master/docs/source/tutorials/partition_table.rst#partition-table
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xE000, 0x2000,
app0, app, ota_0, 0x10000, 0x150000,
app1, app, ota_1, 0x160000, 0x150000,
storage, data, fat, 0x2B0000, 0x138000,
3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ description = tinyUPS is the Control and Management Tool with SNMP Server for yo
[env]
framework = arduino
extra_scripts =
pre:scripts/prebuild.py
pre:scripts/pre.py
post:scripts/post.py
build_flags =
-D SERIAL_BAUD=115200UL
-D DEBUG_ESP_PORT=Serial
Expand Down
33 changes: 33 additions & 0 deletions scripts/post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Import("env")
import os
import shutil

root = os.getcwd()

def before_buildfs(source, target, env):
env.Execute("yarn build:prod")

env.AddPreAction("$BUILD_DIR/fatfs.bin", before_buildfs)

def after_buildfs(source, target, env):
## source is web/data directory
path = target[0].get_abspath()
shutil.copyfile(path, root + "/filesystem.bin")

env.AddPostAction("$BUILD_DIR/fatfs.bin", after_buildfs)

def after_build(source, target, env):
# print(source[0].get_path())
path = source[0].get_abspath()
# print(path)
shutil.copyfile(os.path.splitext(path)[0] + ".bin", root + "/firmware.bin")

env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", after_build)

def after_cleanup(source, target, env):
print("Clean up root directory...")
os.remove(root + "/filesystem.bin")
os.remove(root + "/firmware.bin")

env.AddPostAction("clean", after_cleanup)
env.AddPostAction("fullclean", after_cleanup)
6 changes: 4 additions & 2 deletions scripts/prebuild.py → scripts/pre.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@

env.Append(CPPDEFINES=defs)

print("FIRMWARE VERSION: ", conf['version'])
print("WEB UI VERSION: ", pkg['version'])
print("\n•----------------------------•")
print(" FIRMWARE VERSION:", conf['version'])
print(" WEB UI VERSION: ", pkg['version'])
print("•----------------------------•\n")
57 changes: 29 additions & 28 deletions src/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Project: tinyUPS #
# File Created: Thursday, 19th May 2022 2:36:45 am #
# Author: Sergey Ko #
# Last Modified: Monday, 4th September 2023 10:13:57 pm #
# Last Modified: Tuesday, 9th January 2024 2:25:40 pm #
# Modified By: Sergey Ko #
# License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.txt) #
#####################################################################################
Expand All @@ -30,7 +30,7 @@
#include <WiFi.h>
#include <sys/param.h>

// #define DEBUG 6
// #define DEBUG 2
#define _STRING(x) #x
#define STRING(x) _STRING(x)
#define VERSION_UI STRING(VERSION_WEBUI)
Expand All @@ -46,41 +46,41 @@ typedef enum
NTP_SYNC_ERR = -2,
} status_t;

#define _CHB(b, s) \
do \
{ \
b = new char[s]; \
memset(b, '\0', s); \
#define _CHB(b, s) \
do \
{ \
b = new char[s]; \
memset(b, '\0', s); \
} while (0)

#define _CHBC(b) \
do \
{ \
memset(b, '\0', strlen(b)); \
#define _CHBC(b) \
do \
{ \
memset(b, '\0', strlen(b)); \
} while (0)

#define _CHBD(b) \
do \
{ \
delete[] b; \
b = NULL; \
#define _CHBD(b) \
do \
{ \
delete[] b; \
b = NULL; \
} while (0)

#if defined(DEBUG_ESP_PORT)
#define __DF(F, ...) \
do \
{ \
DEBUG_ESP_PORT.printf(F, ##__VA_ARGS__); \
#define __DF(F, ...) \
do \
{ \
DEBUG_ESP_PORT.printf(F, ##__VA_ARGS__); \
} while (0)
#define __DL(F) \
do \
{ \
DEBUG_ESP_PORT.println(F); \
#define __DL(F) \
do \
{ \
DEBUG_ESP_PORT.println(F); \
} while (0)
#define __D(F) \
do \
{ \
DEBUG_ESP_PORT.print(F); \
#define __D(F) \
do \
{ \
DEBUG_ESP_PORT.print(F); \
} while (0)
#else
#define __DF(F...) (void)0
Expand Down Expand Up @@ -156,6 +156,7 @@ typedef struct
bool isActiveSnmpAgent = false;
bool isActiveHttpd = false;
bool isActiveMonitor = false;
bool updateInProgress = false;
} common_event_t;
volatile extern common_event_t systemEvent;

Expand Down
Loading

0 comments on commit 5712701

Please sign in to comment.