Skip to main content

SpO2 spot measurement

With a spot measurement your app saves an SpO₂ value that was measured on the patient with an external device, for example a pulse oximeter. The SDK stores the value with a precise start and end time and sends it to the bracelet. This gives accurate time-based tracking and makes it possible to compare the measurements.

The SDK does not measure the value: your app supplies it.

Requirements​

Only available for B2 (287-2B) from FW 7.33

From SDK 1.1.20

  • The bracelet is connected and its bracelet initialization has finished.
  • A valid licence. While the SDK is locked, initSpotMeasurement fails with SdkLicenceException. See Licence Key.

The SDK reads the firmware version at each call and refuses a firmware below 7.33.

Implementation​

The Sample App contains directions and example code for the SpO₂ spot measurement. Follow these steps to integrate the feature:

Spot Measurement

Both calls are suspend functions of the spot measurement manager. There is no listener: the result of each call is its return value.

val manager = DataSdk.getInstance().getManager()
val spotManager = manager.getSpotMeasurementManager()
val bleDevice = BleSdk.getInstance().getDevice(address) // address: the bracelet's BLE MAC address

SDK call 1: start of the measurement​

Call it when the user starts the measurement with the external device:

val result = spotManager.initSpotMeasurement(bleDevice, Date().time) // Result<SpotMeasurementDB?>

It starts the spot measurement mode on the bracelet and creates a measurement without an end in the database. The second parameter is the start time, in epoch milliseconds.

A failed Result means that nothing was started:

CauseWhat to do
The SDK is locked by the licence check (SdkLicenceException)Retrying does not help. See Licence Key
The firmware version could not be read, or the bracelet did not accept the commandCheck the connection and the initialization, then call it again
The firmware is below 7.33Update the firmware (DFU)
The measurement could not be storedCheck manager.currentDatabaseState

SDK call 2: save measurement​

Call it when the user has entered the value:

val result = spotManager.save(bleDevice, spo2Value, now, externalDevice) // Result<SpotMeasurementDB?>
ParameterTypeValue
bleDeviceBleDeviceThe bracelet
valueFloatThe SpO₂ value, in percent
endTimestampLongEnd of the measurement, epoch milliseconds
externalDeviceNameStringName of the device the value was measured with

save completes the newest measurement without an end (the one initSpotMeasurement created), then sends the value to the bracelet. The bracelet receives a whole number: the decimals of value are dropped for the bracelet, not in the database.

ResultMeaningWhat to do
Success, synced == trueThe value is stored and the bracelet accepted itNothing
Success, synced == falseThe value is stored, but the bracelet did not accept itNothing: the SDK does not send the value again later
Failure, "no ongoing measurement"initSpotMeasurement was not called, or it failedCall initSpotMeasurement first
Failure with an SdkLicenceExceptionThe value is stored with synced == false; it was not sent to the braceletSee Licence Key
Other failureThe firmware version could not be read, or the firmware is below 7.33: the value is stored with synced == false. Or the value could not be storedCheck the connection and the firmware version, or manager.currentDatabaseState

Sample code available in the classes

DataOthersFragment DataOthersSpotFragment2

Function return structure​

Since 3.0.0 SpotMeasurementDB is a plain class, and every model the SDK returns is a copy.

open class SpotMeasurementDB {
var startTimestamp: Long = 0L
var endTimestamp: Long? = null
var startDate: String = ""
var endDate: String? = null
var value: Float? = null
var deviceName: String? = null
var synced: Boolean = false
}
FieldValue
startTimestamp / endTimestampStart and end of the measurement, epoch milliseconds. endTimestamp is null until save
startDate / endDateThe same as yyyy-MM-dd'T'HH:mm:ss, local time
valueThe SpO₂ value, in percent; null until save
deviceNameName of the external device; null until save
syncedtrue once the bracelet accepted the value

Reading stored measurements​

Read and delete the measurements with manager.spotMeasurementRepository (a SpotMeasurementRepository; since 3.0.0 you cannot construct one yourself). Its functions are suspend and return a Result. deleteAll also has a callback variant, deleteAll(onSuccess, onError).

FunctionReturns
getAll()Every measurement, oldest first
getLastOngoingMeasurement()The newest measurement without an end, or null
deleteByTimestampRange(startTimestamp, endTimestamp)Deletes the measurements that start in the range, both ends included. Before 3.0.0 this call always failed
deleteAll()Deletes every measurement

A measurement that was started and never saved stays in the database without an end. Delete it if you do not want it in getAll().