From 8aa540cd419a0a138cc8fbaa7506f663199fe06d Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Tue, 8 Oct 2024 15:54:45 +0200 Subject: [PATCH] Fix: handling "off" param in the response --- .../runtime/mcumgr/managers/SUITManager.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/mcumgr-core/src/main/java/io/runtime/mcumgr/managers/SUITManager.java b/mcumgr-core/src/main/java/io/runtime/mcumgr/managers/SUITManager.java index f535048..350d9ef 100644 --- a/mcumgr-core/src/main/java/io/runtime/mcumgr/managers/SUITManager.java +++ b/mcumgr-core/src/main/java/io/runtime/mcumgr/managers/SUITManager.java @@ -276,7 +276,21 @@ public void beginDeferredInstall(@NotNull McuMgrCallback callbac payloadMap.put("len", 0); payloadMap.put("off", 0); // assuming defer_install is false by default, so not set - send(OP_WRITE, ID_ENVELOPE_UPLOAD, payloadMap, SHORT_TIMEOUT, McuMgrResponse.class, callback); + + // The response contains "off", but we don't need to report it, as it's always 0, + // so convert the response to McuMgrResponse. + send(OP_WRITE, ID_ENVELOPE_UPLOAD, payloadMap, SHORT_TIMEOUT, + McuMgrUploadResponse.class, new McuMgrCallback<>() { + @Override + public void onResponse(@NotNull McuMgrUploadResponse response) { + callback.onResponse(response); + } + + @Override + public void onError(@NotNull McuMgrException error) { + callback.onError(error); + } + }); } /** @@ -293,7 +307,10 @@ public McuMgrResponse beginDeferredInstall() throws McuMgrException { payloadMap.put("len", 0); payloadMap.put("off", 0); // assuming defer_install is false by default, so not set - return send(OP_WRITE, ID_ENVELOPE_UPLOAD, payloadMap, SHORT_TIMEOUT, McuMgrResponse.class); + + // The response contains "off", but we don't need to report it, as it's always 0, + // so convert the response to McuMgrResponse. + return send(OP_WRITE, ID_ENVELOPE_UPLOAD, payloadMap, SHORT_TIMEOUT, McuMgrUploadResponse.class); } /**