Bracelet init and setup
To set up the bracelet and the Android SDK here are the main steps to implement:
- Pair and connect to the bracelet
- Set up the bracelet parameters (this page)
- Set up the automatic data transfer from the bracelet to the Android SDK database
- Retrieve the data
Step 2: Set up the bracelet parameters
To get the right data or metrics, the bracelet needs specific settings. Set them before you download data.
There are two groups of settings:
| Settings | Who sends them | When |
|---|---|---|
| Time, plan, sampling rates, raw accelerometer, BioZ / EmoGraphy | The SDK, in the bracelet initialization | Automatically at every connection, once you have called enableAutoInitialization |
| User profile: height, weight, bedtime, rise time, birthdate, gender, wrist, skin tone | Your app, with the commands on this page | After pairing, and whenever the user changes a value. You can also send them after each reconnection |
All commands on this page need a connected and initialized bracelet. Wait for ensureInitialized before you send them:
import com.corsano.sdk.data.util.awaitCommandV2
val device = BleSdk.getInstance().getDevice(address)
val manager = DataSdk.getInstance().getManager()
manager.ensureInitialized(device).onSuccess {
val result: Result<Boolean> = device.awaitCommandV2(SetWeightRequest(72), timeout = 10_000)
}
A Set command returns true when the bracelet acknowledges it. A failure (not connected, not initialized, timeout) arrives as a failed Result, or in onError with the callback style. See BLE SDK for both styles and for the errors.
Bracelet initialization
From SDK 2.0.0
The time, the plan and the sampling rates are set by the bracelet initialization. Your app gives the values once, in the InitializationConfig it passes to enableAutoInitialization.
The initialization replaces these commands, which earlier SDK versions asked you to send. They are deprecated; do not send them yourself:
- SetTimeRequest()
- SetPlanRequest
- SetVitalParameterSamplingRateRequest
- SetEmographyAndBiozPlan
- SetAccelerometerPlan
Set time
The initialization sets the bracelet's clock at every connection: the current UTC time and the time zone offset of the phone. You have nothing to send.
To read the bracelet's clock, use GetTimeRequest(). It returns a Date.
Set bracelet plan
The plan decides what the bracelet measures and how long its battery lasts. See Bracelet Plans.
- Set it with
InitializationConfig.braceletPlan. - Change it later with
updateConfiguration, see Bracelet Initialization. - Read it with
GetPlanRequest(). It returnsGetPlanRequest.Response(devicePlan, ppg2Frequency, sampleRateV1), ornullwhen the bracelet reports a plan the SDK does not know.
Set sampling rate
The sampling rate is how often the bracelet stores a value of a vital parameter. See Sampling rate.
- Set the rates with
InitializationConfig: oneSampleRatefor all parameters, or one each for activity, pulse rate, respiration rate, SpO2 and temperature. NIBP is on (every 30 minutes) or off withisNibpEnabled. - Change them later with
updateConfiguration. - Read one with
GetVitalParameterSamplingRateRequest(type), wheretypeis aVitalParameterWithSamplingRateType:ACTIVITY,PULSE_RATE,RESPIRATION_RATE,SPO2,TEMPERATUREorNIBP. ReadsamplingRatefrom the object it returns. It returnsnullwhen the bracelet reports a rate that is not aSampleRatevalue.
User Profile
It is important to set the user profile (height, weight, birthdate, gender, wrist, skin tone): it is sent to the bracelet and used in its calculations.
| Value | Set | Get | Unit / values |
|---|---|---|---|
| Weight | SetWeightRequest(weight) | GetWeightRequest() returns Int | kg, 0 to 255 |
| Height | SetHeightRequest(height) | GetHeightRequest() returns Int | cm, 0 to 255 |
| Bedtime | SetBedtimeRequest(bedtimeGmt) | GetBedtimeRequest() returns HourMinuteRecord | Hour and minute in GMT |
| Rise time | SetRisetimeRequest(risetimeGmt) | GetRisetimeRequest() returns HourMinuteRecord | Hour and minute in GMT |
| Birthdate, gender, wrist, skin tone | SetUserProfileRequest(userProfile) | GetUserProfileRequest() returns UserProfileGetRecord; GetBirthdayRequest() returns the birthdate | See below |
Weight / Height
Use the following commands:
SetHeightRequest(height)
SetWeightRequest(weight)
Weight in kg
Height in cm
Both take an Int from 0 to 255. A value outside this range throws IllegalArgumentException when you create the request. If you use named arguments, read the warning about SetHeightRequest in BLE commands.
Get commands are available as well, if necessary:
GetWeightRequest()
GetHeightRequest()
Bedtime / risetime
The sleep monitoring uses the bracelet battery, and to avoid a high consumption, the sleep is not monitored all day long. This is why it is important to set a theoretical bedtime and risetime to the bracelet. Sleep Settings describes when the bracelet monitors sleep around these two times.
SET Bedtime / risetime
SetBedtimeRequest(bedtimeGmt)
SetRisetimeRequest(risetimeGmt)
These commands use the following structure
data class HourMinuteRecord(val hour: Int, val minute: Int)
Pass the time in GMT time, not in the user's local time.
Example: user in France, GMT+1
- 7:00 risetime local time: send 6:00 to the bracelet
- 22:30 bedtime local time: send 21:30 to the bracelet
Example 2: user in Iran, GMT+3:30
- 7:00 risetime local time: send 03:30 to the bracelet
- 22:30 bedtime local time: send 19:00 to the bracelet
To transform a local time to GMT, you can use the function transformToGmtTime():
import com.corsano.sdk.ble.command.enqueueCommand
val bedtimeGmt = HourMinuteRecord(22, 30).transformToGmtTime()
val risetimeGmt = HourMinuteRecord(7, 0).transformToGmtTime()
device.enqueueCommand(
request = SetBedtimeRequest(bedtimeGmt),
onSuccess = { acknowledged -> Log.d("Corsano-SDK", "Bedtime set: $acknowledged") },
onError = { error -> Log.e("Corsano-SDK", "Bedtime not set: $error") }
)
transformToGmtTime() subtracts the standard offset of the phone's time zone. It does not take daylight saving time into account.
Full code sample in the sample app file:
UserProfileFragment.kt
Get Bedtime / risetime
Get commands are available as well, if necessary:
GetBedtimeRequest()
GetRisetimeRequest()
Both return an HourMinuteRecord in GMT. transformToLocalTime() gives the local time (it adds the same standard offset).
Full code sample in the sample app file:
UserProfileFragment.kt
Profile: birthdate / gender / wrist / skin tone
SET profile
The bracelet needs to be initialised with the user's profile:
- Birthdate and gender: used mostly for the activity data (steps, workout)
- Wrist: is mandatory for every metric
- Skin tone: based on the Fitzpatrick scale (1 to 6), important for every metric
Please use the UserProfileSetRecord, here is an example:
device.enqueueCommand(
request = SetUserProfileRequest(
UserProfileSetRecord(1960, 1, 22, Gender.MALE, Wrist.LEFT, SkinType.FAIR)
),
onSuccess = { acknowledged -> Log.d("Corsano-SDK", "Profile set: $acknowledged") },
onError = { error -> Log.e("Corsano-SDK", "Profile not set: $error") }
)
data class UserProfileSetRecord(
val birthdayYear: Int,
val birthdayMonth: Int, // 1 = January
val birthdayDay: Int,
val gender: Gender,
val wrist: Wrist,
val skinType: SkinType? = null
)
The SDK computes the age from the birthdate and sends both to the bracelet.
GET profile
device.enqueueCommand(
request = GetUserProfileRequest(),
onSuccess = { profile -> Log.d("Corsano-SDK", "Profile: $profile") },
onError = { error -> Log.e("Corsano-SDK", "Profile not read: $error") }
)
Return object:
data class UserProfileGetRecord(
val age: Int,
val gender: Gender,
val wrist: Wrist,
val skinType: SkinType? = null
)
You set a birthdate but you get an age. To read the birthdate back, use GetBirthdayRequest(). It returns GetBirthdayRequest.Response(year, month, day).
skinType is null when the bracelet does not report a skin type.
Data types
public final enum class Gender : kotlin.Enum<com.corsano.sdk.ble.data.Gender> {
MALE,
FEMALE,
UNSPECIFIED;
}
public final enum class Wrist : kotlin.Enum<com.corsano.sdk.ble.data.Wrist> {
LEFT,
RIGHT;
}
public final enum class SkinType : kotlin.Enum<com.corsano.sdk.ble.data.SkinType> {
VERY_FAIR,
FAIR,
OLIVE,
LIGHT_BROWN,
BROWN,
BLACK_BROWN;
}
- VERY_FAIR = Fitzpatrick 1
- FAIR = Fitzpatrick 2
- OLIVE = Fitzpatrick 3
- LIGHT_BROWN = Fitzpatrick 4
- BROWN = Fitzpatrick 5
- BLACK_BROWN = Fitzpatrick 6
Full code sample in the sample app files:
UserProfileFragment.ktandUserProfileViewModel.kt
Wearing optimization
Moved to its own page: Wearing Optimization.
Sleep settings
Moved to its own page: Sleep Settings.
PPG2 / BioZ / Accelerometer / ECG transfer & export
Moved to its own page: Raw File Transfer & Export.
ECG Measurement
Documented on the ECG measurement page.
Next step: set up the automatic data transfer