Bug fix: Passing correct extended error number and message

Before, the Extended Error code (11|REMOTE_MASK) was sent instead, and
the message was UNKNOWN. Now the errorCode will contain the extended
error code and message will already contain the reason of an error.
This commit is contained in:
Aleksander Nowakowski 2017-10-06 17:21:43 +02:00
parent ae9a424a4c
commit cf1da0ff6b
4 changed files with 12 additions and 5 deletions

View File

@ -1568,7 +1568,7 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres
broadcast.putExtra(EXTRA_DATA, error);
broadcast.putExtra(EXTRA_ERROR_TYPE, ERROR_TYPE_DFU_REMOTE);
} else {
broadcast.putExtra(EXTRA_DATA, error);
broadcast.putExtra(EXTRA_DATA, error & ~ERROR_REMOTE_MASK);
broadcast.putExtra(EXTRA_ERROR_TYPE, ERROR_TYPE_OTHER);
}
broadcast.putExtra(EXTRA_DEVICE_ADDRESS, mDeviceAddress);

View File

@ -230,10 +230,13 @@ import no.nordicsemi.android.error.SecureDfuError;
// For the Extended Error more details can be obtained on some devices.
if (e instanceof RemoteDfuExtendedErrorException) {
final RemoteDfuExtendedErrorException ee = (RemoteDfuExtendedErrorException) e;
logi("Extended Error details: " + SecureDfuError.parseExtendedError(ee.getExtendedErrorNumber()));
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_ERROR, "Details: " + SecureDfuError.parseExtendedError(ee.getExtendedErrorNumber()) + " (Code = " + ee.getExtendedErrorNumber() + ")");
final int extendedError = ee.getExtendedErrorNumber();
logi("Extended Error details: " + SecureDfuError.parseExtendedError(extendedError));
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_ERROR, "Details: " + SecureDfuError.parseExtendedError(extendedError) + " (Code = " + extendedError + ")");
mService.terminateConnection(gatt, extendedError & DfuBaseService.ERROR_REMOTE_MASK);
} else {
mService.terminateConnection(gatt, error);
}
mService.terminateConnection(gatt, error);
}
}

View File

@ -44,6 +44,6 @@ public class RemoteDfuExtendedErrorException extends RemoteDfuException {
@Override
public String getMessage() {
return super.getMessage() + " (error 11." + mError + ")";
return super.getMessage() + " (error " + SecureDfuError.EXTENDED_ERROR + "." + mError + ")";
}
}

View File

@ -104,6 +104,10 @@ public class GattError {
return "GATT UNSUPPORT GRP TYPE";
case 0x0011:
return "GATT INSUF RESOURCE";
case 0x0022:
return "GATT CONN LMP TIMEOUT";
case 0x003A:
return "GATT CONTROLLER BUSY";
case 0x0087:
return "GATT ILLEGAL PARAMETER";
case 0x0080: