Class BDDeviceSessionImpl
-
- All Implemented Interfaces:
-
com.polar.androidcommunications.api.ble.model.gatt.BleGattTxInterface
public final class BDDeviceSessionImpl extends BleDeviceSession implements BleGattTxInterface
-
-
Field Summary
-
Method Summary
Modifier and Type Method Description BluetoothDevicegetBluetoothDevice()UnitsetBluetoothDevice(BluetoothDevice bluetoothDevice)final ObjectgetGattMutex()final JobgetServiceDiscovery()final UnitsetServiceDiscovery(Job serviceDiscovery)final BluetoothGattgetGatt()final UnitsetGatt(BluetoothGatt gatt)final AtomicSet<Channel<Integer>>getRssiObservers()BooleanisNonConnectableAdvertisement()StringgetAddress()BooleanisAuthenticated()final BooleanisAuthenticationNeeded()final BooleangetDirectConnect()When true, this session was opened via connectToBondedDevice. final UnitsetDirectConnect(Boolean directConnect)When true, this session was opened via connectToBondedDevice. final IntegergetDirectConnectRetryCount()Number of consecutive auto-reconnect attempts made after the session dropped to SESSION_OPEN_PARK while directConnect is true. final UnitsetDirectConnectRetryCount(Integer directConnectRetryCount)Number of consecutive auto-reconnect attempts made after the session dropped to SESSION_OPEN_PARK while directConnect is true. final IntegergetConsecutiveNoCallbackConnects()Number of consecutive connects where the watchdog fired before onConnectionStateChange arrived (i.e. final UnitsetConsecutiveNoCallbackConnects(Integer consecutiveNoCallbackConnects)Number of consecutive connects where the watchdog fired before onConnectionStateChange arrived (i.e. final LonggetNextConnectAllowedTimeMs()Earliest System.currentTimeMillis() for the next advertisement-triggered connect. final UnitsetNextConnectAllowedTimeMs(Long nextConnectAllowedTimeMs)Earliest System.currentTimeMillis() for the next advertisement-triggered connect. final BooleangetPendingWatchdogCancel()Set by the watchdog before calling disconnectDevice() so the handler can count this as a no-callback failure and apply backoff. final UnitsetPendingWatchdogCancel(Boolean pendingWatchdogCancel)Set by the watchdog before calling disconnectDevice() so the handler can count this as a no-callback failure and apply backoff. final UnitresetGatt()final UnitsetSessionStates(BleDeviceSession.DeviceSessionState sessionState)Internal use only final Unitreset()Unitauthenticate()start pairing and optionally bonding procedure with the device BooleanclearGattCache()Deferred<Integer>readRssiValue()Pair<Boolean, Integer>getIndicatesPairingProblem()Checks if session indicates pairing problem. UnitgattClientRequestStopScanning()gatt client requests to stop scanning, while there is some heavy attribute operation ongoing UnitgattClientResumeScanning()gatt client has completed heavy attribute operation, and scanning can continue if needed IntegertransportQueueSize()final UnithandleDisconnection()UnittransmitMessages(UUID serviceUuid, UUID characteristicUuid, List<ByteArray> packets, Boolean withResponse)UnittransmitMessage(UUID serviceUuid, UUID characteristicUuid, ByteArray packet, Boolean withResponse)UnitreadValue(UUID serviceUuid, UUID characteristicUuid)UnitsetCharacteristicNotify(UUID serviceUuid, UUID characteristicUuid, Boolean enable)Deferred<List<UUID>>monitorServicesDiscovered(Boolean checkConnection)Monitor services discovered — suspends until services are discovered or disconnection occurs. BooleanisConnected()final UnithandleServicesDiscovered()final UnithandleCharacteristicWrite(BluetoothGattService service, BluetoothGattCharacteristic characteristic, Integer status)final UnithandleCharacteristicRead(BluetoothGattService service, BluetoothGattCharacteristic characteristic, ByteArray value, Integer status)final UnithandleCharacteristicValueUpdated(BluetoothGattService service, BluetoothGattCharacteristic characteristic, ByteArray value)final UnithandleDescriptorRead(BluetoothGattDescriptor descriptor, ByteArray value, Integer status)final UnithandleDescriptorWrite(BluetoothGattService service, BluetoothGattCharacteristic characteristic, ByteArray value, Integer status)final UnithandleMtuChanged(Integer mtu, Integer status)final UnithandleAuthenticationComplete()final UnitprocessNextAttributeOperation(Boolean remove)final UnithandleRssiRead(Integer rssi, Integer status)final UnitresetDirectConnect()final IntegerincrementDirectConnectRetryCount()-
Methods inherited from class com.polar.androidcommunications.api.ble.model.BleDeviceSession
clearDisconnectReason, clientsReady, fetchClient, getAdvertisementContent, getBlePolarHrAdvertisement, getConnectionUuids, getDeviceCommandDisconnectDeadlineMs, getDisconnectReason, getDisconnectStatus, getGetAdvertisementContent, getHasEstablishedBond, getMedianRssi, getName, getPendingDeviceCommand, getPolarDeviceId, getPolarDeviceIdInt, getPolarDeviceType, getPreviousState, getRssi, getSecurityRecoveryAttempts, getSecurityRecoveryExhausted, getSessionState, getWasBondedAtConnection, isAdvertising, isConnectableAdvertisement, isDeviceAlive, isExpectedDeviceCommandDisconnectStillValid, isIntentionalDisconnect, markBondedAtConnection, markDisconnect, markExpectedDeviceCommandDisconnect, markIntentionalDisconnect, recordSecurityRecoveryAttempt, 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 BLE Advertising data spec
-
getAddress
String getAddress()
- Returns:
bluetooth device address in string format
-
isAuthenticated
Boolean isAuthenticated()
- Returns:
true if session is bonded device
-
isAuthenticationNeeded
final Boolean isAuthenticationNeeded()
-
getDirectConnect
final Boolean getDirectConnect()
When true, this session was opened via connectToBondedDevice. The library will retry the connection without waiting for an advertisement.
-
setDirectConnect
final Unit setDirectConnect(Boolean directConnect)
When true, this session was opened via connectToBondedDevice. The library will retry the connection without waiting for an advertisement.
-
getDirectConnectRetryCount
final Integer getDirectConnectRetryCount()
Number of consecutive auto-reconnect attempts made after the session dropped to SESSION_OPEN_PARK while directConnect is true. Reset to 0 each time connectToBondedDevice is called.
-
setDirectConnectRetryCount
final Unit setDirectConnectRetryCount(Integer directConnectRetryCount)
Number of consecutive auto-reconnect attempts made after the session dropped to SESSION_OPEN_PARK while directConnect is true. Reset to 0 each time connectToBondedDevice is called.
-
getConsecutiveNoCallbackConnects
final Integer getConsecutiveNoCallbackConnects()
Number of consecutive connects where the watchdog fired before onConnectionStateChange arrived (i.e. no OS callback).
-
setConsecutiveNoCallbackConnects
final Unit setConsecutiveNoCallbackConnects(Integer consecutiveNoCallbackConnects)
Number of consecutive connects where the watchdog fired before onConnectionStateChange arrived (i.e. no OS callback).
-
getNextConnectAllowedTimeMs
final Long getNextConnectAllowedTimeMs()
Earliest System.currentTimeMillis() for the next advertisement-triggered connect. 0 means no limit.
-
setNextConnectAllowedTimeMs
final Unit setNextConnectAllowedTimeMs(Long nextConnectAllowedTimeMs)
Earliest System.currentTimeMillis() for the next advertisement-triggered connect. 0 means no limit.
-
getPendingWatchdogCancel
final Boolean getPendingWatchdogCancel()
Set by the watchdog before calling disconnectDevice() so the handler can count this as a no-callback failure and apply backoff.
-
setPendingWatchdogCancel
final Unit setPendingWatchdogCancel(Boolean pendingWatchdogCancel)
Set by the watchdog before calling disconnectDevice() so the handler can count this as a no-callback failure and apply backoff.
-
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)
-
resetDirectConnect
final Unit resetDirectConnect()
-
incrementDirectConnectRetryCount
final Integer incrementDirectConnectRetryCount()
-
-
-
-