X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FUSBCECAdapterCommands.h;h=389aa5f680a74a44d19ccf125491f0f45a9b5ffd;hb=99aeafb929fa132a096c236c4ae1eb78c2a595ec;hp=b5f12fb7a1f3ccf92da6a04c76434ffe81c05b9d;hpb=64d46f80cc6f34f531ae26e8677f2f0b0c1f74bb;p=deb_libcec.git diff --git a/src/lib/adapter/USBCECAdapterCommands.h b/src/lib/adapter/USBCECAdapterCommands.h index b5f12fb..389aa5f 100644 --- a/src/lib/adapter/USBCECAdapterCommands.h +++ b/src/lib/adapter/USBCECAdapterCommands.h @@ -38,9 +38,7 @@ namespace CEC class CUSBCECAdapterCommands { public: - CUSBCECAdapterCommands(CUSBCECAdapterCommunication *comm) : - m_comm(comm), - m_iFirmwareVersion(CEC_FW_VERSION_UNKNOWN) {} + CUSBCECAdapterCommands(CUSBCECAdapterCommunication *comm); /*! * @brief Request the firmware version from the adapter. @@ -48,6 +46,73 @@ namespace CEC */ uint16_t RequestFirmwareVersion(void); + /*! + * @return The firmware version of the adapter, retrieved when the connection is opened. + */ + uint16_t GetFirmwareVersion(void) const { return m_persistedConfiguration.iFirmwareVersion; }; + + /*! + * @brief Persist the current configuration in the EEPROM. + * @attention Not all settings are persisted at this time. + * @param configuration The configuration to persist. + * @return True when persisted, false otherwise. + */ + bool PersistConfiguration(libcec_configuration *configuration); + + /*! + * @brief Get the persisted configuration from the EEPROM. + * @param configuration The persisted configuration. + * @return True when retrieved, false otherwise. + */ + bool GetConfiguration(libcec_configuration *configuration); + + /*! + * @brief Send a ping command to the adapter. + * @return True when acked by the adapter, false otherwise. + */ + bool PingAdapter(void); + + /*! + * @brief Change the ackmask of the adapter. + * @param iMask The new mask. + * @return True when the change was acked by the adapter, false otherwise. + */ + bool SetAckMask(uint16_t iMask); + + /*! + * @brief Put the adapter in bootloader mode. + * @attention The connection needs to be closed after this call, since the adapter will no longer be available. + * @return True when the command was sent, false otherwise. + */ + bool StartBootloader(void); + + /*! + * @brief Change the current CEC line timeout. + * @param iTimeout The new timeout. + * @return True when the change was acked by the adapter, false otherwise. + */ + bool SetLineTimeout(uint8_t iTimeout); + + /*! + * @brief Put the adapter in controlled or autonomous mode. + * @param controlled True to switch to controlled mode, false to switch to auto mode. + * @return True when acked by the controller, false otherwise. + */ + bool SetControlledMode(bool controlled); + + /*! + * @brief Request the firmware build date from the device. + * @return The build date in seconds since epoch, or 0 when no (valid) reply was received. + */ + uint32_t RequestBuildDate(void); + + private: + /*! + * @brief Reads all settings from the eeprom. + * @return True when read, false otherwise. + */ + bool RequestSettings(void); + /*! * @brief Request a setting value from the adapter. * @param msgCode The setting to retrieve. @@ -64,10 +129,9 @@ namespace CEC /*! * @brief Request the value of the "auto enabled" setting from the adapter. - * @param enabled The current value. * @return True when retrieved, false otherwise. */ - bool RequestSettingAutoEnabled(bool &enabled); + bool RequestSettingAutoEnabled(void); /*! * @brief Change the value of the "device type" setting, used when the device is in autonomous mode. @@ -78,10 +142,9 @@ namespace CEC /*! * @brief Request the value of the "device type" setting from the adapter. - * @param type The current value. * @return True when retrieved, false otherwise. */ - bool RequestSettingDeviceType(cec_device_type &type); + bool RequestSettingDeviceType(void); /*! * @brief Change the value of the "default logical address" setting, used when the device is in autonomous mode. @@ -92,10 +155,9 @@ namespace CEC /*! * @brief Request the value of the "default logical address" setting from the adapter. - * @param address The current value. * @return True when retrieved, false otherwise. */ - bool RequestSettingDefaultLogicalAddress(cec_logical_address &address); + bool RequestSettingDefaultLogicalAddress(void); /*! * @brief Change the value of the "logical address mask" setting, used when the device is in autonomous mode. @@ -106,10 +168,9 @@ namespace CEC /*! * @brief Request the value of the "logical address mask" setting from the adapter. - * @param iMask The current value. * @return True when retrieved, false otherwise. */ - bool RequestSettingLogicalAddressMask(uint16_t &iMask); + bool RequestSettingLogicalAddressMask(void); /*! * @brief Change the value of the "physical address" setting, used when the device is in autonomous mode. @@ -120,10 +181,9 @@ namespace CEC /*! * @brief Request the value of the "physical address" setting from the adapter. - * @param iPhysicalAddress The current value. * @return True when retrieved, false otherwise. */ - bool RequestSettingPhysicalAddress(uint16_t &iPhysicalAddress); + bool RequestSettingPhysicalAddress(void); /*! * @brief Change the value of the "CEC version" setting, used when the device is in autonomous mode. @@ -134,10 +194,9 @@ namespace CEC /*! * @brief Request the value of the "CEC version" setting from the adapter. - * @param version The current value. * @return True when retrieved, false otherwise. */ - bool RequestSettingCECVersion(cec_version &version); + bool RequestSettingCECVersion(void); /*! * @brief Change the value of the "OSD name" setting, used when the device is in autonomous mode. @@ -148,10 +207,9 @@ namespace CEC /*! * @brief Request the value of the "OSD name" setting from the adapter. - * @param strOSDName The current value. * @return True when retrieved, false otherwise. */ - bool RequestSettingOSDName(CStdString &strOSDName); + bool RequestSettingOSDName(void); /*! * @brief Persist the current settings in the EEPROM @@ -159,62 +217,13 @@ namespace CEC */ bool WriteEEPROM(void); - /*! - * @return The firmware version of the adapter, retrieved when the connection is opened. - */ - uint16_t GetFirmwareVersion(void) const { return m_iFirmwareVersion; }; - - /*! - * @brief Persist the current configuration in the EEPROM. - * @attention Not all settings are persisted at this time. - * @param configuration The configuration to persist. - * @return True when persisted, false otherwise. - */ - bool PersistConfiguration(libcec_configuration *configuration); - - /*! - * @brief Get the persisted configuration from the EEPROM. - * @param configuration The persisted configuration. - * @return True when retrieved, false otherwise. - */ - bool GetConfiguration(libcec_configuration *configuration); - - /*! - * @brief Send a ping command to the adapter. - * @return True when acked by the adapter, false otherwise. - */ - bool PingAdapter(void); - - /*! - * @brief Change the ackmask of the adapter. - * @param iMask The new mask. - * @return True when the change was acked by the adapter, false otherwise. - */ - bool SetAckMask(uint16_t iMask); - - /*! - * @brief Put the adapter in bootloader mode. - * @attention The connection needs to be closed after this call, since the adapter will no longer be available. - * @return True when the command was sent, false otherwise. - */ - bool StartBootloader(void); - - /*! - * @brief Change the current CEC line timeout. - * @param iTimeout The new timeout. - * @return True when the change was acked by the adapter, false otherwise. - */ - bool SetLineTimeout(uint8_t iTimeout); - - /*! - * @brief Put the adapter in controlled or autonomous mode. - * @param controlled True to switch to controlled mode, false to switch to auto mode. - * @return True when acked by the controller, false otherwise. - */ - bool SetControlledMode(bool controlled); - - private: - CUSBCECAdapterCommunication *m_comm; /**< the communication handler */ - uint16_t m_iFirmwareVersion; /**< the firwmare version that was retrieved while opening the connection */ + CUSBCECAdapterCommunication *m_comm; /**< the communication handler */ + bool m_bSettingsRetrieved; /**< true when the settings were read from the eeprom, false otherwise */ + bool m_bSettingAutoEnabled; /**< the value of the auto-enabled setting */ + cec_version m_settingCecVersion; /**< the value of the cec version setting */ + uint16_t m_iSettingLAMask; /**< the value of the LA mask setting */ + bool m_bNeedsWrite; /**< true when we sent changed settings to the adapter that have not been persisted */ + libcec_configuration m_persistedConfiguration; /**< the configuration that is persisted in the eeprom */ + uint32_t m_iBuildDate; /**< the build date of the firmware */ }; }