收藏
回答

发数剧的时候启用notify失败

给蓝牙设备发送数据的时候,启用notify失败

var that = this;

wx.notifyBLECharacteristicValueChange({

    state: true, // 启用 notify 功能

    // 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取

    deviceId: that.data.deviceId,

    // 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取

    serviceId: that.data.wifi_data.service.uuid,

    // 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取

    characteristicId: that.data.wifi_data.characteristic.uuid,

    success: function (res) {

        console.log('notifyBLECharacteristicValueChange success', res.errMsg)

    

    },

    complete: function (res) {

        console.log(res)

    }

})

wx.onBLECharacteristicValueChange(function (res) {

    console.log('特征值变化', res);

    const CharacteristicVal = that.buf2hex(res.value);

    if (res.characteristicId == that.data.wifi_uuid) {

        that.setData({

            device_char: CharacteristicVal

        });

    }

});

写数据是在上述两个接口执行后,间隔2s执行的,启用notify的特征值查看明确是是支持notify的,执行的时候直接是走到fail的 ,咋回事???

回答关注问题邀请回答
收藏

7 个回答

  • 阿旺
    阿旺
    2018-03-15

    同样的问题,解决了么?


    2018-03-15
    有用
    回复
  • Mr_南先生
    Mr_南先生
    2017-11-03

    对于一个设备的一个特征值 多次启用notify没影响吧???

    2017-11-03
    有用
    回复
  • Mr_南先生
    Mr_南先生
    2017-11-03

    indicate不支持的,如果成功的话监听特征值变化的接口应该会触发啊,但是并没有

    2017-11-03
    有用
    回复
  • 王翊夫if
    王翊夫if
    2017-11-03

    可以验证一下,之前遇过这种情况,其实是 notify 成功的

    2017-11-03
    有用
    回复
  • 王翊夫if
    王翊夫if
    2017-11-03

    你们的特征值是不是notify和indicate都支持?

    2017-11-03
    有用
    回复
  • Mr_南先生
    Mr_南先生
    2017-11-03

    在android手机上没有错误码,在IOS手机上看是1008 :the attribute could not be found  但是我可以确定的是

    开启notify的特征值notify:true


    2017-11-03
    有用
    回复
  • 王翊夫if
    王翊夫if
    2017-11-03

    fail 回调返回的错误码是什么呢?

    2017-11-03
    有用
    回复
登录 后发表内容