Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 72 additions & 56 deletions helpers/frontpanel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**

Check failure on line 1 in helpers/frontpanel.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'helpers/frontpanel.cpp' (Match: rdkcentral/rdkservices/1, 723 lines, url: https://github.com/rdkcentral/rdkservices/archive/GRT_v1.tar.gz, file: helpers/frontpanel.cpp)
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
Expand Down Expand Up @@ -143,75 +143,91 @@
if (!s_instance)
s_instance = new CFrontPanel;
#ifdef USE_DS
try
unsigned int retryCount = 1;
do
{
LOGINFO("Front panel init");
fpIndicators = device::FrontPanelConfig::getInstance().getIndicators();

for (uint i = 0; i < fpIndicators.size(); i++)
try
{
std::string IndicatorNameIarm = fpIndicators.at(i).getName();

auto it = std::find(m_lights.begin(), m_lights.end(), IndicatorNameIarm);
if (m_lights.end() == it)
LOGINFO("TRACE:: Front panel init at %d", retryCount);
LOGINFO("Front panel init");
fpIndicators = device::FrontPanelConfig::getInstance().getIndicators();
LOGINFO(" so continue with other initialization \r\n");
for (uint i = 0; i < fpIndicators.size(); i++)
{
m_lights.push_back(IndicatorNameIarm);
LOGINFO("TRACE:: Before getName for %d at %d", i, retryCount);
std::string IndicatorNameIarm = fpIndicators.at(i).getName();
LOGINFO("TRACE:: After getName[%s] for %d at %d", IndicatorNameIarm.c_str(), i, retryCount);

auto it = std::find(m_lights.begin(), m_lights.end(), IndicatorNameIarm);
if (m_lights.end() == it)
{
m_lights.push_back(IndicatorNameIarm);
}
}
}
LOGINFO("TRACE:: Front panel init done with %d lights at %d", (int)m_lights.size(), retryCount);

#if defined(HAS_API_POWERSTATE)
{
Core::hresult res = Core::ERROR_GENERAL;
PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN;
PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN;
ASSERT (_powerManagerPlugin);
if (_powerManagerPlugin) {
res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev);
if (Core::ERROR_NONE == res)
#if defined(HAS_API_POWERSTATE)
{
Core::hresult res = Core::ERROR_GENERAL;
PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN;
PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN;
ASSERT (_powerManagerPlugin);
if (_powerManagerPlugin) {
LOGINFO("TRACE:: Before GetPowerState at %d", retryCount);
res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev);
if (Core::ERROR_NONE == res)
{
if (pwrStateCur == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON)
powerStatus = true;
}
LOGINFO("TRACE:: After GetPowerState at %d", retryCount);
LOGINFO("pwrStateCur[%d] pwrStatePrev[%d] powerStatus[%d]", pwrStateCur, pwrStatePrev, powerStatus);
}
}
#endif
#ifdef CLOCK_BRIGHTNESS_ENABLED
clockBrightness = device::FrontPanelTextDisplay::getInstance("Text").getTextBrightness();
device::FrontPanelTextDisplay::getInstance("Text").setTextBrightness(clockBrightness);
#endif
LOGINFO("TRACE:: Before getBrightness at %d", retryCount);
globalLedBrightness = device::FrontPanelIndicator::getInstance("Power").getBrightness();
LOGINFO("TRACE:: After getBrightness at %d", retryCount);
LOGINFO("Power light brightness, %d, power status %d", globalLedBrightness, powerStatus);

profileType = searchRdkProfile();
if (TV != profileType)
{
for (uint i = 0; i < fpIndicators.size(); i++)
{
if (pwrStateCur == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON)
powerStatus = true;
LOGWARN("Initializing light %s", fpIndicators.at(i).getName().c_str());
if (powerStatus)
device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setBrightness(globalLedBrightness, false);
device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setState(false);
}
LOGINFO("pwrStateCur[%d] pwrStatePrev[%d] powerStatus[%d]", pwrStateCur, pwrStatePrev, powerStatus);
}
}
#endif
#ifdef CLOCK_BRIGHTNESS_ENABLED
clockBrightness = device::FrontPanelTextDisplay::getInstance("Text").getTextBrightness();
device::FrontPanelTextDisplay::getInstance("Text").setTextBrightness(clockBrightness);
#endif
globalLedBrightness = device::FrontPanelIndicator::getInstance("Power").getBrightness();
LOGINFO("Power light brightness, %d, power status %d", globalLedBrightness, powerStatus);
else
{
LOGWARN("Power LED Initializing is not set since we continue with bootloader patern");
}

profileType = searchRdkProfile();
if (TV != profileType)
{
for (uint i = 0; i < fpIndicators.size(); i++)
{
LOGWARN("Initializing light %s", fpIndicators.at(i).getName().c_str());
if (powerStatus)
device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setBrightness(globalLedBrightness, false);

device::FrontPanelIndicator::getInstance(fpIndicators.at(i).getName()).setState(false);
}
}
else
{
LOGWARN("Power LED Initializing is not set since we continue with bootloader patern");
}

if (powerStatus)
device::FrontPanelIndicator::getInstance("Power").setState(true);
LOGINFO("TRACE:: Before setState at %d", retryCount);
if (powerStatus)
device::FrontPanelIndicator::getInstance("Power").setState(true);

LOGINFO("TRACE:: After setState at %d", retryCount);
initDone=1;
}
catch (...)
{
LOGERR("Exception Caught during [CFrontPanel::instance]\r\n");
LOGINFO("TRACE:: Retry will happen in 2s");
//usleep(50000); // Sleep for 50ms before retrying
sleep(2); // Sleep for 50ms before retrying
}
}
catch (...)
{
LOGERR("Exception Caught during [CFrontPanel::instance]\r\n");
}
initDone=1;
while((retryCount++ <= 20) && (initDone == 0) );
#endif
}

return s_instance;
}

Expand Down
Loading