Skip to content

Commit 2e712de

Browse files
committed
Bug fix: Returning error if request failed
1 parent 88bde41 commit 2e712de

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mcumgr-ble/src/main/java/io/runtime/mcumgr/ble/McuMgrBleTransport.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import io.runtime.mcumgr.ble.callback.SmpTransaction;
3939
import io.runtime.mcumgr.ble.util.ResultCondition;
4040
import io.runtime.mcumgr.exception.InsufficientMtuException;
41+
import io.runtime.mcumgr.exception.McuMgrErrorException;
4142
import io.runtime.mcumgr.exception.McuMgrException;
4243
import io.runtime.mcumgr.exception.McuMgrTimeoutException;
4344
import io.runtime.mcumgr.response.McuMgrResponse;
@@ -302,7 +303,6 @@ public <T extends McuMgrResponse> void send(@NonNull final byte[] payload,
302303
mSmpProtocol.send(payload, new SmpTransaction() {
303304
@Override
304305
public void send(@NonNull byte[] data) {
305-
306306
if (mLoggingEnabled) {
307307
try {
308308
log(Log.VERBOSE, "Sending (" + payload.length + " bytes) "
@@ -337,7 +337,11 @@ public void send(@NonNull byte[] data) {
337337
public void onResponse(@NonNull byte[] data) {
338338
try {
339339
T response = McuMgrResponse.buildResponse(McuMgrScheme.BLE, data, responseType);
340-
callback.onResponse(response);
340+
if (response.isSuccess()) {
341+
callback.onResponse(response);
342+
} else {
343+
callback.onError(new McuMgrErrorException(response));
344+
}
341345
} catch (final Exception e) {
342346
callback.onError(new McuMgrException(e));
343347
}

0 commit comments

Comments
 (0)