簡體   English   中英

Windows/.Net 中的藍牙 API?

[英]Bluetooth APIs in Windows/.Net?

我正在編寫一個藍牙掃描儀,用於定位和識別本地附近的移動設備。 這是我可以使用 C# 完成的事情,還是我需要下拉到 C/C++ API 中? 我的應用程序面向 Windows XP 和 Vista。 指針表示贊賞。

謝謝!

PC上的藍牙的一個問題是有幾個BT堆棧在使用中,你永遠不知道在給定的機器上哪個可用。 最常見的是Widcomm(現在是Broadcom)和Microsoft(出現在XP中,可能是其中一個服務包)。 但是,一些BT硬件供應商打包BlueSoleil,有些則使用東芝。 大多數加密狗將使用MS堆棧,因此我見過的.NET庫傾向於使用它。

每個堆棧都有完全不同的方式來執行發現部分,您可以在其中瀏覽附近的設備並查詢其服務。

如果今天我必須選擇一種方法,我可能會在C ++中進行發現,並為.NET添加一個接口。

32feet.net的東西在我嘗試時效果很好但是不支持Widcomm堆棧。

還有Peter Foot的32feet.net

http://inthehand.com/content/32feet.aspx

當它是v1.5並且運行良好時,我已經玩過這個回來了。

Mike Petrichenko有一個很好的BT框架。 它適用於BlueSoleil,Widcomm,Toshiba和Microsoft。

它現在被稱為無線通信庫,可與藍牙802.11和紅外線配合使用。 Mike將該公司命名為Soft Service Company公司,銷售非商業和商業許可證,有或沒有源代碼,價格在100美元到2050美元之間。

了解藍牙設備並從PC向藍牙設備發送文件的最佳方法是使用該代碼。

    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的藍牙開發來說非常棒。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM