Skip to content

04.Device info and configs

Kilnn edited this page Jun 30, 2023 · 4 revisions

All the device info and configs apis are in the FcConfigFeature class. You can get it like this:

    val configFeature = fcSDK.connector.configFeature()

All the device info and configs are cached in memory. So you can get them at any time. like this:

    val deviceInfo = configFeature.getDeviceInfo()
    val dndConfig = configFeature.getDNDConfig()

By default, only device info is cached in file.

You can choose which configs to cache into the file using FcBuiltInFeatures.cacheFlags. This may be helpful for some functions that need to load the last device configs at any time.

The device info and configs are loaded and refresh automatically. And you can observer them changed like this:

    //Observer FcDeviceInfo
    configFeature.observerDeviceInfo().subscribe({

    },{

    })
    
    //Observer FcDNDConfig
    configFeature.observerDNDConfig().subscribe({

    },{

    })

Sometimes you may need to observe multiple configs changes at the same time, you can do like this:

    configFeature.observerAnyChanged().filter {
        it == FcConfigFeature.TYPE_DEVICE_INFO || it == FcConfigFeature.TYPE_DND_CONFIG
    }.subscribe({
        if (it == FcConfigFeature.TYPE_DEVICE_INFO) {
            val deviceInfo = configFeature.getDeviceInfo()
        } else if (it == FcConfigFeature.TYPE_DND_CONFIG) {
            val dndConfig = configFeature.getDNDConfig()
        }
    }, {

    })

FcDeviceInfo

FcDeviceInfo contains the info and version of the device. And also used to query the Feature/Page/Notification supported by the device.

Info and version

FcDeviceInfo#getProject():Project number. Generally, equipment with the same project number has the same feature and shape.

FcDeviceInfo#getPatch():Software patch number. Usually used to display version information and upgrade detection

FcDeviceInfo#getFlash():Software flash number. Usually used to display version information and upgrade detection

FcDeviceInfo#getApp():Firmware app number. Usually used to display version information and upgrade detection

How to display?

sample project:Refer to HardwareType.kt

device_version

private const val HARDWARE_INFO_MIN_LENGTH = 76

fun String.hardwareProject(): String {
    return if (this.length >= HARDWARE_INFO_MIN_LENGTH) this.substring(0, 12) else ""
}

fun String.hardwarePatch(): String {
    return if (this.length >= HARDWARE_INFO_MIN_LENGTH) this.substring(28, 40) else ""
}

fun String.hardwareApp(): String {
    return if (this.length >= HARDWARE_INFO_MIN_LENGTH) this.substring(48, 56) else ""
}

fun String.hardwareFlash(): String {
    return if (this.length >= HARDWARE_INFO_MIN_LENGTH) this.substring(40, 48) else ""
}

fun String.hardwareInfoDisplay(): String {
    if (this.length < HARDWARE_INFO_MIN_LENGTH) return "——.——"
    val project = hardwareProject()
    val patch = hardwarePatch().run {
        substring(this.length - 4)
    }//Patch number only displays 4 characters
    val app = removeFirst0(hardwareApp())

    val subProjectNum = project.substring(0, 2)
    return if (subProjectNum == "00") {
        "${removeFirst0(project)}.$patch.$app"
    } else {
        "${removeFirst0(project.substring(2))}-$subProjectNum.$patch.$app"
    }
}

fun FcDeviceInfo.hardwareInfoDisplay(): String {
    if (this.isSimulated()) return "——.——"
    return toString().hardwareInfoDisplay()
}

/**
 * Remove the 0 at the beginning of the string
 */
private fun removeFirst0(str: String): String {
    if (str.isEmpty()) return str
    var startIndex = 0
    for (i in str.indices) {
        val c = str[i]
        if (c != '0') {
            startIndex = i
            break
        }
    }
    return str.substring(startIndex, str.length)
}

How to save and transfer?

In sample project, we use a concept called hardwareInfo, which is a string converted from FcDeviceInfo.

val deviceInfo = fcSDK.connector.configFeature().getDeviceInfo()
//hardwareInfo is a string with a length of at least 76
val hardwareInfo = deviceInfo.toString()

You can save hardwareInfo anywhere, or use it to request data from the service api, as used in ApiService.kt in sample project.

Detect version updates

If you use our FitCloudPro server, there are detailed examples in the VersionRepository section of the sample project. The service api refer to Version Check

If you use your own server, you need to develop and manage version upgrade files yourself. Here is a development reference: Server Design:Hardware version upgrade

FcNotificationConfig

See also

FcPageConfig

sample project: Refer to PageConfigFragment.kt.

If FcDeviceInfo.Feature.SETTING_PAGE_CONFIG is supported, this config can be used to set the page displayed on the device.

All pages are defined in FcPageConfig.Flag, but not all devices support all pages. Which pages are supported by the device can be queried through FcDeviceInfo.isSupportPage

After using FcPageConfig.Builder to create or change config, you need to use FcConfigFeature.setPageConfig to apply the changes to the device.

FcFunctionConfig

sample project: Refer to FunctionConfigFragment.kt.

Used to set some simple functions on the device.

All functions are defined in FcFunctionConfig.Flag, but not all devices support all functions.

If the device don't support a function item, you can read and set it, but the expected function will not take effect on the device.

After using FcFunctionConfig.Builder to create or change config, you need to use FcConfigFeature.setFunctionConfig to apply the changes to the device.

  • FcFunctionConfig.Flag.WEAR_WAY: Wear device on left or right hand.
  • FcFunctionConfig.Flag.ENHANCED_MEASUREMENT: Whether to enable the enhanced measurement function.
  • FcFunctionConfig.Flag.TIME_FORMAT: Whether the time format is 12-hour or 24-hour
  • FcFunctionConfig.Flag.LENGTH_UNIT: Length unit.
  • FcFunctionConfig.Flag.TEMPERATURE_UNIT: Temperature unit.
  • @IndeterminateApi FcFunctionConfig.Flag.WEATHER_DISPLAY: Whether to display the weather
  • @IndeterminateApi FcFunctionConfig.Flag.DISCONNECT_REMINDER: Whether to enable the reminder when the device is disconnected.
  • @IndeterminateApi FcFunctionConfig.Flag.EXERCISE_GOAL_DISPLAY: Whether to display the exercise goal

FcHealthMonitorConfig

sample project: Refer to HealthMonitorConfigFragment.kt.

Configuration for timed monitoring data (Heart rate, Blood Pressure, Blood Oxygen, Pressure, Temperature).

If FcDeviceInfo.Feature.HEALTH_MONITOR_CONFIG_INTERVAL is supported, data will be generated at the set time getInterval. If not supported, the default is 5 minutes.

After using FcHealthMonitorConfig.Builder to create or change config, you need to use FcConfigFeature.setHealthMonitorConfig to apply the changes to the device.

The start and end time is a int value represent minutes, for example, time 11:30 is value 690(11*60+30).

The interval time limit [5,720] minutes.

FcSedentaryConfig

sample project: Refer to SedentaryConfigFragment.kt.

When users are sedentary and inactive, they will be reminded based on this configuration.

If FcDeviceInfo.Feature.SEDENTARY_CONFIG_INTERVAL is supported, the detection time according to getInterval. If not supported, the default is 60 minutes.

After using FcSedentaryConfig.Builder to create or change config, you need to use FcConfigFeature.setSedentaryConfig to apply the changes to the device.

The start and end time is a int value represent minutes, for example, time 11:30 is value 690(11*60+30).

The interval time limit [10,720] minutes.

FcDrinkWaterConfig

sample project: Refer to DrinkWaterConfigFragment.kt.

Used to set up config to regularly remind users to drink water.

After using FcDrinkWaterConfig.Builder to create or change config, you need to use FcConfigFeature.setDrinkWaterConfig to apply the changes to the device.

The start and end time is a int value represent minutes, for example, time 11:30 is value 690(11*60+30).

The interval time limit [30,180] minutes.

FcBloodPressureConfig

sample project: Refer to BloodPressureConfigFragment.kt.

Config of blood pressure range, used to correct blood pressure data generated by the device to make it more reasonable.

Usually, it is to let the user input the blood pressure value in the past medical records as a reference.

This config only usable when FcDeviceInfo.Feature.BLOOD_PRESSURE is supported and FcDeviceInfo.Feature.BLOOD_PRESSURE_AIR_PUMP isn't supported. Like this:

val isBloodPressureConfigUsable = deviceInfo.isSupportFeature(FcDeviceInfo.Feature.BLOOD_PRESSURE) and !deviceInfo.isSupportFeature(FcDeviceInfo.Feature.BLOOD_PRESSURE_AIR_PUMP)

If the device also supports [FcBloodPressureAlarmConfig], it is recommended to set the dbp and sbp value according to the following range:

  • alarmConfig.dbpUpperLimit > bpConfig.dbp * 1.1f
  • alarmConfig.dbpLowerLimit < bpConfig.dbp * 0.9f
  • alarmConfig.sbpUpperLimit > bpConfig.sbp * 1.1f
  • alarmConfig.sbpLowerLimit < bpConfig.sbp * 0.9f

This range is set to prevent frequent or abnormal triggering of alarms.

After using FcBloodPressureConfig.Builder to create or change config, you need to use FcConfigFeature.setBloodPressureConfig to apply the changes to the device.

FcTurnWristLightingConfig

sample project: Refer to TurnWristLightingConfigFragment.kt.

Config used for turn over the wrist to bright screen.

After using FcTurnWristLightingConfig.Builder to create or change config, you need to use FcConfigFeature.setTurnWristLightingConfig to apply the changes to the device.

The start and end time is a int value represent minutes, for example, time 11:30 is value 690(11*60+30).

FcHeartRateAlarmConfig

sample project: Refer to HrAlarmConfigFragment.kt.

If FcDeviceInfo.Feature.HEART_RATE_ALARM is supported, this config can is used to set the heart rate alarm value.

When [FcHealthMonitorConfig.isEnabled] is true, the device will monitor heart rate data. If the detected heart rate data exceeds the alarm value for a period of time, the device will alarm (ringing or vibration)

isStaticEnabled refers to alarm in non-exercise state. Device alarm when the heart rate value continues to exceed the getStaticValue value for 15 minutes.

isDynamicEnabled refers to alarm in exercise state. Device alarm when the heart rate value continues to exceed the getDynamicValue value for 10 seconds.

Generally, the threshold of dynamic alarm is higher than that of static alarm.

It should be noted that turning on the alarm function will lead to increased power consumption. And in order to ensure the accuracy of the detection, be sure to wear the watch tightly, otherwise false alarms may occur.

After using FcHeartRateAlarmConfig.Builder to create or change config, you need to use FcConfigFeature.setHeartRateAlarmConfig to apply the changes to the device.

FcBloodPressureAlarmConfig

sample project: Refer to BpAlarmConfigFragment.kt.

If FcDeviceInfo.Feature.BLOOD_PRESSURE_ALARM is supported, this config can is used to set the blood pressure alarm value.

When FcHealthMonitorConfig.isEnabled is true, the device will monitor blood pressure data. If the detected blood pressure data exceeds the alarm value range for a 15 minutes, the device will alarm (ringing or vibration)

If FcBloodPressureConfig is also enabled, it is best to detect the range of blood pressure values in the two configs to avoid false alarms. Recommended alarm value range refer to FcBloodPressureConfig

It should be noted that turning on the alarm function will lead to increased power consumption. And in order to ensure the accuracy of the detection, be sure to wear the watch tightly, otherwise false alarms may occur.

After using FcBloodPressureAlarmConfig.Builder to create or change config, you need to use FcConfigFeature.setBloodPressureAlarmConfig to apply the changes to the device.

FcDNDConfig

sample project: Refer to DNDConfigFragment.kt.

If FcDeviceInfo.Feature.DND is support, this config can use for setting "Do Not Disturb" feature for device.

FcDNDConfig contains two different modes.

  1. For all-day dnd: isEnabledAllDay
  2. For a period time dnd: isEnabledPeriodTimegetStartgetEnd

When isEnabledAllDay is ture, the period time config is ignored.

After using FcDNDConfig.Builder to create or change config, you need to use FcConfigFeature.setDNDConfig to apply the changes to the device.

FcWomenHealthConfig

sample project:Refer to WhHomePageFragment.kt

If FcDeviceInfo.Feature.WOMEN_HEALTH is support, this config can use for setting reminders during menstruation and pregnancy.

Due to historical legacy issues, when reading this config from the device, only partial data may be returned. Therefore, it is recommended not to read this config from the device, but always follow the config in your APP, just like the usage in sample project..

For more detail, refer to the javadoc

FcProtectionReminderConfig

If FcDeviceInfo.Feature.PROTECTION_REMINDER is supported, this config is used to set protection reminders.

The usage is exactly the same as that of FcDrinkWaterConfig. Please refer to FcDrinkWaterConfig

FcHandWashingReminderConfig

If FcDeviceInfo.Feature.HAND_WASHING_REMINDER is supported, this config is used to set hand washing reminders.

The usage is exactly the same as that of FcDrinkWaterConfig. Please refer to FcDrinkWaterConfig

FcScreenVibrateConfig

sample project:Refer to ScreenVibrateConfigFragment.kt

If FcDeviceInfo.Feature.SCREEN_VIBRATE is supported, use this config to setting screen brightness and duration and vibrate.

This config contains six sub configs, but your device may only support some of them.

For alwaysBright config, use AlwaysBright.isSupport to determine if it is supported. For other sub configs, use ReadOnlyBaseSubsection.getItems to determine, if items is null or empty, it indicates that it is not supported.

  • vibrate: Setting device vibrate
  • brightness: Setting screen brightness level
  • brightDuration: Setting screen bright duration
  • turnWristBrightDuration: Setting duration when screen bright by turn wrist
  • longTimeBrightDuration: A long lasting bright screen duration. This config has a higher priority than brightDuration.
  • alwaysBright: Keep screen always bright. This config has a higher priority than longTimeBrightDuration.

After using FcScreenVibrateConfig.Builder to create or change config, you need to use FcConfigFeature.setScreenVibrateConfig to apply the changes to the device.

Clone this wiki locally