Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            await IoTHubDeviceService.StartListening();

            await CameraService.FindCameras();

            await Task.CompletedTask;
        }