收藏
回答

wx.onBLECharacteristicValueChange()ios能回调,安卓接收不到?

ios、安卓都能发送数据,但是只有ios能接收到回传的数据

尝试了其他解决方法,设置MTU,设置延时都不行

js代码如下

const mtu = 512;
wx.setBLEMTU({
        deviceId: that.data.connectedDeviceId,
        mtu,
        success:(res)=>{
          console.log("setBLEMTU success>>", res)
        },
        fail:(res)=>{
          console.log("setBLEMTU fail>>", res)
        }
      })
wx.writeBLECharacteristicValue({
        deviceId: that.data.connectedDeviceId,
        serviceId: that.data.services[0].uuid,
        characteristicId: that.data.characteristics[0].uuid,
        value: buffer,
        successfunction (res{
          console.log('发送成功')
          wx.showToast({
            title'wifi id 发送成功',
          })
          setTimeout(function () {}, 1000); // 1秒延时
          wx.notifyBLECharacteristicValueChange({
            statetrue,
            deviceId: that.data.connectedDeviceId,
            serviceId: that.data.services[0].uuid,
            characteristicId: that.data.characteristics[0].uuid,
            successfunction (res{
              console.log('启用notify成功')
              wx.onBLECharacteristicValueChange(function (res{
                var receiveText = app.buf2string(res.value)
                console.log('接收到数据:' + receiveText)
                that.setData({
                  receiveText: receiveText
                })
              })
            }
          })
        }
      })
回答关注问题邀请回答
收藏

1 个回答

  • Demons
    Demons
    2023-09-28

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

    2023-09-28
    有用
    回复 4
    • 王同學
      王同學
      2023-12-19
      一样的问题   微信号 xingxingyatou01 时间 23/12/19 12:05 日志上传了
      2023-12-19
      回复
    • A-
      A-
      01-09
      一样的问题 微信号Liu-18831892965 时间 2024/1/9 9:40日志上传
      01-09
      回复
    • momo
      momo
      01-12
      一样的问题 微信号doiok278 时间 2024/1/12 9:48日志上传
      01-12
      回复
    • Rowling
      Rowling
      02-29
      一样的问题 微信号Rowling06时间 24/02/29 15:21 日志上传了
      02-29
      回复
登录 后发表内容