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,