private async Task InitIoTHubDeviceService() { string deviceConnectionString = _settings.CoffePotDeviceConnectionString; if (!String.IsNullOrWhiteSpace(deviceConnectionString)) { if (iotHubDeviceService == null) { iotHubDeviceService = new Services.IoTHubDeviceService(deviceConnectionString); iotHubDeviceService.MessageReceived += IotHubDeviceService_MessageReceived; iotHubDeviceService.BadMessageReceived += IotHubDeviceService_BadMessageReceived; iotHubDeviceService.UnknownCommandReceived += IotHubDeviceService_UnknownCommandReceived; iotHubDeviceService.PingCommandReceived += IotHubDeviceService_PingCommandReceived; iotHubDeviceService.BrewCommandReceived += IotHubDeviceService_BrewCommandReceived; } else { iotHubDeviceService.DeviceConnectionString = deviceConnectionString; } if (!iotHubDeviceService.IsListening) { iotHubDeviceService.StartListening(); } await Task.CompletedTask; } }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { await IoTHubDeviceService.StartListening(); await CameraService.FindCameras(); await Task.CompletedTask; }