From de16d915a3c87851b25f7c8277acfbbd58f0e685 Mon Sep 17 00:00:00 2001 From: Alex J Lennon Date: Sun, 19 Jul 2026 19:35:12 +0100 Subject: [PATCH] python3-improv: fix missing claim token on Wi-Fi success Pass max_response_bytes=200 when constructing ImprovProtocol on all three board variants. The pyImprov default of 100 is below our Wi-Fi-success redirect URL (~117 B: the active-esl-onboard.active-esl.workers.dev host plus a UUID token), which trips a pyImprov chunking bug in build_rpc_response: it emits a spurious zero-length WIFI_SETTINGS packet *before* the packet that carries the URL. Improv clients that complete on the first (empty) result never see the token, surfacing in the app as "connected to Wi-Fi but did not return a claim token". Raising the threshold returns the URL in a single ~121 B packet, well within the ~185 B BLE MTU the app negotiates, so no split (and no leading empty packet) occurs. The app/CLI also tolerate the empty-then-URL sequence defensively. Co-authored-by: Cursor --- .../imx8mm-jaguar-inst/onboarding-server.py | 9 ++++++++- .../imx93-jaguar-eink/onboarding-server.py | 11 ++++++++++- .../python/python3-improv/onboarding-server.py | 9 ++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/recipes-devtools/python/python3-improv/imx8mm-jaguar-inst/onboarding-server.py b/recipes-devtools/python/python3-improv/imx8mm-jaguar-inst/onboarding-server.py index 7a828f4e..d0ea470b 100644 --- a/recipes-devtools/python/python3-improv/imx8mm-jaguar-inst/onboarding-server.py +++ b/recipes-devtools/python/python3-improv/imx8mm-jaguar-inst/onboarding-server.py @@ -198,7 +198,14 @@ def wifi_connect(ssid: str, passwd: str) -> Optional[list[str]]: server = f"https://{SERVER_HOST}?ip_address={ip_addr}&token={token}" return [server] -improv_server = ImprovProtocol(wifi_connect_callback=wifi_connect) +# Improv chunks its RPC response into <= max_response_bytes packets. The library +# default (100) can be below the Wi-Fi-success redirect URL length (host + UUID +# token), which trips a pyImprov bug: it emits a spurious zero-length +# WIFI_SETTINGS packet *before* the packet carrying the URL. Clients that +# complete on the first result then never see the token. Raise the threshold so +# the URL is returned in a single packet (within the BLE MTU the app negotiates). +improv_server = ImprovProtocol(wifi_connect_callback=wifi_connect, + max_response_bytes=200) def read_request( characteristic: BlessGATTCharacteristic, diff --git a/recipes-devtools/python/python3-improv/imx93-jaguar-eink/onboarding-server.py b/recipes-devtools/python/python3-improv/imx93-jaguar-eink/onboarding-server.py index b93c3467..4a3e26e7 100644 --- a/recipes-devtools/python/python3-improv/imx93-jaguar-eink/onboarding-server.py +++ b/recipes-devtools/python/python3-improv/imx93-jaguar-eink/onboarding-server.py @@ -485,7 +485,16 @@ def wifi_connect(ssid: str, passwd: str) -> Optional[list[str]]: server = f"https://{SERVER_HOST}?ip_address={ip_addr}&token={token}" return [server] -improv_server = ImprovProtocol(wifi_connect_callback=wifi_connect) +# Improv chunks its RPC response into <= max_response_bytes packets. The library +# default (100) is *below* our Wi-Fi-success redirect URL length (~117 B: the +# active-esl-onboard.active-esl.workers.dev host + a UUID token), which trips a +# pyImprov bug: it emits a spurious zero-length WIFI_SETTINGS packet *before* the +# packet carrying the URL. Clients that complete on the first result then never +# see the token ("connected to Wi-Fi but no claim token"). Raise the threshold so +# the URL is returned in a single packet (~121 B, well within the ~185 B BLE MTU +# the app negotiates). +improv_server = ImprovProtocol(wifi_connect_callback=wifi_connect, + max_response_bytes=200) def read_request(characteristic: BlessGATTCharacteristic, **kwargs) -> bytearray: try: diff --git a/recipes-devtools/python/python3-improv/onboarding-server.py b/recipes-devtools/python/python3-improv/onboarding-server.py index 4bf338f2..0552f913 100755 --- a/recipes-devtools/python/python3-improv/onboarding-server.py +++ b/recipes-devtools/python/python3-improv/onboarding-server.py @@ -236,7 +236,14 @@ def wifi_connect(ssid: str, passwd: str) -> Optional[list[str]]: server = f"https://{SERVER_HOST}?ip_address={ip_addr}&token={token}" return [server] -improv_server = ImprovProtocol(wifi_connect_callback=wifi_connect) +# Improv chunks its RPC response into <= max_response_bytes packets. The library +# default (100) can be below the Wi-Fi-success redirect URL length (host + UUID +# token), which trips a pyImprov bug: it emits a spurious zero-length +# WIFI_SETTINGS packet *before* the packet carrying the URL. Clients that +# complete on the first result then never see the token. Raise the threshold so +# the URL is returned in a single packet (within the BLE MTU the app negotiates). +improv_server = ImprovProtocol(wifi_connect_callback=wifi_connect, + max_response_bytes=200) def read_request( characteristic: BlessGATTCharacteristic,