Sleep
Sets sleep listener
Sets up a sleep monitor sleepChangeEveStm, and save the returned value in "event" with the value of the SleepBean object.
_blePlugin.sleepChangeEveStm.listen(
(SleepBean event) {
/// Do something with new state,for example:
setState(() {
switch (event.type) {
case SleepType.sleepChange:
_totalTime = event.sleepInfo!.totalTime!;
_restfulTime = event.sleepInfo!.restfulTime!;
_lightTime = event.sleepInfo!.lightTime!;
_soberTime = event.sleepInfo!.soberTime!;
_remTime = event.sleepInfo!.remTime!;
break;
case SleepType.historySleepChange:
_timeType = event.historySleep!.timeType!;
_totalTime = event.historySleep!.sleepInfo!.totalTime!;
_restfulTime = event.historySleep!.sleepInfo!.restfulTime!;
_lightTime = event.historySleep!.sleepInfo!.lightTime!;
_soberTime = event.historySleep!.sleepInfo!.soberTime!;
_remTime = event.historySleep!.sleepInfo!.remTime!;
break;
default:
break;
}
});
},
),
Callback Description(event):
SleepBean:
callback value | callback value type | callback value description |
---|---|---|
type | int | Weather change return value type, the type is SleepType |
sleepInfo | SleepInfo | Current sleep information |
historySleep | HistorySleepBean | Historical sleep information |
SleepType:
type | value | value description |
---|---|---|
sleepChange | 1 | Gets the data returned by the current sleep monitor |
historySleepChange | 2 | Gets the data returned by the historical sleep monitor |
SleepInfo:
callback value | callback value type | callback value description |
---|---|---|
sleepStateRem | int | 3 |
sleepStateRestful | int | 2 |
sleepStateLight | int | 1 |
sleepStateSober | int | 0 |
totalTime | int | Total sleep time |
restfulTime | int | restful time |
lightTime | int | light time |
soberTime | int | awake time |
remTime | int | rem time |
HistorySleepBean:
callback value | callback value type | callback value description |
---|---|---|
timeType | int | days,from HistoryTimeType |
sleepInfo | SleepInfo | Specifies the user's historical sleep information for the date type |
Parameter Description :
HistoryTimeType:
Use yesterdaySleep and dayBeforeYesterdaySleep parameters.
value | value type | value description |
---|---|---|
yesterdaySteps | int | 1 |
dayBeforeYesterdaySteps | int | 2 |
yesterdaySleep | int | 3 |
dayBeforeYesterdaySleep | int | 4 |
Gets today's sleep
The sleep clear time of the watch is 8 pm, and the sleep time recorded by the watch is from 8 pm to 10 am the next day.
Gets detailed data for a training. The query result will be obtained through the sleepChangeEveStm listening stream and saved in the SleepBean.sleepInfo field.
_blePlugin.querySleep;
Gets historical sleep
The watch can save the sleep data of the past three days, and can query the sleep data of a certain day.
Gets the sleep data of a certain day. The query result will be obtained through the sleepChangeEveStm listening stream and saved in the SleepBean.past field and the SleepBean.pastSleepInfo field.
_blePlugin.queryHistorySleep(HistoryTimeType);