Skip to content

05.Sync Data

Kilnn edited this page Jun 26, 2023 · 12 revisions

The function of sync data refers to obtaining the data of each functional module from the device. This is also the main capability of the device.

Use FcDataFeature.syncData to sync data from device, like this:

val dataFeature = fcSDK.connector.dataFeature()
dataFeature.syncData().observeOn(Schedulers.io(), true).subscribe({
    when (it.type) {
        FcSyncDataType.STEP -> {
            val data = it.toStep()//the step data
        }
        FcSyncDataType.OXYGEN -> {
            val data = it.toOxygen()
        }
        FcSyncDataType.OXYGEN_MEASURE -> {
            val data = it.toOxygenMeasure()
        }
        ...
    }
}, {
    //error
})

After successful synchronization of each type of data, except for FcTodayTotalData, the data on the device will be deleted. If a certain type fails to synchronize data, the subsequent synchronization process will be interrupted.

For monitoring data, devices typically store data for 7 days. Such as step, sleep, heart rate and blood pressure, etc.

For measurement data, it depends on the size of the storage space of the device itself. Such as ECG, Sport, heart rate real-time data, etc.

Types

Base

Devices may contain multiple types of data, but not all devices support them. Use FcDeviceInfo.Feature to determine whether the device supports these types of data, as shown below:

Name Flag Type Class
Step All supported FcSyncDataType.STEP FcStepData
Sleep All supported FcSyncDataType.SLEEP FcSleepData
Heart Rate Feature.HEART_RATE FcSyncDataType.HEART_RATE FcHeartRateData
Oxygen Feature.OXYGEN FcSyncDataType.OXYGEN FcOxygenData
Blood Pressure Feature.BLOOD_PRESSURE FcSyncDataType.BLOOD_PRESSURE FcBloodPressureData
Temperature Feature.TEMPERATURE FcSyncDataType.TEMPERATURE FcTemperatureData
Pressure Feature.PRESSURE FcSyncDataType.PRESSURE FcPressureData
Sport Feature.SPORT FcSyncDataType.SPORT FcSportData
ECG Feature.ECG FcSyncDataType.ECG FcEcgData
Game Feature.GAME FcSyncDataType.GAME FcGameData
GPS Feature.GPS FcSyncDataType.GPS FcGpsData

Measure

Heart Rate, Oxygen, Blood Pressure, Temperature and Pressure are collectively referred to as Health data. These types of data are affected by FcHealthMonitorConfig, We call it monitor data.

APP can use FcDataFeature.openHealthRealTimeData to measure real-time data. Similarly, real-time data measurement can also be performed on the device. The data generated by some devices can also be synchronized, We call it measure data, and their types are as follows:

Name Flag Type Class
Heart Rate measure / FcSyncDataType.HEART_RATE_MEASURE FcHeartRateData
Oxygen measure / FcSyncDataType.OXYGEN_MEASURE FcOxygenData
Blood Pressure measure / FcSyncDataType.BLOOD_PRESSURE_MEASURE FcBloodPressureMeasureData
Temperature measure / FcSyncDataType.TEMPERATURE_MEASURE FcTemperatureData
Pressure measure / FcSyncDataType.PRESSURE_MEASURE FcPressureData
  • Only the data measured on the device will be synchronized. Data measured using FcDataFeature.openHealthRealTimeData from the app will not be synchronized.
  • Not all devices support measure data. You don't need to determine whether the device supports it, just process the data obtained in the syncData results.

Today total data

Due to some historical reasons and device functionality limitations, The FcStepData is not always real-time, it may be delayed by 5 minutes. So if you use the accumulated FcStepData of the day to obtain steps, it will be inconsistent with the steps on the device, At this point, FcTodayTotalDatacan be used.

Name Flag Type Class
Today total data All supported FcSyncDataType.TODAY_TOTAL_DATA FcTodayTotalData

Usage

  • FcDataFeature.syncData : Execute sync
  • FcDataFeature.observerSyncState : Observer sync state. For [0-100] represents the actual progress of synchronization. Others value emit are define in FcSyncState.
  • FcDataFeature.isSyncing : Is currently in data syncing?

Data

Step

The device will monitor the user's motion status throughout the day and generate step data.

When FcDataFeature.syncData emit a FcSyncDataType.STEP type data, you can use FcSyncData.toStep to convert to FcStepData.

FcStepData indicates the number of steps of the user's movement at a certain point in time, such as 2019-05-29 12:00:00 and 50 steps. Actually, it can be understood that the user has accumulated 50 steps in the 5 minute period from 2019-05-29 11:55:00 to 2019-05-29 12:00:00.

If FcDeviceInfo.Feature.STEP_EXTRA is supported, FcStepData also contains the distance and calories exercised during this time. Practically all new devices will support this. For information on how to handle unsupported situations, please refer to the sample project SyncDataRepository.saveStep.

The device generates a step data about every 5 minutes, but this is not absolute. If the user is in continuous motion, each step data will be separated by 5 minutes. If the user is intermittently moving, the interval may be greater than 5 minutes or less than 5 minutes.

Device re-bound solution.

The current design of the device is to clear the data each time it is bound. Therefore, when the device is re-bound, the number of steps will become 0, which may be inconsistent with the data stored locally by the APP.

The solution is to delete the FcStepData of the day cached in APP when the device is re-bound. For more detail, please refer to the sample project SyncDataRepository.saveTodayStep

FcStepData delay solution

The device saves a FcStepData every 5 minutes, but the total number of steps displayed on the device is real-time. If you use FcStepData to accumulate the total number of steps, it is always delayed by 5 minutes relative to the device.

The solution is use total number of steps in FcTodayTotalData. For more detail, please refer to the sample project SyncDataRepository.saveTodayStep

Sleep

Health data

ECG

Sport and GPS

Game

Clone this wiki locally