Skip to content

Commit

Permalink
Fix: handling "off" param in the response
Browse files Browse the repository at this point in the history
  • Loading branch information
philips77 committed Oct 8, 2024
1 parent 66685ee commit 8aa540c
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,21 @@ public void beginDeferredInstall(@NotNull McuMgrCallback<McuMgrResponse> 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);
}
});
}

/**
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 8aa540c

Please sign in to comment.