aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-16 13:18:43 +0100
committerDanilo M. <danix@danix.xyz>2026-11-16 13:18:43 +0100
commitff52144a55d994c642930df3378bcdb7f299e98f (patch)
tree44a39596a0d3564a43afc944552864f05493bd92
parent76a47932467f8e0640e63ee431b23407c09dbb45 (diff)
downloadagent-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-xagent-lamp10
1 files changed, 7 insertions, 3 deletions
diff --git a/agent-lamp b/agent-lamp
index 6c0791a..1ff34c5 100755
--- a/agent-lamp
+++ b/agent-lamp
@@ -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):