wx.getBluetoothDevices有很多手机机型获取不到设备?
发布于 4 年前 作者 juan91 2058 次浏览 来自 问答

这个是我的手机在调用方法wx.getBluetoothDevices获取蓝牙热敏打印机时得到的数据,怎么都获取不到设备,几天前还能正常获取,但是突然就变这样了,我保证我的手机是没问题的,因为我用热敏打印机提供的app,是可以正常连接到打印机打印的。

这个是我朋友调用wx.openBluetoothAdapter就直接失败了,我确保他手机蓝牙是正常开启的。

以下是我的代码:

getPrintData(){
    wx.openBluetoothAdapter({
      success(res) => {
        console.log("开启蓝牙适配器成功");
        wx.startBluetoothDevicesDiscovery({
          //services: ['xxxx'], // 用来过滤掉其他蓝牙设备
          allowDuplicatesKeyfalse,
          interval2000,
          success(res) => {
            console.log(res);
            console.log("开启蓝牙设备成功");
            setTimeout(function(){
              wx.getBluetoothDevices({
                successfunction (res{
                  console.log(res);
                  console.log("获取蓝牙设备OK");
                  wx.onBluetoothDeviceFound(({ devices }) => {
                    console.log(devices);
                    console.log("找到的设备");
                  })
                },
                fail(res) {
                  //self.blueMsg(res);
                },
              });
            },3000);
            
            wx.onBluetoothDeviceFound(({ devices }) => {
              console.log(devices);
              console.log("找到的设备");
            })
          }
        });
      },
      fail:(res)=>{
        console.log(res);
        console.log("开启蓝牙设备失败");
      }
    });
  }
1 回复

你好,麻烦在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点

回到顶部