public async Task UpdateReportedPropertiesAsync()

in DeviceBridge/Services/ConnectionManager.cs [493:517]


        public async Task UpdateReportedPropertiesAsync(Logger logger, string deviceId, IDictionary<string, object> patch, CancellationToken cancellationToken)
        {
            logger.Info("Updating reported properties for device {deviceId}", deviceId);

            // This method expects a connection to have been previously established
            if (!_clients.TryGetValue(deviceId, out DeviceClient client))
            {
                var e = new DeviceConnectionNotFoundException(deviceId);
                logger.Error(e, "Tried to update reported properties for device {deviceId} but an active connection was not found", deviceId);
                throw e;
            }

            TwinCollection reportedProperties = new TwinCollection(JsonSerializer.Serialize(patch));

            try
            {
                await client.UpdateReportedPropertiesAsync(reportedProperties, cancellationToken);
            }
            catch (Exception e)
            {
                throw TranslateSdkException(e, deviceId);
            }

            logger.Info("Successfully updated reported properties for device {deviceId}", deviceId);
        }