Java Code Examples for com.polidea.rxandroidble2.RxBleConnection#RxBleConnectionState

The following examples show how to use com.polidea.rxandroidble2.RxBleConnection#RxBleConnectionState . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PendiqService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
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";

            break;
        case DISCONNECTING:
            connection_state = "Disconnecting";
            break;
        case DISCONNECTED:
            connection_state = "Disconnected";
            // JoH.releaseWakeLock(floatingWakeLock);
            break;
    }
    UserError.Log.d(TAG, connection_state);
    //static_connection_state = connection_state;
    // UserError.Log.d(TAG, "Bluetooth connection: " + static_connection_state);
    if (connection_state.equals("Disconnecting")) {
        //tryGattRefresh();
    }
}
 
Example 2
Source File: PendiqService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
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";

            break;
        case DISCONNECTING:
            connection_state = "Disconnecting";
            break;
        case DISCONNECTED:
            connection_state = "Disconnected";
            // JoH.releaseWakeLock(floatingWakeLock);
            break;
    }
    UserError.Log.d(TAG, connection_state);
    //static_connection_state = connection_state;
    // UserError.Log.d(TAG, "Bluetooth connection: " + static_connection_state);
    if (connection_state.equals("Disconnecting")) {
        //tryGattRefresh();
    }
}
 
Example 3
Source File: MedtrumCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
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);
    }

}
 
Example 4
Source File: JamBaseBluetoothSequencer.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
protected synchronized void onConnectionStateChange(final RxBleConnection.RxBleConnectionState newState) {
    String connection_state = "Unknown";
    switch (newState) {
        case CONNECTING:
            connection_state = "Connecting";
            //  connecting_time = JoH.tsl();
            break;
        case CONNECTED:
            I.isConnected = true;
            I.retry_backoff = 0; // reset counter
            connection_state = "Connected";

            break;
        case DISCONNECTING:
            I.isConnected = false;
            connection_state = "Disconnecting";

            break;
        case DISCONNECTED:
            stopConnect(I.address);
            //I.isConnected = false;
            connection_state = "Disconnected";

            changeState(CLOSE);
            break;
    }

    UserError.Log.d(TAG, "Connection state changed to: " + connection_state);
}
 
Example 5
Source File: MedtrumCollectionService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
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);
    }

}
 
Example 6
Source File: DeviceAdapter.java    From Mi365Locker with GNU General Public License v3.0 5 votes vote down vote up
public void updateDeviceConnection(String address, RxBleConnection.RxBleConnectionState state)
{
    Device device = getDeviceByAddress(address);
    if(device != null) {
        device.setState(state);
        notifyDataSetChanged();
    }
    return;
}
 
Example 7
Source File: JamBaseBluetoothSequencer.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
protected synchronized void onConnectionStateChange(final RxBleConnection.RxBleConnectionState newState) {
    String connection_state = "Unknown";
    switch (newState) {
        case CONNECTING:
            connection_state = "Connecting";
            //  connecting_time = JoH.tsl();
            break;
        case CONNECTED:
            I.isConnected = true;
            I.retry_backoff = 0; // reset counter
            connection_state = "Connected";

            break;
        case DISCONNECTING:
            I.isConnected = false;
            connection_state = "Disconnecting";

            break;
        case DISCONNECTED:
            stopConnect(I.address);
            //I.isConnected = false;
            connection_state = "Disconnected";

            changeState(CLOSE);
            break;
    }

    UserError.Log.d(TAG, "Connection state changed to: " + connection_state);
}
 
Example 8
Source File: RxBleDeviceImpl.java    From RxAndroidBle with Apache License 2.0 5 votes vote down vote up
@Inject
RxBleDeviceImpl(
        BluetoothDevice bluetoothDevice,
        Connector connector,
        BehaviorRelay<RxBleConnection.RxBleConnectionState> connectionStateRelay
) {
    this.bluetoothDevice = bluetoothDevice;
    this.connector = connector;
    this.connectionStateRelay = connectionStateRelay;
}
 
Example 9
Source File: RxBleDeviceImpl.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<RxBleConnection.RxBleConnectionState> observeConnectionStateChanges() {
    return connectionStateRelay.distinctUntilChanged().skip(1);
}
 
Example 10
Source File: RxBleDeviceMock.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<RxBleConnection.RxBleConnectionState> observeConnectionStateChanges() {
    return connectionStateBehaviorSubject.distinctUntilChanged();
}
 
Example 11
Source File: RxBleDeviceMock.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
@Override
public RxBleConnection.RxBleConnectionState getConnectionState() {
    return observeConnectionStateChanges().blockingFirst();
}
 
Example 12
Source File: RssiPeriodicExampleActivity.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
private void onConnectionStateChange(RxBleConnection.RxBleConnectionState newState) {
    connectionStateView.setText(newState.toString());
    updateUI();
}
 
Example 13
Source File: ConnectionExampleActivity.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
private void onConnectionStateChange(RxBleConnection.RxBleConnectionState newState) {
    connectionStateView.setText(newState.toString());
    updateUI();
}
 
Example 14
Source File: RxBleDeviceImpl.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
@Override
public RxBleConnection.RxBleConnectionState getConnectionState() {
    return connectionStateRelay.getValue();
}
 
Example 15
Source File: Device.java    From Mi365Locker with GNU General Public License v3.0 4 votes vote down vote up
public void setState(RxBleConnection.RxBleConnectionState newstate)
{
    this.state = newstate;
}
 
Example 16
Source File: DeviceModule.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
@Provides
@DeviceScope
static BehaviorRelay<RxBleConnection.RxBleConnectionState> provideConnectionStateRelay() {
    return BehaviorRelay.createDefault(RxBleConnection.RxBleConnectionState.DISCONNECTED);
}
 
Example 17
Source File: DeviceConnection.java    From Mi365Locker with GNU General Public License v3.0 4 votes vote down vote up
private void onObserveState(RxBleConnection.RxBleConnectionState newState)
{
    this.updateDeviceStatus();
}
 
Example 18
Source File: DeviceConnection.java    From Mi365Locker with GNU General Public License v3.0 4 votes vote down vote up
public RxBleConnection.RxBleConnectionState getState()
{
    return this.device.getConnectionState();
}
 
Example 19
Source File: Device.java    From Mi365Locker with GNU General Public License v3.0 4 votes vote down vote up
public RxBleConnection.RxBleConnectionState getState() {
    return this.state;
}
 
Example 20
Source File: ConnectionStateChangeListener.java    From RxAndroidBle with Apache License 2.0 votes vote down vote up
void onConnectionStateChange(RxBleConnection.RxBleConnectionState rxBleConnectionState);