Fix: clear dgvBluetoothDevices.
This commit is contained in:
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>
|
||||
Reference in New Issue
Block a user