sleep_config()
Description
Configures sleep over script
Syntax
sleep_config(state, sleep_time, awake_time, wake_up_conditions, g_force_threshold);
Parameters
| Input |
|---|---|
| ENABLE or DISABLE |
| Time for how long the module will sleep in minutes. |
| Time for how long the module will stay awake in seconds. |
| Wake up condition options: WAKEUP_MOTION Wake up conditions can be combined using “|” (or) symbol. |
| Sensitivity of motion detection. |
Returns
Return value | Return explanation |
SCRIPT_OPERATION_SUCCESS | Success |
SCRIPT_OPERATION_FAILED | Failed |
Function call example
Sleep config example
#include <io>
#include <read>
#include <float>
#include <string>
#include <core>
#include <write>
#include <define>
#include <socket>
#define SLEEP_FOR_7_MINUTES 7*60
#define STAY_AWAKE_FOR_7_MINUTES 7*60
#define G_FORCE_THRESHOLD 0.0625
#define ENABLE 1
#define DISABLE 0
main()
{
sleep_config(ENABLE, SLEEP_FOR_7_MINUTES, STAY_AWAKE_FOR_7_MINUTES, WAKEUP_SLEEP_PERIOD_TIMEOUT|WAKEUP_IN5, G_MOTION_THRESHOLD);
while(1)
{
Delay(100);
}
}
Notes and Warnings
In order for this function to work user has to enable it via settings template in deep sleep settings by selecting ‘control over script’. Shown in picture below: