public BuiltInI2CBus(DeviceId id, ILogger logger) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } Id = id; _logger = logger; string deviceSelector = I2cDevice.GetDeviceSelector(); DeviceInformationCollection deviceInformation = DeviceInformation.FindAllAsync(deviceSelector).AsTask().Result; if (deviceInformation.Count == 0) { throw new InvalidOperationException("I2C bus not found."); } _i2CBusId = deviceInformation.First().Id; }
async private void GetDevices() { try { DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(SmartCardReader.GetDeviceSelector(SmartCardReaderKind.Nfc)); // There is a bug on some devices that were updated to WP8.1 where an NFC SmartCardReader is // enumerated despite that the device does not support it. As a workaround, we can do an additonal check // to ensure the device truly does support it. var workaroundDetect = await DeviceInformation.FindAllAsync("System.Devices.InterfaceClassGuid:=\"{50DD5230-BA8A-11D1-BF5D-0000F805F530}\" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True"); if (workaroundDetect.Count == 0 || devices.Count == 0) { PopupMessage("No Reader Found!"); } CardReader = await SmartCardReader.FromIdAsync(devices.First().Id); MifareCard = new MifareCard(new MifareClassic()); CardReader.CardAdded += CardAdded; CardReader.CardRemoved += CardRemoved; } catch (Exception e) { PopupMessage("Exception: " + e.Message); } }
/// <summary> /// Responds when we navigate to this page. /// </summary> /// <param name="e">Event data</param> protected override async void OnNavigatedTo(NavigationEventArgs e) { // Initialize renderer m_objectTrackRenderer = new ObjectTrackRenderer(UICanvasOverlay); UICameraPreview.Source = m_bitmapSource; // Initialize skill await InitializeSkillAsync(); await UpdateSkillUIAsync(); // Pick a default camera device DeviceInformationCollection availableCameras = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture); if (availableCameras.Count > 0) { DeviceInformation defaultCamera = availableCameras.First(); await ConfigureFrameSourceAsync(defaultCamera); // Auto-press the play button for the user await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => TogglePlaybackState(true)); } else { NotifyUser("No cameras detected. Please select a frame source from the top bar to begin", NotifyType.WarningMessage); } }
public async Task InitializeCameraAsync() { try { if (_mediaCapture == null) { _mediaCapture = new MediaCapture(); _mediaCapture.Failed += MediaCapture_Failed; _cameraDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture); if (_cameraDevices == null || !_cameraDevices.Any()) { throw new NotSupportedException(); } var device = _cameraDevices.FirstOrDefault(camera => camera.EnclosureLocation?.Panel == Panel); var cameraId = device?.Id ?? _cameraDevices.First().Id; await _mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = cameraId }); if (Panel == Panel.Back) { _mediaCapture.SetRecordRotation(VideoRotation.Clockwise90Degrees); _mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees); _mirroringPreview = false; } else { _mirroringPreview = true; } IsInitialized = true; CanSwitch = _cameraDevices?.Count > 1; RegisterOrientationEventHandlers(); await StartPreviewAsync(); } } catch (UnauthorizedAccessException) { errorMessage.Text = "Camera_Exception_UnauthorizedAccess".GetLocalized(); } catch (NotSupportedException) { errorMessage.Text = "Camera_Exception_NotSupported".GetLocalized(); } catch (TaskCanceledException) { errorMessage.Text = "Camera_Exception_InitializationCanceled".GetLocalized(); } catch (Exception) { errorMessage.Text = "Camera_Exception_InitializationError".GetLocalized(); } }
public BuiltInI2CBusService() { string deviceSelector = I2cDevice.GetDeviceSelector(); DeviceInformationCollection deviceInformation = DeviceInformation.FindAllAsync(deviceSelector).AsTask().Result; if (deviceInformation.Count == 0) { //throw new InvalidOperationException("I2C bus not found."); return; } _i2CBusId = deviceInformation.First().Id; }
public I2CBus(RestServer.ILogger logger) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); string deviceSelector = I2cDevice.GetDeviceSelector(); DeviceInformationCollection deviceInformation = DeviceInformation.FindAllAsync(deviceSelector).AsTask().Result; if (deviceInformation.Count == 0) { throw new InvalidOperationException("I2C bus not found."); } _i2CBusId = deviceInformation.First().Id; }
///<summary> ///Open port to make a connect ///打开串口开始连接 ///</summary> ///<param name="portName">Name of COM port to open</param> ///<param name="pAddress">StaatusFrame类的实例的地址</param> ///<param name="baudRate">baud rate of COM port 传输速率</param> ///<param name="parity">type of data parity</param> ///<param name="dataBits">Number of data bits</param> ///<param name="stopbits">Number of stop</param> public async Task <bool> Open(string portName, StatusFrame pAddress, uint baudRate = 9600, SerialParity parity = SerialParity.None, ushort dataBits = 8, SerialStopBitCount stopBits = SerialStopBitCount.One) { //close open port 关闭当前正在打开的串口 //防止错误覆盖 Close(); //get a list of devices from the given portname string selector = SerialDevice.GetDeviceSelector(portName); // Get a list of devices that match the given name DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selector); // If any device found... if (devices.Any()) { // Get first device (should be only device) DeviceInformation deviceInfo = devices.First(); // Create a serial port device from the COM port device ID this.SerialDevice = await SerialDevice.FromIdAsync(deviceInfo.Id); // If serial device is valid... if (this.SerialDevice != null) { // Setup serial port configuration this.SerialDevice.StopBits = stopBits; this.SerialDevice.Parity = parity; this.SerialDevice.BaudRate = baudRate; this.SerialDevice.DataBits = dataBits; // Create a single device writer for this port connection this.dataWriterObject = new DataWriter(this.SerialDevice.OutputStream); // Create a single device reader for this port connection this.dataReaderObject = new DataReader(this.SerialDevice.InputStream); // Allow partial reads of the input stream this.dataReaderObject.InputStreamOptions = InputStreamOptions.Partial; pAddress.PortName = portName; // Port is now open this.IsOpen = true; } } return(this.IsOpen); }
/// <summary> /// Initializes the MediaCapture, registers events, gets camera device information for mirroring and rotating, starts preview and unlocks the UI /// </summary> /// <returns>Task</returns> private async Task InitializeCameraAsync() { if (_mediaCapture == null) { _mediaCapture = new MediaCapture(); _mediaCapture.Failed += MediaCapture_Failed; _cameraDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture); if (_cameraDevices == null) { throw new NotSupportedException(); } try { var device = _cameraDevices.FirstOrDefault(camera => camera.EnclosureLocation?.Panel == Panel); var cameraId = device != null ? device.Id : _cameraDevices.First().Id; await _mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = cameraId }); if (Panel == Panel.Back) { _mediaCapture.SetRecordRotation(VideoRotation.Clockwise90Degrees); _mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees); _mirroringPreview = false; } else { _mirroringPreview = true; } IsInitialized = true; } catch (UnauthorizedAccessException ex) { throw ex; } if (IsInitialized) { CanSwitch = _cameraDevices?.Count > 1; PreviewControl.Source = _mediaCapture; RegisterOrientationEventHandlers(); await StartPreviewAsync(); } } }
static public async void bluetoothle() { //デバイスを検索 string deveiceSelector = GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.HealthThermometer);//uuidから取得 DeviceInformationCollection themometerServices = await DeviceInformation.FindAllAsync(deveiceSelector, null); Console.WriteLine(themometerServices[0].Name); Console.ReadLine(); //デバイの指定 if (themometerServices.Count > 0) { DeviceInformation themometerService = themometerServices.First(); string ServiceNameText = "Using service: " + themometerService.Name; // サービスを作成 GattDeviceService firstThermometerService = await GattDeviceService.FromIdAsync(themometerService.Id); if (firstThermometerService != null) { //Gattの選択 // キャラクタリスティックを取得 GattCharacteristic thermometerCharacteristic = firstThermometerService.GetCharacteristics(GattCharacteristicUuids.TemperatureMeasurement).First(); // 通知イベントを登録 Console.WriteLine("Connect:" + ServiceNameText + "\n"); await thermometerCharacteristic.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Indicate); thermometerCharacteristic.ValueChanged += TemperatureMeasurementChanged; } else { // サービスを見つけられなかった // Capabilityの設定漏れはここへ Console.WriteLine("Notfound:" + ServiceNameText + "\n"); return; } } else { // 発見できなかった // BluetoothがOFFの場合はここへ Console.WriteLine("Notfound : Bluetooth" + "\n"); return; } }
private async Task InitializeCameraAsync() { if (mediaCapture == null) { DeviceInformationCollection cameraDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture); deviceInformation = cameraDevices.First(); mediaCapture = new MediaCapture(); await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = deviceInformation.Id }); VideoFeed.Source = mediaCapture; captureElement = VideoFeed; await captureElement.Source.StartPreviewAsync(); } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { string qFilter = SerialDevice.GetDeviceSelector("COM3"); DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(qFilter); if (devices.Any()) { string deviceId = devices.First().Id; await OpenPort(deviceId); } ReadCancellationTokenSource = new CancellationTokenSource(); while (true) { await Listen(); } }
/// <summary> /// Funcion que se encarga de abrir el puerto /// </summary> /// <returns></returns> public async Task <bool> OpenPort() { // Close open port ClosePort(); // Get a device selector from the given port name string selector = SerialDevice.GetDeviceSelector(_portName); // Get a list of devices that match the given name DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selector); // If any device found... if (devices.Any()) { // Get first device (should be only device) DeviceInformation deviceInfo = devices.First(); // Create a serial port device from the COM port device ID this.serialDevice = await SerialDevice.FromIdAsync(deviceInfo.Id); // If serial device is valid... if (this.serialDevice != null) { // Setup serial port configuration this.serialDevice.StopBits = _stopBits; this.serialDevice.Parity = _parity; this.serialDevice.BaudRate = _baudRate; this.serialDevice.DataBits = _dataBits; // Create a single device writer for this port connection this.dataWriterObject = new DataWriter(this.serialDevice.OutputStream); // Create a single device reader for this port connection this.dataReaderObject = new DataReader(this.serialDevice.InputStream); // Allow partial reads of the input stream this.dataReaderObject.InputStreamOptions = InputStreamOptions.Partial; // Port is now open this.IsOpen = true; } } return(this.IsOpen); }
public async void SerialConnection() { string qFilter = SerialDevice.GetDeviceSelector("COM3"); DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(qFilter); if (devices.Any()) { string deviceId = devices.First().Id; await OpenPort(deviceId); } ReadCancellationTokenSource = new CancellationTokenSource(); while (true) { await Listen(); } }
private async void com2() { string deviceId = ""; string aqs = SerialDevice.GetDeviceSelector(); DeviceInformationCollection dlist = await DeviceInformation.FindAllAsync(aqs); if (dlist.Any()) { deviceId = dlist.First().Id;//调试这个是有值了的 } t2.Text = deviceId; using (SerialDevice serialPort = await SerialDevice.FromIdAsync(deviceId)) { //serialPort 这个值都是空的 null var vv = SerialDevice.FromIdAsync(deviceId); var v = serialPort?.PortName; t1.Text = v; t3.Text = "还是没有数据"; } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { string qFilter = SerialDevice.GetDeviceSelector("UART0"); DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(qFilter); if (devices.Any()) { string deviceId = devices.First().Id; await OpenPort(deviceId); } ReadCancellationTokenSource = new CancellationTokenSource(); while (true) { //System.Diagnostics.Debug.WriteLine("program came before await listen"); await Listen(); } }
public async void Run(IBackgroundTaskInstance taskInstance) { this.taskInstance = taskInstance; this.deferral = taskInstance.GetDeferral(); // Find all paired instances of the Rfcomm chat service and display them in a list chatServiceDeviceCollection = await DeviceInformation.FindAllAsync( RfcommDeviceService.GetDeviceSelector(RfcommServiceId.FromUuid(RfcommChatServiceUuid))); if (chatServiceDeviceCollection.Count > 0) { deviceName = chatServiceDeviceCollection.First().Name; } if (deviceName != null) await SendMessage(chatServiceDeviceCollection.FirstOrDefault().Id); else { ApplicationData.Current.LocalSettings.Values["ReceivedMessage"] = "Device not found"; deferral.Complete(); } }
private async Task <DeviceInformation> ChooseCameraDevice() { switchIcon.Visibility = Visibility.Visible; cameraIcon.Visibility = Visibility.Visible; StartIcon.Visibility = Visibility.Collapsed; Debug.WriteLine("Choose a Camera Device"); //Get all Devices _CameraDeviceGroup = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture); for (int i = 0; i < _CameraDeviceGroup.Count; i++) { Debug.WriteLine(_CameraDeviceGroup[i].Name.ToString()); } // try to get the back facing device for a phone var backFacingDevice = _CameraDeviceGroup .First(c => c.EnclosureLocation?.Panel == Windows.Devices.Enumeration.Panel.Front); // but if that doesn't exist, take the first camera device available var preferredDevice = backFacingDevice ?? _CameraDeviceGroup.Last(); _CurrentCamera = preferredDevice; return(_CurrentCamera); }
private async Task InitializeSerialPort() { string deviceSelector = SerialDevice.GetDeviceSelector(); DeviceInformationCollection deviceInformations = await DeviceInformation.FindAllAsync(deviceSelector); SerialDevice serialPort = await InitializeSerialDeviceAsync(deviceInformations.First().Id); SetSerialPortParameters(serialPort); DataWriter dataWriter = new DataWriter(serialPort.OutputStream); dataWriter.WriteString(ProbeCommand); await dataWriter.StoreAsync(); DataReader dataReader = new DataReader(serialPort.InputStream); string readString = await GetDataFromDataReader(dataReader, _readCancellationTokenSource.Token); if (SnocModuleResponseRegex.IsMatch(readString)) { _snocModule = serialPort; _dataReader = dataReader; _dataWriter = dataWriter; } else { dataReader.DetachBuffer(); dataReader.DetachStream(); dataReader.Dispose(); dataWriter.DetachBuffer(); dataWriter.DetachStream(); dataWriter.Dispose(); serialPort.Dispose(); throw new IOException("Unable to init SNOC module"); } }
private async Task InitializeCameraAsync() { if (_mediacCapture1 == null) { DeviceInformationCollection cameraDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture); _fpvDevice1 = cameraDevices.First(); foreach (DeviceInformation device in cameraDevices) { if (device.Name.Contains("USB2.0 PC CAMERA")) { _fpvDevice1 = device; } } _mediacCapture1 = new MediaCapture(); await _mediacCapture1.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = _fpvDevice1.Id }); Preview1.Source = _mediacCapture1; _frontCam = Preview1; await _frontCam.Source.StartPreviewAsync(); } }
/// <summary> /// When the user presses the run button, check to see if any of the currently paired devices support the Rfcomm chat service and display them in a list. /// Note that in this case, the other device must be running the Rfcomm Chat Server before being paired. /// </summary> /// <param name="sender">Instance that triggered the event.</param> /// <param name="e">Event data describing the conditions that led to the event.</param> private async void findDevices_Click(object sender, RoutedEventArgs e) { var button = sender as Button; // Disable the button while we do async operations so the user can't Run twice. button.IsEnabled = false; // Clear any previous messages statusTextBlock.Text = ""; // Find all paired instances of the Rfcomm chat service and display them in a list chatServiceDeviceCollection = await DeviceInformation.FindAllAsync( RfcommDeviceService.GetDeviceSelector(RfcommServiceId.FromUuid(RfcommChatServiceUuid))); if (chatServiceDeviceCollection.Count > 0) { deviceName = chatServiceDeviceCollection.First().Name; statusTextBlock.Text = "STATUS: Found device: " + chatServiceDeviceCollection.FirstOrDefault().Name; } else { statusTextBlock.Text = "STATUS: No devices found!"; } button.IsEnabled = true; }
async Task StartMediaCapture() { Debug.WriteLine("Starting MediaCapture"); app.MediaCapture = new MediaCapture(); var selectedDevice = _devices.FirstOrDefault(x => x.EnclosureLocation != null && x.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back); if (selectedDevice == null) { selectedDevice = _devices.First(); } await app.MediaCapture.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = selectedDevice.Id }); app.PreviewElement.Source = app.MediaCapture; _encodingPreviewProperties = app.MediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview); _encodingRecorderProperties = app.MediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoRecord); ListAllResolutionDetails(); var selectedPreviewProperties = _encodingPreviewProperties.First(x => ((VideoEncodingProperties)x).Width == 800); ListResolutionDetails((VideoEncodingProperties)selectedPreviewProperties); await app.MediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoPreview, selectedPreviewProperties); var selectedRecordingProperties = _encodingRecorderProperties.First(x => ((VideoEncodingProperties)x).Width == _encodingRecorderProperties.Max(y => ((VideoEncodingProperties)y).Width)); ListResolutionDetails((VideoEncodingProperties)selectedRecordingProperties); await app.MediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoRecord, selectedRecordingProperties); PropertySet testSet = new PropertySet(); FilterEffect effect = new FilterEffect(); //LomoFilter lomoFilter = new LomoFilter(); //VignettingFilter vignettingFilter = new VignettingFilter(); //effect.Filters = new IFilter[] { lomoFilter, vignettingFilter }; HdrEffect hdrEffect = new HdrEffect(effect); List <IImageProvider> providers = new List <IImageProvider>(); providers.Add(effect); providers.Add(hdrEffect); testSet.Add(new KeyValuePair <string, object>("IImageProviders", providers)); await app.MediaCapture.AddEffectAsync(MediaStreamType.VideoPreview, "ImagingEffects.ImagingEffect", testSet); //app.MediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees); //need this if portrait mode or landscapeflipped. app.IsPreviewing = true; await app.MediaCapture.StartPreviewAsync(); if (app.MediaCapture.VideoDeviceController.FocusControl.Supported) //.SetPresetAsync(Windows.Media.Devices.FocusPreset.Manual); { await app.MediaCapture.VideoDeviceController.FocusControl.SetPresetAsync(Windows.Media.Devices.FocusPreset.Manual); } else { app.MediaCapture.VideoDeviceController.Focus.TrySetAuto(false); } }
public async Task InitializeCameraAsync() { try { if (_setup == null) { _setup = new SetupService(); } isAutoShot = await _setup.GetAutomode(); if (_mediaCapture == null) { _mediaCapture = new MediaCapture(); _mediaCapture.Failed += MediaCapture_Failed; _cameraDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture); if (_cameraDevices == null || !_cameraDevices.Any()) { throw new NotSupportedException(); } DeviceInformation device; if (_cameraDevices.Count > 1) { device = _cameraDevices.FirstOrDefault(camera => camera.EnclosureLocation?.Panel == Windows.Devices.Enumeration.Panel.Back); } else { device = _cameraDevices.FirstOrDefault(camera => camera.EnclosureLocation?.Panel == Panel); } var cameraId = device?.Id ?? _cameraDevices.First().Id; await _mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = cameraId }); if (_mediaCapture.VideoDeviceController.FocusControl.Supported) { isAutoFocusCapable = true; errorMessage.Text = "VIZZoneInFront".GetLocalized(); } else { isAutoFocusCapable = false; errorMessage.Text = "NoFocusCamera".GetLocalized(); } IMediaEncodingProperties IProps = this._mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview); vep = (VideoEncodingProperties)IProps; DrawLineOnCanvas(vep.Width, vep.Height); if (Panel == Windows.Devices.Enumeration.Panel.Back) { //_mediaCapture.SetRecordRotation(VideoRotation.Clockwise90Degrees); //_mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees); _mirroringPreview = false; } else { _mirroringPreview = false; } IsInitialized = true; CanSwitch = _cameraDevices?.Count > 1; RegisterOrientationEventHandlers(); await StartPreviewAsync(); } } catch (UnauthorizedAccessException) { errorMessage.Text = "Camera_Exception_UnauthorizedAccess".GetLocalized(); } catch (NotSupportedException) { errorMessage.Text = "Camera_Exception_NotSupported".GetLocalized(); } catch (TaskCanceledException) { errorMessage.Text = "Camera_Exception_InitializationCanceled".GetLocalized(); } catch (Exception) { errorMessage.Text = "Camera_Exception_InitializationError".GetLocalized(); } }
private async void Light_Controll(object sender, RoutedEventArgs e) { objTextBox.Text = "Θέλετε να ανοίξετε ή να κλείσετε τα φώτα;"; await Speak(sender, e); await Task.Delay(TimeSpan.FromSeconds(2)); await SpeakToComputer(sender, e); // Create a socket and send udp message Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPAddress serverAddr = IPAddress.Parse("192.168.2.20"); IPEndPoint endPoint = new IPEndPoint(serverAddr, 5005); Debug.WriteLine(endPoint.ToString()); string selector = SerialDevice.GetDeviceSelector("COM5"); DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selector); Debug.WriteLine(devices); if (!devices.Any()) { return; } string deviceId = devices.First().Id; SerialDevice serialDevice = await SerialDevice.FromIdAsync(deviceId); serialDevice.BaudRate = 9600; serialDevice.DataBits = 8; serialDevice.StopBits = SerialStopBitCount.Two; serialDevice.Parity = SerialParity.None; serialDevice.Handshake = SerialHandshake.None; DataWriter dataWriter = new DataWriter(serialDevice.OutputStream); Debug.WriteLine(objTextBox.Text); switch (objTextBox.Text) { case ("open"): string text = "1"; Debug.WriteLine("sending " + text); byte[] send_buffer = Encoding.ASCII.GetBytes(text); sock.SendTo(send_buffer, endPoint); break; case ("open USB"): dataWriter.WriteString("1"); await dataWriter.StoreAsync(); dataWriter.DetachStream(); dataWriter = null; break; case ("close USB"): dataWriter.WriteString("0"); await dataWriter.StoreAsync(); dataWriter.DetachStream(); dataWriter = null; break; case ("close"): text = "0"; send_buffer = Encoding.ASCII.GetBytes(text); Debug.WriteLine("sending " + text); sock.SendTo(send_buffer, endPoint); break; default: text = "1"; send_buffer = Encoding.ASCII.GetBytes(text); Debug.WriteLine("sending " + text); // sock.SendTo(send_buffer, endPoint); await Task.Delay(TimeSpan.FromSeconds(1f)); text = "0"; send_buffer = Encoding.ASCII.GetBytes(text); Debug.WriteLine("sending " + text); // sock.SendTo(send_buffer, endPoint); await Task.Delay(TimeSpan.FromSeconds(1f)); text = "1"; send_buffer = Encoding.ASCII.GetBytes(text); Debug.WriteLine("sending " + text); // sock.SendTo(send_buffer, endPoint); await Task.Delay(TimeSpan.FromSeconds(1f)); text = "0"; send_buffer = Encoding.ASCII.GetBytes(text); Debug.WriteLine("sending " + text); // sock.SendTo(send_buffer, endPoint); break; } }