sleep_config()

sleep_config()

Description

Configures sleep over script

Syntax

sleep_config(state, sleep_time, awake_time, wake_up_conditions, g_force_threshold);

Parameters

sleep_timeVariable

Input

sleep_timeVariable

Input

state

ENABLE or DISABLE

sleep_time

Time for how long the module will sleep in minutes.

awake_time

Time for how long the module will stay awake in seconds.

wake_up_conditions

Wake up condition options:

WAKEUP_MOTION
WAKEUP_IN2
WAKEUP_IN3
WAKEUP_IN4
WAKEUP_IN5
WAKEUP_SLEEP_PERIOD_TIMEOUT
WAKEUP_GSM_ACTIVITY
WAKEUP_CAN_ACTIVITY
WAKEUP_ONEWIRE_ACTIVITY
WAKEUP_BT_ACTIVITY
WAKEUP_IN7

Wake up conditions can be combined using “|” (or) symbol.

g_force_threshold

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:

 

image-20250127-152940.png