* http://www.pulse-eight.net/
*/
+#include "env.h"
#include "USBCECAdapterCommands.h"
-#include "../LibCEC.h"
-#include "../CECProcessor.h"
-#include "../CECTypeUtils.h"
+
+#include "USBCECAdapterMessage.h"
+#include "USBCECAdapterCommunication.h"
+#include "lib/LibCEC.h"
+#include "lib/CECProcessor.h"
+#include "lib/CECTypeUtils.h"
+#include <stdio.h>
using namespace CEC;
using namespace PLATFORM;
bool CUSBCECAdapterCommands::SetSettingAutoEnabled(bool enabled)
{
- bool bReturn(true);
+ bool bReturn(false);
/* check whether this value was changed */
if (m_bSettingAutoEnabled == enabled)
- {
- LIB_CEC->AddLog(CEC_LOG_DEBUG, "autonomous mode setting unchanged (%s)", enabled ? "on" : "off");
return bReturn;
- }
m_bNeedsWrite = true;
LIB_CEC->AddLog(CEC_LOG_DEBUG, "turning autonomous mode %s", enabled ? "on" : "off");
bool CUSBCECAdapterCommands::SetSettingDeviceType(cec_device_type type)
{
- bool bReturn(true);
+ bool bReturn(false);
/* check whether this value was changed */
if (m_persistedConfiguration.deviceTypes.types[0] == type)
- {
- LIB_CEC->AddLog(CEC_LOG_DEBUG, "device type setting unchanged (%X)", (uint8_t)type);
return bReturn;
- }
m_bNeedsWrite = true;
LIB_CEC->AddLog(CEC_LOG_DEBUG, "setting the device type to %X (previous: %X)", (uint8_t)type, (uint8_t)m_persistedConfiguration.deviceTypes.types[0]);
bool CUSBCECAdapterCommands::SetSettingDefaultLogicalAddress(cec_logical_address address)
{
- bool bReturn(true);
+ bool bReturn(false);
/* check whether this value was changed */
if (m_persistedConfiguration.logicalAddresses.primary == address)
- {
- LIB_CEC->AddLog(CEC_LOG_DEBUG, "logical address setting unchanged (%X)", (uint8_t)address);
return bReturn;
- }
m_bNeedsWrite = true;
LIB_CEC->AddLog(CEC_LOG_DEBUG, "setting the default logical address to %X (previous: %X)", (uint8_t)address, (uint8_t)m_persistedConfiguration.logicalAddresses.primary);
bool CUSBCECAdapterCommands::SetSettingLogicalAddressMask(uint16_t iMask)
{
- bool bReturn(true);
+ bool bReturn(false);
/* check whether this value was changed */
if (m_iSettingLAMask == iMask)
- {
- LIB_CEC->AddLog(CEC_LOG_DEBUG, "logical address mask setting unchanged (%2X)", iMask);
return bReturn;
- }
m_bNeedsWrite = true;
LIB_CEC->AddLog(CEC_LOG_DEBUG, "setting the logical address mask to %2X (previous: %2X)", iMask, m_iSettingLAMask);
bool CUSBCECAdapterCommands::SetSettingPhysicalAddress(uint16_t iPhysicalAddress)
{
- bool bReturn(true);
+ bool bReturn(false);
/* check whether this value was changed */
if (m_persistedConfiguration.iPhysicalAddress == iPhysicalAddress)
- {
- LIB_CEC->AddLog(CEC_LOG_DEBUG, "physical address setting unchanged (%04X)", iPhysicalAddress);
return bReturn;
- }
m_bNeedsWrite = true;
LIB_CEC->AddLog(CEC_LOG_DEBUG, "setting the physical address to %04X (previous: %04X)", iPhysicalAddress, m_persistedConfiguration.iPhysicalAddress);
bool CUSBCECAdapterCommands::SetSettingCECVersion(cec_version version)
{
- bool bReturn(true);
+ bool bReturn(false);
/* check whether this value was changed */
if (m_settingCecVersion == version)
- {
- LIB_CEC->AddLog(CEC_LOG_DEBUG, "CEC version setting unchanged (%s)", ToString(version));
return bReturn;
- }
m_bNeedsWrite = true;
LIB_CEC->AddLog(CEC_LOG_DEBUG, "setting the CEC version to %s (previous: %s)", ToString(version), ToString(m_settingCecVersion));
bool CUSBCECAdapterCommands::SetSettingOSDName(const char *strOSDName)
{
- bool bReturn(true);
+ bool bReturn(false);
/* check whether this value was changed */
if (!strcmp(m_persistedConfiguration.strDeviceName, strOSDName))
- {
- LIB_CEC->AddLog(CEC_LOG_DEBUG, "OSD name setting unchanged (%s)", strOSDName);
return bReturn;
- }
LIB_CEC->AddLog(CEC_LOG_DEBUG, "setting the OSD name to %s (previous: %s)", strOSDName, m_persistedConfiguration.strDeviceName);
bool CUSBCECAdapterCommands::PersistConfiguration(const libcec_configuration &configuration)
{
+ bool bReturn(false);
if (m_persistedConfiguration.iFirmwareVersion < 2)
- return false;
+ return bReturn;
if (!RequestSettings())
- return false;
+ return bReturn;
+
+ bReturn |= SetSettingAutoEnabled(true);
+ bReturn |= SetSettingDeviceType(CLibCEC::GetType(configuration.logicalAddresses.primary));
+ bReturn |= SetSettingDefaultLogicalAddress(configuration.logicalAddresses.primary);
+ bReturn |= SetSettingLogicalAddressMask(CLibCEC::GetMaskForType(configuration.logicalAddresses.primary));
+ bReturn |= SetSettingPhysicalAddress(configuration.iPhysicalAddress);
+ bReturn |= SetSettingCECVersion(configuration.clientVersion >= CEC_CLIENT_VERSION_1_8_0 ? configuration.cecVersion : CEC_VERSION_1_4);
+ bReturn |= SetSettingOSDName(configuration.strDeviceName);
- bool bReturn(true);
- bReturn &= SetSettingAutoEnabled(true);
- bReturn &= SetSettingDeviceType(CLibCEC::GetType(configuration.logicalAddresses.primary));
- bReturn &= SetSettingDefaultLogicalAddress(configuration.logicalAddresses.primary);
- bReturn &= SetSettingLogicalAddressMask(CLibCEC::GetMaskForType(configuration.logicalAddresses.primary));
- bReturn &= SetSettingPhysicalAddress(configuration.iPhysicalAddress);
- bReturn &= SetSettingCECVersion(CEC_VERSION_1_3A);
- bReturn &= SetSettingOSDName(configuration.strDeviceName);
- bReturn &= WriteEEPROM();
return bReturn;
}