Windows/.net의 Bluetooth API?
-
02-07-2019 - |
문제
나는 현지 근처에서 모바일 장치를 찾아서 식별하는 블루투스 스캐너를 작성하는 과정에 있습니다. C#을 사용하여 달성 할 수있는 것입니까, 아니면 C/C ++ API로 드롭 다운해야합니까? 내 응용 프로그램은 Windows XP 및 Vista를 대상으로합니다. 포인터에게 감사합니다.
감사!
해결책
PC의 Bluetooth와 관련된 한 가지 문제는 사용 중에 여러 BT 스택이 있으며 특정 시스템에서 사용할 수있는 것을 알 수 없다는 것입니다. 가장 일반적인 것은 Widcomm (현재 Broadcom)과 Microsoft (XP, 아마도 서비스 팩 중 하나)입니다. 그러나 일부 BT 하드웨어 공급 업체는 Bluesoleil을 패키지하고 일부는 Toshiba를 사용합니다. 대부분의 동글은 MS 스택과 함께 작동하므로 내가 본 .NET Libs가 사용하는 경향이 있습니다.
각 스택은 근처의 장치를 탐색하고 서비스를 문의하는 발견 부분을 수행하는 완전히 다른 방법을 가지고 있습니다.
오늘 하나의 접근 방식을 선택해야한다면 아마도 C ++에서 발견을하고 .NET에 대한 인터페이스를 추가 할 것입니다.
32feet.net 물건은 시도했을 때 꽤 잘 작동했지만 Widcomm 스택을 지원하지 않았습니다.
다른 팁
Peter Foot의 32feet.net도 있습니다
http://inthehand.com/content/32feet.aspx
나는 V1.5 일 때 이것과 함께 놀았고 잘 작동했습니다.
Mike Petrichenko 멋진 BT 프레임 워크가 있습니다. Bluesoleil, Widcomm, Toshiba 및 Microsoft와 함께 작동합니다.
이제 무선 통신 라이브러리라고하며 Bluetooth 802.11 및 Infrared와 함께 작동합니다. Mike는 회사 Soft Service Company를 지명했으며 소스 코드가 있거나없는 비영리 및 상업 라이센스를 $ 100에서 $ 2050 사이의 가격으로 판매합니다.
Bluetooth 장치를 알고 PC의 Bluetooth 장치로 파일을 보내는 가장 좋은 방법은 해당 코드를 사용하는 것입니다.
public void ExecuteCommandSync(object command)
{
try
{
// create the ProcessStartInfo using "cmd" as the program to be run,
// and "/c " as the parameters.
// Incidentally, /c tells cmd that we want it to execute the command that follows,
// and then exit.
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
// The following commands are needed to redirect the standard output.
// This means that it will be redirected to the Process.StandardOutput StreamReader.
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
// Now we create a process, assign its ProcessStartInfo and start it
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
// Get the output into a string
string result = proc.StandardOutput.ReadToEnd();
// Display the command output.
Console.WriteLine(result);
}
catch (Exception objException)
{
// Log the exception
MessageBox.Show(objException.Message);
}
}
이 메소드를 다음과 같이 호출 할 수 있습니다
string command = "fsquirt";
ExecuteCommandSync(command);
따라서 Bluetoothfiletransferwizard가 나타나고 사용 가능한 장치를 선택하고 해당 장치를 보낼 파일을 보낼 수 있습니다. 그런 식으로 사용하지 않으려면 32feet.net.uk를 사용해보십시오. C# 및 vb.net의 Bluetooth 개발에 좋았습니다.