Skip to content

Commit 09609cf

Browse files
committed
show exception
1 parent 7b59ed1 commit 09609cf

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Diff for: UnityBLE_Editor/Class1.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private void DeviceWatcher_Added(DeviceWatcher sender, DeviceInformation deviceI
9696
{
9797
if (sender == deviceWatcher)
9898
{
99-
if (deviceInfo.Name != string.Empty)
99+
if (deviceInfo.Name != string.Empty && deviceInfo.Pairing.IsPaired)
100100
{
101101
DeviceAdded(this, new DeviceArgs(deviceInfo.Id, deviceInfo.Name));
102102
}

Diff for: Use/MainPage.xaml.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,16 @@ private async void deviceRemovedAsync(object sender, UnityBLE.DeviceArgs args)
6565

6666
private async void characteristicReceivedAsync(object sender, UnityBLE.CharacteristicArgs args)
6767
{
68-
if (sender == ble && args.ex == null)
68+
if (sender == ble)
6969
{
70-
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => receivedData.Text = System.Text.Encoding.UTF8.GetString(args.Value));
70+
if (args.ex == null)
71+
{
72+
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => receivedData.Text = System.Text.Encoding.UTF8.GetString(args.Value));
73+
}
74+
else
75+
{
76+
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => receivedData.Text = args.ex.Message);
77+
}
7178
}
7279
}
7380
}

0 commit comments

Comments
 (0)