PolarBleApiObserver

public protocol PolarBleApiObserver : AnyObject

Polar Ble API connection observer.

  • Callback when connection attempt is started to device

    Requires

    Requires SDK feature(s): None (core API callback).

    Declaration

    Swift

    func deviceConnecting(_ identifier: PolarDeviceInfo)

    Parameters

    identifier

    Polar device info

  • Device connection has been established.

    Requires

    Requires SDK feature(s): None (core API callback).

    Declaration

    Swift

    func deviceConnected(_ identifier: PolarDeviceInfo)

    Parameters

    identifier

    Polar device info

  • deviceDisconnected(_:info:) Default implementation

    Connection lost to device with a typed diagnostic and recovery recommendation.

    Requires

    Requires SDK feature(s): None (core API callback).

    For .retryOperation, the application should not immediately replay an operation against the old connection. The SDK attempts to restore the BLE session and its normal connection setup. The application may retry its failed SDK request only after deviceConnected is received again. The SDK does not retain and replay arbitrary application operations for the app. Reads, streaming setup, and notification subscriptions can normally be requested again. Applications must not blindly repeat a non-idempotent write unless they know that the device did not apply it before the disconnect.

    For .retryConnection, the SDK attempts to retry the connection and security establishment. The application should keep the device nearby and powered on, and wait for deviceConnected before retrying its operation. If the SDK cannot restore the session, the application should present a connection/security failure and may offer another manual connection attempt. A timeout alone is not proof that the pairing record was removed.

    For .removePairingAndPairAgain, the pairing information is no longer usable. The application should stop retrying, instruct the user to remove or forget the device in iOS Bluetooth settings, remove the corresponding pairing from the sensor/watch when the device requires it, put the device into pairing mode, and connect again. The application should not repeatedly reconnect until this action has been completed.

    For .none, no pairing-specific recovery is indicated. The application should use its normal disconnected-device handling and may try a new connection when appropriate.

    The SDK may emit this callback before automatic recovery is complete. Applications should use deviceConnected as the signal that a new connection is ready; they should not assume that this callback alone means an operation can be retried immediately.

    Default Implementation

    Declaration

    Swift

    func deviceDisconnected(_ identifier: PolarDeviceInfo, info: PolarBleDisconnectInfo)

    Parameters

    identifier

    Polar device info

    info

    Disconnect reason and recommended recovery action. The action describes the next recovery category; it does not guarantee that recovery will succeed.

  • deviceDisconnected(_:pairingError:) Default implementation

    Connection lost to device. If PolarBleApi#disconnectFromPolarDevice is not called, a new connection attempt is dispatched automatically.

    Requires

    Requires SDK feature(s): None (core API callback).

    Default Implementation

    Declaration

    Swift

    @available(*, deprecated, message: "Use deviceDisconnected(_:info:﹚ to receive the specific disconnect reason and recovery action.")
    func deviceDisconnected(_ identifier: PolarDeviceInfo, pairingError: Bool)

    Parameters

    identifier

    Polar device info

    pairingError

    If true, it indicates that the disconnection was caused by a pairing error. In this case, try removing the pairing from the system settings.