蓝牙写入数据一次不能超过20位
发布于 6 年前 作者 weihao 4439 次浏览 来自 问答

代码如下: 

write: function () {

    var that = this;

    // 向蓝牙设备发送25位

    var buffer = new ArrayBuffer(25);

    let str = ‘fegzwYboqM4vBy3ttdzjydIbS’;

      console.log(‘bt_key:’ + that.data.bt_key)

      buffer = that.s2ab(str);

    wx.writeBLECharacteristicValue({

      deviceId: that.data.devices_id,

      serviceId: that.data.service_uuid,

      characteristicId: that.data.character_w_uuid,

      value: buffer,

      success: function (res) {

        console.log(res.errMsg)

      },

      fail: function (res) {

        console.log(res.errMsg + res.errCode)

      }

    })

  },

通过蓝牙透传模块测试获取到的数据只有前20 位,发低于或等于20位的数据都能成功完全写入,但20位后剩下的部分会不见了。

回到顶部