Timeout during handshake notification

This commit is contained in:
TebbeUbben 2019-02-16 20:28:49 +01:00
parent d2b0665af1
commit 361cc158e8
4 changed files with 19 additions and 2 deletions

View file

@ -73,6 +73,7 @@ public class Notification {
public static final int RILEYLINK_CONNECTION = 45;
public static final int PERMISSION_PHONESTATE = 46;
public static final int INSIGHT_DATE_TIME_UPDATED = 47;
public static final int INSIGHT_TIMEOUT_DURING_HANDSHAKE = 48;
public int id;

View file

@ -1557,4 +1557,10 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
public void onPumpPaired() {
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Pump paired", null);
}
@Override
public void onTimeoutDuringHandshake() {
Notification notification = new Notification(Notification.INSIGHT_TIMEOUT_DURING_HANDSHAKE, MainApp.gs(R.string.timeout_during_handshake), Notification.URGENT);
new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventNewNotification(notification)));
}
}

View file

@ -352,6 +352,11 @@ public class InsightConnectionService extends Service implements ConnectionEstab
}
log.info("Exception occurred: " + e.getClass().getSimpleName());
if (pairingDataStorage.isPaired()) {
if (e instanceof TimeoutException && (state == InsightState.SATL_SYN_REQUEST || state == InsightState.APP_CONNECT_MESSAGE)) {
for (StateCallback stateCallback : stateCallbacks) {
stateCallback.onTimeoutDuringHandshake();
}
}
setState(connectionRequests.size() != 0 ? InsightState.RECOVERING : InsightState.DISCONNECTED);
if (e instanceof ConnectionFailedException) {
cleanup(((ConnectionFailedException) e).getDurationOfConnectionAttempt() <= 1000);
@ -726,7 +731,8 @@ public class InsightConnectionService extends Service implements ConnectionEstab
private void processReadParameterBlockMessage(ReadParameterBlockMessage message) {
if (state == InsightState.APP_SYSTEM_IDENTIFICATION) {
if (!(message.getParameterBlock() instanceof SystemIdentificationBlock)) handleException(new TooChattyPumpException());
if (!(message.getParameterBlock() instanceof SystemIdentificationBlock))
handleException(new TooChattyPumpException());
else {
SystemIdentification systemIdentification = ((SystemIdentificationBlock) message.getParameterBlock()).getSystemIdentification();
pairingDataStorage.setSystemIdentification(systemIdentification);
@ -802,8 +808,11 @@ public class InsightConnectionService extends Service implements ConnectionEstab
public interface StateCallback {
void onStateChanged(InsightState state);
default void onPumpPaired() {
default void onPumpPaired() {
}
default void onTimeoutDuringHandshake() {
}
}

View file

@ -1295,6 +1295,7 @@
<string name="max_recovery_duration">Max. recovery duration [s]</string>
<string name="min_recovery_duration">Min. recovery duration [s]</string>
<string name="recovery_duration">Recovery duration</string>
<string name="timeout_during_handshake">Timeout during handshake - reset bluetooth</string>
<string name="profile_total">== ∑ %1$s U</string>
<string name="profile_ins_units_per_hout">U/h</string>