Notifications (Ping)
The bracelet sends a few notification (or ping) when some events occur.
- Regular Ping
- Instant data Ping
- Charger event Ping
How to register to these events?
- Observe notifications:
val bleDevice = BleSdk.getInstance().getDevice(address)
bleDevice.observeNotifications {
result("Notif: $it")
}
1 - Regular Ping
Ping sent by the bracelet every minute, this triggers the data download. It is not necessary to listen to this event, but it is a good indication of the connection quality.
data class RegularPing(
val batteryLevel: Int,
val ppgSize: Int,
val activitySize: Int,
val hrvSize: Int,
val workoutSize: Int,
val sleepSize: Int,
val logSize: Int
) : Notification()
2 - Instant data (B2 only)
Available starting SDK 0.8.8
Only for B2 bracelets
What are the instant data?
The instant data is a set of data like bpm, respiration rate, battery level that come through that come regurlarly without needing a sync.
The bracelet needs to be connected.
Then this set of data will come automatically every 25 seconds.
data class RealTimePing(
val timestampSecs: Long, // in secs
val hrm: Int,
val hrmQ: Int,
val respRate: Float,
val respRateQ: Int,
val spo2: Int,
val spo2Q: Int,
val coreBodyTemp: Float,
val movementLevel: Int,
val batteryLevel: Int
) : Notification()
Movement level [0-4] 0 = not moving much, 4 = lots of movements
Example:
RealTimePing(timestampSecs=1697104452, hrm=86, hrmQ=1, respRate=0.0, respRateQ=0, spo2=0, spo2Q=0, coreBodyTemp=29.66, movementLevel=4, batteryLevel=61)
How to implement it
- Enable it
bleDevice.enqueueCommand(
SetRealTimePingEnableRequest(true),
- Get value on device
bleDevice.enqueueCommand(
GetRealTimePingEnableRequest(),
3 - Charger event ping
From SDK 0.9.9
Triggered when the bracelet is put on or taken off the charger
Data structure:
data class ChargingEventPing(
val percentage: Int,
val voltageMillivolts: Int,
val isCharging: Boolean
) : Notification()