Skip to content

Commit dfa25d3

Browse files
committed
sys: add reset reason to reboot confirm callback
This gives application a control over system resets and application can decide whether to reboot or not based on reset reason. Signed-off-by: Ajay Bhargav <[email protected]>
1 parent 3db4e5c commit dfa25d3

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

include/lib.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ enum loglevel_e {
6161
#endif
6262
#endif
6363

64+
/**
65+
* @brief Reboot reasons
66+
*
67+
*/
68+
enum reboot_reason_e {
69+
RESET_REASON_REBOOT, /**< Reboot command or sys_reset() */
70+
RESET_REASON_NOSIM, /**< Reboot due to No SIM card */
71+
RESET_REASON_NETWORKFAIL, /**< Reboot due to network registration failure */
72+
RESET_REASON_DATAFAIL, /**< Reboot due to data connection failure */
73+
RESET_REASON_FOTA, /**< Reboot due to FOTA update */
74+
RESET_REASON_PARAMRESET, /**< Reboot due to parameter reset */
75+
RESET_REASON_SYSFORMAT, /**< Reboot due to system memory format */
76+
};
77+
6478
/**
6579
* Unsolicited response code handler callback
6680
* @param urc_code URC code @ref sysurc_e
@@ -69,11 +83,14 @@ enum loglevel_e {
6983
typedef void (*urc_callback_f)(unsigned int urc_code, unsigned int urc_param);
7084

7185
/**
72-
* Reboot callback function called when reboot command is given
86+
* Reboot callback function called when reboot is issued by the system.
87+
* this callback can be used to confirm or deny reboot.
88+
*
89+
* @param reason [in] Reboot reason @ref reboot_reason_e
7390
*
7491
* @return True if reboot is allowed, false otherwise
7592
*/
76-
typedef int (*reboot_callback_f)(void);
93+
typedef int (*reboot_confirm_callback_f)(int reason);
7794

7895
/**
7996
* Initialize Logicrom OpenCPU SDK library
@@ -111,7 +128,7 @@ void system_gettz(char *tz, int size);
111128
* Set reboot confirm callback
112129
* @param callback [in] Callback function pointer
113130
*/
114-
int system_set_reboot_callback(reboot_callback_f callback);
131+
int system_set_reboot_callback(reboot_confirm_callback_f callback);
115132

116133
/**
117134
* Debug printf with debug level.

0 commit comments

Comments
 (0)