Skip to main content

ECG measurement

Only available for B2

Available starting version 0.8.2

The ECG measurement is 50 seconds.

During the 50 seconds there are 8 seconds of warm up and 42 seconds of effective ECG data.

The ECG has to be started and stopped by your application. Please follow the sample app example in DataEcgFragment.kt

Start ECG measurement

Start ECG using the code bellow:

DataSdk.getInstance().getManager().getEcgManager().startEcg(bleDevice, {  
result("Start Ecg success")
updateUI()
}, {
result("Start Ecg error: $it")
})

The start ECG command will be sent to the bracelet, and a row will be created in the Measurement table

A blue light is visible on the bracelet when the ECG is running:

IMG_4885.JPG

Stop ECG measurement

Stop ECG using the code bellow:

DataSdk.getInstance().getManager().getEcgManager().stopEcg(bleDevice, {  
result("Stop Ecg success")
updateUI()
}, {
result("Stop Ecg error: $it")
})

The stop ECG command will be sent to the bracelet, and the row in the Measurement table will be updated with the stop timestamp

The blue light on the bracelet is turned off when the ECG is stopped.

IMG_4969.jpeg

ECG in the database

The ECG are saved into the table EcgMeasurementModel

open class EcgMeasurementModel : RealmObject() {
@PrimaryKey
var startTimestamp: Long = 0L // start time of the ECG on the bracelet
var endTimestamp: Long? = null // end time of the ECG on the bracelet
var wiffFilename: String? = null // filename of the full .wiff file of the measurement when the measurement is finished and after a succesfull sync

Retrieve data of the ECG measurement

In order to retrieve the ECG data, please make sure the bracelet is syncing regularly using the Data Download

  • Small .wiff.part files at each synchronisation

The ECG data from the bracelet is synced at each regular sync. At each sync, the ECG data is synced then written in a file, the file name is “ECG-watch address-timestamp.wiff.part”Ex:The .wiff.part files are stored in the app internal folder, in the ECG directory

Screenshot 2022-06-01 at 13.39.54.png

  • Merge to a .wiff files at the end of the ECG

When the ECG is stopped, after the next sync with the bracelet, when we are sure that there is no remaining ECG data on the bracelet, the .wiff.part files are merges to a .wiff file.The filename contains the stop data of the ECG.This is the file that is available for export.After the merge, the .wiff.part are deleted

Screenshot 2022-06-01 at 13.40.17.png

Export ECG files

Export to phone storage

Use the function exportWiffFiles, this function will:

  • Get in the DB the ECG with a wiff file to export
  • Check that the file exist
  • Export it
  • If the flag deleteAfterExport is true, the file will be deleted from the app storage (recommanded)
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
val mainActivity = requireActivity() as MainActivity
mainActivity.startActivityForResult(intent) { a, b ->
b?.data?.also { uri ->
val docFile =
DocumentFile.fromTreeUri(requireContext(), uri)
?: return@startActivityForResult
DataSdk.getInstance().getManager().getEcgManager().exportWiffFiles(
requireContext(),
docFile,
true,
{
Toast.makeText(
requireContext(),
"${it?.size} files saved successfully",
Toast.LENGTH_SHORT
).show()
},
{
result("Export ECG error $it")
})
}
}

Export to another directory in the app folder

Use the function exportWiffFilesToAppDirectory, this function will:

  • Get in the DB the ECG with a wiff file to export
  • Check that the file exist
  • Copy it to the destination directory
  • If the flag deleteAfterExport is true, the file will be deleted from the app storage (recommanded)

Parsing wiff files

Use the function parseEcgMeasurement, this function will:

  • Check the ECG in the database and parse the wiff file associated

The parsing result is a list of EcgSlotModel:

data class EcgSlotModel(
var timestamp: Long = 0L,
var chunkIndex: Int = 0,
var qualityIndexElectrodeContact: Int? = null,
var qualityIndexStability: Int? = null,
var qualityIndexNoise: Int? = null,
var qualityIndexPower: Int? = null,
var qualityIndexMovements: Int? = null,
var ecg: Double = 0.0
)