Azure-iot-sdk-c: How to set the System Properties of "EventData"

Created on 29 Jan 2018  路  4Comments  路  Source: Azure/azure-iot-sdk-c

Hello,

I want to set following System Properties of MQTT Message from Non-SDK C client ( I am not using Azure SDK-C but using Open Source MQTT Client written in C) ?

_message-id
user-id
to
correlation-id_

This the simplified code that I use for testing ...

_mqtt_publish((mqtt_broker_handle_t *)TRMqttGetBroker(), "devices/MyDeviceID1/messages/events/MessageId=12&To=myIotHub.azure-devices.net&CorrelationId=0&UserId=MyUserID1&Type=Telemetry&Subtype=Telemetry&Priority=5&Version=1.1.0", "Hello World", 11, 0);_

image

I can see that my "Application Properties" does get set correctly ... but how to set "System Properties"

image

When I use Azure C-SDK , these message-id, user-id, to , correlation-id does get set correctly as shown in following image...

Here I am using SDK code as follows -

                        (void)IoTHubMessage_SetMessageId(messages[iterator].messageHandle, "MSG_ID");
                        (void)IoTHubMessage_SetCorrelationId(messages[iterator].messageHandle, "CORE_ID");
                   (void)IoTHubMessage_SetContentTypeSystemProperty(messages[iterator].messageHandle, "application%2Fjson");                          (void)IoTHubMessage_SetContentEncodingSystemProperty(messages[iterator].messageHandle, "utf-8");

https://github.com/Azure/azure-iot-sdk-c/blob/master/iothub_client/samples/iothub_client_sample_mqtt/iothub_client_sample_mqtt.c

image

In Azure documentation , they are talking about "property_bag"
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support

and they mention to use $ for System Property but I am not able to use it. Can someone explain how to use it ?

image

I will appreciate if any help is available.

Thanks,
Kum

question

Most helpful comment

You can explore how we do that in the C SDK by looking at this code:
https://github.com/Azure/azure-iot-sdk-c/blob/master/iothub_client/src/iothubtransport_mqtt_common.c#L655

All 4 comments

Hi @thematrix9 ,
you mention C language, but your screenshots look like from C# code.
Could you clarify about that? If you want c# code you should post your question on https://github.com/Azure/azure-iot-sdk-csharp

You can explore how we do that in the C SDK by looking at this code:
https://github.com/Azure/azure-iot-sdk-c/blob/master/iothub_client/src/iothubtransport_mqtt_common.c#L655

Alright, glad to hear that @thematrix9 .
Thanks for using the Azure IoT SDKs.

  • Azure IoT Team
Was this page helpful?
0 / 5 - 0 ratings

Related issues

kskog picture kskog  路  5Comments

zvrba picture zvrba  路  5Comments

vpetrigo picture vpetrigo  路  6Comments

kiranpradeep picture kiranpradeep  路  5Comments

Anil-Poolayulla-Chelottillam picture Anil-Poolayulla-Chelottillam  路  7Comments