BLE commands
A command is a single request/response exchange with the bracelet. You build a request object, enqueue it on a connected BleDevice, and receive a typed result.
This page is the command reference. For how commands are executed, queued and timed out, and how errors surface, see BLE SDK.
DeviceManager in these examples is a sample-app helper, not SDK API. See Pairing for what to use instead.
Sending a command
Callback style:
DeviceManager.getCurrentDevice()?.enqueueCommand(
request = ResetWatchRequest(),
onSuccess = { Log.d("Corsano-SDK", "Reset successful, the bracelet will restart") },
onError = { Log.e("Corsano-SDK", "Reset error $it") }
)
Coroutine style (recommended, see BLE SDK):
val bleDevice = BleSdk.getInstance().getDevice(address)
val result: Result<Boolean> = bleDevice.awaitCommandV2(ResetWatchRequest(), timeout = 10_000)
The result arrives in onSuccess or in the returned Result. An error arrives in onError or as a failed Result.
Sample app: DataOthersFragment.kt in the sample module (sdk/sample/src/main/java/com/corsano/sdk/sample/screens/data/tabs/) drives reset, shutdown, erase-all, battery, bracelet status and the LED test from buttons. It is the closest thing to a command playground.
Initialization required
From SDK 2.0.0, a command sent to a connected but not-yet-initialized bracelet is rejected with NotInitializedException. Almost every command on this page requires the bracelet to be initialized first. Enable auto-initialization at startup, or initialize the device after connecting, see Bracelet Initialization. The exceptions are the commands that make up the initialization sequence itself, which set requiresInitialization = false.
The tables below have a column Init. "Yes" means that the command needs an initialized bracelet. "No" means that it also runs before initialization. Every command needs a connected and bonded bracelet; until then it waits in the queue.
The requests that run without initialization are: SetTimeRequest, GetFwVersionRequest, GetAuthenticationRequest, SetAuthenticationRequest, GetPlanRequest, SetPlanRequest, GetVitalParameterSamplingRateRequest, SetVitalParameterSamplingRateRequest, GetAccelerometerPlan, SetAccelerometerPlan, GetEmoGraphyAndBiozPlan and SetEmographyAndBiozPlan.
Return value conventions
Three conventions run through the whole command set, and they are worth knowing before reading the tables:
- Set commands return
Boolean. The bracelet acknowledges with the value100, which the SDK maps totrue. Afalsemeans the bracelet replied but did not acknowledge. It is not an error andonErrorwill not fire. - Some Get commands return a nullable type.
GetPlanRequest,GetSessionStatusRequest,GetVitalParameterSamplingRateRequestand the raw stream getters returnnullwhen the bracelet's reply holds a value the SDK does not know, or answers about a different parameter than the one asked for. Treatnullas "no usable answer", not as an error.GetBraceletStatusRequestis declared nullable too, but in SDK 3.0.0 it never returnsnull. - A failed command surfaces through
onError/ a failedResult, never as afalseornull. The errors are listed in BLE SDK.
Requests that take a single number (SetHeightRequest, SetWeightRequest, SetRealTimePingPeriodRequest) accept 0..255. Anything outside that range throws IllegalArgumentException when the request is constructed, before it reaches the bracelet.
Device information
| Request | Returns | Init | Notes |
|---|---|---|---|
GetFwVersionRequest() | FirmwareVersion | No | major, minor, text (for example "9.50"). See DFU SDK |
GetHwIdRequest() | HardwareId | Yes | HardwareId.UNKNOWN for an id the SDK does not know |
GetModelIdRequest() | Int | Yes | |
GetSerialNumberRequest() | String | Yes | |
GetBrandRequest() | String | Yes | |
GetDeviceNameRequest() | String | Yes | |
GetBatteryLevelRequest() | BatteryLevel | Yes | See below |
GetActiveModeRequest() | DeviceMode | Yes | Fails with InvalidCommandResponseException for a mode the SDK does not know |
GetBraceletStatusRequest() | Response? | Yes | Wearing, charging and motion state. See below |
GetSessionStatusRequest() | Response? | Yes | Status of the bracelet's sleep session. See below |
BatteryLevel
data class BatteryLevel(
val level: Int, // percentage, 0 to 100
val voltage: Int,
val isCharging: Boolean
)
| Field | Description |
|---|---|
level | Battery level in percent, 0 to 100 |
voltage | The battery voltage as the bracelet sends it. The charger ping carries the same value as voltageMillivolts |
isCharging | true while the bracelet is on the charger, also when the battery is already full |
From SDK 3.0.0 the request fails with CommandResponseValidationException when the bracelet reports a level above 100. No BatteryLevel comes back in that case. Before, it returned the impossible percentage.
Sample app: DataOthersFragment.kt, and DeviceImpl.kt which reads it after each connection to keep the device model up to date.
GetBraceletStatusRequest.Response
Wearing, charging and motion state in one call.
data class Response(
val wearingState: Int, // 0..4. 0 = not wearing, 4 = good wearing.
// 0, 1 and 2 are worth warning the user about.
val modeState: Int, // 1 = sleep-idle mode to save battery, 0 = active
val batteryPercentage: Int,
val isCharging: Boolean,
val idleState: Int, // 0..4. 0 = completely still, 4 = in motion.
val wearingQuality: Int? = null
)
wearingQuality is the quality of wearing during the last night:
| Value | Meaning |
|---|---|
| 0 to 100 | The quality. Higher is better |
| 101 | The sleep is still running |
| 102 | The analysis is in progress |
| 103 | Not enough data |
null | The bracelet's reply does not carry the value |
This is not the quality of a wearing optimization. For that one, see Wearing Optimization.
A reply that is too short fails with InvalidCommandResponseException.
Sample app: DataOthersFragment.kt.
GetSessionStatusRequest.Response
The request asks for the sleep session.
data class Response(
val mode: Int,
val sessionNumber: Int,
val startTime: Int,
val durationSecs: Int,
val status: SessionStatus // NOT_STARTED, ON_GOING, FINISHED
)
Returns null when the bracelet reports a status that is not one of the three SessionStatus values.
DeviceMode
Returned by GetActiveModeRequest.
enum class DeviceMode(val id: Int) {
SHIPPING(0), POWER_SAVING(1), HRM(2), SLEEP_TRACKING(3),
PREVENTICUS(4), PREVENTICUS_SLEEP(5), WORKOUT(6),
NORMAL(7), CHARGING(8), MAX_BATTERY(9)
}
HardwareId
Returned by GetHwIdRequest. See DFU SDK for the values and which bracelets are supported.
Time
| Request | Parameters | Returns | Init | Notes |
|---|---|---|---|---|
GetTimeRequest() | None | Date | Yes | The bracelet's clock |
SetTimeRequest() | None | Boolean | No | Deprecated: the bracelet initialization sends it |
GetBedtimeRequest() | None | HourMinuteRecord | Yes | GMT |
GetRisetimeRequest() | None | HourMinuteRecord | Yes | GMT |
SetBedtimeRequest(bedtimeRecord) | bedtimeRecord: HourMinuteRecord | Boolean | Yes | GMT |
SetRisetimeRequest(risetimeRecord) | risetimeRecord: HourMinuteRecord | Boolean | Yes | GMT |
SetTimeRequest takes no parameter. It writes the phone's current time (UTC) and the phone's time zone offset to the bracelet.
Bedtime and risetime are GMT, and they gate sleep monitoring. See Setup bracelet for the conversion and Sleep Settings.
data class HourMinuteRecord(val hour: Int, val minute: Int)
Sample app: UserProfileViewModel.kt sends the bedtime and the risetime; DataOthersFragment.kt reads them.
User profile
| Request | Parameters | Returns | Init |
|---|---|---|---|
GetUserProfileRequest() | None | UserProfileGetRecord | Yes |
SetUserProfileRequest(userProfile) | userProfile: UserProfileSetRecord | Boolean | Yes |
GetBirthdayRequest() | None | Response | Yes |
GetHeightRequest() | None | Int (cm) | Yes |
SetHeightRequest(weight) | weight: Int, which is the height in cm, see the warning below | Boolean | Yes |
GetWeightRequest() | None | Int (kg) | Yes |
SetWeightRequest(weight) | weight: Int (kg) | Boolean | Yes |
data class UserProfileSetRecord(
val birthdayYear: Int,
val birthdayMonth: Int, // 1 = January
val birthdayDay: Int,
val gender: Gender, // MALE, FEMALE, UNSPECIFIED
val wrist: Wrist, // LEFT, RIGHT
val skinType: SkinType? = null
)
data class UserProfileGetRecord(
val age: Int,
val gender: Gender,
val wrist: Wrist,
val skinType: SkinType? = null
)
Note the asymmetry: you set a birthdate but get an age.
GetBirthdayRequest returns Response(year, month, day).
Height and weight go through a shared base that requires the value to be in 0..255. Passing anything outside that range throws IllegalArgumentException when the request is constructed, before it ever reaches the bracelet.
SetHeightRequest's constructor parameter is named weight, not height. This is a naming slip in the SDK. It does set the height. If you use named arguments you have to write SetHeightRequest(weight = 180); positional arguments are unaffected.
Skin type and wrist matter for measurement accuracy, see Wearing Optimization. The walkthrough with the SkinType values is in Setup bracelet.
Sample app: UserProfileViewModel.kt.
Plan and sampling rate
| Request | Parameters | Returns | Init | Notes |
|---|---|---|---|---|
GetPlanRequest() | None | Response? | No | |
SetPlanRequest(plan, ppg2Frequency, sampleRateV1) | See below | Boolean | No | Deprecated: the bracelet initialization sends it |
GetVitalParameterSamplingRateRequest(type) | type: VitalParameterWithSamplingRateType | SetVitalParameterSamplingRateRequest? | No | |
SetVitalParameterSamplingRateRequest(type, samplingRate) | type, samplingRate: SampleRate | Boolean | No | Deprecated: the bracelet initialization sends it |
To set or change the plan and the sampling rates, use enableAutoInitialization and updateConfiguration, see Bracelet Initialization. The SDK stores the configuration and applies it again at every connection; a plan you set with SetPlanRequest yourself is replaced at the next initialization.
SetPlanRequest
class SetPlanRequest(
val plan: DevicePlan,
val ppg2Frequency: Ppg2Frequency = Ppg2Frequency.THIRTY_TWO_HZ,
val sampleRateV1: Int = 60 // only used by FW < 5.67
)
| Parameter | Type | Default | Description |
|---|---|---|---|
plan | DevicePlan | (required) | The measurement plan. See Bracelet Plans |
ppg2Frequency | Ppg2Frequency | THIRTY_TWO_HZ | PPG2 sampling frequency. B2 only |
sampleRateV1 | Int | 60 | Legacy sampling rate, only honoured by firmware older than 5.67 |
bleDevice.enqueueCommand(
request = SetPlanRequest(DevicePlan.HOSPITAL_MULTICOLOR),
onSuccess = { Log.d("Corsano-SDK", "Plan set: $it") },
onError = { Log.e("Corsano-SDK", "SetPlanRequest error: $it") }
)
GetPlanRequest returns Response(devicePlan, ppg2Frequency, sampleRateV1), all but the first nullable, or null if the bracelet reports a plan the SDK does not know.
Sample app: DataStartFragment.kt reads the plan and the sampling rates.
Sampling rates
GetVitalParameterSamplingRateRequest has an unusual signature: it returns a SetVitalParameterSamplingRateRequest (the setter object) rather than a plain value. Read .type and .samplingRate off it. It returns null if the bracelet answers about a different parameter, or reports a rate that does not correspond to a known SampleRate.
enum class VitalParameterWithSamplingRateType {
ACTIVITY, PULSE_RATE, RESPIRATION_RATE, SPO2, TEMPERATURE, NIBP
}
enum class SampleRate(val rateSecs: Int, val friendlyName: String) {
OFF(0, "OFF"),
THIRTY_SECS(30, "1/30 secs"),
ONE_MIN(60, "1/minute"),
FIVE_MIN(5 * 60, "1/5 minutes"),
THIRTY_MIN(30 * 60, "1/30 minutes")
}
See Set Sampling rate.
Raw stream enablement
These control whether EmoGraphy, BioZ, accelerometer and raw temperature are recorded. All of them are VitalParameterWatchType variants of the same underlying pair of commands.
| Request | Parameters | Returns | Init | Notes |
|---|---|---|---|---|
GetEmoGraphyAndBiozPlan() | None | VitalParametersRequest? | No | param1 is EmoGraphy, param2 is BioZ |
SetEmographyAndBiozPlan(emographyValue, biozValue) | Two VitalParameterValue | Boolean | No | Deprecated: the bracelet initialization sends it |
GetAccelerometerPlan() | None | VitalParametersRequest? | No | param1 is the accelerometer |
SetAccelerometerPlan(value) | value: VitalParameterValue | Boolean | No | Deprecated: the bracelet initialization sends it |
GetTemperatureRawPlan() | None | VitalParametersRequest? | Yes | param1 is the raw temperature |
SetTemperatureRawPlan(value) | value: VitalParameterValue | Boolean | Yes | Not part of the bracelet initialization: send it yourself |
enum class VitalParameterValue { DISABLE, CONTINUOUS, BEDTIME_RISETIME, UNKNOWN }
data class VitalParametersRequest(
val type: VitalParameterWatchType, // ACCELEROMETER, BIOZ, TEMPERATURE_RAW, UNKNOWN
val param1: VitalParameterValue,
val param2: VitalParameterValue?
)
The getters return null when the bracelet replies about a different parameter than the one requested.
Full walkthrough: Enable EmoGraphy, BioZ & Accelerometer.
Files
| Request | Parameters | Returns | Init |
|---|---|---|---|
GetFileSizeRequest(file) | file: FileOnWatch | FileSize | Yes |
EraseFileRequest(file, size) | file: FileOnWatch, size: Long (bytes to erase) | Boolean | Yes |
EraseFileRequest(fileSize) | fileSize: FileSize | Boolean | Yes |
EraseAllRequest() | None | Boolean | Yes |
FileOnWatch values:
| Value | Content | Record size |
|---|---|---|
ACTIVITY | Activity | 38 bytes |
PPG | PPG (green) | 256 bytes |
PPG2 | Raw PPG2 (multicolor) | Raw file |
HRV | HRV | 7 bytes |
SLEEP | Sleep | Raw file |
CORSANO_SLEEP | Sleep computed on the bracelet ("Corsano sleep", from SDK 2.2.0) | 16 bytes |
ECG | Raw ECG | Raw file |
BIOZ | Raw BioZ | Raw file |
ACC_FILE | Raw accelerometer | Raw file |
STRESS_FILE | EmoGraphy | 18 bytes |
GREENTEG | Raw temperature | 15 bytes |
WORKOUT | Workout | 40 bytes |
LOGS | Bracelet logs | Text lines |
NIBP | Long-term NIBP file. From SDK 3.0.0. No download includes it unless you ask for it | 60 bytes |
FileOnWatch and CommandId get new values in new SDK versions (FileOnWatch.NIBP and more CommandId values in 3.0.0). A Kotlin when over them without an else branch stops compiling, so add an else branch.
FileSize
class FileSize(val file: FileOnWatch, val sizeInBytes: Long) {
fun getCapacity(hardwareId: HardwareId): Double?
}
getCapacity gives how full the file is as a percentage: 0.0 when empty, 100.0 when full, and null when not applicable, for instance PPG2 on a B1, which has no such file. It returns a Double, so format it before displaying.
bleDevice.enqueueCommand(
request = GetFileSizeRequest(FileOnWatch.ACTIVITY),
onSuccess = {
val hardwareId = DeviceManager.getCurrentDevice()?.deviceInfo?.hardwareId ?: HardwareId.UNKNOWN
Log.d("Corsano-SDK", "File size $it and capacity ${it.getCapacity(hardwareId)}")
},
onError = { }
)
EraseFileRequest erases size bytes from the file. size must be between 0 and 4 294 967 295, otherwise the constructor throws IllegalArgumentException.
EraseAllRequest erases every data file on the bracelet: activity, sleep, hrv, ppg and the rest.
Sample app: DataActivityFragment.kt and DataMeasurementFragment.kt for file size; DataOthersFragment.kt for erase-all.
In normal use you do not send file commands yourself. The automatic file transfer reads and erases files for you.
Measurements
Each of these has a dedicated page that covers the full sequence. The commands are listed here only for completeness. All of them need an initialized bracelet.
| Request | Returns | Documented in |
|---|---|---|
StartEcgMeasurement() | Boolean | ECG (B2 only) |
StopEcgMeasurement() | Boolean | ECG |
StartNibpCalibrationMeasurement() | Boolean | NIBP |
StopNibpCalibrationMeasurement() | Boolean | NIBP |
ResetNibpCalibrationRequest() | Boolean | NIBP |
GetNibpTrainingInfoRequest() | Response(engineStatus, modelStatus) | NIBP |
SetBpCuffCalibrationRequest(timestamp, sys, dia, pulseRate) | SetBpCuffCalibrationRequestModel(timestamp, accuracyShortTerm, accuracyLongTerm) | NIBP |
StartWearingOptimizationMeasurement() | Boolean | Wearing Optimization |
StopWearingOptimizationMeasurement() | Boolean | Wearing Optimization |
GetWearingOptimizationStatusRequest() | Response(isFinished, progressPercent, movementLevel, quality, isSuccess) | Wearing Optimization |
GetSp02StatsRequest() | Response(woRequired, goodSp02PercentAtNight, nbSp02AtNight, goodSp02PercentDuringDay, nbSp02DuringDay) | Wearing Optimization |
StartSpotMeasurementCmd() | Boolean | SpO2 spot measurement |
SetSpotMeasurementRequest(value) | Boolean | SpO2 spot measurement. value: Int is the SpO2 value in percent. From firmware 7.30 |
Prefer the managers (EcgManager, NibpCalibrationManager, WearingOptimizationManager, SpotMeasurementManager) over sending these commands directly. You get them from DataSdk.getInstance().getManager() with getEcgManager(), getNibpCalibrationManager(), getWearingOptimizationManager() and getSpotMeasurementManager(). They handle the ordering, retries and database writes that a raw command sequence does not.
Notes on single commands:
GetNibpTrainingInfoRequest: a firmware without this command does not answer. From SDK 3.0.0 the request then fails with its timeout (15 seconds) and the connection is kept. Before, the SDK disconnected and reconnected the bracelet.GetSp02StatsRequest: fixed in SDK 3.0.0. Before, it read the wearing optimization status instead of the SpO2 statistics.- When the SDK is locked by its licence check,
StopEcgMeasurement,StopWearingOptimizationMeasurementandStopNibpCalibrationMeasurementare still sent, so that a running measurement can be ended. Every other command fails withSdkLicenceException. See Licence Key.
Sleep
| Request | Parameters | Returns | Init |
|---|---|---|---|
SetStopSleepRequest() | None | Int | Yes |
Stops the current sleep session early. This one returns an Int, not the Boolean that Set commands normally return, because it is built on the raw single-byte base class.
See Sleep Settings.
Real-time ping
B2 only.
| Request | Parameters | Returns | Init |
|---|---|---|---|
GetRealTimeEnabledRequest() | None | Boolean | Yes |
SetRealTimePingEnableRequest(value) | value: Boolean | Boolean | Yes |
GetRealTimePeriodRequest() | None | Int (seconds) | Yes |
SetRealTimePingPeriodRequest(periodSecs) | periodSecs: Int | Boolean | Yes |
Real-time pings push live vitals without the app asking. The pings themselves arrive as notifications, see Instant data.
SetRealTimePingPeriodRequest shares the 0..255 constraint described under User profile; a period outside that range throws IllegalArgumentException at construction.
Sample app: DataStartFragment.kt.
Authentication
From SDK 2.0.0. FW 8.48 requires the connection to be authenticated before it will act on commands; the initialization sequence runs the authentication step when the bracelet reports firmware 8.41 or later, and skips it for older firmware. So you rarely send these directly. See Firmware authentication.
| Request | Command | Parameters | Returns | Init |
|---|---|---|---|---|
SetAuthenticationRequest(phoneId) | 250 | phoneId: String (pass Settings.Secure.ANDROID_ID) | Boolean | No |
GetAuthenticationRequest() | 251 | None | Boolean | No |
Device actions
| Request | Parameters | Returns | Init |
|---|---|---|---|
ResetWatchRequest() | None | Boolean | Yes |
ShutdownWatchRequest() | None | Boolean | Yes |
LedTestWatchRequestV2(ledNumber, blinking, durationSecs) | See below | Boolean | Yes |
Led1TestWatchRequest() | None | Boolean | Yes |
Led2TestWatchRequest() | None | Boolean | Yes |
Reset
Restarts the firmware. The LEDs turn off, then on.
Resend your setup commands after a reset: time, user profile and bracelet plan. The firmware may restore them itself, but it does not always, so do not rely on it. The time and the plan are sent by the bracelet initialization at the next connection; send the user profile yourself.
Shutdown
Turns the bracelet off. It stops measuring and disappears from scans, since it no longer advertises over BLE. Connecting the charger brings it back, and its LEDs turn on when it restarts.
LED test
Turns on an LED on the side of the bracelet for a few seconds.
LedTestWatchRequestV2, from SDK 1.1.5 and FW 6.87:
| Parameter | Type | Description |
|---|---|---|
ledNumber | Int | 0 = green, 1 = orange, 2 = blue |
blinking | Boolean | true to blink, false for continuous |
durationSecs | Int | Duration in seconds, 0 to 255 |
Led1TestWatchRequest and Led2TestWatchRequest are the older, parameterless equivalents. The sample app uses LedTestWatchRequestV2 for a 287-2B with firmware 6.87 or later, and the older requests otherwise.
Sample app: DataOthersFragment.kt for the LED test, reset and shutdown.
File transfer requests
File transfers are enqueued with enqueueFileTransfer (or awaitFileTransferV2) rather than enqueueCommand, and each takes the number of bytes to read, which you get from GetFileSizeRequest. All of them need an initialized bracelet. See BLE SDK.
| Request | Returns |
|---|---|
ActivityFileTransferRequest(sizeInBytes) | StructFileData<ActivityDataRecord> |
PpgFileTransferRequest(sizeInBytes) | StructFileData<PpgChunk> |
HrvFileTransferRequest(sizeInBytes) | StructFileData<HrvDataRecord> |
EmographyFileTransferRequest(sizeInBytes) | StructFileData<EmographyDataRecord> |
TemperatureRawFileTransferRequest(sizeInBytes) | StructFileData<TemperatureRawDataRecord> |
CorsanoSleepFileTransferRequest(sizeInBytes) | StructFileData<CorsanoSleepDataRecord> |
WorkoutFileTransferRequest(sizeInBytes) | StructFileData<WorkoutDataRecord> |
LogFileTransferRequest(size) | StructFileData<String> |
Ppg2FileTransferRequest(size) | ByteArray |
AccFileTransferRequest(size) | ByteArray |
BiozFileTransferRequest(size) | ByteArray |
EcgFileTransferRequest(size) | ByteArray |
SleepFileTransferRequest(size) | ByteArray |
data class StructFileData<T>(
val items: List<T>,
val totalBytes: Int,
val processedBytes: Int
)
items are the decoded records, totalBytes the bytes read from the bracelet and processedBytes the bytes that were decoded. If you erase the file yourself, erase processedBytes bytes: the bytes after them were not decoded and must stay on the bracelet for the next transfer.
From SDK 3.0.0 the transfers of the activity, HRV, EmoGraphy, raw temperature, Corsano sleep and workout files do not return a record dated before 2021-01-01 or more than 10 minutes after the phone's clock.
The transfers returning ByteArray deliver raw .wiff content, which the SDK writes to disk. To decode it into samples, see Parsing Raw Files.