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 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 get_data() { status("Asking for data"); sendTx(new StatusTx()); }
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 get_data() { status("Asking for data"); sendTx(new StatusTx()); }
private void connect_to_device() { if (JoH.quietratelimit("medtrum-connect-cooldown", 2)) { status("Connecting"); UserError.Log.d(TAG, "Connecting to device: " + address); connect_to_device(false); } }
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 scan_for_device() { status("Scanning"); UserError.Log.d(TAG, "Scanning for device"); scanner.setAddress(address).scan(); }
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 scan_for_device() { status("Scanning"); UserError.Log.d(TAG, "Scanning for device"); scanner.setAddress(address).scan(); }
private void connect_to_device() { if (JoH.quietratelimit("medtrum-connect-cooldown", 2)) { status("Connecting"); UserError.Log.d(TAG, "Connecting to device: " + address); connect_to_device(false); } }
@Override public void onDestroy() { try { scanner.stop(); } catch (Exception e) { // } stopConnect(); DisconnectReceiver.removeCallBack(TAG); wakeup_time = 0; last_automata_state = CLOSED; status("Stopped"); super.onDestroy(); }
@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 onDestroy() { try { scanner.stop(); } catch (Exception e) { // } stopConnect(); DisconnectReceiver.removeCallBack(TAG); wakeup_time = 0; last_automata_state = CLOSED; status("Stopped"); super.onDestroy(); }
@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); } }
status("Connecting");
status("Connecting");
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()); } }