in roscpp_azure_iothub/src/ros_azure_iothub_cpp_node.cpp [53:97]
static IOTHUBMESSAGE_DISPOSITION_RESULT receive_msg_callback(IOTHUB_MESSAGE_HANDLE message, void* user_context)
{
(void)user_context;
const char* messageId;
const char* correlationId;
// Message properties
if ((messageId = IoTHubMessage_GetMessageId(message)) == NULL)
{
messageId = "<unavailable>";
}
if ((correlationId = IoTHubMessage_GetCorrelationId(message)) == NULL)
{
correlationId = "<unavailable>";
}
IOTHUBMESSAGE_CONTENT_TYPE content_type = IoTHubMessage_GetContentType(message);
if (content_type == IOTHUBMESSAGE_BYTEARRAY)
{
const unsigned char* buff_msg;
size_t buff_len;
if (IoTHubMessage_GetByteArray(message, &buff_msg, &buff_len) != IOTHUB_MESSAGE_OK)
{
ROS_ERROR("Failure retrieving byte array message");
}
else
{
ROS_INFO("Received Binary message\r\n Message ID: %s\r\n Correlation ID: %s\r\n Data: <<<%.*s>>> & Size=%d", messageId, correlationId, (int)buff_len, buff_msg, (int)buff_len);
}
}
else
{
const char* string_msg = IoTHubMessage_GetString(message);
if (string_msg == NULL)
{
ROS_ERROR("Failure retrieving byte array message");
}
else
{
ROS_INFO("Received String Message\r\n Message ID: %s\r\n Correlation ID: %s\r\n Data: <<<%s>>>", messageId, correlationId, string_msg);
}
}
return IOTHUBMESSAGE_ACCEPTED;
}