简体   繁体   中英

How to send writable property data in Azure IoT Central

I'm developing small IoT app using IoT Central. below is my device DCM

在此处输入图片说明

I'm sending telemetry & property data using .Net simulator, but I cannot see TelemetryInterval property data in Azure IoT Central. (Telemetry data visible properly)

Simulator Code

var telemetryDataPoint = new
            {
                MessageTime = messageTime,
                Moisture = randMoisture
            };
            var telemetryDataString = JsonConvert.SerializeObject(telemetryDataPoint);

            //set the body of the message to the serialized value of the telemetry data
            var message = new Message(Encoding.ASCII.GetBytes(telemetryDataString));

            message.Properties.Add("TelemetryInterval", "10");
            message.ContentEncoding = "utf-8";
            message.ContentType = "application/json";
            message.MessageId = Guid.NewGuid().ToString();
            await deviceClient.SendEventAsync(message);

在此处输入图片说明

I'm able to fix this.

This is reported property of device twin, We can use TwinCollection to update this property.

private static async void SendTwinData()
    {
        var twinProperties = new Microsoft.Azure.Devices.Shared.TwinCollection();
        twinProperties["TelemetryInterval"] = "2";
        await s_deviceClient.UpdateReportedPropertiesAsync(twinProperties);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM