diff --git a/ESP32_AP-Flasher/src/contentmanager.cpp b/ESP32_AP-Flasher/src/contentmanager.cpp index 3ca772bf..4868694d 100644 --- a/ESP32_AP-Flasher/src/contentmanager.cpp +++ b/ESP32_AP-Flasher/src/contentmanager.cpp @@ -1364,7 +1364,7 @@ int getJsonTemplateUrl(String &filename, String URL, time_t fetched, String MAC, void drawJsonStream(Stream &stream, String &filename, tagRecord *&taginfo, imgParam &imageParams) { TFT_eSprite spr = TFT_eSprite(&tft); initSprite(spr, imageParams.width, imageParams.height, imageParams); - DynamicJsonDocument doc(300); + DynamicJsonDocument doc(500); if (stream.find("[")) { do { DeserializationError error = deserializeJson(doc, stream); diff --git a/ESP32_AP-Flasher/src/flasher.cpp b/ESP32_AP-Flasher/src/flasher.cpp index 6c88c5d4..39256e90 100644 --- a/ESP32_AP-Flasher/src/flasher.cpp +++ b/ESP32_AP-Flasher/src/flasher.cpp @@ -443,7 +443,7 @@ bool flasher::writeFlashFromPackOffset(fs::File *file, uint16_t length) { } bool flasher::writeFlashFromPack(String filename, uint8_t type) { - StaticJsonDocument<512> doc; + DynamicJsonDocument doc(1024); fs::File readfile = contentFS->open(filename, "r"); DeserializationError err = deserializeJson(doc, readfile); if (!err) { @@ -466,6 +466,7 @@ bool flasher::writeFlashFromPack(String filename, uint8_t type) { } Serial.print("Failed to find this tag's type in the FW pack database.\n"); } else { + Serial.println(err.c_str()); Serial.print("Failed to read json header from FW pack\n"); } readfile.close(); diff --git a/binaries/Tag/Tag_FW_Pack.bin b/binaries/Tag/Tag_FW_Pack.bin new file mode 100644 index 00000000..18288080 Binary files /dev/null and b/binaries/Tag/Tag_FW_Pack.bin differ diff --git a/zbs243_Tag_FW/packagebinaries.php b/zbs243_Tag_FW/packagebinaries.php index eeef4c04..4074ee86 100644 --- a/zbs243_Tag_FW/packagebinaries.php +++ b/zbs243_Tag_FW/packagebinaries.php @@ -1,12 +1,12 @@ , sorry...\n"); + if($type!=-1)echo("Adding filetype <$file>\n"); $binary = file_get_contents($binpath.$file); $length = strlen($binary); $offset = strlen($output); diff --git a/zbs243_Tag_FW/packagebinaries.py b/zbs243_Tag_FW/packagebinaries.py new file mode 100644 index 00000000..12ebf9cf --- /dev/null +++ b/zbs243_Tag_FW/packagebinaries.py @@ -0,0 +1,58 @@ +import os +import json + +version = "0022" # You can set your desired version here. + +types = { + 0x00: "SOLUM_154_SSD1619-tag-00-" + version + ".bin", + 0x01: "SOLUM_29_SSD1619-tag-01-" + version + ".bin", + 0xF0: "Tag_FW_Segmented_UK.bin", + 0x02: "SOLUM_42_SSD1619-tag-02-" + version + ".bin", + 0x11: "SOLUM_29_UC8151-tag-11-" + version + ".bin", +} + +binpath = "../binaries/Tag" +tocmaxsize = 512 + +toc = [] +output = b'\0' * tocmaxsize # Initialize as bytes + +binaries = [file for file in os.listdir(binpath) if 'Pack' not in file and version in file] +for file in binaries: + file = file.strip() + type = -1 + for typeid, typefile in types.items(): + if typefile == file: + type = typeid + if type != -1: + print("Adding filetype <{}>".format(file)) + with open(os.path.join(binpath, file), 'rb') as binary_file: + binary = binary_file.read() + length = len(binary) + offset = len(output) + subarr = { + 'type': type, + 'version': version, + 'name': file, + 'offset': offset, + 'length': length, + } + toc.append(subarr) + output += binary + +jtoc = json.dumps(toc) +jtoc = jtoc.replace("'", '"') +tocsize = len(jtoc) +if tocsize > tocmaxsize: + raise ValueError("TOC is too big! (" + str(tocsize) + "). Adjust size and try again") + +# Encode jtoc as bytes +jtoc = jtoc.encode('utf-8') + +# Concatenate bytes and write to the file +output = jtoc + output[len(jtoc):] +with open(os.path.join(binpath, "Tag_FW_Pack.bin"), 'wb') as output_file: + output_file.write(output) + +print(toc) +print("All done.")