Skip to main content

Summaries

Summaries are daily aggregates computed by the SDK from the raw metrics. Each summary covers one day and holds day-level values (total steps, average heart rate) and a list of slots, which are back-to-back time buckets within that day.

The slot length is set by slotsIntervalSecs when you initialise the Data SDK; see Data SDK configuration. The default is 60 seconds, which is also the minimum. With a 10-minute slot interval, a day's summary carries slots for 00:00–00:10, 00:10–00:20, and so on.

note

From SDK 3.0.0 the models are plain classes (no RealmObject) and the slot lists are MutableList (they were RealmList). Every model a repository returns is a copy: changing it does not change the database. See Migrating to 3.0.

Reading summaries​

Each summary has a repository and a listener on the Data SDK manager.

ModelRepositoryListenerComputed fromWhat it needs
StepsSummaryModelstepsSummaryRepositorystepsSummaryUpdatedMetricActivity
HeartRateSummaryModelheartRateSummaryRepositoryheartRateSummaryUpdatedMetricActivity
RespirationSummaryModelrespirationSummaryRepositoryrespirationSummaryUpdatedMetricActivity
SpO2SummaryModelspo2SummaryRepositoryspo2SummaryUpdatedMetricActivity287-2B
TemperatureSummaryModeltemperatureSummaryRepositorytemperatureSummaryUpdatedMetricTemperature
SleepSummaryModelsleepSummaryRepositorysleepSummaryUpdatedMetricSleep287-2B
MetricBloodPressureSummarybloodPressureSummaryRepositorybloodPressureSummaryUpdatedMetricActivityNIBP enabled and calibrated, see NIBP
EmographySummaryModelemographySummaryRepositoryemographySummaryUpdatedMetricEmography287-2B, a licence that includes PPG2 raw data, EmoGraphy enabled

Read a day with getByDate. The result arrives in a callback.

import android.util.Log
import com.corsano.sdk.data.DataSdk
import com.corsano.sdk.data.util.DateFormat
import java.util.Date

val manager = DataSdk.getInstance().getManager()

// "yyyy-MM-dd", written the way the SDK writes serverDate
val today = DateFormat.ISO_DATE.createForThread().format(Date())

manager.stepsSummaryRepository.getByDate(today) { summary ->
// null when the day has no summary yet
Log.d("Corsano-SDK", "Steps today: ${summary?.stepCount}")
}

To be told when a summary changes, add a listener. It receives each day the SDK has just saved.

import com.corsano.sdk.data.external.realm.models.StepsSummaryModel
import com.corsano.sdk.data.summary.ValueUpdated

val stepsListener = object : ValueUpdated.Listener<StepsSummaryModel> {
override fun onValueUpdated(model: StepsSummaryModel) {
if (model.serverDate == today) Log.d("Corsano-SDK", "Steps today: ${model.stepCount}")
}
}

manager.stepsSummaryUpdated.addListener(stepsListener)
// when you no longer need it
manager.stepsSummaryUpdated.removeListener(stepsListener)

Listeners are explained in Data events.

Repository methods​

T is the repository's model.

MethodParametersDelivers
getByDate(date, result)date: String, formatted "yyyy-MM-dd"T?
getByTimestampRange(startTimestamp, endTimestamp, result)startTimestamp: Long, endTimestamp: LongArray<T>?
getAll(result)Array<T>?
deleteByDate(date, onSuccess, onError)date: StringNothing
deleteByTimestampRange(startTimestamp, endTimestamp, onSuccess, onError)startTimestamp: Long, endTimestamp: LongNothing
deleteAll(onSuccess, onError)Nothing

How they behave:

  • getByDate gives null when there is no summary for that day. A day without raw data has no summary.
  • getByTimestampRange returns the summaries whose startTimestamp lies in the range, both ends included, in milliseconds UTC. deleteByTimestampRange deletes the same summaries.
  • Order and limit. getAll and getByTimestampRange return the summaries sorted by serverDate, at most 10,000 per call.
  • sleepSummaryRepository has no getByTimestampRange. It has suspend fun getLast(), which returns a Result with the night that started last.
  • Thread. Callbacks run on the SDK's callback scheduler, which is the main thread unless you changed it in the configuration.
  • onSuccess and onError are optional on the delete methods. The read methods have no error callback: if the SDK's database cannot be opened, the callback is not called.

Note the difference from the metric repositories, which are keyed by timestamp: summaries are fetched by date string.

When a summary is updated​

You do not start the calculation. For every summary except sleep (see Sleep), the SDK runs it after each download block it has stored:

  1. It takes the oldest record of the block and starts at that record's day.
  2. It keeps the slots of that day that end before the record, and computes the later slots again from the raw metrics.
  3. It computes every later day again from the raw metrics, up to the newest record.
  4. It saves the days and calls the listener once per saved day.

This has two consequences:

  • A summary of the current day changes during the day. Its last slot is the one that holds the newest record.
  • The calculation needs the raw metrics. If you delete the raw metrics of a day that is computed again, its summary is replaced by one computed from what is left. Keep the raw metrics of the last 2 days; see Data deletion and clean up.

Field conventions​

  • serverDate is the local day of the summary, formatted "yyyy-MM-dd". There is one summary per serverDate. The SDK writes it with the phone's time zone and locale, so build the string for getByDate with DateFormat.ISO_DATE, as in the example above.
  • startTimestamp / endTimestamp are UTC milliseconds: local midnight of the day, and local midnight of the day after. A day is 24 hours, except when summer time starts or ends, or when the phone changes time zone during the day.
  • Slots run back to back from startTimestamp. A slot without data is still in the list, with the "no value" shown in the tables below. The list ends with the slot that holds the day's newest record.
  • Slot timestamp is the start of the slot, in UTC milliseconds. Slot date is the local time of that start, formatted HH:mm (for example 18:37). Sleep slots are different, see SleepSlotModel.
  • uuid is present on most models but is not used: it is always an empty string.
  • Quality fields run 0–4, where 0 is unusable and 4 is very good. See Quality.

Steps​

StepsSummaryModel​

FieldTypeDescription
serverDateStringLocal day. Key of the summary
stepCountIntTotal steps for the day
stepDistanceFloatDistance in metres: stepCount × 0.414 × 1.75, the stride of a person 175 cm tall
stepCaloriesIntTotal calories for the day (active + rest) in kcal
goalStepPercentageIntPercentage against a 10 000-step goal, rounded down. 3 000 steps gives 30. It can exceed 100
startTimestampLongMidnight of the day, UTC ms
endTimestampLongMidnight of the following day, UTC ms
stepsSlotsMutableList<StepsSlotModel>Per-slot breakdown
uuidStringNot used
moveEveryHourIntDeprecated. Always zero
workoutsCountIntDeprecated. Always zero
note

stepDistance assumes a fixed 175 cm height and not the height on the user profile, and goalStepPercentage is computed against a fixed 10 000-step goal. Neither is configurable.

StepsSlotModel​

FieldTypeDescription
timestampLongSlot start, UTC ms. Key of the slot
dateStringLocal time of the slot start, HH:mm
stepCountIntSteps in the slot. 0 when there are none
energyExpDoubleEnergy expenditure in the slot, in kcal (active + passive)
speedDouble?Deprecated: always null (0.0 before 3.0.0). The bracelet's gait speed is not exposed
activityTypeInt?The most frequent activity of the slot: 1 OTHER, 2 WALK, 4 RUN, 6 CYCLE, 7 REST. 0 UNSPECIFIED when the slot has no known activity

Heart rate​

HeartRateSummaryModel​

FieldTypeDescription
serverDateStringLocal day. Key of the summary
avgDailyHeartRateIntAverage of the slots' heart rates, in beats per minute. 0 when no slot has a heart rate
maxDailyHeartRateIntHighest slot heart rate of the day. 0 when there is none
restDailyHeartRateIntResting heart rate: the lowest slot heart rate of the day. 0 when there is none
restHeartRateTimeIntSeconds in the rest zone
warmUpHeartRateTimeIntSeconds in the warm-up zone
fatBurnHeartRateTimeIntSeconds in the fat-burn zone
enduranceHeartRateTimeIntSeconds in the endurance zone
performanceHeartRateTimeIntSeconds in the performance zone
maxHeartRateTimeIntSeconds in the maximum zone
allActiveTimeIntSeconds of the slots that have a heart rate: the total of the six zone times
startTimestampLongMidnight of the day, UTC ms
endTimestampLongMidnight of the following day, UTC ms
heartRateSlotsMutableList<HeartRateSlotModel>Per-slot breakdown
syncedBooleanFor the SDK's own use. Always false
uuidStringNot used
dailyPercentInt?Always null. The SDK never fills it

Heart rate zones​

The six *Time fields are durations in seconds, one per zone. Each slot that has a heart rate adds the slot length (slotsIntervalSecs) to the zone of its bpm. allActiveTime is their total.

The zone boundaries are percentages of a maximum heart rate:

maxHeartRate = 220 - age

The SDK uses a fixed age of 40, so maxHeartRate is 180. The age on the user profile is not used.

FieldHeart rate rangeWith maxHeartRate 180
restHeartRateTimeup to 50% of maxHeartRateup to 90
warmUpHeartRateTimeabove 50%, up to 60%91 to 108
fatBurnHeartRateTimeabove 60%, up to 70%109 to 126
enduranceHeartRateTimeabove 70%, up to 80%127 to 144
performanceHeartRateTimeabove 80%, up to 90%145 to 162
maxHeartRateTimeabove 90%163 and above
note

Changed in 3.0.0. Up to 2.3.0 the zone times were a number of records divided by 6, which was only a duration in minutes at a 10-second sampling rate, and allActiveTime was always 0.

HeartRateSlotModel​

FieldTypeDescription
timestampLongSlot start, UTC ms. Key of the slot
dateStringLocal time of the slot start, HH:mm
bpmInt?Average heart rate over the slot, in beats per minute. null when the slot has no usable record
bpm_qInt?Average quality of the records counted, rounded [1-4]. null when bpm is null

A record counts for a slot only when the bracelet was worn (wearing above 0) and the heart rate quality (bpm_q) was above 0. Records of quality 1 are counted, so check the slot's bpm_q before you use its bpm for a clinical decision.

Respiration​

RespirationSummaryModel​

FieldTypeDescription
serverDateStringLocal day. Key of the summary
averageFloatAverage respiration rate of the day's readings, in breaths/min. 0 when the day has none
slotsMutableList<RespirationSlotModel>Per-slot breakdown
startTimestampLongMidnight of the day, UTC ms
endTimestampLongMidnight of the following day, UTC ms
uuidStringNot used

RespirationSlotModel​

FieldTypeDescription
timestampLongSlot start, UTC ms. Key of the slot
dateStringLocal time of the slot start, HH:mm
rateFloatAverage respiration rate over the slot, in breaths/min. 0 when the slot has no usable reading
qualityFloatAverage quality of the readings counted [1-4]. 0 when the slot has none. Note this is a Float, unlike most quality fields

A reading counts only when the bracelet was worn (wearing above 0), the rate is above 0 and its quality (resp_q) is above 0.

SpO2​

SpO2SummaryModel​

FieldTypeDescription
serverDateStringLocal day. Key of the summary
averageIntAverage of the slots' SpO2 values, in percent, rounded. 0 when no slot has a value
slotsMutableList<Spo2SlotModel>Per-slot breakdown
startTimestampLongMidnight of the day, UTC ms
endTimestampLongMidnight of the following day, UTC ms
uuidStringNot used

A day with activity records but without any SpO2 value still has a summary, with an average of 0.

Spo2SlotModel​

FieldTypeDescription
timestampLongSlot start, UTC ms. Key of the slot
dateStringLocal time of the slot start, HH:mm
valueInt?Average SpO2 over the slot, in percent, rounded. null when the slot has no usable reading
qualityInt?Quality of the slot, see below. null when value is null. Values 103–106 carry a specific meaning, see Quality

A reading counts only when its SpO2 and its quality (spo2Q) are both above 0. The slot's quality is:

  • the rounded average of the qualities 1 to 4 of its readings, when it has at least one such reading;
  • otherwise the rounded average of the codes (103 and above) of its readings.
note

Changed in 3.0.0. Up to 2.3.0 the qualities 1 to 4 and the codes were averaged together, and the day's average counted every record with a value, with or without a quality.

Temperature​

The day averages and the slot values are not rounded. For how to round a temperature for display, see Temperature resolution and rounding.

TemperatureSummaryModel​

FieldTypeDescription
serverDateStringLocal day. Key of the summary
average1FloatAverage of the slots' temp1, in °C. 0 when no slot is in range
average2FloatAverage of the slots' temp2, in °C. 0 when no slot is in range
slotsMutableList<TemperatureSlotModel>Per-slot breakdown
startTimestampLongMidnight of the day, UTC ms
endTimestampLongMidnight of the following day, UTC ms
uuidStringNot used

The day averages only count the slots whose value is above 28 °C and below 40 °C.

note

Changed in 3.0.0. The day averages are over the slots in range, as in the other summaries. temperatureSummaryUpdated is called for every saved day, after it is saved; up to 2.3.0 it was called for the last day only, before the save.

TemperatureSlotModel​

FieldTypeDescription
timestampLongSlot start, UTC ms. Key of the slot
dateStringLocal time of the slot start, HH:mm
temp1Float287-2B: core body temperature in °C, averaged over the slot. 0 when the slot has no reading
temp2Float287-1B: skin temperature in °C. On the 287-2B, skin temperature at night. 0 when the slot has no reading

A slot value is the average of the slot's readings above 0. As with MetricTemperature, temp1 and temp2 mean different things depending on the bracelet.

Sleep​

SleepSummaryModel​

Unlike the other summaries, a sleep summary covers a night, not a calendar day. Its serverDate is the day the night ended. 287-2B only.

The SDK builds a night when it has downloaded the night's "got out of bed" marker; see MetricSleep and Sleep processing. The night runs from the "went to bed" marker to the "got out of bed" marker, in slots of one minute.

FieldTypeDescription
serverDateStringDay the night ended. Key of the summary
dateDateLocal midnight of that day, as a Date object
sleepDurationIntTotal sleep in seconds: REM + light + deep. Excludes awake time
remTimeIntSeconds in REM sleep
lightTimeIntSeconds in light sleep
deepTimeIntSeconds in deep sleep
awakeTimeIntSeconds awake in bed, including the time before falling asleep and after waking up
sleepNeedDurationIntTarget sleep in seconds. Always 25 200 (7 hours)
performanceIntsleepDuration / sleepNeedDuration × 100, as a rounded percentage. It can exceed 100
tranquilityIntNumber of wake-ups during the night, not a score
goalSleepPercentageIntThe night's sleep against a need of 7 hours, in percent: the same value as performance. Filled since 3.0.0; nights summarised before hold 0
startTimestampLong?Start of the first slot, UTC ms
endTimestampLong?Start of the last slot, UTC ms
sleepSlotsMutableList<SleepSlotModel>Per-slot sleep states
slotDurationSecondsIntComputed: seconds between the first two slots (60), or 30 when the night has fewer than two slots
uuidStringNot used
note

Despite its name, tranquility is a count of wake-ups. A higher value means a more disturbed night, not a calmer one. A wake-up is a period awake between the first and the last minute of sleep. Falling asleep and the final wake-up are not counted.

warning

sleepNeedDuration is hard-coded to 7 hours (25 200 seconds). The sleepGoalMinutes, sleepCatchUpMinutes and sleepIntensityMinutes values in Sleep Settings are not applied to it, so performance is computed against 7 hours regardless of what you configure.

How a night is built:

  • One summary per serverDate. A night the bracelet split into two sessions (for example 02:30 to 04:32 and 05:00 to 08:17) is one summary from the first bedtime to the last out-of-bed minute. The minutes between the sessions are awake, and the totals cover both. The second session is joined also when it arrives with a later download.
  • A session ends before the next "went to bed" marker, so a split night is no longer read as one long session.
  • Missing minutes. A gap in the bracelet's records keeps the last stage for at most 10 minutes. The rest of the gap is counted as awake.
  • Before and after sleep. Every minute up to the "fell asleep" marker and from the "woke up" marker on is awake.
note

Changed in 3.0.0. Up to 2.3.0, sleepDuration was the whole time from going to bed to getting out of bed, awake time included, and performance followed from it. tranquility counted two more wake-ups (falling asleep and the final wake-up). A gap of missing minutes took the stage that followed it, so time off the wrist counted as sleep. A night that ended in the afternoon had a date at noon.

SleepSlotModel​

One slot per minute of the night.

FieldTypeDescription
timestampLongSlot start, UTC ms. Key of the slot
startDateStringLocal start time of the slot, formatted yyyy-MM-dd'T'HH:mm:ss
endDateStringLocal end time of the slot (59 seconds after the start), in the same format
sleepStateIntRaw state value
sleepTypeSleepTypeComputed: sleepState mapped to the enum below. Any other value gives NONE
enum class SleepType(var value: Int) {
NONE(0),
AWAKE(1),
LIGHT(2),
DEEP(3),
REM(4)
}

Read sleepType and not sleepState: the numeric values are not in a natural order, so comparing sleepState directly is misleading.

Blood pressure​

Produced by NIBP, from the nibpSystolic and nibpDiastolic values of MetricActivity. See NIBP for how to enable and calibrate it.

MetricBloodPressureSummary​

FieldTypeDescription
startTimestampLongMidnight of the day, UTC ms. Key of the summary
endTimestampLongMidnight of the following day, UTC ms
serverDateStringLocal day
averageSysInt?Average of the slots' systolic pressure, in mmHg, rounded
averageDiaInt?Average of the slots' diastolic pressure, in mmHg, rounded
maxDaySysInt?Highest slot systolic pressure of the day
maxDayDiaInt?Highest slot diastolic pressure of the day
minDaySysInt?Lowest slot systolic pressure of the day
minDayDiaInt?Lowest slot diastolic pressure of the day
slotsMutableList<MetricBloodPressureSummarySlot>Per-slot breakdown
  • A day without any blood pressure value has no summary: getByDate gives null. Since 3.0.0 the other days are still saved; up to 2.3.0 such a day stopped the whole calculation.
  • The day values are computed from the slots that have both pressures, not from single readings.
note

This is the one summary whose key is startTimestamp and not serverDate, and it carries no uuid. Its slot interval is nibpSlotsIntervalSecs, not slotsIntervalSecs. It defaults to 2 hours with a 30-minute minimum; a lower value is replaced by 2 hours. After you change the interval, a stored day is computed again from the raw metrics the next time it is updated.

MetricBloodPressureSummarySlot​

FieldTypeDescription
startTimestampLongSlot start, UTC ms. Key of the slot
endTimestampLongSlot end, UTC ms
dateStringLocal start time of the slot, HH:mm
endDateStringLocal end time of the slot, HH:mm
systolicPressureInt?Average systolic pressure of the slot's readings, in mmHg, rounded. null when the slot has no reading
diastolicPressureInt?Average diastolic pressure of the slot's readings, in mmHg, rounded. null when the slot has no reading

A reading counts only when its systolic and its diastolic value are both above 0.

EmographySummaryModel (B2 only)​

EmoGraphy, also called EDA or stress data. 287-2B only. It is produced when your licence includes PPG2 raw data and EmoGraphy is enabled on the bracelet; see Stress data.

FieldTypeDescription
serverDateStringLocal day. Key of the summary
stressLevelSkinConductanceAvgIntAverage stress level from skin conductance of the day's records [0-1000], rounded. Only records with a level above 0 count. 0 when there is none
slotsMutableList<EmographySlotModel>Per-slot breakdown
startTimestampLongMidnight of the day, UTC ms
endTimestampLongMidnight of the following day, UTC ms
uuidStringNot used
note

The day-level summary carries only the skin-conductance average. Cognitive zone values exist per slot only. The average is computed from the MetricEmography rows of the day, so keep the rows of the current day.

EmographySlotModel (B2 only)​

Each value is the plain average of the slot's MetricEmography records, rounded. The quality is not used as a weight. A slot without records has 0 in every field.

FieldTypeDescription
timestampLongSlot start, UTC ms. Key of the slot
dateStringLocal time of the slot start, HH:mm
cognitiveZoneIntCognitive zone [0-3]: 0 undefined, 1 under-stimulated, 2 balanced, 3 over-stimulated
cognitiveZoneQIntQuality of the cognitive zone [0-4]
predictiveCZIntPredicted cognitive zone [0-3]
predictiveCZTransitionTimeIntMinutes until the predicted transition [0-65535]. Filled since 3.0.0: slots of records downloaded before hold 0
czHourIntCognitive zone one hour ahead [0-3]
cortisolContributionLongCortisol contribution
stressLevelSkinConductanceIntStress level from skin conductance [0-1000]
stressLevelSkinConductanceQIntQuality of the skin conductance value [0-4]

The slot fields mirror MetricEmography.