Class BleDeviceSession
-
- All Implemented Interfaces:
public abstract class BleDeviceSessionBluetooth le device class, contains all essential api's for sufficient usage of bluetooth le device
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumBleDeviceSession.DisconnectReasonpublic enumBleDeviceSession.DeviceCommandDevice-control command that a DEVICE_COMMAND disconnect is expected to follow.
public enumBleDeviceSession.DeviceSessionStateConnection state
-
Field Summary
-
Method Summary
-
-
Method Detail
-
getDisconnectReason
final BleDeviceSession.DisconnectReason getDisconnectReason()
-
getDisconnectStatus
final Integer getDisconnectStatus()
-
isIntentionalDisconnect
final Boolean isIntentionalDisconnect()
-
getDeviceCommandDisconnectDeadlineMs
final Long getDeviceCommandDisconnectDeadlineMs()
-
getPendingDeviceCommand
final BleDeviceSession.DeviceCommand getPendingDeviceCommand()
-
getWasBondedAtConnection
final Boolean getWasBondedAtConnection()
-
getHasEstablishedBond
final Boolean getHasEstablishedBond()
-
getSecurityRecoveryAttempts
final Integer getSecurityRecoveryAttempts()
-
getSecurityRecoveryExhausted
final Boolean getSecurityRecoveryExhausted()
-
getSessionState
final BleDeviceSession.DeviceSessionState getSessionState()
Members
-
setSessionState
final Unit setSessionState(BleDeviceSession.DeviceSessionState sessionState)
Members
-
getPreviousState
final BleDeviceSession.DeviceSessionState getPreviousState()
- Returns:
state before current one
-
getAdvertisementContent
final BleAdvertisementContent getAdvertisementContent()
-
setAdvertisementContent
final Unit setAdvertisementContent(BleAdvertisementContent advertisementContent)
-
getGetAdvertisementContent
final BleAdvertisementContent getGetAdvertisementContent()
-
getConnectionUuids
final List<String> getConnectionUuids()
- Returns:
current connection uuid's needed for connection attempt
-
setConnectionUuids
final Unit setConnectionUuids(List<String> connectionUuids)
- Parameters:
connectionUuids- set connection uuid's
-
isNonConnectableAdvertisement
abstract 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
-
isConnectableAdvertisement
final Boolean isConnectableAdvertisement()
- Returns:
true if device is 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
abstract String getAddress()
- Returns:
bluetooth device address in string format
-
isAuthenticated
abstract Boolean isAuthenticated()
- Returns:
true if session is bonded device
-
getBluetoothDevice
abstract BluetoothDevice getBluetoothDevice()
- Returns:
android bluetooth device instance
-
getPolarDeviceId
final String getPolarDeviceId()
- Returns:
polar device id
-
getPolarDeviceType
String getPolarDeviceType()
- Returns:
polar device type
-
getPolarDeviceIdInt
final Long getPolarDeviceIdInt()
- Returns:
polar device id in int
-
getMedianRssi
final Integer getMedianRssi()
- Returns:
current median rssi value
-
getBlePolarHrAdvertisement
final BlePolarHrAdvertisement getBlePolarHrAdvertisement()
- Returns:
polar hr advertisement content @see BlePolarHrAdvertisement
-
markBondedAtConnection
final Unit markBondedAtConnection(Boolean bonded)
-
recordSecurityRecoveryAttempt
final Boolean recordSecurityRecoveryAttempt(Integer maxAttempts)
-
markDisconnect
final Unit markDisconnect(BleDeviceSession.DisconnectReason reason, Integer status)
-
markIntentionalDisconnect
final Unit markIntentionalDisconnect()
-
markExpectedDeviceCommandDisconnect
final Unit markExpectedDeviceCommandDisconnect(BleDeviceSession.DeviceCommand command, Long validForMs)
Call right after a device-control command's success path (e.g. GATT write acked) to mark the disconnect that is expected to follow as non-actionable.
-
isExpectedDeviceCommandDisconnectStillValid
final Boolean isExpectedDeviceCommandDisconnectStillValid()
-
clearDisconnectReason
final Unit clearDisconnectReason()
-
isDeviceAlive
final Boolean isDeviceAlive(Long time, TimeUnit timeUnit)
- Parameters:
time- max time for the last advertisement eventtimeUnit- desired timeunit- Returns:
true, device is still somewhat considered "alive"
-
isAdvertising
final Boolean isAdvertising(Long time, TimeUnit timeUnit)
- Parameters:
time- max time for the last advertisement eventtimeUnit- desired timeunit- Returns:
true if device is advertising in the required timespan
-
authenticate
abstract 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
-
monitorServicesDiscovered
abstract Deferred<List<UUID>> monitorServicesDiscovered(Boolean checkConnection)
Monitor services discovered
- Returns:
Deferred result
-
clearGattCache
abstract Boolean clearGattCache()
- Returns:
true if current gatt cache clear was ok
-
readRssiValue
abstract Deferred<Integer> readRssiValue()
- Returns:
Deferred result for rssi values
-
getIndicatesPairingProblem
abstract 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).
-
fetchClient
final BleGattBase fetchClient(UUID uuid)
- Parameters:
uuid- service uuid- Returns:
get a specific client from the list
-
clientsReady
final Unit clientsReady(Boolean checkConnection)
Helper to combine all available/desired clients ready.
- Parameters:
checkConnection- check initial connection
-
-
-
-