zoukankan      html  css  js  c++  java
  • C#蓝牙开发之查找设备以及配对

               
    BluetoothClient Blueclient = new BluetoothClient();
             Dictionary<string, BluetoothAddress> deviceAddresses = new Dictionary<string, BluetoothAddress>();
             BluetoothRadio BuleRadio = BluetoothRadio.PrimaryRadio;
                BuleRadio.Mode = RadioMode.Connectable;
                BluetoothDeviceInfo[] Devices = Blueclient.DiscoverDevices();
                lsbDevices.Items.Clear();
                deviceAddresses.Clear();
                foreach (BluetoothDeviceInfo device in Devices)
                {
                    //循环将所有搜索到的设备添加进来。
                    lsbDevices.Items.Add(device.DeviceName);
                    deviceAddresses[device.DeviceName] = device.DeviceAddress;
                }
     
    配对:
          Blueclient.SetPin(DeviceAddress, txtPwd.Text.Trim());
          Blueclient.Connect(DeviceAddress, BluetoothService.Handsfree);

    PC上安装Windows Mobile 6.0 SDK和ActiveSync同步软件,ActiveSync目前为4.5版本,通过VS新建的程序便可以部署在相应的设备上面,这里我使用自己的手机来作为测试机,刚好手机也是Windows Mobile的系统.

    点击“Find Devices”开始搜索周围的蓝牙设备

    下图为搜索到的蓝牙设备。图中PC-2012...为我的开发电脑,电脑上面安装了有一个蓝牙的驱动,另一个6690的另一个开了蓝牙的手机.。

    选中一个设备进行连接。

    如果这里不输入对方设置的密码或者输入错误的密码,那么会提示“目标主动拒绝。。。”
     

    如果密码正确,则可以正常配对。
     

    从下图可以看得出已经配对成功了,

    另外,通过VS的远程放大可以捕捉到设备的屏幕,

    BlueTooth
查看全文
  • 相关阅读:
    shell test条件检查
    Mysql 创建只读账户
    cmd 批处理创建 IIS 站点
    Linux date获取时间戳
    数据结构与算法面试题80道(25)
    数据结构与算法面试题80道(24)
    数据结构与算法面试题80道(23)
    数据结构与算法面试题80道(22)
    数据结构与算法面试题80道(21)
    数据结构与算法面试题80道(20)
  • 原文地址:https://www.cnblogs.com/allen0118/p/2657327.html
  • Copyright © 2011-2022 走看看