Skip to content

Commit

Permalink
Add compressed OTA file
Browse files Browse the repository at this point in the history
change acpeted OTA file to bin.gz
  • Loading branch information
softwarecrash committed Apr 7, 2024
1 parent 370c3db commit 78218ab
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ monitor_filters = esp8266_exception_decoder, default, time, printable, colorize
board_build.ldscript = eagle.flash.4m.ld ; 4MB (FS:4MB OTA:~3600KB)
upload_speed = 921600

custom_prog_version = 1.2.0RC1
custom_prog_version = 1.2.0RC3

build_flags =
-DVERSION=${this.custom_prog_version}
-DPIO_SRC_NAM="Victron2MQTT"
-DESP8266 -DATOMIC_FS_UPDATE
extra_scripts = pre:tools/mini_html.py
pre:tools/pre_compile.py
post:tools/post_compile.py
Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ bool sendHaDiscovery()
"{\"ids\":[\"" + mqttClientId + "\"]," +
"\"name\":\"" + _settings.data.deviceName + "\"," +
"\"cu\":\"http://" + WiFi.localIP().toString() + "\"," +
"\"mdl\":\"" + Json["Model_description"].as<String>().c_str() + "\"," +
"\"mdl\":\"" + Json["Device_model"].as<String>().c_str() + "\"," +
"\"mf\":\"SoftWareCrash\"," +
"\"sw\":\"" + SOFTWARE_VERSION + "\"" +
"}";
Expand All @@ -777,7 +777,7 @@ bool sendHaDiscovery()
haPayLoad += (String) "\"unit_of_meas\":\"" + haDescriptor[i][2] + "\",";

if (strcmp(haDescriptor[i][2], "kWh") == 0 || strcmp(haDescriptor[i][2], "Wh") == 0)
haPayLoad += (String) "\"state_class\":\"total_increasing\",";
haPayLoad += (String) "\"state_class\":\"total\",";
if (strcmp(haDescriptor[i][2], "A") == 0 || strcmp(haDescriptor[i][2], "V") == 0 || strcmp(haDescriptor[i][2], "W") == 0)
haPayLoad += (String) "\"state_class\":\"measurement\",";

Expand Down Expand Up @@ -812,7 +812,7 @@ bool sendHaDiscovery()

haPayLoad += haDeviceDescription;
haPayLoad += "}";
sprintf(topBuff, "homeassistant/switch/%s/%s/config", _settings.data.mqttTopic, "Remote_Control"); // build the topic
sprintf(topBuff, "homeassistant/switch/%s/%s/config", _settings.data.deviceName, "Remote_Control"); // build the topic

mqttclient.beginPublish(topBuff, haPayLoad.length(), true);
for (size_t i = 0; i < haPayLoad.length(); i++)
Expand Down
2 changes: 1 addition & 1 deletion src/webpages/HTML_SETTINGS.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h1>Settings</h1>

<form id="uploadform">
<div class="input-group">
<input class="form-control" id="uploadformfield" aria-describedby="uploadformfield" aria-label="Upload" accept=".bin"
<input class="form-control" id="uploadformfield" aria-describedby="uploadformfield" aria-label="Upload" accept=".bin.gz"
type="file" name="update">
<input id="uploadbutton" class="btn btn-outline-secondary" type="button" value="Firmware Update" onclick="postFile()">
</div>
Expand Down
2 changes: 2 additions & 0 deletions tools/post_compile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Import("env")
import os
import shutil
import gzip

def post_program_action(source, target, env):

Expand All @@ -24,5 +25,6 @@ def post_program_action(source, target, env):
# copy the target file to the destination, if it exist
if os.path.exists(targetfile):
shutil.copy(targetfile, destpath)
with open(destpath+'/'+filename, 'rb') as src, gzip.open(destpath+'/'+os.path.splitext(filename)[0]+'_OTA.bin.gz', 'wb') as dst: dst.writelines(src)

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

0 comments on commit 78218ab

Please sign in to comment.