RDK Documentation (Open Sourced RDK Components)
pwrMgrInternal.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21  * @file pwrMgrInternal.h
22  *
23  * @defgroup IARMBUS_POWER_MGR Power Manager
24  * @ingroup IARM_MGR_RPC
25  *
26  * Power Manager monitors Power key events and reacts to power state changes. It dispatches Power Mode Change events to IARM-Bus.
27  *
28  * @par Feature Summary
29  *
30  * - Persist current power state (on/off) across power cycles.
31  * - If box was shutdown via a scheduled reboot, then restore the last known power state
32  * - If box was shutdown due to crash, then restore the last known power state.
33  * - In all other cases, default to power on at startup.
34  *
35  * @par Possible power states
36  * Power State | Description
37  * -----------------------------------------------|------------
38  * IARM_BUS_PWRMGR_POWERSTATE_OFF | Power state OFF
39  * IARM_BUS_PWRMGR_POWERSTATE_STANDBY | Power state STANDBY
40  * IARM_BUS_PWRMGR_POWERSTATE_ON | Power state ON
41  * IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP | Power state Light Sleep
42  * IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP | Power state Deep Sleep
43  *
44  * @par Power manager sends these events to other applications
45  *
46  * - IARM_BUS_PWRMGR_EVENT_MODECHANGED
47  * - IARM_BUS_PWRMGR_EVENT_DEEPSLEEP_TIMEOUT
48  *
49  * @par The Event Data contains
50  * @n
51  * @code
52  * IARM_Bus_PWRMgr_PowerState_t curState; // current power state
53  * IARM_Bus_PWRMgr_PowerState_t newState; // A new power state
54  * unsigned int timeout; //Timeout
55  * @endcode
56  *
57  * @par Power Manager: Events
58  *
59  * - @b IARM_BUS_PWRMGR_EVENT_MODECHANGED
60  * @n Event to notify power mode change.
61  * This event is broadcasted in case of power state change.
62  * @n Along with the current power state and neew state, this event is boradcasted which will be handled by the application.
63  * @n Example:
64  * @code
65  * IARM_Bus_PWRMgr_EventData_t param;
66  * param.data.state.curState = curState;
67  * param.data.state.newState = newState;
68  * IARM_Bus_BroadcastEvent( IARM_BUS_PWRMGR_NAME, IARM_BUS_PWRMGR_EVENT_MODECHANGED,
69  * (void *)&param, sizeof(param));
70  * @endcode
71  *
72  * - @b IARM_BUS_PWRMGR_EVENT_DEEPSLEEP_TIMEOUT
73  * @n Event to notify deep sleep timeout.
74  * Deep sleep timeout is set for the time set by the IARM_BUS_PWRMGR_API_SetDeepSleepTimeOut
75  * API after which this event will be broadcasted.
76  * @n Example:
77  * @code
78  * IARM_BUS_PWRMgr_DeepSleepTimeout_EventData_t param;
79  * param.timeout = deep_sleep_wakeup_timeout_sec;
80  * IARM_Bus_BroadcastEvent( IARM_BUS_PWRMGR_NAME, IARM_BUS_PWRMGR_EVENT_DEEPSLEEP_TIMEOUT,
81  * (void*)&param, sizeof(param));
82  * @endcode
83  *
84  * @par Power Manager: RPC Methods
85  * @n
86  * Power manager publishes four RPC Methods
87  * @n
88  * - @b IARM_BUS_PWRMGR_API_SetPowerState
89  * @n This RPC method is used to set a new power state and the power state can be ON, OFF, STANDBY,
90  * STANDY-LIGHT-SLEEP or STANDBY-DEEP-SLEEP
91  * @n Example:
92  * @code
93  * IARM_Bus_PWRMgr_SetPowerState_Param_t param;
94  * param.newState = IARM_BUS_PWRMGR_POWERSTATE_ON
95  * IARM_Bus_Call(IARM_BUS_PWRMGR_NAME,
96  * IARM_BUS_PWRMGR_API_SetPowerState, (void *)&param, sizeof(param));
97  * @endcode
98  *
99  *
100  * - @b IARM_BUS_PWRMGR_API_GetPowerState
101  * @n This API is used to retrieve the current power state of the box
102  * @n Example:
103  * @code
104  * IARM_Bus_PWRMgr_GetPowerState_Param_t param;
105  * IARM_Bus_Call(IARM_BUS_PWRMGR_NAME,
106  * IARM_BUS_PWRMGR_API_GetPowerState, (void *)&param, sizeof(param));
107  * @endcode
108  *
109  *
110  * - @b IARM_BUS_PWRMGR_API_WareHouseReset
111  * @n This API is used to perform a Ware House Reset to user data so that STB can be recycled.
112  * @n Example:
113  * @code
114  * IARM_Bus_Call(IARM_BUS_PWRMGR_NAME, IARM_BUS_PWRMGR_API_WareHouseReset, NULL, 0);
115  * @endcode
116  *
117  *
118  * - @b IARM_BUS_PWRMGR_API_SetDeepSleepTimeOut
119  * This API is used to sets the timeout for deep sleep
120  * @n Example:
121  * @code
122  * IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t param;
123  * param.timeout = timeOut;
124  * IARM_Bus_Call(IARM_BUS_PWRMGR_NAME,
125  * IARM_BUS_PWRMGR_API_SetDeepSleepTimeOut, (void *)&param, sizeof(param));
126  * @endcode
127  */
128 
129 /**
130 * @defgroup iarmmgrs
131 * @{
132 * @defgroup power
133 * @{
134 **/
135 
136 #ifndef _IARM_PWRMGR_INTERNAL_
137 #define _IARM_PWRMGR_INTERNAL_
138 #include "libIARM.h"
139 IARM_Result_t PWRMgr_Start(int argc, char *argv[]);
140 IARM_Result_t PWRMgr_Loop();
141 IARM_Result_t PWRMgr_Stop(void);
142 
143 IARM_Result_t initReset();
144 int checkResetSequence(int keyType, int keyCode);
145 void setResetPowerState(IARM_Bus_PWRMgr_PowerState_t newPwrState);
146 void PwrMgr_Reset(IARM_Bus_PWRMgr_PowerState_t newState, bool isFPKeyPress);
147 void performReboot(const char * requestor, const char * reboot_reason_custom, const char * reboot_reason_other);
148 
149 #endif
150 
151 
152 /** @} */
153 /** @} */
154 
155 
keyType
Definition: reset.c:85