forked from KonkerLabs/libKonkerESP
-
Notifications
You must be signed in to change notification settings - Fork 1
/
upload_fw_info.py
33 lines (27 loc) · 1.03 KB
/
upload_fw_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Import("env")
import time, json
# import platform,subprocess
def storeFWInfo(source, target, env):
content = {"version":"0.0.0", "sequence_number":str(round(time.time() * 1000)), "device":"S000"}
with open("data/firmware_info.json", "w") as cred:
cred.write(json.dumps(content))
# tool = 'esptool' if platform.system().lower()=='windows' else 'esptool.py'
# command = [tool, '--no-stub', '--after', 'soft_reset', 'write_flash', '0xFD000', 'firmware_info.json']
# p = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
#
# if p.returncode != 0:
# print("Error setting platform credential")
# sys.exit()
#
# print("FW information stored")
#
# # Delete temporary generated binary file
# os.remove('firmware_info.json')
# def before_upload(source, target, env):
# print "before_upload"
# do some actions
# def after_upload(source, target, env):
# print "after_upload"
# do some actions
env.AddPreAction("upload", storeFWInfo)
# env.AddPostAction("upload", storeFWInfo)