RDK Documentation (Open Sourced RDK Components)
ledmgr.cpp
Go to the documentation of this file.
1 /**
2  * @file ledmgr.cpp
3  *
4  * @brief This file is an template implementation. OEM vendors are to implement the functions required for their platform.
5  *
6  */
7 
8 #include "ledmgr.hpp"
9 #include "sysMgr.h"
10 #include "libIBusDaemon.h"
11 #include "irMgr.h"
12 
13 /**
14  * @addtogroup LED_TYPES
15  * @{
16  */
17 typedef enum
18 {
19  GATEWAY_CONNECTION_ERROR = 0,
20 }errorTypes_t;
21 
22 /* @} */ // End of group LED_TYPES
23 
24 
25 ledMgr::ledMgr()
26 {
27  //TODO: Explore autodetection
28  m_indicators.push_back(indicator("Power"));
29 }
30 
31 ledMgr ledMgr::m_singleton;
32 ledMgr& ledMgr::getInstance()
33 {
34  return m_singleton;
35 }
36 
37 /**
38  * @addtogroup LED_APIS
39  * @{
40  */
41 /**
42  * @brief Ths API shows a reference implementation for handles when there is a changes in system mode(IARM bus system modes: NORMAL, EAS, WAREHOUSE).
43  *
44  * @param[in] mode IARM bus system mode.
45  */
46 void ledMgr::handleModeChange(unsigned int mode)
47 {
48  if(IARM_BUS_PWRMGR_POWERSTATE_ON != getPowerState())
49  {
50  return;
51  }
52 
53  if(IARM_BUS_SYS_MODE_NORMAL == mode)
54  {
55  INFO("Detected mode change to NORMAL\n");
56  try
57  {
58  //TODO (OEM): Call appropriate ledmgr indicator API
59  }
60  catch(...)
61  {
62  ERROR("Error setting steady state!\n");
63  }
64 
65  }
66 }
67 
68 
69 /**
70  * @brief This API shows a reference implementation of calling appropriate ledmgr indicator API depends of the gateway connection event.
71  *
72  * @param[in] state error state.
73  * @param[in] error error
74  */
75 void ledMgr::handleGatewayConnectionEvent(unsigned int state, unsigned int error)
76 {
77  if(0 == state)
78  {
79  INFO("Detected gateway disconnect.\n");
80  if(true == setError(GATEWAY_CONNECTION_ERROR, true))
81  {
82  //Transition to error state.
83  //TODO (OEM): Call appropriate ledmgr indicator API
84  }
85  }
86  else if(1 == state)
87  {
88  INFO("Detected gateway connection.\n");
89  /*Clear this error and if no other errors are present, clear
90  * the error blinking pattern */
91  if(true == setError(GATEWAY_CONNECTION_ERROR, false))
92  {
93  //TODO (OEM): Call appropriate ledmgr indicator API
94  }
95  }
96 }
97 
98 /**
99  * @brief This API shows a reference implementation for handling key press and give LED indication accordingly.
100  * Indicator functions are called with the supported LED pattern or color
101  *
102  * @param[in] key_code key code.
103  * @param[in] key_type key type.
104  */
105 void ledMgr::handleKeyPress(int key_code, int key_type)
106 {
107  //TODO (OEM): Call appropriate ledmgr indicator API for keypress
108 }
109 
110 /** @} */ //END OF GROUP LED_APIS
ledMgrBase::setError
bool setError(unsigned int position, bool value)
This API stores the error and returns the transition state in order to call appropriate ledmgr indica...
Definition: ledmgrbase.cpp:130
ledMgr::handleModeChange
virtual void handleModeChange(unsigned int mode)
Ths API shows a reference implementation for handles when there is a changes in system mode(IARM bus ...
Definition: ledmgr.cpp:46
ledMgr::handleKeyPress
virtual void handleKeyPress(int key_code, int key_type)
This API shows a reference implementation for handling key press and give LED indication accordingly....
Definition: ledmgr.cpp:105
sysMgr.h
IARM-Bus Sys Manager Public API.
ledMgrBase::getPowerState
int getPowerState()
This function used to get the power state.
Definition: ledmgrbase.cpp:113
indicator
Definition: indicator.hpp:26
ledMgr
Definition: ledmgr.hpp:8
irMgr.h
IARM-Bus IR Manager API.
ledMgr::handleGatewayConnectionEvent
virtual void handleGatewayConnectionEvent(unsigned int state, unsigned int error)
This API shows a reference implementation of calling appropriate ledmgr indicator API depends of the ...
Definition: ledmgr.cpp:75