Commit | Line | Data |
---|---|---|
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 | ||
34 | #include "USBCECAdapterCommunication.h" | |
35 | ||
36 | namespace CEC | |
37 | { | |
38 | class CUSBCECAdapterCommands | |
39 | { | |
40 | public: | |
41 | CUSBCECAdapterCommands(CUSBCECAdapterCommunication *comm) : | |
42 | m_comm(comm), | |
43 | m_iFirmwareVersion(CEC_FW_VERSION_UNKNOWN) {} | |
44 | ||
45 | /*! | |
46 | * @brief Request the firmware version from the adapter. | |
47 | * @return The firmware version, or 1 (default) if it couldn't be retrieved. | |
48 | */ | |
49 | uint16_t RequestFirmwareVersion(void); | |
50 | ||
51 | /*! | |
52 | * @brief Request a setting value from the adapter. | |
53 | * @param msgCode The setting to retrieve. | |
54 | * @return The response from the adapter. | |
55 | */ | |
56 | cec_datapacket RequestSetting(cec_adapter_messagecode msgCode); | |
57 | ||
58 | /*! | |
59 | * @brief Change the value of the "auto enabled" setting. | |
60 | * @param enabled The new value. | |
61 | * @return True when set, false otherwise. | |
62 | */ | |
63 | bool SetSettingAutoEnabled(bool enabled); | |
64 | ||
65 | /*! | |
66 | * @brief Request the value of the "auto enabled" setting from the adapter. | |
67 | * @param enabled The current value. | |
68 | * @return True when retrieved, false otherwise. | |
69 | */ | |
70 | bool RequestSettingAutoEnabled(bool &enabled); | |
71 | ||
72 | /*! | |
73 | * @brief Change the value of the "device type" setting, used when the device is in autonomous mode. | |
74 | * @param type The new value. | |
75 | * @return True when set, false otherwise. | |
76 | */ | |
77 | bool SetSettingDeviceType(cec_device_type type); | |
78 | ||
79 | /*! | |
80 | * @brief Request the value of the "device type" setting from the adapter. | |
81 | * @param type The current value. | |
82 | * @return True when retrieved, false otherwise. | |
83 | */ | |
84 | bool RequestSettingDeviceType(cec_device_type &type); | |
85 | ||
86 | /*! | |
87 | * @brief Change the value of the "default logical address" setting, used when the device is in autonomous mode. | |
88 | * @param address The new value. | |
89 | * @return True when set, false otherwise. | |
90 | */ | |
91 | bool SetSettingDefaultLogicalAddress(cec_logical_address address); | |
92 | ||
93 | /*! | |
94 | * @brief Request the value of the "default logical address" setting from the adapter. | |
95 | * @param address The current value. | |
96 | * @return True when retrieved, false otherwise. | |
97 | */ | |
98 | bool RequestSettingDefaultLogicalAddress(cec_logical_address &address); | |
99 | ||
100 | /*! | |
101 | * @brief Change the value of the "logical address mask" setting, used when the device is in autonomous mode. | |
102 | * @param iMask The new value. | |
103 | * @return True when set, false otherwise. | |
104 | */ | |
105 | bool SetSettingLogicalAddressMask(uint16_t iMask); | |
106 | ||
107 | /*! | |
108 | * @brief Request the value of the "logical address mask" setting from the adapter. | |
109 | * @param iMask The current value. | |
110 | * @return True when retrieved, false otherwise. | |
111 | */ | |
112 | bool RequestSettingLogicalAddressMask(uint16_t &iMask); | |
113 | ||
114 | /*! | |
115 | * @brief Change the value of the "physical address" setting, used when the device is in autonomous mode. | |
116 | * @param iPhysicalAddress The new value. | |
117 | * @return True when set, false otherwise. | |
118 | */ | |
119 | bool SetSettingPhysicalAddress(uint16_t iPhysicalAddress); | |
120 | ||
121 | /*! | |
122 | * @brief Request the value of the "physical address" setting from the adapter. | |
123 | * @param iPhysicalAddress The current value. | |
124 | * @return True when retrieved, false otherwise. | |
125 | */ | |
126 | bool RequestSettingPhysicalAddress(uint16_t &iPhysicalAddress); | |
127 | ||
128 | /*! | |
129 | * @brief Change the value of the "CEC version" setting, used when the device is in autonomous mode. | |
130 | * @param version The new value. | |
131 | * @return True when set, false otherwise. | |
132 | */ | |
133 | bool SetSettingCECVersion(cec_version version); | |
134 | ||
135 | /*! | |
136 | * @brief Request the value of the "CEC version" setting from the adapter. | |
137 | * @param version The current value. | |
138 | * @return True when retrieved, false otherwise. | |
139 | */ | |
140 | bool RequestSettingCECVersion(cec_version &version); | |
141 | ||
142 | /*! | |
143 | * @brief Change the value of the "OSD name" setting, used when the device is in autonomous mode. | |
144 | * @param strOSDName The new value. | |
145 | * @return True when set, false otherwise. | |
146 | */ | |
147 | bool SetSettingOSDName(const char *strOSDName); | |
148 | ||
149 | /*! | |
150 | * @brief Request the value of the "OSD name" setting from the adapter. | |
151 | * @param strOSDName The current value. | |
152 | * @return True when retrieved, false otherwise. | |
153 | */ | |
154 | bool RequestSettingOSDName(CStdString &strOSDName); | |
155 | ||
156 | /*! | |
157 | * @brief Persist the current settings in the EEPROM | |
158 | * @return True when persisted, false otherwise. | |
159 | */ | |
160 | bool WriteEEPROM(void); | |
161 | ||
162 | /*! | |
163 | * @return The firmware version of the adapter, retrieved when the connection is opened. | |
164 | */ | |
165 | uint16_t GetFirmwareVersion(void) const { return m_iFirmwareVersion; }; | |
166 | ||
167 | /*! | |
168 | * @brief Persist the current configuration in the EEPROM. | |
169 | * @attention Not all settings are persisted at this time. | |
170 | * @param configuration The configuration to persist. | |
171 | * @return True when persisted, false otherwise. | |
172 | */ | |
173 | bool PersistConfiguration(libcec_configuration *configuration); | |
174 | ||
175 | /*! | |
176 | * @brief Get the persisted configuration from the EEPROM. | |
177 | * @param configuration The persisted configuration. | |
178 | * @return True when retrieved, false otherwise. | |
179 | */ | |
180 | bool GetConfiguration(libcec_configuration *configuration); | |
181 | ||
182 | /*! | |
183 | * @brief Send a ping command to the adapter. | |
184 | * @return True when acked by the adapter, false otherwise. | |
185 | */ | |
186 | bool PingAdapter(void); | |
187 | ||
188 | /*! | |
189 | * @brief Change the ackmask of the adapter. | |
190 | * @param iMask The new mask. | |
191 | * @return True when the change was acked by the adapter, false otherwise. | |
192 | */ | |
193 | bool SetAckMask(uint16_t iMask); | |
194 | ||
195 | /*! | |
196 | * @brief Put the adapter in bootloader mode. | |
197 | * @attention The connection needs to be closed after this call, since the adapter will no longer be available. | |
198 | * @return True when the command was sent, false otherwise. | |
199 | */ | |
200 | bool StartBootloader(void); | |
201 | ||
202 | /*! | |
203 | * @brief Change the current CEC line timeout. | |
204 | * @param iTimeout The new timeout. | |
205 | * @return True when the change was acked by the adapter, false otherwise. | |
206 | */ | |
207 | bool SetLineTimeout(uint8_t iTimeout); | |
208 | ||
209 | /*! | |
210 | * @brief Put the adapter in controlled or autonomous mode. | |
211 | * @param controlled True to switch to controlled mode, false to switch to auto mode. | |
212 | * @return True when acked by the controller, false otherwise. | |
213 | */ | |
214 | bool SetControlledMode(bool controlled); | |
215 | ||
216 | private: | |
217 | CUSBCECAdapterCommunication *m_comm; /**< the communication handler */ | |
218 | uint16_t m_iFirmwareVersion; /**< the firwmare version that was retrieved while opening the connection */ | |
219 | }; | |
220 | } |