From 5daed059e1d5bca3ddfa0787679ef4e7b349e382 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 8 May 2012 12:25:04 +0200 Subject: [PATCH] cec: display an alert message when the firmware of the adapter can be upgraded. bugzid: 778 --- include/cectypes.h | 19 ++++++++++++++++++- src/lib/CECProcessor.cpp | 11 +++++++++++ src/lib/adapter/AdapterCommunication.h | 5 +++++ .../adapter/USBCECAdapterCommunication.cpp | 11 +++++++++++ src/lib/adapter/USBCECAdapterCommunication.h | 1 + 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/include/cectypes.h b/include/cectypes.h index efa5a3c..904db4c 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -1095,13 +1095,30 @@ typedef enum libcec_alert typedef enum libcec_parameter_type { - CEC_PARAMETER_TYPE_STRING + CEC_PARAMETER_TYPE_STRING, + CEC_PARAMETER_TYPE_UNKOWN } libcec_parameter_type; struct libcec_parameter { libcec_parameter_type paramType; /**< the type of this parameter */ void* paramData; /**< the value of this parameter */ + +#ifdef __cplusplus + libcec_parameter(void) + { + paramType = CEC_PARAMETER_TYPE_UNKOWN; + paramData = NULL; + } + + libcec_parameter(const char *strMessage) + { + paramType = CEC_PARAMETER_TYPE_STRING; + paramData = (void*)strMessage; + } + + virtual ~libcec_parameter(void) {} +#endif }; struct libcec_configuration; diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 48a416c..272723e 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -203,6 +203,17 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint CLibCEC::AddLog(CEC_LOG_NOTICE, strLog); } + if (!m_communication->IsRunningLatestFirmware()) + { + const char *strUpgradeMessage = "The firmware of this adapter can be upgraded. Please visit http://blog.pulse-eight.com/ for more information."; + CLibCEC::AddLog(CEC_LOG_WARNING, strUpgradeMessage); + CLibCEC::Alert(CEC_ALERT_SERVICE_DEVICE, libcec_parameter(strUpgradeMessage)); + } + else + { + CLibCEC::AddLog(CEC_LOG_DEBUG, "the adapter is using the latest (known) firmware version"); + } + if (m_configuration.bGetSettingsFromROM == 1) { libcec_configuration config; diff --git a/src/lib/adapter/AdapterCommunication.h b/src/lib/adapter/AdapterCommunication.h index 48883bb..f8dc4bc 100644 --- a/src/lib/adapter/AdapterCommunication.h +++ b/src/lib/adapter/AdapterCommunication.h @@ -143,6 +143,11 @@ namespace CEC */ virtual uint32_t GetFirmwareBuildDate(void) = 0; + /*! + * @return True when this adapter is using the latest firmware build, or when the latest firmware build for this adapter type is unknown. False otherwise. + */ + virtual bool IsRunningLatestFirmware(void) = 0; + /*! * @return True when the control mode has been set, false otherwise. */ diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index 6a4a0b9..6c548b0 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -44,6 +44,11 @@ using namespace PLATFORM; #define CEC_ADAPTER_PING_TIMEOUT 15000 +// firmware version 2 +#define CEC_LATEST_ADAPTER_FW_VERSION 2 +// firmware date Thu Apr 26 20:14:49 2012 +0000 +#define CEC_LATEST_ADAPTER_FW_DATE 0x4F99ACB9 + CUSBCECAdapterCommunication::CUSBCECAdapterCommunication(IAdapterCommunicationCallback *callback, const char *strPort, uint16_t iBaudRate /* = CEC_SERIAL_DEFAULT_BAUDRATE */) : IAdapterCommunication(callback), m_port(NULL), @@ -486,6 +491,12 @@ uint32_t CUSBCECAdapterCommunication::GetFirmwareBuildDate(void) return m_commands->RequestBuildDate(); } +bool CUSBCECAdapterCommunication::IsRunningLatestFirmware(void) +{ + return GetFirmwareVersion() >= CEC_LATEST_ADAPTER_FW_VERSION && + GetFirmwareBuildDate() >= CEC_LATEST_ADAPTER_FW_DATE; +} + bool CUSBCECAdapterCommunication::PersistConfiguration(libcec_configuration *configuration) { return m_port->IsOpen() ? m_commands->PersistConfiguration(configuration) : false; diff --git a/src/lib/adapter/USBCECAdapterCommunication.h b/src/lib/adapter/USBCECAdapterCommunication.h index a117158..cfe2944 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.h +++ b/src/lib/adapter/USBCECAdapterCommunication.h @@ -77,6 +77,7 @@ namespace CEC bool PingAdapter(void); uint16_t GetFirmwareVersion(void); uint32_t GetFirmwareBuildDate(void); + bool IsRunningLatestFirmware(void); bool PersistConfiguration(libcec_configuration *configuration); bool GetConfiguration(libcec_configuration *configuration); CStdString GetPortName(void); -- 2.34.1