- fixed 4 (or more) crashalytics problems

This commit is contained in:
Andy Rozman 2019-08-07 11:48:37 +01:00
parent 9d27b5f83e
commit d06c5fdcc8
3 changed files with 37 additions and 12 deletions

View file

@ -370,13 +370,21 @@ public class RileyLinkBLE {
rileyLinkDevice = bluetoothAdapter.getRemoteDevice(RileyLinkAddress); rileyLinkDevice = bluetoothAdapter.getRemoteDevice(RileyLinkAddress);
// if this succeeds, we get a connection state change callback? // if this succeeds, we get a connection state change callback?
if (rileyLinkDevice!=null) if (rileyLinkDevice!=null) {
connectGatt(); connectGatt();
} else {
LOG.error("RileyLink device not found with address: " + RileyLinkAddress);
}
} }
// This function must be run on UI thread. // This function must be run on UI thread.
public void connectGatt() { public void connectGatt() {
if (this.rileyLinkDevice==null) {
LOG.error("RileyLink device is null, can't do connectGatt.");
return;
}
bluetoothConnectionGatt = rileyLinkDevice.connectGatt(context, true, bluetoothGattCallback); bluetoothConnectionGatt = rileyLinkDevice.connectGatt(context, true, bluetoothGattCallback);
// , BluetoothDevice.TRANSPORT_LE // , BluetoothDevice.TRANSPORT_LE
if (bluetoothConnectionGatt == null) { if (bluetoothConnectionGatt == null) {
@ -384,7 +392,7 @@ public class RileyLinkBLE {
} else { } else {
if (gattDebugEnabled) { if (gattDebugEnabled) {
if (isLogEnabled()) if (isLogEnabled())
LOG.debug("Gatt Connected?"); LOG.debug("Gatt Connected.");
} }
} }
} }
@ -527,17 +535,24 @@ public class RileyLinkBLE {
if (mCurrentOperation != null) { if (mCurrentOperation != null) {
rval.resultCode = BLECommOperationResult.RESULT_BUSY; rval.resultCode = BLECommOperationResult.RESULT_BUSY;
} else { } else {
BluetoothGattCharacteristic chara = bluetoothConnectionGatt.getService(serviceUUID).getCharacteristic( if (bluetoothConnectionGatt.getService(serviceUUID) == null) {
charaUUID); // Catch if the service is not supported by the BLE device
mCurrentOperation = new CharacteristicReadOperation(bluetoothConnectionGatt, chara); rval.resultCode = BLECommOperationResult.RESULT_NONE;
mCurrentOperation.execute(this); LOG.error("BT Device not supported");
if (mCurrentOperation.timedOut) { // TODO: 11/07/2016 UI update for user
rval.resultCode = BLECommOperationResult.RESULT_TIMEOUT;
} else if (mCurrentOperation.interrupted) {
rval.resultCode = BLECommOperationResult.RESULT_INTERRUPTED;
} else { } else {
rval.resultCode = BLECommOperationResult.RESULT_SUCCESS; BluetoothGattCharacteristic chara = bluetoothConnectionGatt.getService(serviceUUID).getCharacteristic(
rval.value = mCurrentOperation.getValue(); charaUUID);
mCurrentOperation = new CharacteristicReadOperation(bluetoothConnectionGatt, chara);
mCurrentOperation.execute(this);
if (mCurrentOperation.timedOut) {
rval.resultCode = BLECommOperationResult.RESULT_TIMEOUT;
} else if (mCurrentOperation.interrupted) {
rval.resultCode = BLECommOperationResult.RESULT_INTERRUPTED;
} else {
rval.resultCode = BLECommOperationResult.RESULT_SUCCESS;
rval.value = mCurrentOperation.getValue();
}
} }
} }
mCurrentOperation = null; mCurrentOperation = null;

View file

@ -742,6 +742,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
ClockDTO clock = MedtronicUtil.getPumpTime(); ClockDTO clock = MedtronicUtil.getPumpTime();
if (clock==null) { // retry
medtronicUIComm.executeCommand(MedtronicCommandType.GetRealTimeClock);
clock = MedtronicUtil.getPumpTime();
}
if (clock==null)
return;
int timeDiff = Math.abs(clock.timeDifference); int timeDiff = Math.abs(clock.timeDifference);
if (timeDiff > 20) { if (timeDiff > 20) {

View file

@ -68,6 +68,7 @@ public class MedtronicUITask {
case GetRealTimeClock: { case GetRealTimeClock: {
returnData = communicationManager.getPumpTime(); returnData = communicationManager.getPumpTime();
MedtronicUtil.setPumpTime(null);
} }
break; break;