okListも表示/コメント追加

parent 56081e89
...@@ -6,11 +6,17 @@ ...@@ -6,11 +6,17 @@
xmlns:local="clr-namespace:WpfBleSampleApp" xmlns:local="clr-namespace:WpfBleSampleApp"
mc:Ignorable="d" mc:Ignorable="d"
Title="MainWindow" Title="MainWindow"
Height="200" Height="500"
Width="566.338" Width="566.338"
Loaded="Window_Loaded" Loaded="Window_Loaded"
Closed="Window_Closed"> Closed="Window_Closed">
<Grid> <Grid Margin="0,62,13.5,186.5">
<TextBlock x:Name="TextBlockRSSI" Margin="0,27,-0.5,0.5" /> <Grid.ColumnDefinitions>
<ColumnDefinition Width="9*"/>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="257*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TextBlockokList" Margin="24,-31,-11,0" Height="52" VerticalAlignment="Top" RenderTransformOrigin="0.495,1.012" Grid.Column="2" Text="okList" />
<TextBlock x:Name="TextBlockRSSI" Margin="10,60,-1,-103" Height="267" VerticalAlignment="Top" Grid.ColumnSpan="3" RenderTransformOrigin="0.492,1.471" />
</Grid> </Grid>
</Window> </Window>
\ No newline at end of file
...@@ -7,6 +7,11 @@ using System.Windows; ...@@ -7,6 +7,11 @@ using System.Windows;
using Windows.Devices.Bluetooth; using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.Advertisement; using Windows.Devices.Bluetooth.Advertisement;
//special thanks
//https://blog.okazuki.jp/entry/2016/07/19/221226
namespace WpfBleSampleApp namespace WpfBleSampleApp
{ {
/// <summary> /// <summary>
...@@ -22,6 +27,11 @@ namespace WpfBleSampleApp ...@@ -22,6 +27,11 @@ namespace WpfBleSampleApp
private string[] okList = private string[] okList =
{ {
"BluetoothLE#BluetoothLE98:5f:d3:d1:35:3f-74:99:95:70:e8:29", "BluetoothLE#BluetoothLE98:5f:d3:d1:35:3f-74:99:95:70:e8:29",
"BluetoothLE#BluetoothLE98:5f:d3:d1:35:3f-4e:03:3e:8f:50:96",
"BluetoothLE#BluetoothLE98:5f:d3:d1:35:3f-43:2d:3f:b7:45:02",
"",
"",
}; };
public MainWindow() public MainWindow()
...@@ -29,6 +39,13 @@ namespace WpfBleSampleApp ...@@ -29,6 +39,13 @@ namespace WpfBleSampleApp
InitializeComponent(); InitializeComponent();
this.watcher = new BluetoothLEAdvertisementWatcher(); this.watcher = new BluetoothLEAdvertisementWatcher();
this.TextBlockokList.Text += $"\n";
foreach (var ok in okList)
{
this.TextBlockokList.Text += $"{ok}\n";
}
this.TextBlockokList.Text += $"--------------------------------\n";
// CompanyIDとかDataでフィルタリングしたいとき // CompanyIDとかDataでフィルタリングしたいとき
//var md = new BluetoothLEManufacturerData(); //var md = new BluetoothLEManufacturerData();
//// company id 0xFFFF (多分これ https://www.bluetooth.com/specifications/assigned-numbers/company-Identifiers) //// company id 0xFFFF (多分これ https://www.bluetooth.com/specifications/assigned-numbers/company-Identifiers)
...@@ -40,11 +57,13 @@ namespace WpfBleSampleApp ...@@ -40,11 +57,13 @@ namespace WpfBleSampleApp
//md.Data = w.DetachBuffer(); //md.Data = w.DetachBuffer();
//this.watcher.AdvertisementFilter.Advertisement.ManufacturerData.Add(md); //this.watcher.AdvertisementFilter.Advertisement.ManufacturerData.Add(md);
// ↓https://docs.microsoft.com/ja-jp/windows/uwp/devices-sensors/ble-beacon
// rssi >= -60のとき受信開始するっぽい // rssi >= -60のとき受信開始するっぽい
this.watcher.SignalStrengthFilter.InRangeThresholdInDBm = -60; this.watcher.SignalStrengthFilter.InRangeThresholdInDBm = -60; // >=-60dBm
// rssi <= -65が2秒続いたら受信終わるっぽい // rssi <= -65が2秒続いたら受信終わるっぽい
this.watcher.SignalStrengthFilter.OutOfRangeThresholdInDBm = -65; this.watcher.SignalStrengthFilter.OutOfRangeThresholdInDBm = -65; // <=-65dBm
this.watcher.SignalStrengthFilter.OutOfRangeTimeout = TimeSpan.FromMilliseconds(2000); this.watcher.SignalStrengthFilter.OutOfRangeTimeout = TimeSpan.FromMilliseconds(2000);// 2000ミリ秒以上遠ざかっていると受信終了
this.watcher.Received += this.Watcher_Received; this.watcher.Received += this.Watcher_Received;
} }
...@@ -76,7 +95,7 @@ namespace WpfBleSampleApp ...@@ -76,7 +95,7 @@ namespace WpfBleSampleApp
Debug.WriteLine($"device found: {device.Name}"); Debug.WriteLine($"device found: {device.Name}");
mutex.WaitOne(); mutex.WaitOne();
devices[device.DeviceId] = device; devices[device.DeviceId] = device;//DeviceId と device を結び付けている
Debug.WriteLine("===========begin"); Debug.WriteLine("===========begin");
foreach (var x in devices) foreach (var x in devices)
...@@ -104,7 +123,7 @@ namespace WpfBleSampleApp ...@@ -104,7 +123,7 @@ namespace WpfBleSampleApp
// OKリストの中身と何個一致しているか // OKリストの中身と何個一致しているか
var count = okList.Count((okId) => devices.ContainsKey(okId)); var count = okList.Count((okId) => devices.ContainsKey(okId));
this.TextBlockRSSI.Text += $"ok count: {count}"; this.TextBlockRSSI.Text += $"ok count: {count}\n";
mutex.ReleaseMutex(); mutex.ReleaseMutex();
}); });
......
#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "FAFEFD3F01B8A5633EA83447C6063184262A7EAD" #pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3E8643B1D2420B6754788BA2F1DE4AFABEF42E89"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// このコードはツールによって生成されました。 // このコードはツールによって生成されました。
...@@ -41,7 +41,15 @@ namespace WpfBleSampleApp { ...@@ -41,7 +41,15 @@ namespace WpfBleSampleApp {
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector { public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 14 "..\..\MainWindow.xaml" #line 19 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock TextBlockokList;
#line default
#line hidden
#line 20 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock TextBlockRSSI; internal System.Windows.Controls.TextBlock TextBlockRSSI;
...@@ -93,6 +101,9 @@ namespace WpfBleSampleApp { ...@@ -93,6 +101,9 @@ namespace WpfBleSampleApp {
#line hidden #line hidden
return; return;
case 2: case 2:
this.TextBlockokList = ((System.Windows.Controls.TextBlock)(target));
return;
case 3:
this.TextBlockRSSI = ((System.Windows.Controls.TextBlock)(target)); this.TextBlockRSSI = ((System.Windows.Controls.TextBlock)(target));
return; return;
} }
......
#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "FAFEFD3F01B8A5633EA83447C6063184262A7EAD" #pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "3E8643B1D2420B6754788BA2F1DE4AFABEF42E89"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// このコードはツールによって生成されました。 // このコードはツールによって生成されました。
...@@ -41,7 +41,15 @@ namespace WpfBleSampleApp { ...@@ -41,7 +41,15 @@ namespace WpfBleSampleApp {
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector { public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 14 "..\..\MainWindow.xaml" #line 19 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock TextBlockokList;
#line default
#line hidden
#line 20 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock TextBlockRSSI; internal System.Windows.Controls.TextBlock TextBlockRSSI;
...@@ -93,6 +101,9 @@ namespace WpfBleSampleApp { ...@@ -93,6 +101,9 @@ namespace WpfBleSampleApp {
#line hidden #line hidden
return; return;
case 2: case 2:
this.TextBlockokList = ((System.Windows.Controls.TextBlock)(target));
return;
case 3:
this.TextBlockRSSI = ((System.Windows.Controls.TextBlock)(target)); this.TextBlockRSSI = ((System.Windows.Controls.TextBlock)(target));
return; return;
} }
......
87547dbd71f0f6358cb90fadc383c4e531b27c80 982da2a63defad06f7788fc2a61c45b51255c7eb
...@@ -61,3 +61,24 @@ C:\Users\Kaoru\source\repos\catch1ble\WpfApp1\obj\Debug\WpfApp1.csproj.CoreCompi ...@@ -61,3 +61,24 @@ C:\Users\Kaoru\source\repos\catch1ble\WpfApp1\obj\Debug\WpfApp1.csproj.CoreCompi
C:\Users\Kaoru\source\repos\catch1ble\WpfApp1\obj\Debug\WpfApp1.csproj.CopyComplete C:\Users\Kaoru\source\repos\catch1ble\WpfApp1\obj\Debug\WpfApp1.csproj.CopyComplete
C:\Users\Kaoru\source\repos\catch1ble\WpfApp1\obj\Debug\WpfApp1.exe C:\Users\Kaoru\source\repos\catch1ble\WpfApp1\obj\Debug\WpfApp1.exe
C:\Users\Kaoru\source\repos\catch1ble\WpfApp1\obj\Debug\WpfApp1.pdb C:\Users\Kaoru\source\repos\catch1ble\WpfApp1\obj\Debug\WpfApp1.pdb
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\bin\Debug\WpfApp1.exe.config
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\bin\Debug\WpfApp1.exe
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\bin\Debug\WpfApp1.pdb
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\bin\Debug\System.Runtime.WindowsRuntime.dll
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\bin\Debug\System.Runtime.WindowsRuntime.UI.Xaml.dll
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\bin\Debug\Windows.WinMD
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\bin\Debug\System.Runtime.WindowsRuntime.xml
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\bin\Debug\System.Runtime.WindowsRuntime.UI.Xaml.xml
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\WpfApp1.csprojAssemblyReference.cache
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\MainWindow.g.cs
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\App.g.cs
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\WpfApp1_MarkupCompile.cache
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\WpfApp1_MarkupCompile.lref
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\MainWindow.baml
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\WpfApp1.g.resources
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\WpfApp1.Properties.Resources.resources
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\WpfApp1.csproj.GenerateResource.cache
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\WpfApp1.csproj.CoreCompileInputs.cache
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\WpfApp1.csproj.CopyComplete
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\WpfApp1.exe
C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\WpfApp1.pdb
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
winexe winexe
C# C#
.cs .cs
C:\Users\Kaoru\source\repos\catch1ble\WpfApp1\obj\Debug\ C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\obj\Debug\
WpfApp1 WpfApp1
none none
false false
DEBUG;TRACE DEBUG;TRACE
C:\Users\Kaoru\source\repos\catch1ble\WpfApp1\App.xaml C:\Users\Kaoru\source\repos\catchBLE\WpfApp1\App.xaml
11151548125 11151548125
5-2017746502 5-2017746502
......
 
FC:\Users\Kaoru\source\repos\catch1ble\WpfApp1\MainWindow.xaml;; FC:\Users\Kaoru\source\repos\catchBLE\WpfApp1\MainWindow.xaml;;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment