Raw data models
Raw metrics are the measurements as the bracelet recorded them. The SDK downloads the bracelet's files, decodes them and stores one row per record in its database. The daily Summaries are computed from these rows.
This page tells you, for each raw metric model: which repository returns it, which listener announces new rows, what each field means and what "no value" looks like.
From SDK 3.0.0 the models are plain classes (no RealmObject). Every model a repository returns is a copy: changing it does not change the database. See Migrating to 3.0.
What you get and where it arrives
All repositories and listeners are properties of the Data SDK manager, DataSdk.getInstance().getManager().
| Model | Contents | Repository | Listener | What it needs |
|---|---|---|---|---|
MetricActivity | Heart rate, steps, SpO2, respiration, NIBP, battery, wearing | metricActivityRepository | metricActivityUpdated | Always downloaded |
MetricTemperature | Core body and skin temperature | metricTemperatureRepository | metricTemperatureUpdated | Always downloaded. It comes from the same file as MetricActivity |
MetricHrv | RR intervals | metricHrvRepository | metricHrvUpdated | Always downloaded |
MetricSleep | Sleep state per interval | metricSleepRepository | metricSleepUpdated | 287-2B |
MetricPpg | Green PPG samples with accelerometer | metricPpgRepository | metricPpgUpdated | A licence that includes PPG (green) raw data |
MetricTemperatureRaw | Raw heat-flux sensor channels | metricTemperatureRawRepository | metricTemperatureRawUpdated | 287-2B, a licence that includes raw temperature, and raw temperature enabled on the bracelet |
MetricEmography | Cognitive zone and skin conductance | metricEmographyRepository | None, see MetricEmography | 287-2B, a licence that includes PPG2 raw data, and EmoGraphy enabled on the bracelet |
Things to know before you look for data:
- Rows appear after a download from the bracelet, not live. Set up the download first: Data transfer.
- How often the bracelet records a row depends on the bracelet plan and the sampling rates you set in the bracelet initialization. See Bracelet Plans. At a 60-second sampling rate, a
MetricActivityrow arrives every 60 seconds, holding the steps taken and the average heart rate over that minute. - Which raw data your licence includes is explained in The licence and raw data.
- A listener receives the list of rows the SDK has just stored. How to add and remove listeners is explained in Data events.
Raw metrics accumulate quickly. Read Data deletion and clean up before you ship.
Reading raw metrics
Each model has a repository on the manager. The result arrives in a callback.
import android.util.Log
import com.corsano.sdk.data.DataSdk
val manager = DataSdk.getInstance().getManager()
val to = System.currentTimeMillis()
val from = to - 60 * 60 * 1000L // the last hour
manager.metricActivityRepository.getByTimestampRange(from, to) { metrics ->
metrics?.forEach { metric ->
Log.d("Corsano-SDK", "${metric.date} bpm=${metric.bpm} quality=${metric.bpm_q}")
}
}
To be told when new rows are stored, add a listener:
import com.corsano.sdk.data.external.realm.models.MetricActivity
import com.corsano.sdk.data.summary.ValueUpdated
val activityListener = object : ValueUpdated.Listener<List<MetricActivity>> {
override fun onValueUpdated(model: List<MetricActivity>) {
// the rows the SDK has just stored
}
}
manager.metricActivityUpdated.addListener(activityListener)
// when you no longer need it
manager.metricActivityUpdated.removeListener(activityListener)
Repository methods
T is the repository's model.
| Method | Delivers | Available on |
|---|---|---|
getByTimestampRange(startTimestamp, endTimestamp, results) | Array<T>? | All seven repositories |
getByTimestampRange(startTimestamp, endTimestamp, groupedBySeconds, results) | Array<T>? | All except metricEmographyRepository and metricTemperatureRawRepository |
getAll(results) | Array<T>? | All seven |
getAll(groupedBySeconds, results) | Array<T>? | All seven. On metricTemperatureRawRepository the rows are not grouped |
getLast(result) | T? | All seven |
deleteByTimestamp(timestamp, onSuccess, onError) | Nothing | All seven |
deleteByTimestampRange(startTimestamp, endTimestamp, onSuccess, onError) | Nothing | All seven |
deleteAll(onSuccess, onError) | Nothing | All seven |
How they behave:
- Timestamps are milliseconds since 1970-01-01 UTC (
Long). A range includes both ends. - Order. Rows come back sorted by
timestamp, oldest first. - No rows. A range without rows gives an empty array.
getLastgivesnullwhen the table is empty. The array type is nullable; treatnullas "no rows". - Thread. Callbacks run on the SDK's callback scheduler, which is the main thread unless you changed it in the configuration. See Retrieve the Data.
- Row limit.
metricPpgRepository,metricHrvRepository,metricSleepRepositoryandmetricEmographyRepositoryreturn at most 50,000 rows per call, the oldest of the range. Ask for shorter ranges when you read these. The other three return the whole range. getLastreturns the row with the highesttimestamp.deleteByTimestampdeletes the row whosetimestampis exactly the value you pass.deleteAlldeletes every row up to the phone's current time.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.- First start after an upgrade from SDK 2.x. A call made while the SDK imports the old data waits, then answers as usual.
getByTimestamp(startOfFirstDay, results) is deprecated. It returns every row from startOfFirstDay on. Use getByTimestampRange instead.
Grouping rows with groupedBySeconds
groupedBySeconds returns one model per time bucket instead of one per row. Use it to chart a long period of MetricActivity. A value of 0 returns the rows unchanged.
- Buckets are counted from
startTimestamp. A bucket without rows is not returned. - The returned model's
timestampis the start of its bucket. Itsdateis thedateof the first row in the bucket.
For MetricActivity, a bucket is groupedBySeconds seconds long and its values are computed like this:
| Fields | Value of the bucket |
|---|---|
bpm, respiration_rate | Average of the rows that have a value and a quality above 0, weighted by the quality. null when there is none |
spo2 | Average of the rows that have a value and a quality from 1 to 4, weighted by the quality. When the bucket has only rows with a code (103 to 106), the plain average of their values. null when there is none. See Quality |
bpm_q, q, resp_q | Average of the qualities 1 to 4, rounded up. null when there is none |
spo2Q | As bpm_q. When the bucket's spo2 comes from rows with a code alone, the average of their codes, so the quality describes the value |
last_steps | Sum |
energy_exp, activityCount | Sum of the rows that have a value, a 0 included. null when no row has one |
activity_type | The most frequent value other than 0 |
wearing, isCharging | The most frequent value |
battery, nibpSystolic, nibpDiastolic, cardiacArrest | Average of the values other than 0, rounded. null when there is none |
Only MetricActivity is grouped in seconds. For MetricPpg, MetricHrv, MetricSleep, MetricTemperature and MetricEmography the bucket is groupedBySeconds milliseconds long. This is a known behaviour of the SDK, kept unchanged in 3.0.0. If you need buckets of several seconds or minutes for these models, read the rows and group them in your app.
In a bucket of the other models:
| Model | Value of the bucket |
|---|---|
MetricSleep | sleepState: the most frequent state, the earliest on a tie. movementLevel: the average, 0 included. activityCount: the sum. hrm, rmssd: the average of the values other than 0 |
MetricTemperature | temp1, temp2: the average of the values above 0 °C; the bracelet's -100 ("no new value") and any value at or below 0 are left out. null when there is none |
MetricPpg, MetricHrv, MetricEmography | The average of the values other than 0, weighted by their quality where they have one. predictiveCZ and czHour take the most frequent value other than 0 |
Changed in 3.0.0. The bucket sizes are as they were in 2.x, but some values of a bucket changed (BT-1330): SpO2 is weighted by its quality 1 to 4 only (a code above 4 counted 25 times as much as a quality 4), energy_exp and activityCount are summed (they were averaged, with 0 left out), the temperatures leave out -100, and a grouped MetricSleep keeps its most frequent sleepState (it was 0) and its movementLevel, activityCount, hrm and rmssd (they were null). Ungrouped reads are unchanged.
Field conventions
These apply to all the models below.
timestampis the time of the record, in milliseconds since 1970-01-01 UTC. It is the key of the row: a record with the sametimestampreplaces the stored one.dateis the same instant as text, in the phone's time zone at the moment the row was stored, formattedyyyy-MM-dd'T'HH:mm:ss.SSSXXX(for example2023-09-17T16:33:54.000+02:00).- Quality fields (
bpm_q,spo2Q,resp_q, …) run 0–4, where 0 is unusable and 4 is very good. Values of 0 and 1 should not drive clinical alerts. See Quality. isSyncedis a flag for the SDK's own use. Do not read or write it.
Since 3.0.0 the SDK drops every record dated before 2021-01-01 (UTC) or more than 10 minutes after the phone's clock. Such a record is not stored, not passed to a listener and not used in a summary. A record at most a day later than that limit (a bracelet clock ahead of the phone's) is not dropped by the file transfer: the transfer stops at it and leaves it, and the records after it, on the bracelet until the phone's clock has caught up. A bracelet whose clock was never set writes records dated 2020-01-01; these are dropped too.
MetricActivity
The main raw metric: one row per sampling interval with the vitals measured during it.
| Field | Type | Description | No value |
|---|---|---|---|
timestamp | Long | Time of the record, UTC milliseconds. Key of the row | |
date | String | Local date of the timestamp | |
bpm | Int? | Heart rate in beats per minute [0-255]. Use it only when bpm_q and wearing are above 0; this is what the summaries do | |
bpm_q | Int? | Heart rate quality [0-4] | 0 |
q | Int? | Same as bpm_q | 0 |
last_steps | Int? | Steps taken since the previous record | 0 |
activity_type | Int? | 0 UNSPECIFIED, 1 OTHER, 2 WALK, 4 RUN, 6 CYCLE, 7 REST. The enum ActivityDataRecord.ActivityType has the same values | 0 |
spo2 | Int? | SpO2 in percent. 287-2B only | 0 |
spo2Q | Int? | SpO2 quality [0-4], or one of the codes 103–106. See Quality | 0 |
energy_exp | Int? | Energy expenditure since the previous record, in cal (active + passive) | 0 |
activityCount | Int? | Activity count since the previous record. Stored since 3.0.0: rows downloaded before the update hold null | null |
respiration_rate | Float? | Respiration rate in breaths/min, in steps of 0.25 | 0 |
resp_q | Int? | Respiration rate quality [0-4] | 0 |
wearing | Int? | Wearing status [0-4]. 0 not worn, 4 correctly worn on the wrist | |
battery | Int? | Battery percentage [0-100]. A value above 100 is an error code, see Battery error detection | |
isCharging | Boolean? | true when the bracelet was on the charger | |
nibpSystolic | Int? | Systolic blood pressure in mmHg. Only when NIBP is enabled, see NIBP | 0, or null when the SDK refused the pair as implausible |
nibpDiastolic | Int? | Diastolic blood pressure in mmHg | Same as nibpSystolic |
cardiacArrest | Int? | 0 unspecified, 1 normal rhythm, 2 cardiac arrest detected | null for any other code from the bracelet |
isSynced | Boolean | For the SDK's own use. Always false |
A value is the bracelet's own: the SDK stores the record as it decodes it. For heart rate, SpO2 and respiration, check the quality field before you use the value.
Fields that are never filled
These fields exist on the model but the SDK does not fill them. Most are annotated @Deprecated("value always null"). Do not write code that reads them.
| Field | Type | What you read |
|---|---|---|
speed | Double? | null on rows downloaded since 3.0.0; 0.0 on older rows. Was the speed in m/s |
pha, pha_q | Int? | 0 |
move_alert | Int? | 0 |
active_calories | Int? | 0. Use energy_exp |
cw, cwt | Int? | null |
step_calories, rest_calories | Int? | null |
distance, step_duration | Int? | null |
In a grouped read (groupedBySeconds) all of them are null.
temp1 and temp2 (Double?) exist on MetricActivity but are not stored. A MetricActivity you read from the repository has both set to null. For temperature use MetricTemperature.
MetricActivity implements the IMetricActivity interface, which is where the field documentation lives in the SDK.
Example
A row of a 287-2B, as stored. The fields that are never filled are left out.
{
"timestamp": 1694961234000,
"date": "2023-09-17T16:33:54.000+02:00",
"bpm": 78,
"bpm_q": 1,
"q": 1,
"last_steps": 2,
"activity_type": 1,
"spo2": 100,
"spo2Q": 2,
"energy_exp": 175,
"respiration_rate": 0,
"resp_q": 0,
"wearing": 4,
"battery": 70,
"isCharging": false
}
In this row the heart rate has quality 1 (informative only) and there is no respiration rate.
MetricPpg
The samples of the green PPG file: one row per PPG sample, with the accelerometer value and the heart rate of that moment. The rows of one block of the file are 40 ms apart.
| Field | Type | Description |
|---|---|---|
timestamp | Long | Time of the sample, UTC milliseconds. Key of the row |
date | String | Local date of the timestamp |
ppg | Int | PPG value [0-65535] |
acc | Int | Accelerometer magnitude [0-617], without a unit. The bracelet sends one byte, which the SDK expands: 0-99 as sent, 100-149 to 100-198 in steps of 2, 150-254 to 200-616 in steps of 4, 255 to 617. It is not on the scale of the accelerometer file |
accX | Int? | Accelerometer X. null when the bracelet's file format does not carry the axes. For the scale, see Other accelerometer values in the SDK |
accY | Int? | Accelerometer Y. null in the same case |
accZ | Int? | Accelerometer Z. null in the same case |
bpm | Int | Heart rate in beats per minute. The same value for about one second of samples |
bpmQ | Int | Heart rate quality [0-4] |
crc | Int | Deprecated: always 0. The bracelet's CRC is per chunk, not per sample |
isSynced | Boolean | For the SDK's own use. Always false |
The quality field here is bpmQ, camel case, unlike MetricActivity, which uses bpm_q. The two models do not share a naming convention.
MetricPpg rows are many. Read them in short ranges (a call returns at most 50,000 rows) and delete them often.
For the multicolour PPG2 waveform, which is stored in files and not in the database, see Parsing Raw Files.
MetricHrv
RR intervals: the time between successive heartbeats.
| Field | Type | Description |
|---|---|---|
timestamp | Long | Time of the beat, UTC milliseconds. Key of the row |
date | String | Local date of the timestamp |
beats | Int | RR interval in milliseconds |
isSynced | Boolean | For the SDK's own use. Always false |
- The bracelet dates an RR interval to the second. When several intervals carry the same second, the SDK adds 1 ms to each next one, so that every row keeps its own
timestampand the rows stay in order. - The SDK does not store an interval of 5000 or more.
MetricHrv arrives frequently, close to once per second, but only while the wearer is reasonably still. Movement prevents the RR interval from being determined, so gaps in this series are expected and are not a fault.
MetricSleep
One row per sleep-measurement interval, and one row for each marker of the night. 287-2B only.
| Field | Type | Description |
|---|---|---|
timestamp | Long | Time of the record, UTC milliseconds. Key of the row |
date | String | Local date of the timestamp |
sleepState | Int | Sleep stage or marker, see below |
movementLevel | Int? | Movement level during the interval [0-65535]. Added with Corsano sleep (2.2.0) |
activityCount | Int? | Activity count during the interval [0-65535]. Added with Corsano sleep (2.2.0) |
hrm | Int? | Heart rate during the interval [0-255]. Added with Corsano sleep (2.2.0) |
rmssd | Int? | RMSSD (HRV) during the interval [0-255]. Added with Corsano sleep (2.2.0) |
isSynced | Boolean | For the SDK's own use: true once the row was used for a SleepSummaryModel |
quality | Int | Deprecated since Corsano sleep (2.2.0). Always 0 |
Values of sleepState:
| Value | Meaning |
|---|---|
| 0 | No stage |
| 1 | Awake |
| 2 | Light sleep |
| 3 | Deep sleep |
| 4 | REM sleep |
| 101 | Marker: went to bed |
| 102 | Marker: fell asleep |
| 103 | Marker: woke up |
| 104 | Marker: got out of bed |
A value of MetricSleepRepository.SLEEP_MARKER_THRESHOLD (100) or more is a marker, not a stage. The SDK builds a night's summary once the "got out of bed" marker has been downloaded.
When a record arrives with the timestamp of a stored row and a different sleepState, the stored row stays, except that a marker replaces a stage.
From 2.2.0 sleep is computed on the bracelet ("Corsano sleep") and no longer on the phone. This added movementLevel, activityCount, hrm and rmssd to each interval, and deprecated quality. See Sleep processing for the migration.
Sleep monitoring only runs inside the bedtime/risetime window. For how sessions are built and how the summary is produced, see Sleep processing and Sleep Settings.
MetricTemperature
The temperatures of the activity records. The SDK writes these rows from the same download as MetricActivity, with the same timestamps, when the downloaded block holds at least one temperature above 0.
| Field | Type | Description |
|---|---|---|
timestamp | Long | Time of the record, UTC milliseconds. Key of the row |
date | String | Local date of the timestamp |
temp1 | Float? | 287-2B: core body temperature in °C, averaged since the previous raw metric |
temp2 | Float? | 287-1B: skin temperature in °C, averaged. On the 287-2B, skin temperature at night |
tempAmb | Float? | Deprecated: always null. No bracelet file carries an ambient temperature |
isSynced | Boolean | For the SDK's own use. Always false |
- Values come in steps of 0.01 °C. See Temperature resolution and rounding before you display them.
- A value of 0 or below means that the record has no reading. The summaries only count values above 0.
temp1andtemp2mean different things depending on the bracelet. Check the hardware before you interpret them.
MetricTemperatureRaw
The unprocessed heat-flux sensor channels. 287-2B only.
You get these rows when your licence includes raw temperature and raw temperature is enabled on the bracelet with the command SetTemperatureRawPlan. See Raw stream enablement.
| Field | Type | Description |
|---|---|---|
timestamp | Long | Time of the record, UTC milliseconds. Key of the row |
date | String | Local date of the timestamp |
skinTemp | Float? | Skin temperature in °C, resolution 0.01 |
heatFlux | Float? | Heat flux measured by the sensor, resolution 0.02 |
cbt | Float? | Core body temperature in °C, resolution 0.01 |
pulseRate | Int? | Pulse rate recorded alongside the sample [0-255] |
accX | Float? | Accelerometer X, resolution 0.02 |
accY | Float? | Accelerometer Y, resolution 0.02 |
accZ | Float? | Accelerometer Z, resolution 0.02 |
Unlike the other raw metrics, MetricTemperatureRaw has no isSynced field. Its accelerometer axes are Float, whereas MetricPpg uses Int. The repository does not group these rows.
Temperature resolution and rounding
Every temperature the SDK gives you is in degrees Celsius. The bracelet sends each temperature as a whole number of hundredths of a degree (3745 means 37.45 °C). The SDK divides it by 100 and passes it on without rounding. So the raw values come in steps of 0.01 °C.
| Model | Fields | Type | What the SDK gives |
|---|---|---|---|
MetricTemperature | temp1, temp2 | Float? | The bracelet's value, in steps of 0.01 °C |
MetricTemperatureRaw | skinTemp, cbt | Float? | The bracelet's value, in steps of 0.01 °C |
MetricActivity | temp1, temp2 | Double? | The same value as MetricTemperature, but only in the list a metricActivityUpdated listener receives. Not stored |
TemperatureSlotModel | temp1, temp2 | Float | The average of the slot's readings, not rounded. It can have more than two decimals |
TemperatureSummaryModel | average1, average2 | Float | The average of the day's slots, not rounded. It can have more than two decimals |
Follow these rules when you use the values:
- Resolution is not accuracy. The second decimal does not mean that the reading is accurate to 0.01 °C. The accuracy of the device is the one stated in Corsano's technical documentation.
- Do not round at the source. Store, upload and calculate (averages, trends) with the values as the SDK gives them. A calculation on rounded values adds a rounding error.
- Round only for display. For clinical display, round to one decimal (0.1 °C) and round halves upward: 37.45 °C is shown as 37.5 °C, and 37.44 °C as 37.4 °C. The Corsano portal and the Corsano apps do this.
The display rule must be the same in every system that shows the value. Two systems that round 37.45 differently show 37.4 and 37.5 for the same reading. Clinical thresholds, such as the NEWS2 temperature bands, are set in steps of 0.1 °C, so that difference can put the same reading on two sides of a threshold.
Round through BigDecimal, from the value's text:
import java.math.BigDecimal
import java.math.RoundingMode
/** A temperature for display: one decimal, halves rounded upward. */
fun displayTemperature(celsius: Float): BigDecimal =
BigDecimal(celsius.toString()).setScale(1, RoundingMode.HALF_UP)
displayTemperature(37.45f) // 37.5
displayTemperature(37.44f) // 37.4
displayTemperature(37.35f) // 37.4
displayTemperature(38.05f) // 38.1
Do not round the binary value directly. A Float cannot hold every hundredth exactly: 37.35 is stored as 37.349998 and 38.05 as 38.049999. For these, String.format("%.1f", celsius) and Math.round(celsius.toDouble() * 10) / 10.0 give 37.3 and 38.0, where the rule gives 37.4 and 38.1. celsius.toString() gives the decimal value the bracelet sent, which is why the example starts from the text.
Round only real readings. In MetricTemperature, in the temperature slots and in the day averages, a value of 0 or below means "no reading": do not display it as a temperature.
MetricEmography
EmoGraphy, also called EDA or stress data. 287-2B only.
You get these rows when your licence includes PPG2 raw data and EmoGraphy is enabled on the bracelet. See Stress data and Enable EmoGraphy, BioZ & Accelerometer.
| Field | Type | Description |
|---|---|---|
timestamp | Long | Time of the record, UTC milliseconds. Key of the row |
date | String | Local date of the timestamp |
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]: 0 bad, 4 good |
predictiveCZ | Int | Predicted cognitive zone [0-3] |
predictiveCZTransitionTime | Int | Minutes until the predicted transition [0-65535]. Stored since 3.0.0: rows downloaded before the update 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] |
isSynced | Boolean | For the SDK's own use. Always false |
- A record whose values are all 0 is not stored.
- As for
MetricHrv, records that carry the same second get 1 ms added each, so that every row keeps its owntimestamp. - No listener announces these rows.
Manager.metricEdaUpdatedexists, but the SDK does not call it in 3.0.0. Listen toemographySummaryUpdatedinstead and read the rows frommetricEmographyRepositorywhen it fires. See EmographySummaryModel. metricEmographyRepositoryhas nogetByTimestampRangewithgroupedBySeconds.