Skip to main content

Data transfer

To set up the bracelet and the Android SDK here are the main steps to implement:

  • Pair and connect to the bracelet
  • Set up the bracelet parameter
  • Set up the automatic data transfer between the Bracelet to the Android SDK database
  • Retrieve the data

Step 3: Set up the automatic data transfer between the Bracelet to the Android SDK database

Prerequis: Set up the bracelet parameter

The Android SDK has an automatic file transfer of the data from the bracelet to the SDK. Once activated, a job will run every minute to get the bracelet data, parse it and store it in the SDK database. A download progress event is triggered as well as other events when the database has been updated with new data.

Data transfer

Activation

To start the automatic syncing of the data on the bracelet:

val downloadManager = DataSdk.getInstance().getDownloadManager()

DeviceManager.getCurrentDevice()?.deviceInfo?.plan?.devicePlan?.let { plan ->
// Start Automatic Syncing of the data on the bracelet.
downloadManager?.subscribeDeviceForDownload(
address = address,
hardwareId = hardwareId,
plan,
onSuccess = { result("Automatic file transfer enabled") },
onError = { error -> result("Error: ${error.message}") }
)
}

Transfer of all metrics from the bracelet.

B1:

  • Activity
  • HRV
  • PPG
  • Sleep

B2:

  • Activity
  • HRV
  • PPG2
  • Sleep
  • ECG
  • BioZ
  • Stress (EmoGraphy)

Deactivate

To stop the automatic syncing of the data on the bracelet:

val downloadManager = DataSdk.getInstance().getDownloadManager()
downloadManager?.unsubscribeDeviceForDownload(
address = address,
onSuccess = { result("Automatic file transfer disabled") },
onError = { error -> result("Error: ${error.message}") }
)

Trigger a single download

We recommand using the automatic transfer only, the data will be transferred regurlarly. But if needed, here is a way to trigger a full download instantly:

val downloadManager = DataSdk.getInstance().getDownloadManager()
DeviceManager.getCurrentDevice()?.deviceInfo?.plan?.devicePlan?.let {
downloadManager?.triggerDownload(address, hardwareId, plan = it)
}

Trigger a single download with filters

It is possible to add filters to trigger the download without one or more specific files. Here is an example without PPG file

Available from SDK 0.8.8

val downloadManager = DataSdk.getInstance().getDownloadManager()
DeviceManager.getCurrentDevice()?.deviceInfo?.plan?.devicePlan?.let {
downloadManager?.triggerDownload(address, hardwareId, plan = it, listOf(FileOnWatch.PPG))
}

Data transfer event

Progress during a transfer

The data transfer can take a few minutes if the bracelet hasn't been connected in a few days.

To view the progress of the download:

val downloadManager = DataSdk.getInstance().getDownloadManager()
DeviceManager.getCurrentDevice()?.deviceInfo?.plan?.devicePlan?.let {
downloadManager?.triggerDownload(address, hardwareId, plan = it)
}
downloadManager?.getProgressLiveData()?.observe(viewLifecycleOwner) { listOfWorkInfo ->
downloadManager?.parseProgressLiveData(listOfWorkInfo)?.let { downloadProgressInfo ->
if (downloadProgressInfo.workState == WorkInfo.State.RUNNING) {
result(
String.format(
"Download in progress %s %.02f %%",
downloadProgressInfo.step?.name ?: "",
downloadProgressInfo.progress
)
)
} else {
result("Download ${downloadProgressInfo.workState} at ${Date()}")
}
}
}

You can have access to the following object

DownloadProgress(val workState: WorkInfo.State, val progress: Float, val step: FileOnWatch?)

Full code sample in the sample app file: DataStartFragment.kt