Skip to content
On this page

PPG Device Info

The application can receive info related to the PPG device by implementing PPGDeviceInfoListener, and then pass it to the session builder when creating a session.

Kotlin
try {
    val licenseDetails = LicenseDetails("<ENTER_YOUR_LICENSE_KEY>")
    val deviceID = "<ENTER_POLAR_DEVICE_ID>"
    val session = PolarSessionBuilder(applicationContext, deviceID)
                    .withVitalSignsListener(this)
                    .withSessionInfoListener(this)
                    .withPPGDeviceInfoListener(this) 
                    .build(licenseDetails);
} catch (e: HealthMonitorException) {
    Log.i("ERROR", "Received Error. Domain: ${e.domain} Code: ${e.errorCode}")
}
Java
try {
    LicenseDetails licenseDetails = new LicenseDetails("<ENTER_YOUR_LICENSE_KEY>");
    String deviceID = "<ENTER_POLAR_DEVICE_ID>";
    Session session = new PolarSessionBuilder(getApplicationContext(), deviceID)
                    .withVitalSignsListener(this)
                    .withSessionInfoListener(this)
                    .withPPGDeviceInfoListener(this) 
                    .build(licenseDetails);
} catch (HealthMonitorException e) {
    Log.i("ERROR", "Received Error. Domain: "+ e.getDomain() +" Code: "+ e.getErrorCode());
}

Upon successful initialization and connection with a PPG Device, the SDK sends a PPGDeviceInfo object containing the device type, ID, and version.

  • The info of the connected PPG Device.
Kotlin
override fun onPPGDeviceInfo(ppgDeviceInfo: PPGDeviceInfo) { 
    runOnUiThread {
        // ppgDeviceInfo.type       -      The PPGDeviceType
        // ppgDeviceInfo.deviceID   -      The device's ID
        // ppgDeviceInfo.version    -      The firmware version of the device
    }
}

override fun onPPGDeviceBatteryLevel(level: Int) {
    runOnUiThread {
        // Receive battery level changes
    }
}
Java
@Override 
public void onPPGDeviceInfo(@NonNull PPGDeviceInfo ppgDeviceInfo) {
    runOnUiThread(() -> {
        // ppgDeviceInfo.getType()      -      The PPGDeviceType
        // ppgDeviceInfo.getDeviceID()  -      The device's ID
        // ppgDeviceInfo.getVersion()   -      The firmware version of the device
    });
}

@Override
public void onPPGDeviceBatteryLevel(int level) {
    runOnUiThread(() -> {
        // Receive battery level changes
    });
}

The SDK also provides the initial battery level of the device upon connection, as well as any subsequent changes in the device's battery level while the session is active.

Kotlin
override fun onPPGDeviceInfo(ppgDeviceInfo: PPGDeviceInfo) {
    runOnUiThread {
        // ppgDeviceInfo.type       -      The PPGDeviceType
        // ppgDeviceInfo.deviceID   -      The device's ID
        // ppgDeviceInfo.version    -      The firmware version of the device
    }
}

override fun onPPGDeviceBatteryLevel(level: int) { 
    runOnUiThread {
        // Receive battery level changes
    }
}
Java
@Override
public void onPPGDeviceInfo(@NonNull PPGDeviceInfo ppgDeviceInfo) {
    runOnUiThread(() -> {
        // ppgDeviceInfo.getType()      -      The PPGDeviceType
        // ppgDeviceInfo.getDeviceID()  -      The device's ID
        // ppgDeviceInfo.getVersion()   -      The firmware version of the device
    });
}

@Override 
public void onPPGDeviceBatteryLevel(Int level) {
    runOnUiThread(() -> {
        // Receive battery level changes
    });
}

Important

Note that info on the PPG Device and battery level changes are sent on a background thread. The application must switch to the UI thread in order to perform UI updates.