LibCecSharp: fixed - set the primary LA in CecLogicalAddresses
[deb_libcec.git] / src / lib / adapter / Pulse-Eight / USBCECAdapterCommands.h
CommitLineData
a75e3a5a
LOK
1#pragma once
2/*
3 * This file is part of the libCEC(R) library.
4 *
5 * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
6 * libCEC(R) is an original work, containing original code.
7 *
8 * libCEC(R) is a trademark of Pulse-Eight Limited.
9 *
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.
14 *
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.
19 *
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.
23 *
24 *
25 * Alternatively, you can license this library under a commercial license,
26 * please contact Pulse-Eight Licensing for more information.
27 *
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/
32 */
33
a75e3a5a
LOK
34namespace CEC
35{
2b44051c
LOK
36 class CUSBCECAdapterCommunication;
37
a75e3a5a
LOK
38 class CUSBCECAdapterCommands
39 {
40 public:
7c5c5bf4 41 CUSBCECAdapterCommands(CUSBCECAdapterCommunication *comm);
a75e3a5a
LOK
42
43 /*!
44 * @brief Request the firmware version from the adapter.
45 * @return The firmware version, or 1 (default) if it couldn't be retrieved.
46 */
47 uint16_t RequestFirmwareVersion(void);
48
7c5c5bf4
LOK
49 /*!
50 * @return The firmware version of the adapter, retrieved when the connection is opened.
51 */
52 uint16_t GetFirmwareVersion(void) const { return m_persistedConfiguration.iFirmwareVersion; };
53
54 /*!
2b44051c 55 * @brief Update the current configuration in the adapter. Does not do an eeprom update.
7c5c5bf4
LOK
56 * @attention Not all settings are persisted at this time.
57 * @param configuration The configuration to persist.
2b44051c 58 * @return True when something changed, false otherwise.
7c5c5bf4 59 */
c0152c09 60 bool PersistConfiguration(const libcec_configuration &configuration);
7c5c5bf4
LOK
61
62 /*!
63 * @brief Get the persisted configuration from the EEPROM.
64 * @param configuration The persisted configuration.
65 * @return True when retrieved, false otherwise.
66 */
c0152c09 67 bool GetConfiguration(libcec_configuration &configuration);
7c5c5bf4
LOK
68
69 /*!
70 * @brief Send a ping command to the adapter.
71 * @return True when acked by the adapter, false otherwise.
72 */
73 bool PingAdapter(void);
74
75 /*!
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.
79 */
80 bool SetAckMask(uint16_t iMask);
81
82 /*!
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.
86 */
87 bool StartBootloader(void);
88
89 /*!
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.
93 */
94 bool SetLineTimeout(uint8_t iTimeout);
95
96 /*!
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.
100 */
101 bool SetControlledMode(bool controlled);
102
b2f56d35
LOK
103 /*!
104 * @brief Request the firmware build date from the device.
105 * @return The build date in seconds since epoch, or 0 when no (valid) reply was received.
106 */
107 uint32_t RequestBuildDate(void);
108
5943b9d1
LOK
109 /*!
110 * @return The persisted build date.
111 */
112 uint32_t GetPersistedBuildDate(void) const { return m_iBuildDate; };
113
2b44051c
LOK
114 /*!
115 * @brief Persist the current settings in the EEPROM
116 * @return True when persisted, false otherwise.
117 */
118 bool WriteEEPROM(void);
119
7c5c5bf4
LOK
120 private:
121 /*!
122 * @brief Reads all settings from the eeprom.
123 * @return True when read, false otherwise.
124 */
125 bool RequestSettings(void);
126
a75e3a5a
LOK
127 /*!
128 * @brief Request a setting value from the adapter.
129 * @param msgCode The setting to retrieve.
130 * @return The response from the adapter.
131 */
132 cec_datapacket RequestSetting(cec_adapter_messagecode msgCode);
133
134 /*!
135 * @brief Change the value of the "auto enabled" setting.
136 * @param enabled The new value.
2b44051c 137 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
138 */
139 bool SetSettingAutoEnabled(bool enabled);
140
141 /*!
142 * @brief Request the value of the "auto enabled" setting from the adapter.
a75e3a5a
LOK
143 * @return True when retrieved, false otherwise.
144 */
7c5c5bf4 145 bool RequestSettingAutoEnabled(void);
a75e3a5a
LOK
146
147 /*!
148 * @brief Change the value of the "device type" setting, used when the device is in autonomous mode.
149 * @param type The new value.
2b44051c 150 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
151 */
152 bool SetSettingDeviceType(cec_device_type type);
153
154 /*!
155 * @brief Request the value of the "device type" setting from the adapter.
a75e3a5a
LOK
156 * @return True when retrieved, false otherwise.
157 */
7c5c5bf4 158 bool RequestSettingDeviceType(void);
a75e3a5a
LOK
159
160 /*!
161 * @brief Change the value of the "default logical address" setting, used when the device is in autonomous mode.
162 * @param address The new value.
2b44051c 163 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
164 */
165 bool SetSettingDefaultLogicalAddress(cec_logical_address address);
166
167 /*!
168 * @brief Request the value of the "default logical address" setting from the adapter.
a75e3a5a
LOK
169 * @return True when retrieved, false otherwise.
170 */
7c5c5bf4 171 bool RequestSettingDefaultLogicalAddress(void);
a75e3a5a
LOK
172
173 /*!
174 * @brief Change the value of the "logical address mask" setting, used when the device is in autonomous mode.
175 * @param iMask The new value.
2b44051c 176 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
177 */
178 bool SetSettingLogicalAddressMask(uint16_t iMask);
179
180 /*!
181 * @brief Request the value of the "logical address mask" setting from the adapter.
a75e3a5a
LOK
182 * @return True when retrieved, false otherwise.
183 */
7c5c5bf4 184 bool RequestSettingLogicalAddressMask(void);
a75e3a5a
LOK
185
186 /*!
187 * @brief Change the value of the "physical address" setting, used when the device is in autonomous mode.
188 * @param iPhysicalAddress The new value.
2b44051c 189 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
190 */
191 bool SetSettingPhysicalAddress(uint16_t iPhysicalAddress);
192
193 /*!
194 * @brief Request the value of the "physical address" setting from the adapter.
a75e3a5a
LOK
195 * @return True when retrieved, false otherwise.
196 */
7c5c5bf4 197 bool RequestSettingPhysicalAddress(void);
a75e3a5a
LOK
198
199 /*!
200 * @brief Change the value of the "CEC version" setting, used when the device is in autonomous mode.
201 * @param version The new value.
2b44051c 202 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
203 */
204 bool SetSettingCECVersion(cec_version version);
205
206 /*!
207 * @brief Request the value of the "CEC version" setting from the adapter.
a75e3a5a
LOK
208 * @return True when retrieved, false otherwise.
209 */
7c5c5bf4 210 bool RequestSettingCECVersion(void);
a75e3a5a
LOK
211
212 /*!
213 * @brief Change the value of the "OSD name" setting, used when the device is in autonomous mode.
214 * @param strOSDName The new value.
215 * @return True when set, false otherwise.
216 */
217 bool SetSettingOSDName(const char *strOSDName);
218
219 /*!
220 * @brief Request the value of the "OSD name" setting from the adapter.
a75e3a5a
LOK
221 * @return True when retrieved, false otherwise.
222 */
7c5c5bf4 223 bool RequestSettingOSDName(void);
a75e3a5a 224
7c5c5bf4
LOK
225 CUSBCECAdapterCommunication *m_comm; /**< the communication handler */
226 bool m_bSettingsRetrieved; /**< true when the settings were read from the eeprom, false otherwise */
227 bool m_bSettingAutoEnabled; /**< the value of the auto-enabled setting */
228 cec_version m_settingCecVersion; /**< the value of the cec version setting */
229 uint16_t m_iSettingLAMask; /**< the value of the LA mask setting */
230 bool m_bNeedsWrite; /**< true when we sent changed settings to the adapter that have not been persisted */
231 libcec_configuration m_persistedConfiguration; /**< the configuration that is persisted in the eeprom */
b2f56d35 232 uint32_t m_iBuildDate; /**< the build date of the firmware */
a75e3a5a
LOK
233 };
234}