#129 fixed: improved characteristic validation

This commit is contained in:
Aleksander Nowakowski 2018-10-16 15:44:39 +02:00
parent 92fd8d647c
commit 31bf36350a
6 changed files with 28 additions and 12 deletions

View File

@ -60,8 +60,11 @@ import no.nordicsemi.android.dfu.internal.exception.UploadAbortedException;
final BluetoothGattService dfuService = gatt.getService(BUTTONLESS_DFU_SERVICE_UUID);
if (dfuService == null)
return false;
mButtonlessDfuCharacteristic = dfuService.getCharacteristic(BUTTONLESS_DFU_UUID);
return mButtonlessDfuCharacteristic != null;
final BluetoothGattCharacteristic characteristic = dfuService.getCharacteristic(BUTTONLESS_DFU_UUID);
if (characteristic == null || characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG) == null)
return false;
mButtonlessDfuCharacteristic = characteristic;
return true;
}
@Override

View File

@ -69,8 +69,11 @@ import no.nordicsemi.android.dfu.internal.exception.UploadAbortedException;
final BluetoothGattService dfuService = gatt.getService(BUTTONLESS_DFU_SERVICE_UUID);
if (dfuService == null)
return false;
mButtonlessDfuCharacteristic = dfuService.getCharacteristic(BUTTONLESS_DFU_UUID);
return mButtonlessDfuCharacteristic != null;
final BluetoothGattCharacteristic characteristic = dfuService.getCharacteristic(BUTTONLESS_DFU_UUID);
if (characteristic == null || characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG) == null)
return false;
mButtonlessDfuCharacteristic = characteristic;
return true;
}
@Override

View File

@ -59,8 +59,11 @@ import no.nordicsemi.android.dfu.internal.exception.UploadAbortedException;
final BluetoothGattService dfuService = gatt.getService(EXPERIMENTAL_BUTTONLESS_DFU_SERVICE_UUID);
if (dfuService == null)
return false;
mButtonlessDfuCharacteristic = dfuService.getCharacteristic(EXPERIMENTAL_BUTTONLESS_DFU_UUID);
return mButtonlessDfuCharacteristic != null;
final BluetoothGattCharacteristic characteristic = dfuService.getCharacteristic(EXPERIMENTAL_BUTTONLESS_DFU_UUID);
if (characteristic == null || characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG) == null)
return false;
mButtonlessDfuCharacteristic = characteristic;
return true;
}
@Override

View File

@ -58,9 +58,10 @@ import no.nordicsemi.android.dfu.internal.exception.UploadAbortedException;
final BluetoothGattService dfuService = gatt.getService(DFU_SERVICE_UUID);
if (dfuService == null)
return false;
mControlPointCharacteristic = dfuService.getCharacteristic(DFU_CONTROL_POINT_UUID);
if (mControlPointCharacteristic == null)
final BluetoothGattCharacteristic characteristic = dfuService.getCharacteristic(DFU_CONTROL_POINT_UUID);
if (characteristic == null || characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG) == null)
return false;
mControlPointCharacteristic = characteristic;
mProgressInfo.setProgress(DfuBaseService.PROGRESS_STARTING);

View File

@ -132,9 +132,12 @@ import no.nordicsemi.android.error.LegacyDfuError;
final BluetoothGattService dfuService = gatt.getService(DFU_SERVICE_UUID);
if (dfuService == null)
return false;
mControlPointCharacteristic = dfuService.getCharacteristic(DFU_CONTROL_POINT_UUID);
final BluetoothGattCharacteristic characteristic = dfuService.getCharacteristic(DFU_CONTROL_POINT_UUID);
if (characteristic == null || characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG) == null)
return false;
mControlPointCharacteristic = characteristic;
mPacketCharacteristic = dfuService.getCharacteristic(DFU_PACKET_UUID);
return mControlPointCharacteristic != null && mPacketCharacteristic != null;
return mPacketCharacteristic != null;
}
@Override

View File

@ -148,9 +148,12 @@ import no.nordicsemi.android.error.SecureDfuError;
final BluetoothGattService dfuService = gatt.getService(DFU_SERVICE_UUID);
if (dfuService == null)
return false;
mControlPointCharacteristic = dfuService.getCharacteristic(DFU_CONTROL_POINT_UUID);
final BluetoothGattCharacteristic characteristic = dfuService.getCharacteristic(DFU_CONTROL_POINT_UUID);
if (characteristic == null || characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG) == null)
return false;
mControlPointCharacteristic = characteristic;
mPacketCharacteristic = dfuService.getCharacteristic(DFU_PACKET_UUID);
return mControlPointCharacteristic != null && mPacketCharacteristic != null;
return mPacketCharacteristic != null;
}
@Override