-
public interface RxBleDevice
-
-
Method Summary
Modifier and Type Method Description abstract Observable<RxBleConnection.RxBleConnectionState>observeConnectionStateChanges()Observe changes to connection state of the device's android.bluetooth.BluetoothGatt.This Observable will never emit errors.If you would like to have the initial state as well you can use observeConnectionStateChanges().startWith(getConnectionState())NOTE: This is a convenience function for easy state changes monitoring of an individual peripheral that may be useful in the UI. abstract RxBleConnection.RxBleConnectionStategetConnectionState()Returns current connection state of the device's android.bluetooth.BluetoothGatt abstract Observable<RxBleConnection>establishConnection(boolean autoConnect)Establishes connection with a given BLE device. abstract Observable<RxBleConnection>establishConnection(boolean autoConnect, @NonNull() Timeout operationTimeout)Establishes connection with a given BLE device. abstract StringgetName()Name of the device. abstract StringgetMacAddress()MAC address of the corresponding device. abstract BluetoothDevicegetBluetoothDevice()The underlying android.bluetooth.BluetoothDevice.NOTE: this should be used with caution and knowledge as interaction with the BluetoothDevice may interrupt the flow of this library. -
-
Method Detail
-
observeConnectionStateChanges
abstract Observable<RxBleConnection.RxBleConnectionState> observeConnectionStateChanges()
Observe changes to connection state of the device's android.bluetooth.BluetoothGatt.This Observable will never emit errors.If you would like to have the initial state as well you can use observeConnectionStateChanges().startWith(getConnectionState())NOTE: This is a convenience function for easy state changes monitoring of an individual peripheral that may be useful in the UI.It is not meant to be a trigger for reconnecting a particular device—for this purpose one should react on the errors emitted from establishConnection
-
getConnectionState
abstract RxBleConnection.RxBleConnectionState getConnectionState()
Returns current connection state of the device's android.bluetooth.BluetoothGatt
-
establishConnection
abstract Observable<RxBleConnection> establishConnection(boolean autoConnect)
Establishes connection with a given BLE device. RxBleConnection is a handle, used to process BLE operations with a connecteddevice.
The connection is automatically disconnected (and released) when resulting Observable is unsubscribed.On the other hand when the connections is interrupted by the device or the system, the Observable will be unsubscribed as wellfollowing BleDisconnectedException or BleGattException emission.
During the disconnect process the library automatically handles order and requirement of device disconnect and gatt close operations.
Autoconnect concept may be misleading at first glance. In cases when the BLE device is available and it is advertising constantly youwon't need to use autoconnect. Use autoconnect for connections where the BLE device is not advertising atthe moment of #establishConnection call.
- Parameters:
autoConnect- Flag related toconnectGatt autoConnect flag.
-
establishConnection
abstract Observable<RxBleConnection> establishConnection(boolean autoConnect, @NonNull() Timeout operationTimeout)
Establishes connection with a given BLE device. RxBleConnection is a handle, used to process BLE operations with a connecteddevice.
The connection is automatically disconnected (and released) when resulting Observable is unsubscribed.On the other hand when the connections is interrupted by the device or the system, the Observable will be unsubscribed as wellfollowing BleDisconnectedException or BleGattException emission.
During the disconnect process the library automatically handles order and requirement of device disconnect and gatt close operations.
Autoconnect concept may be misleading at first glance. In cases when the BLE device is available and it is advertising constantly youwon't need to use autoconnect. Use autoconnect for connections where the BLE device is not advertising atthe moment of #establishConnection call.
- Parameters:
autoConnect- Flag related toconnectGatt autoConnect flag.operationTimeout- Timeout configuration for operations scheduled using RxBleConnection emitted from this observable.Those operations will be considered broken after the specified timeout.
-
getName
@Nullable() abstract String getName()
Name of the device. Name is optional and it's up to the device vendor if will be provided.
-
getMacAddress
abstract String getMacAddress()
MAC address of the corresponding device.
-
getBluetoothDevice
abstract BluetoothDevice getBluetoothDevice()
The underlying android.bluetooth.BluetoothDevice.NOTE: this should be used with caution and knowledge as interaction with the BluetoothDevice may interrupt the flow of this library.
-
-
-
-