Skip to main content

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.

note

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​

warning

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 value 100, which the SDK maps to true. A false means the bracelet replied but did not acknowledge. It is not an error and onError will not fire.
  • Some Get commands return a nullable type. GetPlanRequest, GetSessionStatusRequest, GetVitalParameterSamplingRateRequest and the raw stream getters return null when the bracelet's reply holds a value the SDK does not know, or answers about a different parameter than the one asked for. Treat null as "no usable answer", not as an error. GetBraceletStatusRequest is declared nullable too, but in SDK 3.0.0 it never returns null.
  • A failed command surfaces through onError / a failed Result, never as a false or null. 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​

RequestReturnsInitNotes
GetFwVersionRequest()FirmwareVersionNomajor, minor, text (for example "9.50"). See DFU SDK
GetHwIdRequest()HardwareIdYesHardwareId.UNKNOWN for an id the SDK does not know
GetModelIdRequest()IntYes
GetSerialNumberRequest()StringYes
GetBrandRequest()StringYes
GetDeviceNameRequest()StringYes
GetBatteryLevelRequest()BatteryLevelYesSee below
GetActiveModeRequest()DeviceModeYesFails with InvalidCommandResponseException for a mode the SDK does not know
GetBraceletStatusRequest()Response?YesWearing, charging and motion state. See below
GetSessionStatusRequest()Response?YesStatus 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
)
FieldDescription
levelBattery level in percent, 0 to 100
voltageThe battery voltage as the bracelet sends it. The charger ping carries the same value as voltageMillivolts
isChargingtrue 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:

ValueMeaning
0 to 100The quality. Higher is better
101The sleep is still running
102The analysis is in progress
103Not enough data
nullThe 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​

RequestParametersReturnsInitNotes
GetTimeRequest()NoneDateYesThe bracelet's clock
SetTimeRequest()NoneBooleanNoDeprecated: the bracelet initialization sends it
GetBedtimeRequest()NoneHourMinuteRecordYesGMT
GetRisetimeRequest()NoneHourMinuteRecordYesGMT
SetBedtimeRequest(bedtimeRecord)bedtimeRecord: HourMinuteRecordBooleanYesGMT
SetRisetimeRequest(risetimeRecord)risetimeRecord: HourMinuteRecordBooleanYesGMT

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​

RequestParametersReturnsInit
GetUserProfileRequest()NoneUserProfileGetRecordYes
SetUserProfileRequest(userProfile)userProfile: UserProfileSetRecordBooleanYes
GetBirthdayRequest()NoneResponseYes
GetHeightRequest()NoneInt (cm)Yes
SetHeightRequest(weight)weight: Int, which is the height in cm, see the warning belowBooleanYes
GetWeightRequest()NoneInt (kg)Yes
SetWeightRequest(weight)weight: Int (kg)BooleanYes
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).

note

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.

warning

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​

RequestParametersReturnsInitNotes
GetPlanRequest()NoneResponse?No
SetPlanRequest(plan, ppg2Frequency, sampleRateV1)See belowBooleanNoDeprecated: the bracelet initialization sends it
GetVitalParameterSamplingRateRequest(type)type: VitalParameterWithSamplingRateTypeSetVitalParameterSamplingRateRequest?No
SetVitalParameterSamplingRateRequest(type, samplingRate)type, samplingRate: SampleRateBooleanNoDeprecated: 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
)
ParameterTypeDefaultDescription
planDevicePlan(required)The measurement plan. See Bracelet Plans
ppg2FrequencyPpg2FrequencyTHIRTY_TWO_HZPPG2 sampling frequency. B2 only
sampleRateV1Int60Legacy 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.

RequestParametersReturnsInitNotes
GetEmoGraphyAndBiozPlan()NoneVitalParametersRequest?Noparam1 is EmoGraphy, param2 is BioZ
SetEmographyAndBiozPlan(emographyValue, biozValue)Two VitalParameterValueBooleanNoDeprecated: the bracelet initialization sends it
GetAccelerometerPlan()NoneVitalParametersRequest?Noparam1 is the accelerometer
SetAccelerometerPlan(value)value: VitalParameterValueBooleanNoDeprecated: the bracelet initialization sends it
GetTemperatureRawPlan()NoneVitalParametersRequest?Yesparam1 is the raw temperature
SetTemperatureRawPlan(value)value: VitalParameterValueBooleanYesNot 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​

RequestParametersReturnsInit
GetFileSizeRequest(file)file: FileOnWatchFileSizeYes
EraseFileRequest(file, size)file: FileOnWatch, size: Long (bytes to erase)BooleanYes
EraseFileRequest(fileSize)fileSize: FileSizeBooleanYes
EraseAllRequest()NoneBooleanYes

FileOnWatch values:

ValueContentRecord size
ACTIVITYActivity38 bytes
PPGPPG (green)256 bytes
PPG2Raw PPG2 (multicolor)Raw file
HRVHRV7 bytes
SLEEPSleepRaw file
CORSANO_SLEEPSleep computed on the bracelet ("Corsano sleep", from SDK 2.2.0)16 bytes
ECGRaw ECGRaw file
BIOZRaw BioZRaw file
ACC_FILERaw accelerometerRaw file
STRESS_FILEEmoGraphy18 bytes
GREENTEGRaw temperature15 bytes
WORKOUTWorkout40 bytes
LOGSBracelet logsText lines
NIBPLong-term NIBP file. From SDK 3.0.0. No download includes it unless you ask for it60 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.

note

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.

RequestReturnsDocumented in
StartEcgMeasurement()BooleanECG (B2 only)
StopEcgMeasurement()BooleanECG
StartNibpCalibrationMeasurement()BooleanNIBP
StopNibpCalibrationMeasurement()BooleanNIBP
ResetNibpCalibrationRequest()BooleanNIBP
GetNibpTrainingInfoRequest()Response(engineStatus, modelStatus)NIBP
SetBpCuffCalibrationRequest(timestamp, sys, dia, pulseRate)SetBpCuffCalibrationRequestModel(timestamp, accuracyShortTerm, accuracyLongTerm)NIBP
StartWearingOptimizationMeasurement()BooleanWearing Optimization
StopWearingOptimizationMeasurement()BooleanWearing Optimization
GetWearingOptimizationStatusRequest()Response(isFinished, progressPercent, movementLevel, quality, isSuccess)Wearing Optimization
GetSp02StatsRequest()Response(woRequired, goodSp02PercentAtNight, nbSp02AtNight, goodSp02PercentDuringDay, nbSp02DuringDay)Wearing Optimization
StartSpotMeasurementCmd()BooleanSpO2 spot measurement
SetSpotMeasurementRequest(value)BooleanSpO2 spot measurement. value: Int is the SpO2 value in percent. From firmware 7.30
note

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, StopWearingOptimizationMeasurement and StopNibpCalibrationMeasurement are still sent, so that a running measurement can be ended. Every other command fails with SdkLicenceException. See Licence Key.

Sleep​

RequestParametersReturnsInit
SetStopSleepRequest()NoneIntYes

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.

RequestParametersReturnsInit
GetRealTimeEnabledRequest()NoneBooleanYes
SetRealTimePingEnableRequest(value)value: BooleanBooleanYes
GetRealTimePeriodRequest()NoneInt (seconds)Yes
SetRealTimePingPeriodRequest(periodSecs)periodSecs: IntBooleanYes

Real-time pings push live vitals without the app asking. The pings themselves arrive as notifications, see Instant data.

note

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.

RequestCommandParametersReturnsInit
SetAuthenticationRequest(phoneId)250phoneId: String (pass Settings.Secure.ANDROID_ID)BooleanNo
GetAuthenticationRequest()251NoneBooleanNo

Device actions​

RequestParametersReturnsInit
ResetWatchRequest()NoneBooleanYes
ShutdownWatchRequest()NoneBooleanYes
LedTestWatchRequestV2(ledNumber, blinking, durationSecs)See belowBooleanYes
Led1TestWatchRequest()NoneBooleanYes
Led2TestWatchRequest()NoneBooleanYes

Reset​

Restarts the firmware. The LEDs turn off, then on.

warning

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:

ParameterTypeDescription
ledNumberInt0 = green, 1 = orange, 2 = blue
blinkingBooleantrue to blink, false for continuous
durationSecsIntDuration 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.

RequestReturns
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.