#include "lib/LibCEC.h"
#include "lib/CECProcessor.h"
#include "lib/CECTypeUtils.h"
+#include "lib/platform/util/util.h"
#include <stdio.h>
using namespace CEC;
CCECAdapterMessage params;
CCECAdapterMessage *message = m_comm->SendCommand(msgCode, params);
- if (message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED)
+ if (message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED)
{
retVal = message->response;
retVal.Shift(2); // shift out start and msgcode
retVal.size -= 1; // remove end
}
- delete message;
+ DELETE_AND_NULL(message);
return retVal;
}
CCECAdapterMessage params;
params.PushEscaped(enabled ? 1 : 0);
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_AUTO_ENABLED, params);
- bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
if (bReturn)
{
CCECAdapterMessage params;
params.PushEscaped((uint8_t)type);
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_DEVICE_TYPE, params);
- bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
if (bReturn)
{
CCECAdapterMessage params;
params.PushEscaped((uint8_t)address);
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_DEFAULT_LOGICAL_ADDRESS, params);
- bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
if (bReturn)
{
params.PushEscaped(iMask >> 8);
params.PushEscaped((uint8_t)iMask);
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_LOGICAL_ADDRESS_MASK, params);
- bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
if (bReturn)
{
params.PushEscaped(iPhysicalAddress >> 8);
params.PushEscaped((uint8_t)iPhysicalAddress);
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_PHYSICAL_ADDRESS, params);
- bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
if (bReturn)
{
CCECAdapterMessage params;
params.PushEscaped((uint8_t)version);
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_HDMI_VERSION, params);
- bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
if (bReturn)
{
for (size_t iPtr = 0; iPtr < strlen(strOSDName); iPtr++)
params.PushEscaped(strOSDName[iPtr]);
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_OSD_NAME, params);
- bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
if (bReturn)
snprintf(m_persistedConfiguration.strDeviceName, 13, "%s", strOSDName);
CCECAdapterMessage params;
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_WRITE_EEPROM, params);
- bool bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bool bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
if (bReturn)
{
CCECAdapterMessage params;
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_PING, params);
- bool bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bool bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
return bReturn;
}
params.PushEscaped(iMask >> 8);
params.PushEscaped((uint8_t)iMask);
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_ACK_MASK, params);
- bool bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bool bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
return bReturn;
}
CCECAdapterMessage params;
params.PushEscaped(bSetTo ? 1 : 0);
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_ACTIVE_SOURCE, params);
- delete message;
+ DELETE_AND_NULL(message);
}
}
CCECAdapterMessage params;
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_START_BOOTLOADER, params);
- bool bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bool bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
return bReturn;
}
CCECAdapterMessage params;
params.PushEscaped(iTimeout);
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_TRANSMIT_IDLETIME, params);
- bool bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bool bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
return bReturn;
}
CCECAdapterMessage params;
params.PushEscaped(controlled ? 1 : 0);
CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_CONTROLLED, params);
- bool bReturn = message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
- delete message;
+ bool bReturn = message && message->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+ DELETE_AND_NULL(message);
if (bReturn)
{