cec: make add() and clear() camelcased again and re-add the old methods and mark...
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
CommitLineData
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
41using namespace CEC;
42
c4098482
LOK
43#define ToString(p) CCECCommandHandler::ToString(p)
44
e9de9629 45CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress) :
c4098482 46 m_type(CEC_DEVICE_TYPE_RESERVED),
e9de9629 47 m_iPhysicalAddress(iPhysicalAddress),
9dc04b07 48 m_iStreamPath(0),
e9de9629 49 m_iLogicalAddress(iLogicalAddress),
e55f3f70 50 m_powerStatus(CEC_POWER_STATUS_UNKNOWN),
e9de9629 51 m_processor(processor),
c4098482 52 m_vendor(CEC_VENDOR_UNKNOWN),
4abd6768 53 m_menuState(CEC_MENU_STATE_ACTIVATED),
8747dd4f 54 m_bActiveSource(false),
d54e8570 55 m_iLastCommandSent(0),
6a1c0009 56 m_iLastActive(0),
5e822b09 57 m_cecVersion(CEC_VERSION_UNKNOWN)
e9de9629
LOK
58{
59 m_handler = new CCECCommandHandler(this);
51b2a094 60
a3269a0a
LOK
61 for (unsigned int iPtr = 0; iPtr < 4; iPtr++)
62 m_menuLanguage.language[iPtr] = '?';
63 m_menuLanguage.language[3] = 0;
64 m_menuLanguage.device = iLogicalAddress;
1fcf5a3f 65
c4098482 66 m_strDeviceName = ToString(m_iLogicalAddress);
e9de9629
LOK
67}
68
69CCECBusDevice::~CCECBusDevice(void)
70{
6a1c0009 71 m_condition.Broadcast();
e9de9629
LOK
72 delete m_handler;
73}
74
93729720 75void CCECBusDevice::AddLog(cec_log_level level, const CStdString &strMessage)
e9de9629 76{
93729720 77 m_processor->AddLog(level, strMessage);
e9de9629
LOK
78}
79
93729720 80bool CCECBusDevice::HandleCommand(const cec_command &command)
f8513317 81{
93729720
LOK
82 CLockObject lock(&m_mutex);
83 m_iLastActive = GetTimeMs();
84 m_handler->HandleCommand(command);
85 m_condition.Signal();
86 return true;
87}
88
89void CCECBusDevice::PollVendorId(void)
90{
91 CLockObject lock(&m_mutex);
92 if (m_iLastActive > 0 && m_iLogicalAddress != CECDEVICE_BROADCAST &&
c4098482 93 m_vendor == CEC_VENDOR_UNKNOWN &&
d54e8570 94 GetTimeMs() - m_iLastCommandSent > 5000 &&
315ff809 95 !m_processor->IsMonitoring())
93729720 96 {
5e822b09 97 CStdString strLog;
62f5527d 98 strLog.Format("<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
5e822b09 99 AddLog(CEC_LOG_NOTICE, strLog);
d54e8570 100 m_iLastCommandSent = GetTimeMs();
93729720
LOK
101
102 cec_command command;
ab1469a0 103 cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
93729720
LOK
104 if (m_processor->Transmit(command))
105 m_condition.Wait(&m_mutex, 1000);
106 }
107}
108
109bool CCECBusDevice::PowerOn(void)
110{
f437e4be
LOK
111 cec_power_status current = GetPowerStatus();
112 if (current != CEC_POWER_STATUS_ON &&
113 current != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON)
114 {
115 CStdString strLog;
116 strLog.Format("<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
117 AddLog(CEC_LOG_DEBUG, strLog.c_str());
93729720 118
f437e4be 119 SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
93729720 120
f437e4be 121 cec_command command;
ab1469a0 122 cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON);
f437e4be
LOK
123
124 return m_processor->Transmit(command);
125 }
126
127 return true;
93729720
LOK
128}
129
130bool CCECBusDevice::Standby(void)
131{
132 CStdString strLog;
62f5527d 133 strLog.Format("<< putting '%s' (%X) in standby mode", GetLogicalAddressName(), m_iLogicalAddress);
93729720
LOK
134 AddLog(CEC_LOG_DEBUG, strLog.c_str());
135
136 cec_command command;
ab1469a0 137 cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_STANDBY);
93729720
LOK
138
139 return m_processor->Transmit(command);
140}
141
142/** @name Getters */
143//@{
d7be392a 144cec_version CCECBusDevice::GetCecVersion(void)
93729720 145{
d7be392a 146 if (m_cecVersion == CEC_VERSION_UNKNOWN)
93729720 147 {
d7be392a
LOK
148 if (!MyLogicalAddressContains(m_iLogicalAddress))
149 {
5e822b09 150 CStdString strLog;
62f5527d 151 strLog.Format("<< requesting CEC version of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
5e822b09 152 AddLog(CEC_LOG_NOTICE, strLog);
d7be392a 153 cec_command command;
ab1469a0 154 cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_CEC_VERSION);
d7be392a
LOK
155 CLockObject lock(&m_mutex);
156 if (m_processor->Transmit(command))
157 m_condition.Wait(&m_mutex, 1000);
158 }
93729720
LOK
159 }
160
161 return m_cecVersion;
162}
163
62f5527d
LOK
164const char* CCECBusDevice::GetLogicalAddressName(void) const
165{
c4098482 166 return ToString(m_iLogicalAddress);
62f5527d
LOK
167}
168
d7be392a 169cec_menu_language &CCECBusDevice::GetMenuLanguage(void)
93729720 170{
d7be392a 171 if (!strcmp(m_menuLanguage.language, "???"))
93729720 172 {
d7be392a
LOK
173 if (!MyLogicalAddressContains(m_iLogicalAddress))
174 {
5e822b09 175 CStdString strLog;
62f5527d 176 strLog.Format("<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
5e822b09 177 AddLog(CEC_LOG_NOTICE, strLog);
d7be392a 178 cec_command command;
ab1469a0 179 cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_MENU_LANGUAGE);
d7be392a
LOK
180 CLockObject lock(&m_mutex);
181 if (m_processor->Transmit(command))
182 m_condition.Wait(&m_mutex, 1000);
183 }
93729720
LOK
184 }
185
186 return m_menuLanguage;
187}
188
189cec_logical_address CCECBusDevice::GetMyLogicalAddress(void) const
190{
191 return m_processor->GetLogicalAddress();
f8513317
LOK
192}
193
e9de9629
LOK
194uint16_t CCECBusDevice::GetMyPhysicalAddress(void) const
195{
196 return m_processor->GetPhysicalAddress();
197}
198
d7be392a 199cec_power_status CCECBusDevice::GetPowerStatus(void)
e9de9629 200{
d7be392a 201 if (m_powerStatus == CEC_POWER_STATUS_UNKNOWN)
93729720 202 {
d7be392a
LOK
203 if (!MyLogicalAddressContains(m_iLogicalAddress))
204 {
5e822b09 205 CStdString strLog;
62f5527d 206 strLog.Format("<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
5e822b09 207 AddLog(CEC_LOG_NOTICE, strLog);
d7be392a 208 cec_command command;
ab1469a0 209 cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS);
d7be392a
LOK
210 CLockObject lock(&m_mutex);
211 if (m_processor->Transmit(command))
212 m_condition.Wait(&m_mutex, 1000);
213 }
93729720
LOK
214 }
215
216 return m_powerStatus;
e9de9629
LOK
217}
218
c4098482 219const cec_vendor_id CCECBusDevice::GetVendorId(void)
a3269a0a 220{
c4098482 221 if (m_vendor == CEC_VENDOR_UNKNOWN)
a3269a0a 222 {
d7be392a
LOK
223 if (!MyLogicalAddressContains(m_iLogicalAddress))
224 {
5e822b09 225 CStdString strLog;
62f5527d 226 strLog.Format("<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
5e822b09 227 AddLog(CEC_LOG_NOTICE, strLog);
d7be392a 228 cec_command command;
ab1469a0 229 cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
d7be392a 230 CLockObject lock(&m_mutex);
93729720 231
d7be392a
LOK
232 if (m_processor->Transmit(command))
233 m_condition.Wait(&m_mutex, 1000);
234 }
a3269a0a 235 }
93729720
LOK
236
237 return m_vendor;
238}
239
c4098482
LOK
240const char *CCECBusDevice::GetVendorName(void)
241{
242 GetVendorId();
243 return ToString(m_vendor);
244}
245
93729720
LOK
246bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const
247{
248 return m_processor->HasLogicalAddress(address);
a3269a0a
LOK
249}
250
93729720
LOK
251//@}
252
253/** @name Setters */
254//@{
e55f3f70 255void CCECBusDevice::SetCecVersion(const cec_version newVersion)
6a1c0009 256{
6a1c0009
LOK
257 m_cecVersion = newVersion;
258
c686413b 259 CStdString strLog;
c4098482 260 strLog.Format("%s (%X): CEC version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(newVersion));
6a1c0009
LOK
261 AddLog(CEC_LOG_DEBUG, strLog);
262}
263
93729720
LOK
264void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language)
265{
266 if (language.device == m_iLogicalAddress)
267 {
268 CStdString strLog;
62f5527d 269 strLog.Format(">> %s (%X): menu language set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, language.language);
93729720
LOK
270 m_processor->AddLog(CEC_LOG_DEBUG, strLog);
271 m_menuLanguage = language;
272 }
273}
274
28fa6c97
LOK
275void CCECBusDevice::SetMenuState(const cec_menu_state state)
276{
277 if (m_menuState != state)
278 {
279 CStdString strLog;
280 strLog.Format(">> %s (%X): menu state set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_menuState));
281 m_processor->AddLog(CEC_LOG_DEBUG, strLog);
282 m_menuState = state;
283 }
284}
285
9dc04b07 286void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress)
93729720
LOK
287{
288 if (iNewAddress > 0)
289 {
290 CStdString strLog;
62f5527d 291 strLog.Format(">> %s (%X): physical address changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress, iNewAddress);
93729720
LOK
292 AddLog(CEC_LOG_DEBUG, strLog.c_str());
293
294 m_iPhysicalAddress = iNewAddress;
295 }
296}
297
9dc04b07
LOK
298void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */)
299{
300 if (iNewAddress > 0)
301 {
302 CStdString strLog;
62f5527d 303 strLog.Format(">> %s (%X): stream path changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, iOldAddress, iNewAddress);
9dc04b07
LOK
304 AddLog(CEC_LOG_DEBUG, strLog.c_str());
305
306 m_iStreamPath = iNewAddress;
96274140
LOK
307
308 if (iNewAddress > 0)
309 SetPowerStatus(CEC_POWER_STATUS_ON);
9dc04b07
LOK
310 }
311}
312
e55f3f70
LOK
313void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus)
314{
b0271d54
LOK
315 if (m_powerStatus != powerStatus)
316 {
317 CStdString strLog;
c4098482 318 strLog.Format(">> %s (%X): power status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_powerStatus), ToString(powerStatus));
b0271d54
LOK
319 m_processor->AddLog(CEC_LOG_DEBUG, strLog);
320 m_powerStatus = powerStatus;
321 }
e55f3f70
LOK
322}
323
c4098482 324void CCECBusDevice::SetVendorId(uint64_t iVendorId)
e9de9629 325{
c4098482 326 m_vendor = (cec_vendor_id)iVendorId;
e9de9629
LOK
327
328 switch (iVendorId)
329 {
330 case CEC_VENDOR_SAMSUNG:
0ab58650
LOK
331 if (m_handler->GetVendorId() != CEC_VENDOR_SAMSUNG)
332 {
333 delete m_handler;
334 m_handler = new CANCommandHandler(this);
335 }
e9de9629
LOK
336 break;
337 case CEC_VENDOR_LG:
0ab58650
LOK
338 if (m_handler->GetVendorId() != CEC_VENDOR_LG)
339 {
340 delete m_handler;
341 m_handler = new CSLCommandHandler(this);
342 }
e9de9629 343 break;
11621576
LOK
344 case CEC_VENDOR_PANASONIC:
345 if (m_handler->GetVendorId() != CEC_VENDOR_PANASONIC)
346 {
347 delete m_handler;
348 m_handler = new CVLCommandHandler(this);
349 }
350 break;
e9de9629 351 default:
0ab58650
LOK
352 if (m_handler->GetVendorId() != CEC_VENDOR_UNKNOWN)
353 {
354 delete m_handler;
355 m_handler = new CCECCommandHandler(this);
356 }
e9de9629
LOK
357 break;
358 }
359
360 CStdString strLog;
c4098482 361 strLog.Format("%s (%X): vendor = %s (%06x)", GetLogicalAddressName(), m_iLogicalAddress, GetVendorName(), GetVendorId());
e9de9629
LOK
362 m_processor->AddLog(CEC_LOG_DEBUG, strLog.c_str());
363}
93729720 364//@}
e9de9629 365
93729720
LOK
366/** @name Transmit methods */
367//@{
368bool CCECBusDevice::TransmitActiveSource(void)
0f23c85c 369{
58c1f6f5
LOK
370 if (m_powerStatus != CEC_POWER_STATUS_ON)
371 {
372 CStdString strLog;
373 strLog.Format("<< %s (%X) is not powered on", GetLogicalAddressName(), m_iLogicalAddress);
374 AddLog(CEC_LOG_DEBUG, strLog);
375 }
376 else if (m_bActiveSource)
8747dd4f
LOK
377 {
378 CStdString strLog;
62f5527d 379 strLog.Format("<< %s (%X) -> broadcast (F): active source (%4x)", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
8747dd4f 380 AddLog(CEC_LOG_NOTICE, strLog);
0f23c85c 381
8747dd4f 382 cec_command command;
ab1469a0
LOK
383 cec_command::Format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
384 command.parameters.PushBack((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
385 command.parameters.PushBack((uint8_t) (m_iPhysicalAddress & 0xFF));
0f23c85c 386
8747dd4f
LOK
387 return m_processor->Transmit(command);
388 }
389 else
390 {
391 CStdString strLog;
62f5527d 392 strLog.Format("<< %s (%X) is not the active source", GetLogicalAddressName(), m_iLogicalAddress);
8747dd4f
LOK
393 AddLog(CEC_LOG_DEBUG, strLog);
394 }
395
396 return false;
0f23c85c
LOK
397}
398
29912296 399bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest)
0f23c85c 400{
d7be392a 401 CStdString strLog;
c4098482 402 strLog.Format("<< %s (%X) -> %s (%X): cec version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_cecVersion));
d7be392a 403 AddLog(CEC_LOG_NOTICE, strLog);
0f23c85c
LOK
404
405 cec_command command;
ab1469a0
LOK
406 cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_CEC_VERSION);
407 command.parameters.PushBack((uint8_t)m_cecVersion);
0f23c85c
LOK
408
409 return m_processor->Transmit(command);
410}
411
93729720
LOK
412bool CCECBusDevice::TransmitInactiveView(void)
413{
d7be392a 414 CStdString strLog;
62f5527d 415 strLog.Format("<< %s (%X) -> broadcast (F): inactive view", GetLogicalAddressName(), m_iLogicalAddress);
d7be392a 416 AddLog(CEC_LOG_NOTICE, strLog);
93729720
LOK
417
418 cec_command command;
ab1469a0
LOK
419 cec_command::Format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_INACTIVE_SOURCE);
420 command.parameters.PushBack((m_iPhysicalAddress >> 8) & 0xFF);
421 command.parameters.PushBack(m_iPhysicalAddress & 0xFF);
93729720
LOK
422
423 return m_processor->Transmit(command);
424}
425
29912296 426bool CCECBusDevice::TransmitMenuState(cec_logical_address dest)
0f23c85c 427{
d7be392a 428 CStdString strLog;
28fa6c97 429 strLog.Format("<< %s (%X) -> %s (%X): menu state '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_menuState));
d7be392a 430 AddLog(CEC_LOG_NOTICE, strLog);
0f23c85c
LOK
431
432 cec_command command;
ab1469a0
LOK
433 cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_MENU_STATUS);
434 command.parameters.PushBack((uint8_t)m_menuState);
0f23c85c
LOK
435
436 return m_processor->Transmit(command);
437}
438
29912296 439bool CCECBusDevice::TransmitOSDName(cec_logical_address dest)
0f23c85c 440{
0f23c85c 441 CStdString strLog;
c4098482 442 strLog.Format("<< %s (%X) -> %s (%X): OSD name '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, m_strDeviceName.c_str());
0f23c85c
LOK
443 AddLog(CEC_LOG_NOTICE, strLog.c_str());
444
445 cec_command command;
ab1469a0 446 cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_NAME);
787a3cb8 447 for (unsigned int iPtr = 0; iPtr < m_strDeviceName.length(); iPtr++)
ab1469a0 448 command.parameters.PushBack(m_strDeviceName.at(iPtr));
0f23c85c
LOK
449
450 return m_processor->Transmit(command);
451}
452
38bdb943
LOK
453bool CCECBusDevice::TransmitOSDString(cec_logical_address dest, cec_display_control duration, const char *strMessage)
454{
455 CStdString strLog;
c4098482 456 strLog.Format("<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage);
38bdb943
LOK
457 AddLog(CEC_LOG_NOTICE, strLog.c_str());
458
459 cec_command command;
ab1469a0
LOK
460 cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_STRING);
461 command.parameters.PushBack((uint8_t)duration);
38bdb943
LOK
462
463 unsigned int iLen = strlen(strMessage);
464 if (iLen > 13) iLen = 13;
465
466 for (unsigned int iPtr = 0; iPtr < iLen; iPtr++)
ab1469a0 467 command.parameters.PushBack(strMessage[iPtr]);
38bdb943
LOK
468
469 return m_processor->Transmit(command);
470}
471
29912296 472bool CCECBusDevice::TransmitPhysicalAddress(void)
0f23c85c
LOK
473{
474 CStdString strLog;
62f5527d 475 strLog.Format("<< %s (%X) -> broadcast (F): physical adddress %4x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
0f23c85c
LOK
476 AddLog(CEC_LOG_NOTICE, strLog.c_str());
477
478 cec_command command;
ab1469a0
LOK
479 cec_command::Format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS);
480 command.parameters.PushBack((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
481 command.parameters.PushBack((uint8_t) (m_iPhysicalAddress & 0xFF));
482 command.parameters.PushBack((uint8_t) (m_type));
0f23c85c
LOK
483
484 return m_processor->Transmit(command);
485}
486
93729720 487bool CCECBusDevice::TransmitPoll(cec_logical_address dest)
57f45e6c
LOK
488{
489 bool bReturn(false);
490
93729720
LOK
491 if (dest == CECDEVICE_UNKNOWN)
492 dest = m_iLogicalAddress;
f8513317 493
57f45e6c 494 CStdString strLog;
c4098482 495 strLog.Format("<< %s (%X) -> %s (%X): POLL", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
d7be392a 496 AddLog(CEC_LOG_NOTICE, strLog.c_str());
57f45e6c
LOK
497
498 cec_command command;
ab1469a0 499 cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_NONE);
57f45e6c
LOK
500 CLockObject lock(&m_mutex);
501
502 bReturn = m_processor->Transmit(command);
503 AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent");
504 return bReturn;
505}
93729720
LOK
506
507bool CCECBusDevice::TransmitPowerState(cec_logical_address dest)
508{
509 CStdString strLog;
c4098482 510 strLog.Format("<< %s (%X) -> %s (%X): %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_powerStatus));
d7be392a
LOK
511 AddLog(CEC_LOG_NOTICE, strLog.c_str());
512
93729720 513 cec_command command;
ab1469a0
LOK
514 cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_REPORT_POWER_STATUS);
515 command.parameters.PushBack((uint8_t) m_powerStatus);
93729720
LOK
516
517 return m_processor->Transmit(command);
518}
519
520bool CCECBusDevice::TransmitVendorID(cec_logical_address dest)
521{
c4098482
LOK
522 if (m_vendor == CEC_VENDOR_UNKNOWN)
523 {
524 CStdString strLog;
525 strLog.Format("<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
526 AddLog(CEC_LOG_NOTICE, strLog);
d7be392a 527
c4098482
LOK
528 m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
529 return false;
530 }
531 else
532 {
533 CStdString strLog;
534 strLog.Format("<< %s (%X) -> %s (%X): vendor id %s (%x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_vendor), (uint64_t)m_vendor);
535 AddLog(CEC_LOG_NOTICE, strLog);
536
537 cec_command command;
ab1469a0 538 cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
c4098482 539
ab1469a0
LOK
540 command.parameters.PushBack((uint8_t) (((uint64_t)m_vendor >> 16) & 0xFF));
541 command.parameters.PushBack((uint8_t) (((uint64_t)m_vendor >> 8) & 0xFF));
542 command.parameters.PushBack((uint8_t) ((uint64_t)m_vendor & 0xFF));
c4098482
LOK
543
544 return m_processor->Transmit(command);
545 }
93729720
LOK
546}
547//@}