refactor: move the v2 controller to the repository root
The ESP-IDF project, docs, tools, tests and web UI move from v2/ to the root, and the Makefile, README, build scripts and test runner drop the v2/ prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
71bd320661
commit
1c222771a5
66 files changed
+30
-31
No files matched your search
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Upload the firmware (which includes the web UI) to the controller over Ethernet.
|
||||
|
||||
ota.py <host> [firmware.bin]
|
||||
|
||||
Default is build/led_controller.bin next to this script. The board reboots into the new image.
|
||||
"""
|
||||
import http.client
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
host = sys.argv[1] if len(sys.argv) > 1 else sys.exit(__doc__)
|
||||
build = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "build")
|
||||
fw = sys.argv[2] if len(sys.argv) > 2 else os.path.join(build, "led_controller.bin")
|
||||
|
||||
|
||||
def info():
|
||||
try:
|
||||
c = http.client.HTTPConnection(host, 80, timeout=5)
|
||||
c.request("GET", "/ota")
|
||||
r = c.getresponse()
|
||||
return json.loads(r.read().decode()) if r.status == 200 else None
|
||||
except (OSError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def upload(path, url):
|
||||
size = os.path.getsize(path)
|
||||
print(f"uploading {path} ({size} bytes) to {url}")
|
||||
c = http.client.HTTPConnection(host, 80, timeout=120)
|
||||
with open(path, "rb") as f:
|
||||
c.request("POST", url, body=f, headers={"Content-Length": str(size),
|
||||
"Content-Type": "application/octet-stream"})
|
||||
r = c.getresponse()
|
||||
body = r.read().decode()
|
||||
print(r.status, body)
|
||||
if r.status != 200:
|
||||
sys.exit(1)
|
||||
time.sleep(3)
|
||||
for _ in range(30):
|
||||
i = info()
|
||||
if i:
|
||||
print("back up on", i["partition"])
|
||||
return
|
||||
time.sleep(1)
|
||||
sys.exit("controller did not come back within 30 s")
|
||||
|
||||
|
||||
before = info()
|
||||
print("running:", before)
|
||||
if before is None:
|
||||
sys.exit("no OTA endpoint (is this the LED controller?)")
|
||||
upload(fw, "/ota")
|
||||
Reference in new issue
Block a user