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
查看全文
  • 相关阅读:
    4.关于QT中的QFile文件操作,QBuffer,Label上加入QPixmap,QByteArray和QString之间的差别,QTextStream和QDataStream的差别,QT内存映射(
    PlSql加入数据库链接
    UserScan的处理流程分析
    第八十八题(金山笔试题,字符串移动)
    4Sum_leetCode
    LeetCode Add Binary
    Hibernate or JPA Annotation中BLOB、CLOB注解写法
    配置Nginx防止直接用IP訪问Webserver
    Java集合系列之TreeMap源代码分析
    使用Application Loader上传APP流程解读[APP公布]
  • 原文地址:https://www.cnblogs.com/allen0118/p/2657327.html
  • Copyright © 2011-2022 走看看