private void ConnectDevices_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) { BluetoothSerialLib.BluetoothSerial.PairedDeviceInfo pairedDevice = (BluetoothSerialLib.BluetoothSerial.PairedDeviceInfo)ConnectDevices.SelectedItem; this.TxtBlock_SelectedID.Text = pairedDevice.ID; this.textBlockBTName.Text = pairedDevice.Name; ConnectDevice_Click(sender, e); }
async private void ConnectDevice_Click(object sender, RoutedEventArgs e) { BluetoothSerialLib.BluetoothSerial.PairedDeviceInfo pairedDevice = (BluetoothSerialLib.BluetoothSerial.PairedDeviceInfo)ConnectDevices.SelectedItem; DeviceInfo = pairedDevice.DeviceInfo; bool success = await SerialPort.ConnectDevice(pairedDevice); // If the connection was successful, the RemoteAddress field will be populated if (success) { this.buttonDisconnect.IsEnabled = true; this.buttonSend.IsEnabled = true; this.buttonStartRecv.IsEnabled = true; this.buttonStopRecv.IsEnabled = false; string msg = String.Format("Connected to {0}!", SerialPort._socket.Information.RemoteAddress.DisplayName); System.Diagnostics.Debug.WriteLine(msg); } }