cec: display an alert message when the firmware of the adapter can be upgraded. bugzi...
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 8 May 2012 10:25:04 +0000 (12:25 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 8 May 2012 10:26:57 +0000 (12:26 +0200)
include/cectypes.h
src/lib/CECProcessor.cpp
src/lib/adapter/AdapterCommunication.h
src/lib/adapter/USBCECAdapterCommunication.cpp
src/lib/adapter/USBCECAdapterCommunication.h

index efa5a3c44750a267b55cfe25121a34ee2d8a0081..904db4c59f0dd77c006b8dfe4929ddf61547d054 100644 (file)
@@ -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;
index 48a416cd72651e53742e004f2271f77712692218..272723ed48e46567222e92d55ca6f7077167eb31 100644 (file)
@@ -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;
index 48883bb2f3a07646d2b8894f0ad10c5493c67fe7..f8dc4bc23f5122ada19a2e7f829868233649181b 100644 (file)
@@ -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.
      */
index 6a4a0b99b99171cce2621406afdd4309163025c1..6c548b00ad2eab495083b57ed76295c290b1d71d 100644 (file)
@@ -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;
index a1171588bdd0777b9f1523b5acaf2f1c64c79178..cfe294480495033b71e96ddb4e580e552d57c226 100644 (file)
@@ -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);