如何断开蓝牙设备?

时间:2010-06-27 18:41:05

标签: c# .net sockets bluetooth disconnect

我的设备通过蓝牙主动连接到计算机。在我的C#.NET应用程序中,我希望断开设备连接,以便计算机不再连接到设备。

我将如何做到这一点?

我猜它会找到合适的Socket并断开那个套接字? (但这纯粹是冒险,因为我对Socket连接一无所知。)

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

根据我使用蓝牙(Java和Perl,而不是c#)的经验,当您关闭输入/输出流时,连接开始断开。然后毒药的最终剂量是关闭插座。 /$0.02

答案 1 :(得分:-1)

来自Bluetooth Device Development using C#上的MSDN博客:

  using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.WindowsMobile.SharedSource.Bluetooth;

  namespace ToggleBluetooth
   {
     class Program
       {
          static void Main(string[] args)
         {
              BluetoothRadio brad = new BluetoothRadio();
              if (brad.BluetoothRadioMode == BluetoothRadioMode.Off)
                  brad.BluetoothRadioMode = BluetoothRadioMode.On;
               else
                brad.BluetoothRadioMode = BluetoothRadioMode.Off;
          }
     }
   }