Fix: clear dgvBluetoothDevices.
This commit is contained in:
parent
eac82673c8
commit
3896d05526
|
@ -2,12 +2,10 @@
|
|||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using InTheHand.Net.Bluetooth;
|
||||
using InTheHand.Net.Sockets;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing.Printing;
|
||||
using Newtonsoft.Json;
|
||||
using System.Drawing;
|
||||
|
||||
|
@ -29,6 +27,11 @@ namespace BITable
|
|||
|
||||
private void ScanBluetoothDevices()
|
||||
{
|
||||
dgvBluetoothDevices.Invoke(new Action(() =>
|
||||
{
|
||||
dgvBluetoothDevices.Rows.Clear();
|
||||
}));
|
||||
|
||||
devices = client.DiscoverDevices();
|
||||
foreach (var device in devices)
|
||||
{
|
||||
|
@ -44,8 +47,18 @@ namespace BITable
|
|||
{
|
||||
Task.Factory.StartNew(new Action(() =>
|
||||
{
|
||||
ScanBluetoothDevices();
|
||||
btnScanBluetoothDevices.Invoke(new Action(() =>
|
||||
{
|
||||
btnScanBluetoothDevices.Enabled = false;
|
||||
}));
|
||||
ScanBluetoothDevices();
|
||||
})).ContinueWith(t =>
|
||||
{
|
||||
btnScanBluetoothDevices.Invoke(new Action(() =>
|
||||
{
|
||||
btnScanBluetoothDevices.Enabled = true;
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
private void dgvBluetoothDevices_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
|
||||
|
|
6
TestBluetooth/App.config
Normal file
6
TestBluetooth/App.config
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
</configuration>
|
116
TestBluetooth/Program.cs
Normal file
116
TestBluetooth/Program.cs
Normal file
|
@ -0,0 +1,116 @@
|
|||
//using System;
|
||||
//using System.Text;
|
||||
//using InTheHand.Net.Sockets;
|
||||
//using InTheHand.Net;
|
||||
//using InTheHand.Net.Bluetooth;
|
||||
//using System.Net.Sockets;
|
||||
//using System.Linq;
|
||||
|
||||
//namespace dConsoleApp
|
||||
//{
|
||||
// static class Program
|
||||
// {
|
||||
// // My BT USB adapter
|
||||
// //private static BluetoothEndPoint EP = new BluetoothEndPoint(BluetoothAddress.Parse("00:02:72:CD:9A:33"), BluetoothService.BluetoothBase);
|
||||
// //private static BluetoothClient BC = new BluetoothClient(EP);
|
||||
// //static string MY_PAIRING_CODE = "0B8N62R9";
|
||||
// //// The BT device that would connect
|
||||
|
||||
// //private static BluetoothDeviceInfo BTDevice = new BluetoothDeviceInfo(BluetoothAddress.Parse("94:21:97:60:07:C0"));
|
||||
|
||||
// private static NetworkStream stream = null;
|
||||
|
||||
// static void Main(string[] args)
|
||||
// {
|
||||
// BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable;
|
||||
// BluetoothClient client = new BluetoothClient();
|
||||
// BluetoothDeviceInfo[] devices = client.DiscoverDevices();
|
||||
// BluetoothClient bluetoothClient = new BluetoothClient();
|
||||
// String authenticated;
|
||||
// String classOfDevice;
|
||||
// String connected;
|
||||
// String deviceAddress;
|
||||
// String deviceName;
|
||||
// String installedServices;
|
||||
// String lastSeen;
|
||||
// String lastUsed;
|
||||
// String remembered;
|
||||
// String rssi;
|
||||
// foreach (BluetoothDeviceInfo device in devices)
|
||||
// {
|
||||
// authenticated = device.Authenticated.ToString();
|
||||
// classOfDevice = device.ClassOfDevice.ToString();
|
||||
// connected = device.Connected.ToString();
|
||||
// deviceAddress = device.DeviceAddress.ToString();
|
||||
// deviceName = device.DeviceName.ToString();
|
||||
// installedServices = device.InstalledServices.ToString();
|
||||
// lastSeen = device.LastSeen.ToString();
|
||||
// lastUsed = device.LastUsed.ToString();
|
||||
// remembered = device.Remembered.ToString();
|
||||
// rssi = device.Rssi.ToString();
|
||||
// //string[] row = new string[] { authenticated, classOfDevice, connected, deviceAddress, deviceName, installedServices, lastSeen, lastUsed, remembered, rssi };
|
||||
// //dataGridView1.Rows.Add(row);
|
||||
// //label1.Text += $"{""}";
|
||||
// }
|
||||
// var BTDevice = devices.Where(x => x.DeviceName == "BITABLE11").FirstOrDefault();
|
||||
// if (BluetoothSecurity.PairRequest(BTDevice.DeviceAddress, MY_PAIRING_CODE))
|
||||
// {
|
||||
// Console.WriteLine("PairRequest: OK");
|
||||
|
||||
// if (BTDevice.Authenticated)
|
||||
// {
|
||||
// Console.WriteLine("Authenticated: OK");
|
||||
|
||||
// BC.SetPin(MY_PAIRING_CODE);
|
||||
|
||||
// BC.BeginConnect(BTDevice.DeviceAddress, BluetoothService.SerialPort, new AsyncCallback(Connect), BTDevice);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine("Authenticated: No");
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine("PairRequest: No");
|
||||
// }
|
||||
|
||||
// Console.ReadLine();
|
||||
// }
|
||||
|
||||
// private static void Connect(IAsyncResult result)
|
||||
// {
|
||||
// if (result.IsCompleted)
|
||||
// {
|
||||
// // client is connected now :)
|
||||
// Console.WriteLine(BC.Connected);
|
||||
// stream = BC.GetStream();
|
||||
|
||||
// if (stream.CanRead)
|
||||
// {
|
||||
// byte[] myReadBuffer = new byte[1024];
|
||||
// StringBuilder myCompleteMessage = new StringBuilder();
|
||||
// int numberOfBytesRead = 0;
|
||||
|
||||
// // Incoming message may be larger than the buffer size.
|
||||
// do
|
||||
// {
|
||||
// numberOfBytesRead = stream.Read(myReadBuffer, 0, myReadBuffer.Length);
|
||||
|
||||
// myCompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead));
|
||||
// }
|
||||
// while (stream.DataAvailable);
|
||||
|
||||
// // Print out the received message to the console.
|
||||
// Console.WriteLine("You received the following message : " + myCompleteMessage);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine("Sorry. You cannot read from this NetworkStream.");
|
||||
// }
|
||||
|
||||
// Console.ReadLine();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
36
TestBluetooth/Properties/AssemblyInfo.cs
Normal file
36
TestBluetooth/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TestBluetooth")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TestBluetooth")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("b5a312e7-14c1-4261-8a4e-c4b71234a0a7")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
57
TestBluetooth/TestBluetooth.csproj
Normal file
57
TestBluetooth/TestBluetooth.csproj
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{B5A312E7-14C1-4261-8A4E-C4B71234A0A7}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>TestBluetooth</RootNamespace>
|
||||
<AssemblyName>TestBluetooth</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="InTheHand.Net.Personal, Version=3.5.605.0, Culture=neutral, PublicKeyToken=ea38caa273134499, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\32feet.NET.3.5.0.0\lib\net\InTheHand.Net.Personal.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
4
TestBluetooth/packages.config
Normal file
4
TestBluetooth/packages.config
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="32feet.NET" version="3.5.0.0" targetFramework="net461" />
|
||||
</packages>
|
BIN
packages/Network.6.1.4.20/.signature.p7s
vendored
BIN
packages/Network.6.1.4.20/.signature.p7s
vendored
Binary file not shown.
BIN
packages/Network.6.1.4.20/lib/net46/Network.dll
vendored
BIN
packages/Network.6.1.4.20/lib/net46/Network.dll
vendored
Binary file not shown.
4314
packages/Network.6.1.4.20/lib/net46/Network.xml
vendored
4314
packages/Network.6.1.4.20/lib/net46/Network.xml
vendored
File diff suppressed because it is too large
Load Diff
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.3/.signature.p7s
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.3/.signature.p7s
vendored
Normal file
Binary file not shown.
20
packages/Newtonsoft.Json.12.0.3/LICENSE.md
vendored
Normal file
20
packages/Newtonsoft.Json.12.0.3/LICENSE.md
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2007 James Newton-King
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
BIN
packages/Newtonsoft.Json.12.0.3/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.3/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
10298
packages/Newtonsoft.Json.12.0.3/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
10298
packages/Newtonsoft.Json.12.0.3/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.3/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.3/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
9446
packages/Newtonsoft.Json.12.0.3/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
9446
packages/Newtonsoft.Json.12.0.3/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.3/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.3/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
9646
packages/Newtonsoft.Json.12.0.3/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
9646
packages/Newtonsoft.Json.12.0.3/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11262
packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
11262
packages/Newtonsoft.Json.12.0.3/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.3/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.3/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
10950
packages/Newtonsoft.Json.12.0.3/lib/netstandard1.0/Newtonsoft.Json.xml
vendored
Normal file
10950
packages/Newtonsoft.Json.12.0.3/lib/netstandard1.0/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.3/lib/netstandard1.3/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.3/lib/netstandard1.3/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11072
packages/Newtonsoft.Json.12.0.3/lib/netstandard1.3/Newtonsoft.Json.xml
vendored
Normal file
11072
packages/Newtonsoft.Json.12.0.3/lib/netstandard1.3/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.3/lib/netstandard2.0/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.3/lib/netstandard2.0/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11237
packages/Newtonsoft.Json.12.0.3/lib/netstandard2.0/Newtonsoft.Json.xml
vendored
Normal file
11237
packages/Newtonsoft.Json.12.0.3/lib/netstandard2.0/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.3/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.3/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
9010
packages/Newtonsoft.Json.12.0.3/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
9010
packages/Newtonsoft.Json.12.0.3/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.3/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.3/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
10950
packages/Newtonsoft.Json.12.0.3/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
10950
packages/Newtonsoft.Json.12.0.3/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.3/packageIcon.png
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.3/packageIcon.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
Loading…
Reference in New Issue
Block a user