private async Task UpdateMaxTemperatureSinceLastRebootAsync(string componentName, CancellationToken cancellationToken)
        {
            const string   propertyName       = "maxTempSinceLastReboot";
            double         maxTemp            = _maxTemp[componentName];
            TwinCollection reportedProperties = PnpConvention.CreateComponentPropertyPatch(componentName, propertyName, maxTemp);

            await _deviceClient.UpdateReportedPropertiesAsync(reportedProperties, cancellationToken);

            _logger.LogDebug($"Property: Update - component=\"{componentName}\", {{ \"{propertyName}\": {maxTemp} }} in °C is complete.");
        }
Exemple #2
0
        private static async Task UpdateReadOnlyProperties(string propertyName, string componentName)
        {
            if (propertyName == "maxTempSinceLastReboot")
            {
                //var reportedProperties = new TwinCollection();
                //reportedProperties[propertyName] = max_temperature;
                //await deviceClient.UpdateReportedPropertiesAsync(reportedProperties);

                TwinCollection reportedProperties = PnpConvention.CreateComponentPropertyPatch(componentName, propertyName, max_temperature);
                await deviceClient.UpdateReportedPropertiesAsync(reportedProperties);
            }
            if (propertyName == "maxHumiditySinceLastReboot")
            {
                var reportedProperties = new TwinCollection();
                reportedProperties[propertyName] = max_humidity;
                await deviceClient.UpdateReportedPropertiesAsync(reportedProperties);
            }
        }
        // Report the property updates on "deviceInformation" component.
        private async Task UpdateDeviceInformationAsync(CancellationToken cancellationToken)
        {
            const string componentName = "deviceInformation";

            TwinCollection deviceInfoTc = PnpConvention.CreateComponentPropertyPatch(
                componentName,
                new Dictionary <string, object>
            {
                { "manufacturer", "element15" },
                { "model", "ModelIDxcdvmk" },
                { "swVersion", "1.0.0" },
                { "osName", "Windows 10" },
                { "processorArchitecture", "64-bit" },
                { "processorManufacturer", "Intel" },
                { "totalStorage", 256 },
                { "totalMemory", 1024 },
            });

            await _deviceClient.UpdateReportedPropertiesAsync(deviceInfoTc, cancellationToken);

            _logger.LogDebug($"Property: Update - component = '{componentName}', properties update is complete.");
        }
Exemple #4
0
        private static async Task PatchProperty(string componentName, Dictionary <string, object> dictio)
        {
            TwinCollection deviceInfoTc = PnpConvention.CreateComponentPropertyPatch(componentName, dictio);

            await deviceClient.UpdateReportedPropertiesAsync(deviceInfoTc);
        }
Exemple #5
0
 private static async Task UpdateProperty(string componentName, string propertyName, string v)
 {
     TwinCollection reportedProperties = PnpConvention.CreateComponentPropertyPatch(componentName, propertyName, v);
     await deviceClient.UpdateReportedPropertiesAsync(reportedProperties);
 }