Files
IoTManager/PrepareServer.py
biver 08116d84c7 Добавляем скрипт PrepareServer.py для подготовки обновления "по воздуху"
Компилируется прошивка и файловая система. Рекомендуется предварительно подготовить проект с помощью PrepareProject.py
Автоматически создается папка iotm с бинарными файлами и структурой достаточной для обновления "по воздуху".
Временно предлагается воспользоваться версий 999, но после прошивки будет установлена та, которой соответствует сборка.
Для запуска веб-сервера можно использовать расширение vscode: Live Server.
2023-02-15 00:20:08 +03:00

43 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# подготавливаем папку для локального сервера обновлений
# для этого компилируем проект и получаем бинарные файлы:
# firmware.bin, littlefs.bin и ver.json
import shutil
import configparser
import os, json, sys, getopt
from pathlib import Path
config = configparser.ConfigParser() # создаём объекта парсера INI
config.read("platformio.ini")
deviceName = config["platformio"]["default_envs"]
homeDir = os.path.expanduser('~')
os.system(homeDir + "\.platformio\penv\Scripts\pio run")
os.system(homeDir + "\.platformio\penv\Scripts\pio run -t buildfs")
firmwareSrcPath = ".pio/build/" + deviceName + "/firmware.bin"
littlefsSrcPath = ".pio/build/" + deviceName + "/littlefs.bin"
if Path(firmwareSrcPath).is_file():
print("Ok...... \"" + firmwareSrcPath + "\" Exist!")
firmwareDstPath = "iotm/" + deviceName + "/999/firmware.bin"
Path(firmwareDstPath).parent.mkdir(parents=True, exist_ok=True)
shutil.copy(firmwareSrcPath, firmwareDstPath)
if Path(littlefsSrcPath).is_file():
print("Ok...... \"" + littlefsSrcPath + "\" Exist!")
littlefsDstPath = "iotm/" + deviceName + "/999/littlefs.bin"
Path(littlefsDstPath).parent.mkdir(parents=True, exist_ok=True)
shutil.copy(littlefsSrcPath, littlefsDstPath)
versionsJson = json.loads('{"' + deviceName + '": {"0": "999"}}')
with open("iotm/ver.json", "w", encoding='utf-8') as write_file:
json.dump(versionsJson, write_file, ensure_ascii=False, indent=4, sort_keys=False)
print(f"\x1b[1;31;42m Сервер для обновления 'по воздуху' для " + deviceName + " подготовлен. Не забудьте установить расширение Live Server, запустить его и прописать в ESP IP вашего компьютера. Подробнее смотрите в WIKI: https://iotmanager.org/wiki.\x1b[0m")
else:
print("Error...... \"" + littlefsSrcPath + "\" Not exist!")
else:
print("Error...... \"" + firmwareSrcPath + "\" Not exist!")