Module device.wakeupmgr

RTC wakeup interface.

Many devices can schedule hardware wakeups with a real time clock alarm. On embedded devices this can typically be easily manipulated by the user through /sys/class/rtc/rtc0/wakealarm. Some, like the Kobo Aura H2O, can only schedule wakeups through ioctl.

See ffi.rtc for implementation details.

See also: https://linux.die.net/man/4/rtc.

Functions

WakeupMgr:new (o) Initiate a WakeupMgr instance.
WakeupMgr:addTask (seconds_from_now, callback) Add a task to the queue.
WakeupMgr:removeTask (idx, epoch, callback) Remove task from queue.
WakeupMgr:wakeupAction () Execute wakeup action.
WakeupMgr:setWakeupAlarm (epoch, enabled) Set wakeup alarm.
WakeupMgr:unsetWakeupAlarm () Unset wakeup alarm.
WakeupMgr:getWakeupAlarm () Get wakealarm as set by us.
WakeupMgr:getWakeupAlarmSys () Get RTC wakealarm from system.
WakeupMgr:validateWakeupAlarmByProximity (task_alarm_epoch, proximity) Validate wakeup alarm.
WakeupMgr:isWakeupAlarmScheduled () Check if a wakeup is scheduled.

Tables

WakeupMgr WakeupMgr base class.

Issues

WakeupMgr:addTask-todo5 Binary insert? This table should be so small that performance doesn't matter. It might be useful to have that available as a utility function regardless.


Functions

WakeupMgr:new (o)
Initiate a WakeupMgr instance.

Parameters:

  • o

Usage:

    local WakeupMgr = require("device/wakeupmgr")
    local wakeup_mgr = WakeupMgr:new{
        -- The default is /dev/rtc0, but some devices have more than one RTC.
        -- You might therefore need to use /dev/rtc1, etc.
        dev_rtc = "/dev/rtc0",
    }
WakeupMgr:addTask (seconds_from_now, callback)
Add a task to the queue.

Parameters:

  • seconds_from_now
  • callback
WakeupMgr:removeTask (idx, epoch, callback)
Remove task from queue.

This method removes a task by either index, scheduled time or callback.

Parameters:

  • idx int Task queue index. Mainly useful within this module.
  • epoch int The epoch for when this task is scheduled to wake up. Normally the preferred method for outside callers.
  • callback int A scheduled callback function. Store a reference for use with anonymous functions.
WakeupMgr:wakeupAction ()
Execute wakeup action.

This method should be called by the device resume logic in case of a scheduled wakeup.

It checks if the wakeup was scheduled by us using validateWakeupAlarmByProximity, executes the task, and schedules the next wakeup if any.

Returns:

    bool
WakeupMgr:setWakeupAlarm (epoch, enabled)
Set wakeup alarm.

Simple wrapper for ffi.rtc.setWakeupAlarm.

Parameters:

  • epoch
  • enabled
WakeupMgr:unsetWakeupAlarm ()
Unset wakeup alarm.

Simple wrapper for ffi.rtc.unsetWakeupAlarm.

WakeupMgr:getWakeupAlarm ()
Get wakealarm as set by us.

Simple wrapper for ffi.rtc.getWakeupAlarm.

WakeupMgr:getWakeupAlarmSys ()
Get RTC wakealarm from system.

Simple wrapper for ffi.rtc.getWakeupAlarm.

WakeupMgr:validateWakeupAlarmByProximity (task_alarm_epoch, proximity)
Validate wakeup alarm.

Checks if we set the alarm.

Simple wrapper for ffi.rtc.validateWakeupAlarmByProximity.

Parameters:

  • task_alarm_epoch
  • proximity
WakeupMgr:isWakeupAlarmScheduled ()
Check if a wakeup is scheduled.

Simple wrapper for ffi.rtc.isWakeupAlarmScheduled.

Tables

WakeupMgr
WakeupMgr base class.

Fields:

  • dev_rtc RTC device
  • _task_queue

Issues

WakeupMgr:addTask-todo5
Binary insert? This table should be so small that performance doesn't matter. It might be useful to have that available as a utility function regardless.
generated by LDoc 1.4.6 Last updated 2019-10-22 22:20:15