Ejemplo n.º 1
0
        public async Task NotifyTwinChangedAsync(string deviceId, TwinInformation twinChangedNotification)
        {
            var baseUri = GetBaseUri();
            var uri     = $"{baseUri}/api/v1/devices/{deviceId}/twin/notifications/changed";

            await PostRequestAsync(uri, twinChangedNotification);
        }
Ejemplo n.º 2
0
        public async Task ProvisionAsync(DeviceInfo info, TwinInformation initialTwinInfo)
        {
            await SetInfoAsync(info);

            Logger.LogEvent("Device Provisioned");

            TrackDeviceProvisionedEvent(info);
        }
Ejemplo n.º 3
0
        public async Task NotifyTwinInformationChangedAsync(TwinInformation notification)
        {
            // TODO: Patch, not overwrite
            await StateManager.AddOrUpdateStateAsync(ReportedPropertiesStateKey, notification.Properties.Reported, (stateName, currentValue) => notification.Properties.Reported);

            await StateManager.AddOrUpdateStateAsync(DesiredPropertiesStateKey, notification.Properties.Desired, (stateName, currentValue) => notification.Properties.Desired);

            await StateManager.AddOrUpdateStateAsync(TagStateKey, notification.Tags, (stateName, currentValue) => notification.Tags);
        }
        public async Task ProcessAsync(NotificationMetadata notificationMetadata, string rawEvent)
        {
            var twinChangedNotification = JsonConvert.DeserializeObject <TwinChangedNotification>(rawEvent);

            // Don't do anything if it's just reported twin updates
            if (twinChangedNotification.Properties.Desired == null && twinChangedNotification.Tags == null)
            {
                _logger.LogInformation("Device twin change ignored as it only contained reported properties");
                return;
            }

            var twinInformation = TwinInformation.Parse(twinChangedNotification);

            await _deviceRegistryClient.NotifyTwinChangedAsync(notificationMetadata.DeviceId, twinInformation);

            _logger.LogInformation("Device twin change processed");
        }
Ejemplo n.º 5
0
 public async Task NotifyTwinInformationChangedAsync(string deviceId, TwinInformation twinChangedNotification)
 {
     await Interact(deviceId, deviceActor => deviceActor.NotifyTwinInformationChangedAsync(twinChangedNotification));
 }
Ejemplo n.º 6
0
        public async Task <IActionResult> TwinChangedNotification([FromRoute] string deviceId, [Required, FromBody] TwinInformation twinInformation)
        {
            try
            {
                await _deviceRepository.NotifyTwinInformationChangedAsync(deviceId, twinInformation);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }