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.
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.
| Model | Repository | Listener | Computed from | What it needs |
|---|---|---|---|---|
StepsSummaryModel | stepsSummaryRepository | stepsSummaryUpdated | MetricActivity | |
HeartRateSummaryModel | heartRateSummaryRepository | heartRateSummaryUpdated | MetricActivity | |
RespirationSummaryModel | respirationSummaryRepository | respirationSummaryUpdated | MetricActivity | |
SpO2SummaryModel | spo2SummaryRepository | spo2SummaryUpdated | MetricActivity | 287-2B |
TemperatureSummaryModel | temperatureSummaryRepository | temperatureSummaryUpdated | MetricTemperature | |
SleepSummaryModel | sleepSummaryRepository | sleepSummaryUpdated | MetricSleep | 287-2B |
MetricBloodPressureSummary | bloodPressureSummaryRepository | bloodPressureSummaryUpdated | MetricActivity | NIBP enabled and calibrated, see NIBP |
EmographySummaryModel | emographySummaryRepository | emographySummaryUpdated | MetricEmography | 287-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.
| Method | Parameters | Delivers |
|---|---|---|
getByDate(date, result) | date: String, formatted "yyyy-MM-dd" | T? |
getByTimestampRange(startTimestamp, endTimestamp, result) | startTimestamp: Long, endTimestamp: Long | Array<T>? |
getAll(result) | Array<T>? | |
deleteByDate(date, onSuccess, onError) | date: String | Nothing |
deleteByTimestampRange(startTimestamp, endTimestamp, onSuccess, onError) | startTimestamp: Long, endTimestamp: Long | Nothing |
deleteAll(onSuccess, onError) | Nothing |
How they behave:
getByDategivesnullwhen there is no summary for that day. A day without raw data has no summary.getByTimestampRangereturns the summaries whosestartTimestamplies in the range, both ends included, in milliseconds UTC.deleteByTimestampRangedeletes the same summaries.- Order and limit.
getAllandgetByTimestampRangereturn the summaries sorted byserverDate, at most 10,000 per call. sleepSummaryRepositoryhas nogetByTimestampRange. It hassuspend fun getLast(), which returns aResultwith 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.
onSuccessandonErrorare 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:
- It takes the oldest record of the block and starts at that record's day.
- It keeps the slots of that day that end before the record, and computes the later slots again from the raw metrics.
- It computes every later day again from the raw metrics, up to the newest record.
- 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
serverDateis the local day of the summary, formatted"yyyy-MM-dd". There is one summary perserverDate. The SDK writes it with the phone's time zone and locale, so build the string forgetByDatewithDateFormat.ISO_DATE, as in the example above.startTimestamp/endTimestampare 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
timestampis the start of the slot, in UTC milliseconds. Slotdateis the local time of that start, formattedHH:mm(for example18:37). Sleep slots are different, see SleepSlotModel. uuidis 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
| Field | Type | Description |
|---|---|---|
serverDate | String | Local day. Key of the summary |
stepCount | Int | Total steps for the day |
stepDistance | Float | Distance in metres: stepCount × 0.414 × 1.75, the stride of a person 175 cm tall |
stepCalories | Int | Total calories for the day (active + rest) in kcal |
goalStepPercentage | Int | Percentage against a 10 000-step goal, rounded down. 3 000 steps gives 30. It can exceed 100 |
startTimestamp | Long | Midnight of the day, UTC ms |
endTimestamp | Long | Midnight of the following day, UTC ms |
stepsSlots | MutableList<StepsSlotModel> | Per-slot breakdown |
uuid | String | Not used |
moveEveryHour | Int | Deprecated. Always zero |
workoutsCount | Int | Deprecated. Always zero |
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
| Field | Type | Description |
|---|---|---|
timestamp | Long | Slot start, UTC ms. Key of the slot |
date | String | Local time of the slot start, HH:mm |
stepCount | Int | Steps in the slot. 0 when there are none |
energyExp | Double | Energy expenditure in the slot, in kcal (active + passive) |
speed | Double? | Deprecated: always null (0.0 before 3.0.0). The bracelet's gait speed is not exposed |
activityType | Int? | 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
| Field | Type | Description |
|---|---|---|
serverDate | String | Local day. Key of the summary |
avgDailyHeartRate | Int | Average of the slots' heart rates, in beats per minute. 0 when no slot has a heart rate |
maxDailyHeartRate | Int | Highest slot heart rate of the day. 0 when there is none |
restDailyHeartRate | Int | Resting heart rate: the lowest slot heart rate of the day. 0 when there is none |
restHeartRateTime | Int | Seconds in the rest zone |
warmUpHeartRateTime | Int | Seconds in the warm-up zone |
fatBurnHeartRateTime | Int | Seconds in the fat-burn zone |
enduranceHeartRateTime | Int | Seconds in the endurance zone |
performanceHeartRateTime | Int | Seconds in the performance zone |
maxHeartRateTime | Int | Seconds in the maximum zone |
allActiveTime | Int | Seconds of the slots that have a heart rate: the total of the six zone times |
startTimestamp | Long | Midnight of the day, UTC ms |
endTimestamp | Long | Midnight of the following day, UTC ms |
heartRateSlots | MutableList<HeartRateSlotModel> | Per-slot breakdown |
synced | Boolean | For the SDK's own use. Always false |
uuid | String | Not used |
dailyPercent | Int? | 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.
| Field | Heart rate range | With maxHeartRate 180 |
|---|---|---|
restHeartRateTime | up to 50% of maxHeartRate | up to 90 |
warmUpHeartRateTime | above 50%, up to 60% | 91 to 108 |
fatBurnHeartRateTime | above 60%, up to 70% | 109 to 126 |
enduranceHeartRateTime | above 70%, up to 80% | 127 to 144 |
performanceHeartRateTime | above 80%, up to 90% | 145 to 162 |
maxHeartRateTime | above 90% | 163 and above |
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
| Field | Type | Description |
|---|---|---|
timestamp | Long | Slot start, UTC ms. Key of the slot |
date | String | Local time of the slot start, HH:mm |
bpm | Int? | Average heart rate over the slot, in beats per minute. null when the slot has no usable record |
bpm_q | Int? | 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
| Field | Type | Description |
|---|---|---|
serverDate | String | Local day. Key of the summary |
average | Float | Average respiration rate of the day's readings, in breaths/min. 0 when the day has none |
slots | MutableList<RespirationSlotModel> | Per-slot breakdown |
startTimestamp | Long | Midnight of the day, UTC ms |
endTimestamp | Long | Midnight of the following day, UTC ms |
uuid | String | Not used |
RespirationSlotModel
| Field | Type | Description |
|---|---|---|
timestamp | Long | Slot start, UTC ms. Key of the slot |
date | String | Local time of the slot start, HH:mm |
rate | Float | Average respiration rate over the slot, in breaths/min. 0 when the slot has no usable reading |
quality | Float | Average 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
| Field | Type | Description |
|---|---|---|
serverDate | String | Local day. Key of the summary |
average | Int | Average of the slots' SpO2 values, in percent, rounded. 0 when no slot has a value |
slots | MutableList<Spo2SlotModel> | Per-slot breakdown |
startTimestamp | Long | Midnight of the day, UTC ms |
endTimestamp | Long | Midnight of the following day, UTC ms |
uuid | String | Not used |
A day with activity records but without any SpO2 value still has a summary, with an average of 0.
Spo2SlotModel
| Field | Type | Description |
|---|---|---|
timestamp | Long | Slot start, UTC ms. Key of the slot |
date | String | Local time of the slot start, HH:mm |
value | Int? | Average SpO2 over the slot, in percent, rounded. null when the slot has no usable reading |
quality | Int? | 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.
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
| Field | Type | Description |
|---|---|---|
serverDate | String | Local day. Key of the summary |
average1 | Float | Average of the slots' temp1, in °C. 0 when no slot is in range |
average2 | Float | Average of the slots' temp2, in °C. 0 when no slot is in range |
slots | MutableList<TemperatureSlotModel> | Per-slot breakdown |
startTimestamp | Long | Midnight of the day, UTC ms |
endTimestamp | Long | Midnight of the following day, UTC ms |
uuid | String | Not used |
The day averages only count the slots whose value is above 28 °C and below 40 °C.
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
| Field | Type | Description |
|---|---|---|
timestamp | Long | Slot start, UTC ms. Key of the slot |
date | String | Local time of the slot start, HH:mm |
temp1 | Float | 287-2B: core body temperature in °C, averaged over the slot. 0 when the slot has no reading |
temp2 | Float | 287-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.
| Field | Type | Description |
|---|---|---|
serverDate | String | Day the night ended. Key of the summary |
date | Date | Local midnight of that day, as a Date object |
sleepDuration | Int | Total sleep in seconds: REM + light + deep. Excludes awake time |
remTime | Int | Seconds in REM sleep |
lightTime | Int | Seconds in light sleep |
deepTime | Int | Seconds in deep sleep |
awakeTime | Int | Seconds awake in bed, including the time before falling asleep and after waking up |
sleepNeedDuration | Int | Target sleep in seconds. Always 25 200 (7 hours) |
performance | Int | sleepDuration / sleepNeedDuration × 100, as a rounded percentage. It can exceed 100 |
tranquility | Int | Number of wake-ups during the night, not a score |
goalSleepPercentage | Int | The 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 |
startTimestamp | Long? | Start of the first slot, UTC ms |
endTimestamp | Long? | Start of the last slot, UTC ms |
sleepSlots | MutableList<SleepSlotModel> | Per-slot sleep states |
slotDurationSeconds | Int | Computed: seconds between the first two slots (60), or 30 when the night has fewer than two slots |
uuid | String | Not used |
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.
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.
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.
| Field | Type | Description |
|---|---|---|
timestamp | Long | Slot start, UTC ms. Key of the slot |
startDate | String | Local start time of the slot, formatted yyyy-MM-dd'T'HH:mm:ss |
endDate | String | Local end time of the slot (59 seconds after the start), in the same format |
sleepState | Int | Raw state value |
sleepType | SleepType | Computed: 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
| Field | Type | Description |
|---|---|---|
startTimestamp | Long | Midnight of the day, UTC ms. Key of the summary |
endTimestamp | Long | Midnight of the following day, UTC ms |
serverDate | String | Local day |
averageSys | Int? | Average of the slots' systolic pressure, in mmHg, rounded |
averageDia | Int? | Average of the slots' diastolic pressure, in mmHg, rounded |
maxDaySys | Int? | Highest slot systolic pressure of the day |
maxDayDia | Int? | Highest slot diastolic pressure of the day |
minDaySys | Int? | Lowest slot systolic pressure of the day |
minDayDia | Int? | Lowest slot diastolic pressure of the day |
slots | MutableList<MetricBloodPressureSummarySlot> | Per-slot breakdown |
- A day without any blood pressure value has no summary:
getByDategivesnull. 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.
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
| Field | Type | Description |
|---|---|---|
startTimestamp | Long | Slot start, UTC ms. Key of the slot |
endTimestamp | Long | Slot end, UTC ms |
date | String | Local start time of the slot, HH:mm |
endDate | String | Local end time of the slot, HH:mm |
systolicPressure | Int? | Average systolic pressure of the slot's readings, in mmHg, rounded. null when the slot has no reading |
diastolicPressure | Int? | 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.
| Field | Type | Description |
|---|---|---|
serverDate | String | Local day. Key of the summary |
stressLevelSkinConductanceAvg | Int | Average 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 |
slots | MutableList<EmographySlotModel> | Per-slot breakdown |
startTimestamp | Long | Midnight of the day, UTC ms |
endTimestamp | Long | Midnight of the following day, UTC ms |
uuid | String | Not used |
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.
| Field | Type | Description |
|---|---|---|
timestamp | Long | Slot start, UTC ms. Key of the slot |
date | String | Local time of the slot start, HH:mm |
cognitiveZone | Int | Cognitive zone [0-3]: 0 undefined, 1 under-stimulated, 2 balanced, 3 over-stimulated |
cognitiveZoneQ | Int | Quality of the cognitive zone [0-4] |
predictiveCZ | Int | Predicted cognitive zone [0-3] |
predictiveCZTransitionTime | Int | Minutes until the predicted transition [0-65535]. Filled since 3.0.0: slots of records downloaded before hold 0 |
czHour | Int | Cognitive zone one hour ahead [0-3] |
cortisolContribution | Long | Cortisol contribution |
stressLevelSkinConductance | Int | Stress level from skin conductance [0-1000] |
stressLevelSkinConductanceQ | Int | Quality of the skin conductance value [0-4] |
The slot fields mirror MetricEmography.