3 * This file is part of the libCEC(R) library.
5 * libCEC(R) is Copyright (C) 2011-2013 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 "lib/platform/threads/mutex.h"
35 #include "USBCECAdapterMessage.h"
39 class CUSBCECAdapterCommunication
;
41 class CUSBCECAdapterCommands
44 CUSBCECAdapterCommands(CUSBCECAdapterCommunication
*comm
);
47 * @brief Request the firmware version from the adapter.
48 * @return The firmware version, or 1 (default) if it couldn't be retrieved.
50 uint16_t RequestFirmwareVersion(void);
53 * @return The firmware version of the adapter, retrieved when the connection is opened.
55 uint16_t GetFirmwareVersion(void) const { return m_persistedConfiguration
.iFirmwareVersion
; };
58 * @brief Update the current configuration in the adapter. Does not do an eeprom update.
59 * @attention Not all settings are persisted at this time.
60 * @param configuration The configuration to persist.
61 * @return True when something changed, false otherwise.
63 bool PersistConfiguration(const libcec_configuration
&configuration
);
66 * @brief Get the persisted configuration from the EEPROM.
67 * @param configuration The persisted configuration.
68 * @return True when retrieved, false otherwise.
70 bool GetConfiguration(libcec_configuration
&configuration
);
73 * @brief Send a ping command to the adapter.
74 * @return True when acked by the adapter, false otherwise.
76 bool PingAdapter(void);
79 * @brief Change the ackmask of the adapter.
80 * @param iMask The new mask.
81 * @return True when the change was acked by the adapter, false otherwise.
83 bool SetAckMask(uint16_t iMask
);
86 * @brief Put the adapter in bootloader mode.
87 * @attention The connection needs to be closed after this call, since the adapter will no longer be available.
88 * @return True when the command was sent, false otherwise.
90 bool StartBootloader(void);
93 * @brief Change the current CEC line timeout.
94 * @param iTimeout The new timeout.
95 * @return True when the change was acked by the adapter, false otherwise.
97 bool SetLineTimeout(uint8_t iTimeout
);
100 * @brief Put the adapter in controlled or autonomous mode.
101 * @param controlled True to switch to controlled mode, false to switch to auto mode.
102 * @return True when acked by the controller, false otherwise.
104 bool SetControlledMode(bool controlled
);
107 * @brief Request the firmware build date from the device.
108 * @return The build date in seconds since epoch, or 0 when no (valid) reply was received.
110 uint32_t RequestBuildDate(void);
113 * @return The persisted build date.
115 uint32_t GetPersistedBuildDate(void) const { return m_iBuildDate
; };
118 * @brief Request the adapter type.
121 p8_cec_adapter_type
RequestAdapterType(void);
124 * @return The persisted build date.
126 p8_cec_adapter_type
GetPersistedAdapterType(void) const { return m_adapterType
; };
129 * @brief Persist the current settings in the EEPROM
130 * @return True when persisted, false otherwise.
132 bool WriteEEPROM(void);
134 void SetActiveSource(bool bSetTo
, bool bClientUnregistered
);
138 * @brief Reads all settings from the eeprom.
139 * @return True when read, false otherwise.
141 bool RequestSettings(void);
144 * @brief Request a setting value from the adapter.
145 * @param msgCode The setting to retrieve.
146 * @return The response from the adapter.
148 cec_datapacket
RequestSetting(cec_adapter_messagecode msgCode
);
151 * @brief Change the value of the "auto enabled" setting.
152 * @param enabled The new value.
153 * @return True when changed and set, false otherwise.
155 bool SetSettingAutoEnabled(bool enabled
);
158 * @brief Request the value of the "auto enabled" setting from the adapter.
159 * @return True when retrieved, false otherwise.
161 bool RequestSettingAutoEnabled(void);
164 * @brief Change the value of the "device type" setting, used when the device is in autonomous mode.
165 * @param type The new value.
166 * @return True when changed and set, false otherwise.
168 bool SetSettingDeviceType(cec_device_type type
);
171 * @brief Request the value of the "device type" setting from the adapter.
172 * @return True when retrieved, false otherwise.
174 bool RequestSettingDeviceType(void);
177 * @brief Change the value of the "default logical address" setting, used when the device is in autonomous mode.
178 * @param address The new value.
179 * @return True when changed and set, false otherwise.
181 bool SetSettingDefaultLogicalAddress(cec_logical_address address
);
184 * @brief Request the value of the "default logical address" setting from the adapter.
185 * @return True when retrieved, false otherwise.
187 bool RequestSettingDefaultLogicalAddress(void);
190 * @brief Change the value of the "logical address mask" setting, used when the device is in autonomous mode.
191 * @param iMask The new value.
192 * @return True when changed and set, false otherwise.
194 bool SetSettingLogicalAddressMask(uint16_t iMask
);
197 * @brief Request the value of the "logical address mask" setting from the adapter.
198 * @return True when retrieved, false otherwise.
200 bool RequestSettingLogicalAddressMask(void);
203 * @brief Change the value of the "physical address" setting, used when the device is in autonomous mode.
204 * @param iPhysicalAddress The new value.
205 * @return True when changed and set, false otherwise.
207 bool SetSettingPhysicalAddress(uint16_t iPhysicalAddress
);
210 * @brief Request the value of the "physical address" setting from the adapter.
211 * @return True when retrieved, false otherwise.
213 bool RequestSettingPhysicalAddress(void);
216 * @brief Change the value of the "CEC version" setting, used when the device is in autonomous mode.
217 * @param version The new value.
218 * @return True when changed and set, false otherwise.
220 bool SetSettingCECVersion(cec_version version
);
223 * @brief Request the value of the "CEC version" setting from the adapter.
224 * @return True when retrieved, false otherwise.
226 bool RequestSettingCECVersion(void);
229 * @brief Change the value of the "OSD name" setting, used when the device is in autonomous mode.
230 * @param strOSDName The new value.
231 * @return True when set, false otherwise.
233 bool SetSettingOSDName(const char *strOSDName
);
236 * @brief Request the value of the "OSD name" setting from the adapter.
237 * @return True when retrieved, false otherwise.
239 bool RequestSettingOSDName(void);
241 CUSBCECAdapterCommunication
*m_comm
; /**< the communication handler */
242 bool m_bSettingsRetrieved
; /**< true when the settings were read from the eeprom, false otherwise */
243 bool m_bSettingAutoEnabled
; /**< the value of the auto-enabled setting */
244 cec_version m_settingCecVersion
; /**< the value of the cec version setting */
245 uint16_t m_iSettingLAMask
; /**< the value of the LA mask setting */
246 bool m_bNeedsWrite
; /**< true when we sent changed settings to the adapter that have not been persisted */
247 libcec_configuration m_persistedConfiguration
; /**< the configuration that is persisted in the eeprom */
248 uint32_t m_iBuildDate
; /**< the build date of the firmware */
249 bool m_bControlledMode
; /**< current value of the controlled mode feature */
250 p8_cec_adapter_type m_adapterType
; /**< the type of the adapter that we're connected to */
251 PLATFORM::CMutex m_mutex
;