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
查看全文
  • 相关阅读:
    Java学习笔记day01
    对有序数组进行二分查找(折半查找)
    对数组进行冒泡排序
    LeetCode #344. Reverse String
    LeetCode #292. Nim Game
    LeetCode #258. Add Digits
    Android DiskLruCache完全解析,硬盘缓存的最佳方案
    Android源码解析——LruCache
    Messenger与AIDL的异同
    Android应用层View绘制流程与源码分析
  • 原文地址:https://www.cnblogs.com/allen0118/p/2657327.html
  • Copyright © 2011-2022 走看看