3 * This file is part of the libCEC(R) library.
5 * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
6 * libCEC(R) is an original work, containing original code.
8 * libCEC(R) is a trademark of Pulse-Eight Limited.
10 * This program is dual-licensed; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * Alternatively, you can license this library under a commercial license,
26 * please contact Pulse-Eight Licensing for more information.
28 * For more information contact:
29 * Pulse-Eight Licensing <license@pulse-eight.com>
30 * http://www.pulse-eight.com/
31 * http://www.pulse-eight.net/
34 #include "USBCECAdapterCommunication.h"
38 class CUSBCECAdapterCommands
41 CUSBCECAdapterCommands(CUSBCECAdapterCommunication
*comm
);
44 * @brief Request the firmware version from the adapter.
45 * @return The firmware version, or 1 (default) if it couldn't be retrieved.
47 uint16_t RequestFirmwareVersion(void);
50 * @return The firmware version of the adapter, retrieved when the connection is opened.
52 uint16_t GetFirmwareVersion(void) const { return m_persistedConfiguration
.iFirmwareVersion
; };
55 * @brief Persist the current configuration in the EEPROM.
56 * @attention Not all settings are persisted at this time.
57 * @param configuration The configuration to persist.
58 * @return True when persisted, false otherwise.
60 bool PersistConfiguration(libcec_configuration
*configuration
);
63 * @brief Get the persisted configuration from the EEPROM.
64 * @param configuration The persisted configuration.
65 * @return True when retrieved, false otherwise.
67 bool GetConfiguration(libcec_configuration
*configuration
);
70 * @brief Send a ping command to the adapter.
71 * @return True when acked by the adapter, false otherwise.
73 bool PingAdapter(void);
76 * @brief Change the ackmask of the adapter.
77 * @param iMask The new mask.
78 * @return True when the change was acked by the adapter, false otherwise.
80 bool SetAckMask(uint16_t iMask
);
83 * @brief Put the adapter in bootloader mode.
84 * @attention The connection needs to be closed after this call, since the adapter will no longer be available.
85 * @return True when the command was sent, false otherwise.
87 bool StartBootloader(void);
90 * @brief Change the current CEC line timeout.
91 * @param iTimeout The new timeout.
92 * @return True when the change was acked by the adapter, false otherwise.
94 bool SetLineTimeout(uint8_t iTimeout
);
97 * @brief Put the adapter in controlled or autonomous mode.
98 * @param controlled True to switch to controlled mode, false to switch to auto mode.
99 * @return True when acked by the controller, false otherwise.
101 bool SetControlledMode(bool controlled
);
105 * @brief Reads all settings from the eeprom.
106 * @return True when read, false otherwise.
108 bool RequestSettings(void);
111 * @brief Request a setting value from the adapter.
112 * @param msgCode The setting to retrieve.
113 * @return The response from the adapter.
115 cec_datapacket
RequestSetting(cec_adapter_messagecode msgCode
);
118 * @brief Change the value of the "auto enabled" setting.
119 * @param enabled The new value.
120 * @return True when set, false otherwise.
122 bool SetSettingAutoEnabled(bool enabled
);
125 * @brief Request the value of the "auto enabled" setting from the adapter.
126 * @return True when retrieved, false otherwise.
128 bool RequestSettingAutoEnabled(void);
131 * @brief Change the value of the "device type" setting, used when the device is in autonomous mode.
132 * @param type The new value.
133 * @return True when set, false otherwise.
135 bool SetSettingDeviceType(cec_device_type type
);
138 * @brief Request the value of the "device type" setting from the adapter.
139 * @return True when retrieved, false otherwise.
141 bool RequestSettingDeviceType(void);
144 * @brief Change the value of the "default logical address" setting, used when the device is in autonomous mode.
145 * @param address The new value.
146 * @return True when set, false otherwise.
148 bool SetSettingDefaultLogicalAddress(cec_logical_address address
);
151 * @brief Request the value of the "default logical address" setting from the adapter.
152 * @return True when retrieved, false otherwise.
154 bool RequestSettingDefaultLogicalAddress(void);
157 * @brief Change the value of the "logical address mask" setting, used when the device is in autonomous mode.
158 * @param iMask The new value.
159 * @return True when set, false otherwise.
161 bool SetSettingLogicalAddressMask(uint16_t iMask
);
164 * @brief Request the value of the "logical address mask" setting from the adapter.
165 * @return True when retrieved, false otherwise.
167 bool RequestSettingLogicalAddressMask(void);
170 * @brief Change the value of the "physical address" setting, used when the device is in autonomous mode.
171 * @param iPhysicalAddress The new value.
172 * @return True when set, false otherwise.
174 bool SetSettingPhysicalAddress(uint16_t iPhysicalAddress
);
177 * @brief Request the value of the "physical address" setting from the adapter.
178 * @return True when retrieved, false otherwise.
180 bool RequestSettingPhysicalAddress(void);
183 * @brief Change the value of the "CEC version" setting, used when the device is in autonomous mode.
184 * @param version The new value.
185 * @return True when set, false otherwise.
187 bool SetSettingCECVersion(cec_version version
);
190 * @brief Request the value of the "CEC version" setting from the adapter.
191 * @return True when retrieved, false otherwise.
193 bool RequestSettingCECVersion(void);
196 * @brief Change the value of the "OSD name" setting, used when the device is in autonomous mode.
197 * @param strOSDName The new value.
198 * @return True when set, false otherwise.
200 bool SetSettingOSDName(const char *strOSDName
);
203 * @brief Request the value of the "OSD name" setting from the adapter.
204 * @return True when retrieved, false otherwise.
206 bool RequestSettingOSDName(void);
209 * @brief Persist the current settings in the EEPROM
210 * @return True when persisted, false otherwise.
212 bool WriteEEPROM(void);
214 CUSBCECAdapterCommunication
*m_comm
; /**< the communication handler */
215 bool m_bSettingsRetrieved
; /**< true when the settings were read from the eeprom, false otherwise */
216 bool m_bSettingAutoEnabled
; /**< the value of the auto-enabled setting */
217 cec_version m_settingCecVersion
; /**< the value of the cec version setting */
218 uint16_t m_iSettingLAMask
; /**< the value of the LA mask setting */
219 bool m_bNeedsWrite
; /**< true when we sent changed settings to the adapter that have not been persisted */
220 libcec_configuration m_persistedConfiguration
; /**< the configuration that is persisted in the eeprom */