extern "C" {
namespace CEC {
#endif
- #define CEC_MIN_VERSION 1
+ #define CEC_MIN_VERSION 2
#define CEC_LIB_VERSION 2
#define CEC_SETTLE_DOWN_TIME 1000
#endif
/*!
- * @brief Set the ack mask for the CEC adapter.
- * @param ackmask The new ack mask.
+ * @brief Set the logical address of the CEC adapter.
+ * @param iLogicalAddress The cec adapter's logical address.
+ * @return True when the logical address was set succesfully, false otherwise.
+ */
+#ifdef __cplusplus
+extern DECLSPEC bool cec_set_logical_address(CEC::cec_logical_address iLogicalAddress);
+#else
+extern DECLSPEC bool cec_set_logical_address(cec_logical_address myAddress, cec_logical_address targetAddress);
+#endif
+
+/*!
+ * @deprecated Use cec_set_logical_address() instead.
+ * @brief Set the ack mask of the CEC adapter.
+ * @param iMask The cec adapter's ack mask.
* @return True when the ack mask was sent succesfully, false otherwise.
*/
-extern DECLSPEC bool cec_set_ack_mask(uint16_t ackmask);
+extern DECLSPEC bool cec_set_ack_mask(uint16_t iMask);
/*!
* @return Get the minimal version of libcec that this version of libcec can interface with.
virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 5000) = 0;
/*!
- * @see cec_set_ack_mask
+ * @see cec_set_logical_address
*/
- virtual bool SetAckMask(cec_logical_address ackmask) = 0;
+ virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress) = 0;
+
+ /*!
+ * @deprecated use SetLogicalAddress() instead
+ */
+ virtual bool SetAckMask(uint16_t iMask) = 0;
/*!
* @see cec_get_min_version
m_serialport->Read(buff, sizeof(buff), CEC_SETTLE_DOWN_TIME);
if (bReturn)
- bReturn = SetAckMask(m_iLogicalAddress);
+ bReturn = SetLogicalAddress(m_iLogicalAddress);
if (!bReturn)
{
}
}
-bool CCECParser::SetAckMask(cec_logical_address ackmask)
+bool CCECParser::SetLogicalAddress(cec_logical_address iLogicalAddress)
{
CStdString strLog;
- strLog.Format("setting ackmask to %d", (uint16_t) ackmask);
+ strLog.Format("setting logical address to %d", iLogicalAddress);
AddLog(CEC_LOG_NOTICE, strLog.c_str());
+ m_iLogicalAddress = iLogicalAddress;
+ return SetAckMask(0x1 << (uint8_t)m_iLogicalAddress);
+}
+
+bool CCECParser::SetAckMask(uint16_t iMask)
+{
+ CStdString strLog;
+ strLog.Format("setting ackmask to %2x", iMask);
+ AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
cec_frame output;
- m_iLogicalAddress = ackmask;
- output.push_back(MSGSTART);
+ output.push_back(MSGSTART);
PushEscaped(output, MSGCODE_SET_ACK_MASK);
- PushEscaped(output, (uint8_t) ackmask >> 8);
- PushEscaped(output, (uint8_t) ackmask << 2);
-
+ PushEscaped(output, iMask >> 8);
+ PushEscaped(output, iMask);
output.push_back(MSGEND);
if (m_serialport->Write(output) == -1)
{
- CStdString strDebug;
- strDebug.Format("error writing to serial port: %s", m_serialport->GetError().c_str());
- AddLog(CEC_LOG_ERROR, strDebug);
+ strLog.Format("error writing to serial port: %s", m_serialport->GetError().c_str());
+ AddLog(CEC_LOG_ERROR, strLog);
return false;
}
virtual bool GetNextLogMessage(cec_log_message *message);
virtual bool GetNextKeypress(cec_keypress *key);
virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 5000);
- virtual bool SetAckMask(cec_logical_address ackmask);
+ virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress);
+ virtual bool SetAckMask(uint16_t iMask);
virtual int GetMinVersion(void);
virtual int GetLibVersion(void);
//@}
return false;
}
-bool cec_set_ack_mask(uint16_t ackmask)
+bool cec_set_logical_address(cec_logical_address iLogicalAddress)
{
if (cec_parser)
- return cec_parser->SetAckMask((cec_logical_address) ackmask);
+ return cec_parser->SetLogicalAddress(iLogicalAddress);
+ return false;
+}
+
+bool cec_set_ack_mask(uint16_t iMask)
+{
+ if (cec_parser)
+ return cec_parser->SetAckMask(iMask);
return false;
}
using namespace CEC;
using namespace std;
-#define CEC_TEST_CLIENT_VERSION 1
+#define CEC_TEST_CLIENT_VERSION 2
void flush_log(ICECDevice *cecParser)
{
{
string strvalue;
int ackmask;
- vector<uint8_t> bytes;
if (GetWord(input, strvalue) && HexStrToInt(strvalue, ackmask))
{
- parser->SetAckMask((cec_logical_address) ackmask);
+ parser->SetAckMask(ackmask);
+ }
+ }
+ else if (command == "la")
+ {
+ string strvalue;
+ int iLogicalAddress;
+ if (GetWord(input, strvalue))
+ {
+ parser->SetLogicalAddress((cec_logical_address) atoi(strvalue.c_str()));
}
}
else if (command == "ping")