diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-16 13:18:43 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-16 13:18:43 +0100 |
| commit | ff52144a55d994c642930df3378bcdb7f299e98f (patch) | |
| tree | 44a39596a0d3564a43afc944552864f05493bd92 | |
| parent | 76a47932467f8e0640e63ee431b23407c09dbb45 (diff) | |
| download | agent-lamp-ff52144a55d994c642930df3378bcdb7f299e98f.tar.gz agent-lamp-ff52144a55d994c642930df3378bcdb7f299e98f.zip | |
fix: a 4.xx/5.xx CoAP response is a failure
coap-client exits 0 on an error response and prints the code on stderr,
so show() marked rejected requests as shown and never retried them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rwxr-xr-x | agent-lamp | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -138,11 +138,15 @@ def coap(method, url, ident, key, payload=None): if payload is not None: cmd += ["-e", json.dumps(payload, separators=(",", ":"))] try: - out = subprocess.run(cmd + [url], capture_output=True, text=True, - timeout=TIMEOUT + 2, check=True).stdout + done = subprocess.run(cmd + [url], capture_output=True, text=True, + timeout=TIMEOUT + 2) except (subprocess.SubprocessError, OSError): return None - return out.strip() + # coap-client exits 0 on a 4.xx/5.xx response and prints the code on + # stderr only (verified against the gateway: "4.04 Not Found"). + if done.returncode or done.stderr.lstrip()[:2] in ("4.", "5."): + return None + return done.stdout.strip() def put(url, auth, state): |
