#include "env.h"
#include "AQCommandHandler.h"
#include "devices/CECBusDevice.h"
#include "CECProcessor.h"
#include "LibCEC.h"
#include "CECClient.h"
using namespace CEC;
using namespace P8PLATFORM;
#define LIB_CEC m_busDevice->GetProcessor()->GetLib()
#define ToString(p) LIB_CEC->ToString(p)
CAQCommandHandler::CAQCommandHandler(CCECBusDevice *busDevice,
int32_t iTransmitTimeout ,
int32_t iTransmitWait ,
int8_t iTransmitRetries ,
int64_t iActiveSourcePending ) :
CCECCommandHandler(busDevice, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending),
m_powerOnCheck(NULL)
{
m_vendorId = CEC_VENDOR_SHARP;
}
CAQCommandHandler::~CAQCommandHandler(void)
{
delete m_powerOnCheck;
}
bool CAQCommandHandler::PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination)
{
bool bCheck(false);
bool bRetval(false);
if (m_busDevice->GetCurrentPowerStatus() != CEC_POWER_STATUS_ON && (!m_powerOnCheck || !m_powerOnCheck->IsRunning()))
bCheck = true;
bRetval = CCECCommandHandler::PowerOn(iInitiator, iDestination);
if (bRetval && bCheck)
{
if (!m_powerOnCheck)
m_powerOnCheck = new CAQPowerStatusCheck(this, iInitiator, iDestination);
if (m_powerOnCheck)
m_powerOnCheck->CreateThread();
}
return bRetval;
}
void* CAQPowerStatusCheck::Process(void)
{
Sleep(2000);
if (m_handler->m_busDevice->GetProcessor()->GetDevice(m_iDestination)->GetPowerStatus(m_iInitiator, true) == CEC_POWER_STATUS_STANDBY)
m_handler->m_busDevice->GetProcessor()->GetLib()->AddLog(CEC_LOG_WARNING, "AQUOS LINK 'auto power on' is disabled, which prevents the TV from being powered on. To correct this, press the menu button on your remote, go to 'link operation' -> 'AQUOS LINK setup' -> 'Auto power on' and set it to 'On'");
return NULL;
}