public void changeState(STATE new_state) { changeState(new_state, DEFAULT_AUTOMATA_DELAY); }
public void changeState(STATE new_state) { changeState(new_state, DEFAULT_AUTOMATA_DELAY); }
private void onConnectionReceived(final RxBleConnection this_connection) { listen_connected = true; status("Connected"); // TODO close off existing connection? connection = this_connection; if (this_connection != null) { changeState(ENABLE); } else { UserError.Log.d(TAG, "New connection null!"); changeState(CLOSE); } }
private void onConnectionReceived(final RxBleConnection this_connection) { listen_connected = true; status("Connected"); // TODO close off existing connection? connection = this_connection; if (this_connection != null) { changeState(ENABLE); } else { UserError.Log.d(TAG, "New connection null!"); changeState(CLOSE); } }
@Override public void btCallback(String address, String status) { UserError.Log.d(TAG, "Processing callback: " + address + " :: " + status); if (address.equals(MedtrumCollectionService.address)) { switch (status) { case "DISCONNECTED": changeState(CLOSE); break; case "SCAN_FOUND": changeState(CONNECT); break; case "SCAN_TIMEOUT": status("Scan timed out"); changeState(CONNECT); // setRetryTimer(); break; case "SCAN_FAILED": status("Scan Failed!"); changeState(CONNECT); // if location services off etc break; default: UserError.Log.e(TAG, "Unknown status callback for: " + address + " with " + status); } } else { UserError.Log.d(TAG, "Ignoring: " + status + " for " + address + " as we are using: " + MedtrumCollectionService.address); } }
@Override public void btCallback(String address, String status) { UserError.Log.d(TAG, "Processing callback: " + address + " :: " + status); if (address.equals(MedtrumCollectionService.address)) { switch (status) { case "DISCONNECTED": changeState(CLOSE); break; case "SCAN_FOUND": changeState(CONNECT); break; case "SCAN_TIMEOUT": status("Scan timed out"); changeState(CONNECT); // setRetryTimer(); break; case "SCAN_FAILED": status("Scan Failed!"); changeState(CONNECT); // if location services off etc break; default: UserError.Log.e(TAG, "Unknown status callback for: " + address + " with " + status); } } else { UserError.Log.d(TAG, "Ignoring: " + status + " for " + address + " as we are using: " + MedtrumCollectionService.address); } }
private synchronized void onConnectionStateChange(RxBleConnection.RxBleConnectionState newState) { String connection_state = "Unknown"; switch (newState) { case CONNECTING: connection_state = "Connecting"; // connecting_time = JoH.tsl(); break; case CONNECTED: connection_state = "Connected"; retry_backoff = 0; break; case DISCONNECTING: connection_state = "Disconnecting"; break; case DISCONNECTED: connection_state = "Disconnected"; status("Disconnected"); changeState(CLOSE); break; } status(connection_state); if (connection_state.equals("Disconnecting")) { tryGattRefresh(connection); } }
private synchronized void onConnectionStateChange(RxBleConnection.RxBleConnectionState newState) { String connection_state = "Unknown"; switch (newState) { case CONNECTING: connection_state = "Connecting"; // connecting_time = JoH.tsl(); break; case CONNECTED: connection_state = "Connected"; retry_backoff = 0; break; case DISCONNECTING: connection_state = "Disconnecting"; break; case DISCONNECTED: connection_state = "Disconnected"; status("Disconnected"); changeState(CLOSE); break; } status(connection_state); if (connection_state.equals("Disconnecting")) { tryGattRefresh(connection); } }
private void initialize() { serial = getSerial(); if (serial != 0) { changeState(SCAN); } else { final String msg = "Medtrum cannot start without serial number - please rescan"; if (JoH.ratelimit("medtrum-cannot-start", 120)) { UserError.Log.e(TAG, msg); } JoH.static_toast_long(msg); } }
private void initialize() { serial = getSerial(); if (serial != 0) { changeState(SCAN); } else { final String msg = "Medtrum cannot start without serial number - please rescan"; if (JoH.ratelimit("medtrum-cannot-start", 120)) { UserError.Log.e(TAG, msg); } JoH.static_toast_long(msg); } }
private void onConnectionFailure(Throwable throwable) { if (listen_connected) { status("Disconnected"); } else { status("Connection failure"); } // TODO under what circumstances should we change state or do something here? UserError.Log.d(TAG, "Connection Disconnected/Failed: " + throwable); stopConnect(); changeState(CLOSE); setRetryTimer(); }
private void onConnectionFailure(Throwable throwable) { if (listen_connected) { status("Disconnected"); } else { status("Connection failure"); } // TODO under what circumstances should we change state or do something here? UserError.Log.d(TAG, "Connection Disconnected/Failed: " + throwable); stopConnect(); changeState(CLOSE); setRetryTimer(); }
private void check_calibrate() { final Pair<Long, Integer> calibration = Medtrum.getCalibration(); if (calibration != null) { status("Calibrating"); try { sendTx(new CalibrateTx(serial, calibration.first, calibration.second)); } catch (InvalidAlgorithmParameterException e) { UserError.Log.wtf(TAG, "Cannot calibrate: " + e); } } else { changeState(state.next()); } }
private void check_calibrate() { final Pair<Long, Integer> calibration = Medtrum.getCalibration(); if (calibration != null) { status("Calibrating"); try { sendTx(new CalibrateTx(serial, calibration.first, calibration.second)); } catch (InvalidAlgorithmParameterException e) { UserError.Log.wtf(TAG, "Cannot calibrate: " + e); } } else { changeState(state.next()); } }
break; case DISCOVER: changeState(state.next()); break; case CALIBRATE: sendTx(new TimeTx()); } else { changeState(state.next()); status("Listening"); if (notificationSubscription == null || notificationSubscription.isUnsubscribed()) { changeState(SCAN);
break; case DISCOVER: changeState(state.next()); break; case CALIBRATE: sendTx(new TimeTx()); } else { changeState(state.next()); status("Listening"); if (notificationSubscription == null || notificationSubscription.isUnsubscribed()) { changeState(SCAN);
changeState(state.next()); break; changeState(state.next(), asking_backfill ? 1500 : DEFAULT_AUTOMATA_DELAY); break; UserError.Log.e(TAG, msg); changeState(SET_CONN_PARAM); break; UserError.Log.e(TAG, "Got invalid connection parameter reply msg"); changeState(state.next()); break; UserError.Log.ueh(TAG, thismsg); JoH.static_toast_long(thismsg); changeState(state.next()); break;
changeState(state.next()); break; changeState(state.next(), asking_backfill ? 1500 : DEFAULT_AUTOMATA_DELAY); break; UserError.Log.e(TAG, msg); changeState(SET_CONN_PARAM); break; UserError.Log.e(TAG, "Got invalid connection parameter reply msg"); changeState(state.next()); break; UserError.Log.ueh(TAG, thismsg); JoH.static_toast_long(thismsg); changeState(state.next()); break;