eculocate

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 1d03cfdd39c17de3c009320b2a4ecf678e8202dc
parent 25fffe6ae7525c139d1534e31c93967aa8350513
Author: Daniel Barlow <dan@telent.net>
Date:   Tue, 20 Jan 2026 23:38:49 +0000

convert otaclient to python

it seems easier than packaging the ruby ed25519 gem in nix

Diffstat:
MMakefile | 2+-
Aotaclient.py | 33+++++++++++++++++++++++++++++++++
Mshell.nix | 7+++++--
3 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -11,7 +11,7 @@ ota.bin: $(IMAGE) espflash save-image --chip esp32c3 $< $@ install: ota.bin - time ruby otaclient.rb $< + time python otaclient.py $< privkey.pem: openssl genpkey -algorithm ed25519 -out privkey.pem diff --git a/otaclient.py b/otaclient.py @@ -0,0 +1,33 @@ +import socket +import struct +import sys + +sock = socket.create_connection(("eculocate.local", 5000)) + +with open(sys.argv[1], "rb") as f: + rom_image = f.read() + +image_len = len(rom_image) + +# Build payload +payload = ( + b"ROM0" + + (b"z" * 64) + + struct.pack(">L", image_len) + + rom_image +) + +# Send payload +sock.sendall(payload) + +# Read a line from the socket (until newline) +response = b"" +while not response.endswith(b"\n"): + chunk = sock.recv(1) + if not chunk: + break + response += chunk + +print(response.decode(errors="replace")) + +sock.close() diff --git a/shell.nix b/shell.nix @@ -4,7 +4,10 @@ libPath = with pkgs; lib.makeLibraryPath [ # load external libraries that you need in your rust project here ]; -in + python = (pkgs.python3.withPackages (python-pkgs: [ + python-pkgs.ed25519 + ])); + in pkgs.mkShell rec { buildInputs = with pkgs; [ clang @@ -13,7 +16,7 @@ in rustup entr - ruby + python openssl ]; RUSTC_VERSION = overrides.toolchain.channel;