Commit | Line | Data |
---|---|---|
e9de9629 LOK |
1 | /* |
2 | * This file is part of the libCEC(R) library. | |
3 | * | |
4 | * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. | |
5 | * libCEC(R) is an original work, containing original code. | |
6 | * | |
7 | * libCEC(R) is a trademark of Pulse-Eight Limited. | |
8 | * | |
9 | * This program is dual-licensed; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 | * | |
23 | * | |
24 | * Alternatively, you can license this library under a commercial license, | |
25 | * please contact Pulse-Eight Licensing for more information. | |
26 | * | |
27 | * For more information contact: | |
28 | * Pulse-Eight Licensing <license@pulse-eight.com> | |
29 | * http://www.pulse-eight.com/ | |
30 | * http://www.pulse-eight.net/ | |
31 | */ | |
32 | ||
33 | #include "CECBusDevice.h" | |
eafa9d46 LOK |
34 | #include "../CECProcessor.h" |
35 | #include "../implementations/ANCommandHandler.h" | |
36 | #include "../implementations/CECCommandHandler.h" | |
37 | #include "../implementations/SLCommandHandler.h" | |
11621576 | 38 | #include "../implementations/VLCommandHandler.h" |
eafa9d46 | 39 | #include "../platform/timeutils.h" |
e9de9629 LOK |
40 | |
41 | using namespace CEC; | |
42 | ||
43 | CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress) : | |
44 | m_iPhysicalAddress(iPhysicalAddress), | |
45 | m_iLogicalAddress(iLogicalAddress), | |
e55f3f70 | 46 | m_powerStatus(CEC_POWER_STATUS_UNKNOWN), |
e9de9629 | 47 | m_processor(processor), |
1844f5f7 | 48 | m_bMenuActive(true), |
0ab58650 | 49 | m_iVendorClass(CEC_VENDOR_UNKNOWN), |
6a1c0009 | 50 | m_iLastActive(0), |
700c1ea7 | 51 | m_cecVersion(CEC_VERSION_1_3A) |
e9de9629 LOK |
52 | { |
53 | m_handler = new CCECCommandHandler(this); | |
51b2a094 | 54 | |
a3269a0a LOK |
55 | for (unsigned int iPtr = 0; iPtr < 4; iPtr++) |
56 | m_menuLanguage.language[iPtr] = '?'; | |
57 | m_menuLanguage.language[3] = 0; | |
58 | m_menuLanguage.device = iLogicalAddress; | |
1fcf5a3f | 59 | |
51b2a094 LOK |
60 | m_vendor.vendor = CEC_VENDOR_UNKNOWN; |
61 | m_type = CEC_DEVICE_TYPE_RESERVED; | |
62 | m_strDeviceName = "Unknown"; | |
e9de9629 LOK |
63 | } |
64 | ||
65 | CCECBusDevice::~CCECBusDevice(void) | |
66 | { | |
6a1c0009 | 67 | m_condition.Broadcast(); |
e9de9629 LOK |
68 | delete m_handler; |
69 | } | |
70 | ||
93729720 | 71 | void CCECBusDevice::AddLog(cec_log_level level, const CStdString &strMessage) |
e9de9629 | 72 | { |
93729720 | 73 | m_processor->AddLog(level, strMessage); |
e9de9629 LOK |
74 | } |
75 | ||
93729720 | 76 | bool CCECBusDevice::HandleCommand(const cec_command &command) |
f8513317 | 77 | { |
93729720 LOK |
78 | CLockObject lock(&m_mutex); |
79 | m_iLastActive = GetTimeMs(); | |
80 | m_handler->HandleCommand(command); | |
81 | m_condition.Signal(); | |
82 | return true; | |
83 | } | |
84 | ||
85 | void CCECBusDevice::PollVendorId(void) | |
86 | { | |
87 | CLockObject lock(&m_mutex); | |
88 | if (m_iLastActive > 0 && m_iLogicalAddress != CECDEVICE_BROADCAST && | |
89 | m_vendor.vendor == CEC_VENDOR_UNKNOWN && | |
90 | GetTimeMs() - m_iLastActive > 5000) | |
91 | { | |
92 | m_iLastActive = GetTimeMs(); | |
93 | ||
94 | cec_command command; | |
95 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); | |
96 | if (m_processor->Transmit(command)) | |
97 | m_condition.Wait(&m_mutex, 1000); | |
98 | } | |
99 | } | |
100 | ||
101 | bool CCECBusDevice::PowerOn(void) | |
102 | { | |
103 | CStdString strLog; | |
104 | strLog.Format("<< powering on device with logical address %d", (int8_t)m_iLogicalAddress); | |
105 | AddLog(CEC_LOG_DEBUG, strLog.c_str()); | |
106 | ||
107 | cec_command command; | |
108 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON); | |
109 | ||
110 | return m_processor->Transmit(command); | |
111 | } | |
112 | ||
113 | bool CCECBusDevice::Standby(void) | |
114 | { | |
115 | CStdString strLog; | |
116 | strLog.Format("<< putting device with logical address %d in standby mode", (int8_t)m_iLogicalAddress); | |
117 | AddLog(CEC_LOG_DEBUG, strLog.c_str()); | |
118 | ||
119 | cec_command command; | |
120 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_STANDBY); | |
121 | ||
122 | return m_processor->Transmit(command); | |
123 | } | |
124 | ||
125 | /** @name Getters */ | |
126 | //@{ | |
d7be392a | 127 | cec_version CCECBusDevice::GetCecVersion(void) |
93729720 | 128 | { |
d7be392a | 129 | if (m_cecVersion == CEC_VERSION_UNKNOWN) |
93729720 | 130 | { |
d7be392a LOK |
131 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
132 | { | |
133 | AddLog(CEC_LOG_NOTICE, "<< requesting CEC version"); | |
134 | cec_command command; | |
135 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_CEC_VERSION); | |
136 | CLockObject lock(&m_mutex); | |
137 | if (m_processor->Transmit(command)) | |
138 | m_condition.Wait(&m_mutex, 1000); | |
139 | } | |
93729720 LOK |
140 | } |
141 | ||
142 | return m_cecVersion; | |
143 | } | |
144 | ||
d7be392a | 145 | cec_menu_language &CCECBusDevice::GetMenuLanguage(void) |
93729720 | 146 | { |
d7be392a | 147 | if (!strcmp(m_menuLanguage.language, "???")) |
93729720 | 148 | { |
d7be392a LOK |
149 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
150 | { | |
151 | AddLog(CEC_LOG_NOTICE, "<< requesting menu language"); | |
152 | cec_command command; | |
153 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_MENU_LANGUAGE); | |
154 | CLockObject lock(&m_mutex); | |
155 | if (m_processor->Transmit(command)) | |
156 | m_condition.Wait(&m_mutex, 1000); | |
157 | } | |
93729720 LOK |
158 | } |
159 | ||
160 | return m_menuLanguage; | |
161 | } | |
162 | ||
163 | cec_logical_address CCECBusDevice::GetMyLogicalAddress(void) const | |
164 | { | |
165 | return m_processor->GetLogicalAddress(); | |
f8513317 LOK |
166 | } |
167 | ||
e9de9629 LOK |
168 | uint16_t CCECBusDevice::GetMyPhysicalAddress(void) const |
169 | { | |
170 | return m_processor->GetPhysicalAddress(); | |
171 | } | |
172 | ||
d7be392a | 173 | cec_power_status CCECBusDevice::GetPowerStatus(void) |
e9de9629 | 174 | { |
d7be392a | 175 | if (m_powerStatus == CEC_POWER_STATUS_UNKNOWN) |
93729720 | 176 | { |
d7be392a LOK |
177 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
178 | { | |
179 | AddLog(CEC_LOG_NOTICE, "<< requesting power status"); | |
180 | cec_command command; | |
181 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS); | |
182 | CLockObject lock(&m_mutex); | |
183 | if (m_processor->Transmit(command)) | |
184 | m_condition.Wait(&m_mutex, 1000); | |
185 | } | |
93729720 LOK |
186 | } |
187 | ||
188 | return m_powerStatus; | |
e9de9629 LOK |
189 | } |
190 | ||
93729720 | 191 | const cec_vendor &CCECBusDevice::GetVendor(void) |
a3269a0a | 192 | { |
93729720 | 193 | if (m_vendor.vendor == CEC_VENDOR_UNKNOWN) |
a3269a0a | 194 | { |
d7be392a LOK |
195 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
196 | { | |
197 | AddLog(CEC_LOG_NOTICE, "<< requesting vendor ID"); | |
198 | cec_command command; | |
199 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); | |
200 | CLockObject lock(&m_mutex); | |
93729720 | 201 | |
d7be392a LOK |
202 | if (m_processor->Transmit(command)) |
203 | m_condition.Wait(&m_mutex, 1000); | |
204 | } | |
a3269a0a | 205 | } |
93729720 LOK |
206 | |
207 | return m_vendor; | |
208 | } | |
209 | ||
210 | bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const | |
211 | { | |
212 | return m_processor->HasLogicalAddress(address); | |
a3269a0a LOK |
213 | } |
214 | ||
93729720 LOK |
215 | //@} |
216 | ||
217 | /** @name Setters */ | |
218 | //@{ | |
e55f3f70 | 219 | void CCECBusDevice::SetCecVersion(const cec_version newVersion) |
6a1c0009 LOK |
220 | { |
221 | CStdString strLog; | |
222 | m_cecVersion = newVersion; | |
223 | ||
224 | switch (newVersion) | |
225 | { | |
226 | case CEC_VERSION_1_2: | |
227 | strLog.Format("device %d reports CEC version 1.2", m_iLogicalAddress); | |
228 | break; | |
229 | case CEC_VERSION_1_2A: | |
230 | strLog.Format("device %d reports CEC version 1.2a", m_iLogicalAddress); | |
231 | break; | |
232 | case CEC_VERSION_1_3: | |
233 | strLog.Format("device %d reports CEC version 1.3", m_iLogicalAddress); | |
234 | break; | |
235 | case CEC_VERSION_1_3A: | |
236 | strLog.Format("device %d reports CEC version 1.3a", m_iLogicalAddress); | |
237 | break; | |
238 | default: | |
239 | strLog.Format("device %d reports an unknown CEC version", m_iLogicalAddress); | |
240 | m_cecVersion = CEC_VERSION_UNKNOWN; | |
241 | break; | |
242 | } | |
243 | AddLog(CEC_LOG_DEBUG, strLog); | |
244 | } | |
245 | ||
93729720 LOK |
246 | void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language) |
247 | { | |
248 | if (language.device == m_iLogicalAddress) | |
249 | { | |
250 | CStdString strLog; | |
251 | strLog.Format("device %d menu language set to '%s'", m_iLogicalAddress, language.language); | |
252 | m_processor->AddLog(CEC_LOG_DEBUG, strLog); | |
253 | m_menuLanguage = language; | |
254 | } | |
255 | } | |
256 | ||
93729720 LOK |
257 | void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */) |
258 | { | |
259 | if (iNewAddress > 0) | |
260 | { | |
261 | CStdString strLog; | |
262 | strLog.Format(">> %i changed physical address from %04x to %04x", m_iLogicalAddress, m_iPhysicalAddress, iNewAddress); | |
263 | AddLog(CEC_LOG_DEBUG, strLog.c_str()); | |
264 | ||
265 | m_iPhysicalAddress = iNewAddress; | |
266 | } | |
267 | } | |
268 | ||
e55f3f70 LOK |
269 | void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus) |
270 | { | |
b0271d54 LOK |
271 | if (m_powerStatus != powerStatus) |
272 | { | |
273 | CStdString strLog; | |
274 | strLog.Format("device %d power status changed from %2x to %2x", m_iLogicalAddress, m_powerStatus, powerStatus); | |
275 | m_processor->AddLog(CEC_LOG_DEBUG, strLog); | |
276 | m_powerStatus = powerStatus; | |
277 | } | |
e55f3f70 LOK |
278 | } |
279 | ||
0f23c85c LOK |
280 | void CCECBusDevice::SetVendorId(const cec_datapacket &data) |
281 | { | |
282 | if (data.size < 3) | |
283 | { | |
284 | AddLog(CEC_LOG_WARNING, "invalid vendor ID received"); | |
285 | return; | |
286 | } | |
287 | ||
288 | uint64_t iVendorId = ((uint64_t)data[0] << 3) + | |
289 | ((uint64_t)data[1] << 2) + | |
290 | (uint64_t)data[2]; | |
291 | ||
292 | SetVendorId(iVendorId, data.size >= 4 ? data[3] : 0); | |
293 | } | |
294 | ||
2cd8b5d0 | 295 | void CCECBusDevice::SetVendorId(uint64_t iVendorId, uint8_t iVendorClass /* = 0 */) |
e9de9629 | 296 | { |
0500da96 | 297 | m_vendor.vendor = (cec_vendor_id)iVendorId; |
e9de9629 LOK |
298 | m_iVendorClass = iVendorClass; |
299 | ||
300 | switch (iVendorId) | |
301 | { | |
302 | case CEC_VENDOR_SAMSUNG: | |
0ab58650 LOK |
303 | if (m_handler->GetVendorId() != CEC_VENDOR_SAMSUNG) |
304 | { | |
305 | delete m_handler; | |
306 | m_handler = new CANCommandHandler(this); | |
307 | } | |
e9de9629 LOK |
308 | break; |
309 | case CEC_VENDOR_LG: | |
0ab58650 LOK |
310 | if (m_handler->GetVendorId() != CEC_VENDOR_LG) |
311 | { | |
312 | delete m_handler; | |
313 | m_handler = new CSLCommandHandler(this); | |
314 | } | |
e9de9629 | 315 | break; |
11621576 LOK |
316 | case CEC_VENDOR_PANASONIC: |
317 | if (m_handler->GetVendorId() != CEC_VENDOR_PANASONIC) | |
318 | { | |
319 | delete m_handler; | |
320 | m_handler = new CVLCommandHandler(this); | |
321 | } | |
322 | break; | |
e9de9629 | 323 | default: |
0ab58650 LOK |
324 | if (m_handler->GetVendorId() != CEC_VENDOR_UNKNOWN) |
325 | { | |
326 | delete m_handler; | |
327 | m_handler = new CCECCommandHandler(this); | |
328 | } | |
e9de9629 LOK |
329 | break; |
330 | } | |
331 | ||
332 | CStdString strLog; | |
0f23c85c | 333 | strLog.Format("device %d: vendor = %s (%06x) class = %2x", m_iLogicalAddress, GetVendorName(), GetVendorId(), GetVendorClass()); |
e9de9629 LOK |
334 | m_processor->AddLog(CEC_LOG_DEBUG, strLog.c_str()); |
335 | } | |
93729720 | 336 | //@} |
e9de9629 | 337 | |
93729720 LOK |
338 | /** @name Transmit methods */ |
339 | //@{ | |
340 | bool CCECBusDevice::TransmitActiveSource(void) | |
0f23c85c | 341 | { |
d7be392a | 342 | CStdString strLog; |
6685ae07 | 343 | strLog.Format("<< %x -> broadcast: active source (%4x)", m_iLogicalAddress, m_iPhysicalAddress); |
d7be392a | 344 | AddLog(CEC_LOG_NOTICE, strLog); |
0f23c85c LOK |
345 | |
346 | cec_command command; | |
93729720 LOK |
347 | cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE); |
348 | command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF)); | |
349 | command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF)); | |
0f23c85c LOK |
350 | |
351 | return m_processor->Transmit(command); | |
352 | } | |
353 | ||
93729720 | 354 | bool CCECBusDevice::TransmitActiveView(void) |
0f23c85c | 355 | { |
d7be392a | 356 | CStdString strLog; |
6685ae07 | 357 | strLog.Format("<< %x -> broadcast: active view (%4x)", m_iLogicalAddress, m_iPhysicalAddress); |
d7be392a | 358 | AddLog(CEC_LOG_NOTICE, strLog); |
0f23c85c LOK |
359 | |
360 | cec_command command; | |
93729720 LOK |
361 | cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE); |
362 | command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF); | |
363 | command.parameters.push_back(m_iPhysicalAddress & 0xFF); | |
0f23c85c LOK |
364 | |
365 | return m_processor->Transmit(command); | |
366 | } | |
367 | ||
29912296 | 368 | bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest) |
0f23c85c | 369 | { |
d7be392a LOK |
370 | CStdString strLog; |
371 | strLog.Format("<< %x -> %x: cec version ", m_iLogicalAddress, dest); | |
372 | switch (m_cecVersion) | |
373 | { | |
374 | case CEC_VERSION_1_2: | |
375 | strLog.append("1.2"); | |
376 | break; | |
377 | case CEC_VERSION_1_2A: | |
378 | strLog.append("1.2a"); | |
379 | break; | |
380 | case CEC_VERSION_1_3: | |
381 | strLog.append("1.3"); | |
382 | break; | |
383 | case CEC_VERSION_1_3A: | |
384 | strLog.append("1.3a"); | |
385 | break; | |
386 | default: | |
387 | strLog.append("unknown"); | |
388 | break; | |
389 | } | |
390 | AddLog(CEC_LOG_NOTICE, strLog); | |
0f23c85c LOK |
391 | |
392 | cec_command command; | |
f8513317 | 393 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_CEC_VERSION); |
700c1ea7 | 394 | command.parameters.push_back(m_cecVersion); |
0f23c85c LOK |
395 | |
396 | return m_processor->Transmit(command); | |
397 | } | |
398 | ||
29912296 | 399 | bool CCECBusDevice::TransmitDeckStatus(cec_logical_address dest) |
0f23c85c LOK |
400 | { |
401 | // need to support opcodes play and deck control before doing anything with this | |
d7be392a LOK |
402 | CStdString strLog; |
403 | strLog.Format("<< %x -> %x: deck status feature abort", m_iLogicalAddress, dest); | |
404 | AddLog(CEC_LOG_NOTICE, strLog); | |
405 | ||
a1f8fb1b | 406 | m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DECK_STATUS); |
0f23c85c LOK |
407 | return false; |
408 | } | |
409 | ||
93729720 LOK |
410 | bool CCECBusDevice::TransmitInactiveView(void) |
411 | { | |
d7be392a LOK |
412 | CStdString strLog; |
413 | strLog.Format("<< %x -> broadcast: inactive view", m_iLogicalAddress); | |
414 | AddLog(CEC_LOG_NOTICE, strLog); | |
93729720 LOK |
415 | |
416 | cec_command command; | |
417 | cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_INACTIVE_SOURCE); | |
418 | command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF); | |
419 | command.parameters.push_back(m_iPhysicalAddress & 0xFF); | |
420 | ||
421 | return m_processor->Transmit(command); | |
422 | } | |
423 | ||
29912296 | 424 | bool CCECBusDevice::TransmitMenuState(cec_logical_address dest) |
0f23c85c | 425 | { |
d7be392a LOK |
426 | CStdString strLog; |
427 | strLog.Format("<< %x -> %x: ", m_iLogicalAddress, dest); | |
1844f5f7 | 428 | if (m_bMenuActive) |
d7be392a | 429 | strLog.append("menu active"); |
0f23c85c | 430 | else |
d7be392a LOK |
431 | strLog.append("menu inactive"); |
432 | AddLog(CEC_LOG_NOTICE, strLog); | |
0f23c85c LOK |
433 | |
434 | cec_command command; | |
f8513317 | 435 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_MENU_STATUS); |
1844f5f7 | 436 | command.parameters.push_back(m_bMenuActive ? (uint8_t) CEC_MENU_STATE_ACTIVATED : (uint8_t) CEC_MENU_STATE_DEACTIVATED); |
0f23c85c LOK |
437 | |
438 | return m_processor->Transmit(command); | |
439 | } | |
440 | ||
29912296 | 441 | bool CCECBusDevice::TransmitOSDName(cec_logical_address dest) |
0f23c85c | 442 | { |
0f23c85c | 443 | CStdString strLog; |
d7be392a | 444 | strLog.Format("<< %x -> %x: OSD name '%s'", m_iLogicalAddress, dest, m_strDeviceName.c_str()); |
0f23c85c LOK |
445 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); |
446 | ||
447 | cec_command command; | |
f8513317 | 448 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_NAME); |
787a3cb8 LOK |
449 | for (unsigned int iPtr = 0; iPtr < m_strDeviceName.length(); iPtr++) |
450 | command.parameters.push_back(m_strDeviceName.at(iPtr)); | |
0f23c85c LOK |
451 | |
452 | return m_processor->Transmit(command); | |
453 | } | |
454 | ||
38bdb943 LOK |
455 | bool CCECBusDevice::TransmitOSDString(cec_logical_address dest, cec_display_control duration, const char *strMessage) |
456 | { | |
457 | CStdString strLog; | |
d7be392a | 458 | strLog.Format("<< %x -> %x: display OSD message '%s'", m_iLogicalAddress, dest, strMessage); |
38bdb943 LOK |
459 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); |
460 | ||
461 | cec_command command; | |
462 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_STRING); | |
463 | command.parameters.push_back((uint8_t)duration); | |
464 | ||
465 | unsigned int iLen = strlen(strMessage); | |
466 | if (iLen > 13) iLen = 13; | |
467 | ||
468 | for (unsigned int iPtr = 0; iPtr < iLen; iPtr++) | |
469 | command.parameters.push_back(strMessage[iPtr]); | |
470 | ||
471 | return m_processor->Transmit(command); | |
472 | } | |
473 | ||
29912296 | 474 | bool CCECBusDevice::TransmitPhysicalAddress(void) |
0f23c85c LOK |
475 | { |
476 | CStdString strLog; | |
d7be392a | 477 | strLog.Format("<< %x -> broadcast: physical adddress %4x", m_iLogicalAddress, m_iPhysicalAddress); |
0f23c85c LOK |
478 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); |
479 | ||
480 | cec_command command; | |
f8513317 | 481 | cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS); |
0f23c85c LOK |
482 | command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF)); |
483 | command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF)); | |
6fc97923 | 484 | command.parameters.push_back((uint8_t) (m_type)); |
0f23c85c LOK |
485 | |
486 | return m_processor->Transmit(command); | |
487 | } | |
488 | ||
93729720 | 489 | bool CCECBusDevice::TransmitPoll(cec_logical_address dest) |
57f45e6c LOK |
490 | { |
491 | bool bReturn(false); | |
492 | ||
93729720 LOK |
493 | if (dest == CECDEVICE_UNKNOWN) |
494 | dest = m_iLogicalAddress; | |
f8513317 | 495 | |
57f45e6c | 496 | CStdString strLog; |
d7be392a LOK |
497 | strLog.Format("<< %x -> %x: POLL", m_iLogicalAddress, dest); |
498 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); | |
57f45e6c LOK |
499 | |
500 | cec_command command; | |
93729720 | 501 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_NONE); |
57f45e6c LOK |
502 | CLockObject lock(&m_mutex); |
503 | ||
504 | bReturn = m_processor->Transmit(command); | |
505 | AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent"); | |
506 | return bReturn; | |
507 | } | |
93729720 LOK |
508 | |
509 | bool CCECBusDevice::TransmitPowerState(cec_logical_address dest) | |
510 | { | |
511 | CStdString strLog; | |
d7be392a LOK |
512 | strLog.Format("<< %x -> %x: ", m_iLogicalAddress, dest); |
513 | ||
514 | switch (m_powerStatus) | |
515 | { | |
516 | case CEC_POWER_STATUS_ON: | |
517 | strLog.append("powered on"); | |
518 | break; | |
519 | case CEC_POWER_STATUS_STANDBY: | |
520 | strLog.append("in standby mode"); | |
521 | break; | |
522 | case CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY: | |
523 | strLog.append("in transition from on to standby"); | |
524 | break; | |
525 | case CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON: | |
526 | strLog.append("in transition from standby to on"); | |
527 | break; | |
528 | default: | |
529 | strLog.append("power state unknown"); | |
530 | break; | |
531 | } | |
532 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); | |
533 | ||
93729720 LOK |
534 | strLog.Format("<< reporting power status '%d'", m_powerStatus); |
535 | AddLog(CEC_LOG_NOTICE, strLog); | |
536 | ||
537 | cec_command command; | |
538 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_REPORT_POWER_STATUS); | |
539 | command.parameters.push_back((uint8_t) m_powerStatus); | |
540 | ||
541 | return m_processor->Transmit(command); | |
542 | } | |
543 | ||
544 | bool CCECBusDevice::TransmitVendorID(cec_logical_address dest) | |
545 | { | |
d7be392a LOK |
546 | CStdString strLog; |
547 | strLog.Format("<< %x -> %x: vendor id feature abort", m_iLogicalAddress, dest); | |
548 | AddLog(CEC_LOG_NOTICE, strLog); | |
549 | ||
93729720 LOK |
550 | m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); |
551 | return false; | |
552 | } | |
553 | //@} |