Class BDDeviceSessionImpl
-
- All Implemented Interfaces:
-
com.polar.androidcommunications.api.ble.model.gatt.BleGattTxInterface
public final class BDDeviceSessionImpl extends BleDeviceSession implements BleGattTxInterface
-
-
Field Summary
Fields Modifier and Type Field Description private BluetoothDevicebluetoothDeviceprivate final ObjectgattMutexprivate JobserviceDiscoveryprivate BluetoothGattgattprivate final AtomicSet<Channel<Integer>>rssiObserversprivate final BooleanisNonConnectableAdvertisementprivate final Stringaddressprivate final BooleanisAuthenticatedprivate final BooleanisAuthenticationNeededprivate BleDeviceSession.DeviceSessionStatesessionStateprivate final BleDeviceSession.DeviceSessionStatepreviousStateprivate BleAdvertisementContentadvertisementContentprivate final BleAdvertisementContentgetAdvertisementContentprivate List<String>connectionUuidsprivate final BooleanisConnectableAdvertisementprivate final Stringnameprivate final StringpolarDeviceIdprivate final StringpolarDeviceTypeprivate final LongpolarDeviceIdIntprivate final IntegermedianRssiprivate final Integerrssiprivate final BlePolarHrAdvertisementblePolarHrAdvertisement
-
Method Summary
-
Methods inherited from class com.polar.androidcommunications.api.ble.model.BleDeviceSession
clientsReady, fetchClient, getAdvertisementContent, getBlePolarHrAdvertisement, getConnectionUuids, getGetAdvertisementContent, getMedianRssi, getName, getPolarDeviceId, getPolarDeviceIdInt, getPolarDeviceType, getPreviousState, getRssi, getSessionState, isAdvertising, isConnectableAdvertisement, isDeviceAlive, setAdvertisementContent, setConnectionUuids, setSessionState -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getBluetoothDevice
BluetoothDevice getBluetoothDevice()
- Returns:
android bluetooth device instance
-
setBluetoothDevice
Unit setBluetoothDevice(BluetoothDevice bluetoothDevice)
-
getGattMutex
final Object getGattMutex()
-
getServiceDiscovery
final Job getServiceDiscovery()
-
setServiceDiscovery
final Unit setServiceDiscovery(Job serviceDiscovery)
-
getGatt
final BluetoothGatt getGatt()
-
setGatt
final Unit setGatt(BluetoothGatt gatt)
-
getRssiObservers
final AtomicSet<Channel<Integer>> getRssiObservers()
-
isNonConnectableAdvertisement
Boolean isNonConnectableAdvertisement()
- Returns:
true if device is in non-connectable advertisement<BR></BR> Notes: Depending on Android API version,it's impossible to know this.<BR></BR> So this would work only for Polar Devices that follows Polar SAGRFC31
-
getAddress
String getAddress()
- Returns:
bluetooth device address in string format
-
isAuthenticated
Boolean isAuthenticated()
- Returns:
true if session is bonded device
-
isAuthenticationNeeded
final Boolean isAuthenticationNeeded()
-
setSessionStates
final Unit setSessionStates(BleDeviceSession.DeviceSessionState sessionState)
Internal use only
- Parameters:
sessionState- @see BleDeviceSession.
-
authenticate
Unit authenticate()
start pairing and optionally bonding procedure with the device
- Returns:
Either produces complete for already bonded device or starts pairing/bonding procedure or onError on failure case
-
clearGattCache
Boolean clearGattCache()
- Returns:
true if current gatt cache clear was ok
-
readRssiValue
Deferred<Integer> readRssiValue()
- Returns:
Deferred result for rssi values
-
getIndicatesPairingProblem
Pair<Boolean, Integer> getIndicatesPairingProblem()
Checks if session indicates pairing problem. This is a helper method to check if the session is in a state where pairing problems are likely, for example due to failed authentication attempts or other issues that may arise during the pairing process.
- Returns:
Boolean indicating if the session indicates a pairing problem. True if there are indications of a pairing problem, false otherwise. Int value contains Bluetooth error code if there is a pairing problem, otherwise it is -1 (not set).
-
gattClientRequestStopScanning
Unit gattClientRequestStopScanning()
gatt client requests to stop scanning, while there is some heavy attribute operation ongoing
-
gattClientResumeScanning
Unit gattClientResumeScanning()
gatt client has completed heavy attribute operation, and scanning can continue if needed
-
transportQueueSize
Integer transportQueueSize()
- Returns:
current att operation queue size
-
handleDisconnection
final Unit handleDisconnection()
-
transmitMessages
Unit transmitMessages(UUID serviceUuid, UUID characteristicUuid, List<ByteArray> packets, Boolean withResponse)
-
transmitMessage
Unit transmitMessage(UUID serviceUuid, UUID characteristicUuid, ByteArray packet, Boolean withResponse)
-
setCharacteristicNotify
Unit setCharacteristicNotify(UUID serviceUuid, UUID characteristicUuid, Boolean enable)
-
monitorServicesDiscovered
Deferred<List<UUID>> monitorServicesDiscovered(Boolean checkConnection)
Monitor services discovered — suspends until services are discovered or disconnection occurs.
-
isConnected
Boolean isConnected()
-
handleServicesDiscovered
final Unit handleServicesDiscovered()
-
handleCharacteristicWrite
final Unit handleCharacteristicWrite(BluetoothGattService service, BluetoothGattCharacteristic characteristic, Integer status)
-
handleCharacteristicRead
final Unit handleCharacteristicRead(BluetoothGattService service, BluetoothGattCharacteristic characteristic, ByteArray value, Integer status)
-
handleCharacteristicValueUpdated
final Unit handleCharacteristicValueUpdated(BluetoothGattService service, BluetoothGattCharacteristic characteristic, ByteArray value)
-
handleDescriptorRead
final Unit handleDescriptorRead(BluetoothGattDescriptor descriptor, ByteArray value, Integer status)
-
handleDescriptorWrite
final Unit handleDescriptorWrite(BluetoothGattService service, BluetoothGattCharacteristic characteristic, ByteArray value, Integer status)
-
handleMtuChanged
final Unit handleMtuChanged(Integer mtu, Integer status)
-
handleAuthenticationComplete
final Unit handleAuthenticationComplete()
-
processNextAttributeOperation
final Unit processNextAttributeOperation(Boolean remove)
-
handleRssiRead
final Unit handleRssiRead(Integer rssi, Integer status)
-
-
-
-