khang_91
Diff: mDot.h
- Revision:
- 114:8462870088eb
- Parent:
- 111:4bebf247fa58
- Child:
- 115:bcd44682ac1e
--- a/mDot.h Fri Dec 08 15:09:37 2017 -0600 +++ b/mDot.h Thu Dec 28 12:41:02 2017 -0600 @@ -1322,6 +1322,21 @@ void sleep(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM, const bool& deepsleep = true); /** + * Set auto sleep mode + * Auto sleep mode will automatically put the MCU to sleep in between receive windows + * Note: The MCU will go into a stop mode sleep in between rx windows. This means that + * peripherals such as timers will not function during the sleep intervals. + * @param enable - Flag to enable auto sleep mode + */ + void setAutoSleep(bool enable); + + /** + * Get auto sleep mode + * @returns 0 if sleep mode is disabled, 1 if it is enabled + */ + uint8_t getAutoSleep(); + + /** * Set wake pin * @param pin the pin to use to wake the device from sleep mode * For MDOT, XBEE_DI (2-8) @@ -1654,6 +1669,24 @@ } private: + typedef enum { + AUTO_SLEEP_EVT_CFG, + AUTO_SLEEP_EVT_TXDONE, + AUTO_SLEEP_EVT_RX1_TIMEOUT, + } AutoSleepEvent_t; + + typedef enum { + USER_SLEEP, + AUTO_SLEEP + } SleepClient_t; + + void sleep_ms(uint32_t interval, + uint8_t wakeup_mode = RTC_ALARM, + bool deepsleep = true, + SleepClient_t sleep_client = USER_SLEEP); + + void auto_sleep(AutoSleepEvent_t evt); + mdot_stats _stats; FunctionPointer _wakeup_callback;