aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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):