+
+bool CAdapterCommunication::StartBootloader(void)
+{
+ if (!IsRunning())
+ return false;
+
+ m_controller->AddLog(CEC_LOG_DEBUG, "starting the bootloader");
+ cec_frame output;
+ output.push_back(MSGSTART);
+ PushEscaped(output, MSGCODE_START_BOOTLOADER);
+ output.push_back(MSGEND);
+
+ if (!Write(output))
+ {
+ m_controller->AddLog(CEC_LOG_ERROR, "could not start the bootloader");
+ return false;
+ }
+ m_controller->AddLog(CEC_LOG_DEBUG, "bootloader start command transmitted");
+ return true;
+}
+
+void CAdapterCommunication::PushEscaped(cec_frame &vec, uint8_t byte)
+{
+ if (byte >= MSGESC && byte != MSGSTART)
+ {
+ vec.push_back(MSGESC);
+ vec.push_back(byte - ESCOFFSET);
+ }
+ else
+ {
+ vec.push_back(byte);
+ }
+}
+
+bool CAdapterCommunication::SetAckMask(uint16_t iMask)
+{
+ if (!IsRunning())
+ return false;
+
+ CStdString strLog;
+ strLog.Format("setting ackmask to %2x", iMask);
+ m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+ cec_frame output;
+
+ output.push_back(MSGSTART);
+ PushEscaped(output, MSGCODE_SET_ACK_MASK);
+ PushEscaped(output, iMask >> 8);
+ PushEscaped(output, (uint8_t)iMask);
+ output.push_back(MSGEND);
+
+ if (!Write(output))
+ {
+ m_controller->AddLog(CEC_LOG_ERROR, "could not set the ackmask");
+ return false;
+ }
+
+ return true;
+}
+
+bool CAdapterCommunication::PingAdapter(void)
+{
+ if (!IsRunning())
+ return false;
+
+ m_controller->AddLog(CEC_LOG_DEBUG, "sending ping");
+ cec_frame output;
+ output.push_back(MSGSTART);
+ PushEscaped(output, MSGCODE_PING);
+ output.push_back(MSGEND);
+
+ if (!Write(output))
+ {
+ m_controller->AddLog(CEC_LOG_ERROR, "could not send ping command");
+ return false;
+ }
+
+ m_controller->AddLog(CEC_LOG_DEBUG, "ping tranmitted");
+
+ // TODO check for pong
+ return true;
+}