I am using the Azure IOT SDK, trying to send a Cloud to Device Message with a string body and receive it in the SDK. No matter what I send, the SDK says its in a byte array format. How do I send a string instead of a byte array from the cloud to my device SDK?
This is the code sample I followed: https://github.com/Azure/azure-iot-sdk-c/blob/master/iothub_client/samples/iothub_ll_c2d_sample/iothub_ll_c2d_sample.c
This is my callback:
IOTHUBMESSAGE_DISPOSITION_RESULT CAzureProcessor::ReceiveMessageCallback(IOTHUB_MESSAGE_HANDLE message, void* userContextCallback)
{
CMyObject* pObject = (CMyObject*)userContextCallback;
if (pObject != NULL)
{
IOTHUBMESSAGE_CONTENT_TYPE content_type = IoTHubMessage_GetContentType(message);
if (content_type == IOTHUBMESSAGE_STRING)
{
//do stuff
}
}
return IOTHUBMESSAGE_ACCEPTED;
}
My problem is I never get to 'dostuff' because IoTHubMessage_GetContentType always returns IOTHUBMESSAGE_BYTEARRAY when I send a C2D message either from the "Message to Device" page on the Azure portal or from Device Explorer. How do I go about sending a string from either of those two points?
If it helps, this is the string I am trying to send:
[{"devicename":"My ROC","alias":"elevation","value":100}]