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 valuecallback value typecallback value description
typeintWeather change return value type, the type is SleepType
sleepInfoSleepInfoCurrent sleep information
historySleepHistorySleepBeanHistorical sleep information

SleepType:

typevaluevalue description
sleepChange1Gets the data returned by the current sleep monitor
historySleepChange2Gets the data returned by the historical sleep monitor

SleepInfo:

callback valuecallback value typecallback value description
sleepStateRemint3
sleepStateRestfulint2
sleepStateLightint1
sleepStateSoberint0
totalTimeintTotal sleep time
restfulTimeintrestful time
lightTimeintlight time
soberTimeintawake time
remTimeintrem time

HistorySleepBean:

callback valuecallback value typecallback value description
timeTypeintdays,from HistoryTimeType
sleepInfoSleepInfoSpecifies the user's historical sleep information for the date type

Parameter Description :

HistoryTimeType:

Use yesterdaySleep and dayBeforeYesterdaySleep parameters.

valuevalue typevalue description
yesterdayStepsint1
dayBeforeYesterdayStepsint2
yesterdaySleepint3
dayBeforeYesterdaySleepint4

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);
Last Updated: