求教:wx.createBLEConnection失败后是否需要wx.closeBLEConnection?

文档和其它帖子中描述都是说这2个方法要成对出现。


createBLEConnection: function (devId){

    // 蓝牙连接设备

    console.log("连接蓝牙设备");

    var that = this;

    this.data.devId = devId;

    wx.createBLEConnection({

        // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接

        deviceId: devId,

        success: function (res) {

                                         console.log("蓝牙连接成功");

                                         that.data.connected = true;

                                     },

        fail: function (res) {

                                          that.data.connected = false;

                                          console.error("蓝牙连接出错, " + res.errMsg + ", errCode:" + res.errCode);

                                          that.closeBLEConnection(); // 蓝牙连接失败的情况下是否需要调用关闭接口?

                                          that.createBLEConnection(that.data.devId); // 重试连接

                                     }

    })

    

}


展开全部
收起
1回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
  • 一桶冰水

    13人对此回答表示赞同

    展开
    13
    1回复
    发布于 6年前

    评论(1)

    收起评论

    • Reagan 2019-02-17 12:06

      这个Tip没有说明创建连接失败后是否要关闭连接

      回复
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部