Wirepas SDK
sleep.h File Reference

Detailed Description

The Non-Router Long Sleep (NRLS) Library is used to sleep Wirepas Mesh stack for time periods. Once waking-up from the sleep, Wirepas Mesh stack wakes up from the sleep without system reset. During Wirepas Mesh stack sleep, Single-MCU application can be running using the libraries which does not have dependency to Wirepas Mesh stack functionalities. Before entering to NRLS sleep, Wirepas Mesh stack needs to be running.

Non-Router Long Sleep libraries can be used with Wirepas Mesh stack which is configured to be running as Non-Router mode without any role extensions (APP_LIB_SETTINGS_ROLE_SUBNODE in app_lib_settings_base_role_e and APP_LIB_SETTINGS_ROLE_FLAG_RESV in app_lib_settings_flag_role_e). Any other app_lib_settings_base_role_e and app_lib_settings_flag_role_e definitions do not allow to use NRLS functionality.

Library services are accessed via lib_sleep handle.

Definition in file sleep.h.

Go to the source code of this file.

Typedefs

typedef app_res_e(* app_lib_sleep_stack_for_time_f) (uint32_t seconds, uint32_t appconf_wait_s)
 Start stack sleeping period for a given time. More...
 
typedef app_res_e(* app_lib_sleep_wakeup_stack_f) (void)
 Wakeup stack from sleep. More...
 
typedef app_lib_sleep_stack_state_e(* app_lib_sleep_get_sleep_state_f) (void)
 Get sleep state of stack. More...
 
typedef uint32_t(* app_lib_sleep_get_wakeup_f) (void)
 Returns remaining sleep time. More...
 
typedef void(* applib_wakeup_callback_f) (void)
 Callback called before stack wakes up. More...
 
typedef void(* app_lib_sleep_wakeup_callback_f) (applib_wakeup_callback_f callback)
 Set callback function to be called before stack wakes up. More...
 
typedef uint32_t(* app_lib_sleep_get_gotosleep) (void)
 Get latest time used before stack enters to sleep after NRLS sleep request given. More...
 

Data Structures

struct  app_lib_sleep_t
 List of library functions. More...
 

Enumerations

enum  app_lib_sleep_stack_state_e { APP_LIB_SLEEP_STOPPED = 0, APP_LIB_SLEEP_STARTED }
 Stack state flags. More...
 

Macros

#define APP_LIB_LONGSLEEP_NAME   0x02f20818
 Library symbolic name. More...
 
#define APP_LIB_LONGSLEEP_VERSION   0x201
 Maximum supported library version. More...
 

Typedef Documentation

◆ app_lib_sleep_get_gotosleep

typedef uint32_t(* app_lib_sleep_get_gotosleep) (void)

Get latest time used before stack enters to sleep after NRLS sleep request given.

Returns time in seconds which was used in previous NRLS sleep request starting from application request lib_sleep->sleepStackforTime() until stack enters to NRLS sleep. This value can be used to estimate needed parameter configuration for appconf_wait_s in lib_sleep->sleepStackforTime() function.

Returns
Total time used including application callback during that period in seconds

Definition at line 149 of file sleep.h.

◆ app_lib_sleep_get_sleep_state_f

typedef app_lib_sleep_stack_state_e(* app_lib_sleep_get_sleep_state_f) (void)

Get sleep state of stack.

Returns
APP_LIB_SLEEP_STOPPED is returned until actual NRLS sleep is started. This is happening when network disconnection ongoing before NRLS sleep is started. Signaling before actual stack sleep start might take time up to 30 seconds or more depending of used radio.

Definition at line 107 of file sleep.h.

◆ app_lib_sleep_get_wakeup_f

typedef uint32_t(* app_lib_sleep_get_wakeup_f) (void)

Returns remaining sleep time.

Returns remaining sleep time in seconds. Time period is updated every 3 second. The NRLS sleep time is not decreased while the network disconnection ongoing, once network disconnection is completed, the NRLS sleep time count down is started.

Returns
Remaining sleep time in seconds

Definition at line 119 of file sleep.h.

◆ app_lib_sleep_stack_for_time_f

typedef app_res_e(* app_lib_sleep_stack_for_time_f) (uint32_t seconds, uint32_t appconf_wait_s)

Start stack sleeping period for a given time.

Parameters
secondssleep time in seconds. Sleep time starts when the node gets disconnected from Mesh network. To disconnect from the network, some time is needed for signaling before disconnection is completed (the sleep time does not include this time needed for signaling before going to sleep). Signaling before actual stack sleep start might take time up to 30 seconds or more depending of used radio. If set to 0 - there is APP_RES_INVALID_VALUE response and sleep is not started.
appconf_wait_sWait time in seconds for app config data from network before NRLS stack sleep.
  • 0 = App config is not awaited before going to sleep.
  • Other values = Time used to wait that app config data is received from network.
Returns
APP_RES_INVALID_CONFIGURATION if node role is not correctly configured. Returns APP_RES_INVALID_VALUE if sleep time exceeds the maximum value. Returns APP_RES_INVALID_STACK_STATE if stack is not started and node role and seconds is correct. Returns APP_RES_OK when stack sleep is started.
Note
If the time when waking up from NRLS sleep and going back to NRLS sleep is very short and app config is used to signal to the network e.g. overhaul state, good practice is to have appconf_wait_s long enough (minimum 4 seconds) to make sure that app config data is received before going to NRLS sleep

Definition at line 83 of file sleep.h.

◆ app_lib_sleep_wakeup_callback_f

typedef void(* app_lib_sleep_wakeup_callback_f) (applib_wakeup_callback_f callback)

Set callback function to be called before stack wakes up.

Parameters
callbackThe callback function to set

Definition at line 135 of file sleep.h.

◆ app_lib_sleep_wakeup_stack_f

typedef app_res_e(* app_lib_sleep_wakeup_stack_f) (void)

Wakeup stack from sleep.

Starts the stack from sleep if application wants to wake-up the stack from NRLS sleep before NRLS sleep time has elapsed.

Returns
APP_RES_OK when stack wakeup is started from sleep. Returns APP_RES_INVALID_STACK_STATE if wakeup called when stack is running.

Definition at line 98 of file sleep.h.

◆ applib_wakeup_callback_f

typedef void(* applib_wakeup_callback_f) (void)

Callback called before stack wakes up.

Used with lib_sleep->setOnWakeupCb() service

Definition at line 126 of file sleep.h.


Data Structure Documentation

◆ app_lib_sleep_t

struct app_lib_sleep_t

List of library functions.

Definition at line 154 of file sleep.h.

Data Fields
app_lib_sleep_get_gotosleep getSleepLatestGotosleep
app_lib_sleep_get_sleep_state_f getSleepState
app_lib_sleep_get_wakeup_f getStackWakeup
app_lib_sleep_wakeup_callback_f setOnWakeupCb
app_lib_sleep_stack_for_time_f sleepStackforTime
app_lib_sleep_wakeup_stack_f wakeupStack

Enumeration Type Documentation

◆ app_lib_sleep_stack_state_e

Stack state flags.

Enumerator
APP_LIB_SLEEP_STOPPED 

Sleep is stopped.

APP_LIB_SLEEP_STARTED 

Sleep is started.

Definition at line 47 of file sleep.h.

Macro Definition Documentation

◆ APP_LIB_LONGSLEEP_NAME

#define APP_LIB_LONGSLEEP_NAME   0x02f20818

Library symbolic name.

"SLEEP"

Definition at line 39 of file sleep.h.

◆ APP_LIB_LONGSLEEP_VERSION

#define APP_LIB_LONGSLEEP_VERSION   0x201

Maximum supported library version.

Definition at line 42 of file sleep.h.

APP_LIB_SLEEP_STOPPED
@ APP_LIB_SLEEP_STOPPED
Sleep is stopped.
Definition: sleep.h:49
APP_LIB_SLEEP_STARTED
@ APP_LIB_SLEEP_STARTED
Sleep is started.
Definition: sleep.h:50
app_lib_sleep_stack_state_e
app_lib_sleep_stack_state_e
Stack state flags.
Definition: sleep.h:47