実験するように変更

parent 790b0b45
......@@ -5,12 +5,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:iBeaconScanner"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="938.836">
Title="MainWindow" Height="462" Width="938.836">
<Grid>
<TextBox x:Name="para" Margin="28,35,658,365.5" TextWrapping="Wrap" Text="" IsReadOnly="True"/>
<TextBox x:Name="listBox" Margin="0,95,75,0.5" TextWrapping="Wrap" Text="" IsReadOnly="True"/>
<TextBox x:Name="RUNUBox" Margin="0,35,607,251.5" TextWrapping="Wrap" Text="" IsReadOnly="True"/>
<TextBox x:Name="textBox" Margin="589,35,137,251.5" TextWrapping="Wrap" Text="" IsReadOnly="True"/>
<TextBox x:Name="RUrate" Margin="385,35,387,251.5" TextWrapping="Wrap" Text="" IsReadOnly="True"/>
<TextBox x:Name="RUNUBox" Margin="323,35,421,365.5" TextWrapping="Wrap" Text="" IsReadOnly="True"/>
<TextBox x:Name="textBox" Margin="692,35,75,365.5" TextWrapping="Wrap" Text="" IsReadOnly="True"/>
<TextBox x:Name="RUrate" Margin="535,35,266,365.5" TextWrapping="Wrap" Text="" IsReadOnly="True"/>
</Grid>
</Window>
......@@ -25,8 +25,8 @@ namespace iBeaconScanner
/* パラメータ */
public static int A_thresh = 2;//認証可能人数
public static double B_thresh = 0.3;//RU率
public static TimeSpan LIMIT_TIME = new TimeSpan(0, 0, 18);//n秒パケットが取れなければ終了
public static short RSSI = -50;//探索範囲 大きいほど狭い
public static TimeSpan LIMIT_TIME = new TimeSpan(0, 0, 30);//n秒パケットが取れなければ終了
public static short RSSI = -70;//探索範囲 大きいほど狭い
static int RUcnt, NUcnt;
double rate;
......@@ -44,9 +44,28 @@ namespace iBeaconScanner
/* 事前登録 */
RU_uuid.Add("48534442-4c45-4144-1234-dcba12345678");
RU_uuid.Add("48534442-4c45-4144-1234-abcd12345678");
RU_uuid.Add("48534442-4c45-4144-1234-abcd12345671");
RU_uuid.Add("48534442-4c45-4144-80c0-1800ffffffff");//deafault
RU_uuid.Add("48534442-4c45-4144-1234-abcd12345671");//me
RU_uuid.Add("48534442-4c45-4144-80c0-1800ffffffff");//deafault
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffff0");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffff1");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffff2");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffff3");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffff4");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffff5");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffff6");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffff7");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffff8");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffff9");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffffa");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffffb");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffffc");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffffd");
RU_uuid.Add("48534442-4c45-4144-80c0-1800fffffffe");
this.para.Text = "A="+ A_thresh + ",B=" + B_thresh + ",L="+LIMIT_TIME + ",RSSI="+RSSI;
this.advWatcher = new BluetoothLEAdvertisementWatcher();
// https://blogs.msdn.microsoft.com/shozoa/2016/02/28/windows-10-bluetooth/
......@@ -54,7 +73,7 @@ namespace iBeaconScanner
this.advWatcher.SignalStrengthFilter.SamplingInterval = TimeSpan.FromMilliseconds(1000);
// rssi >= RSSIのときスキャンする
this.advWatcher.SignalStrengthFilter.InRangeThresholdInDBm = RSSI;//-50 で3m強
this.advWatcher.SignalStrengthFilter.InRangeThresholdInDBm = RSSI;//-50 で3m強 -70なら研究室の端から端までOK
this.advWatcher.Received += this.Watcher_Received;
......@@ -86,17 +105,23 @@ namespace iBeaconScanner
{
mutex.WaitOne();
Debug.WriteLine($"-------------");
Debug.WriteLine($"???{args.Timestamp} RSSI={args.RawSignalStrengthInDBm} BD:{args.BluetoothAddress}");
if (manufacturerData.CompanyId != CompanyID_Apple)
{
//Debug.WriteLine($"---NOT Apple's packet");
continue;
}
if (manufacturerData.Data.Length != Length_of_iBeacon_Advertise_Packet)
{
//Debug.WriteLine($"---NOT iBeacon packet");
continue;
}
Debug.WriteLine($"-------------");
Debug.WriteLine($"{args.Timestamp} RSSI={args.RawSignalStrengthInDBm} BD:{args.BluetoothAddress}");
// Debug.WriteLine($"{args.Timestamp} RSSI={args.RawSignalStrengthInDBm} BD:{args.BluetoothAddress}");
// Debug.WriteLine($"{args.AdvertisementType}, {manufacturerData.CompanyId}");
/* All_uuidリストを作成するフェーズ ↓*/
......@@ -104,15 +129,17 @@ namespace iBeaconScanner
{
reader.ByteOrder = ByteOrder.BigEndian;// BigEndian:順方向にパケットを保存
/* 0215 で始まればiBeacon */ //http://d.hatena.ne.jp/shu223/20141208/1418051009
var indicator = reader.ReadByte();
var length = reader.ReadByte();
if (indicator != 0x02 && length != 0x15)
{
Debug.WriteLine($" ?1");
continue; //iBeacon でないAdvertise Packet
}
Debug.WriteLine(" This is iBeacon Packet!!!");
// Debug.WriteLine(" This is iBeacon Packet!!!");
// Parse advertise packet.
var uuidA = reader.ReadInt32();
......@@ -126,14 +153,14 @@ namespace iBeaconScanner
var proximity_uuid = new Guid(uuidA, uuidB, uuidC, uuidD);
Debug.WriteLine($"UUID:{proximity_uuid}, major: {major}, minor: {minor}, power: {power}");
Debug.WriteLine($" UUID:{proximity_uuid}, major: {major}, minor: {minor}, power: {power}");
/* 周囲のuuidの hash set を作成 */
if (!All_uuid.Contains(proximity_uuid.ToString())) //新しいUUIDなら追加
{
All_uuid.Add(proximity_uuid.ToString());
Debug.WriteLine($" It's New UUID!");
this.listBox.Text = this.listBox.Text + proximity_uuid + "\r\n";
this.listBox.Text = this.listBox.Text +args.Timestamp +"///"+ proximity_uuid + "\r\n";
}
}
/* All_uuidリストを作成するフェーズ ↑*/
......@@ -161,12 +188,12 @@ namespace iBeaconScanner
if (RUcnt >= A_thresh && rate >= B_thresh)//安全かどうかの判定
{
this.textBox.Text = "You are ACCEPTED!!";
Debug.WriteLine($"You are ACCEPTED!!");
Debug.WriteLine($" You are ACCEPTED!!");
}
else
{
this.textBox.Text = "Input Password";
Debug.WriteLine($"Input Password");
Debug.WriteLine($" Input Password");
}
/* 判定フェーズ↑ */
......
#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "82CA724FCEE02F7AA65BAF30FD893EB0C35722F7"
#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "354DCB49612DA754EA584F3D1DC515459782B11F"
//------------------------------------------------------------------------------
// <auto-generated>
// このコードはツールによって生成されました。
......@@ -43,7 +43,7 @@ namespace iBeaconScanner {
#line 10 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox listBox;
internal System.Windows.Controls.TextBox para;
#line default
#line hidden
......@@ -51,7 +51,7 @@ namespace iBeaconScanner {
#line 11 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox RUNUBox;
internal System.Windows.Controls.TextBox listBox;
#line default
#line hidden
......@@ -59,7 +59,7 @@ namespace iBeaconScanner {
#line 12 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox textBox;
internal System.Windows.Controls.TextBox RUNUBox;
#line default
#line hidden
......@@ -67,6 +67,14 @@ namespace iBeaconScanner {
#line 13 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox textBox;
#line default
#line hidden
#line 14 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox RUrate;
#line default
......@@ -103,15 +111,18 @@ namespace iBeaconScanner {
switch (connectionId)
{
case 1:
this.listBox = ((System.Windows.Controls.TextBox)(target));
this.para = ((System.Windows.Controls.TextBox)(target));
return;
case 2:
this.RUNUBox = ((System.Windows.Controls.TextBox)(target));
this.listBox = ((System.Windows.Controls.TextBox)(target));
return;
case 3:
this.textBox = ((System.Windows.Controls.TextBox)(target));
this.RUNUBox = ((System.Windows.Controls.TextBox)(target));
return;
case 4:
this.textBox = ((System.Windows.Controls.TextBox)(target));
return;
case 5:
this.RUrate = ((System.Windows.Controls.TextBox)(target));
return;
}
......
#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "82CA724FCEE02F7AA65BAF30FD893EB0C35722F7"
#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "354DCB49612DA754EA584F3D1DC515459782B11F"
//------------------------------------------------------------------------------
// <auto-generated>
// このコードはツールによって生成されました。
......@@ -43,7 +43,7 @@ namespace iBeaconScanner {
#line 10 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox listBox;
internal System.Windows.Controls.TextBox para;
#line default
#line hidden
......@@ -51,7 +51,7 @@ namespace iBeaconScanner {
#line 11 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox RUNUBox;
internal System.Windows.Controls.TextBox listBox;
#line default
#line hidden
......@@ -59,7 +59,7 @@ namespace iBeaconScanner {
#line 12 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox textBox;
internal System.Windows.Controls.TextBox RUNUBox;
#line default
#line hidden
......@@ -67,6 +67,14 @@ namespace iBeaconScanner {
#line 13 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox textBox;
#line default
#line hidden
#line 14 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox RUrate;
#line default
......@@ -103,15 +111,18 @@ namespace iBeaconScanner {
switch (connectionId)
{
case 1:
this.listBox = ((System.Windows.Controls.TextBox)(target));
this.para = ((System.Windows.Controls.TextBox)(target));
return;
case 2:
this.RUNUBox = ((System.Windows.Controls.TextBox)(target));
this.listBox = ((System.Windows.Controls.TextBox)(target));
return;
case 3:
this.textBox = ((System.Windows.Controls.TextBox)(target));
this.RUNUBox = ((System.Windows.Controls.TextBox)(target));
return;
case 4:
this.textBox = ((System.Windows.Controls.TextBox)(target));
return;
case 5:
this.RUrate = ((System.Windows.Controls.TextBox)(target));
return;
}
......
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