使用plus.bluetooth.readBLECharacteristicValue时,报错: {"code":10007,"message":"property not support"}
我再原生测试了特征值都正常获取到数据,但在H5+就报错了,在H5+能够启动notify功能,但使用readBLECharacteristicValue就报错{"code":10007,"message":"property not support"},根本不知道问题出在哪?
下面是我的代码:
// 启用低功耗蓝牙设备特征值变化时的notify功能
function startCharacteristicsNotify(deviceId){
var serviceId=$("#serviceList").val();
var characteristicId=$("#characteristicList").val();
// 监听低功耗蓝牙设备的特征值变化
plus.bluetooth.onBLECharacteristicValueChange(function(e){
if(characteristicId == e.characteristicId){
var value =JSON.stringify(e.value);//这里返回的value也是空的“{}”
// 读取低功耗蓝牙设备的特征值
plus.bluetooth.readBLECharacteristicValue({
deviceId:deviceId,
serviceId:serviceId,
characteristicId:characteristicId,
success:function(e){
mui.hideLoading();
console.log('read characteristics success: '+JSON.stringify(e));
$("#textarea").val(JSON.stringify(e));
},
fail:function(e){
mui.hideLoading();
console.log('read characteristics failed: '+JSON.stringify(e));
$("#textarea").val(JSON.stringify(e));
}
});
}
});
// 启用notify功能
plus.bluetooth.notifyBLECharacteristicValueChange({
deviceId:deviceId,
serviceId:serviceId,
characteristicId:characteristicId,
success:function(e){
var characteristics = e.characteristics;
console.log(JSON.stringify(characteristics));
$("#textnotify").val(JSON.stringify(e));
if(characteristics!=undefined){
//console.log('get characteristics success: '+characteristics.length);
for(var i in characteristics){
console.log(i+': '+JSON.stringify(characteristics[i]));
}
}
},
fail:function(e){
console.log('get characteristics failed: '+JSON.stringify(e));
$("#textnotify").val(JSON.stringify(e));
}
});
}
能够正常启动notify功能,在读取低功耗蓝牙设备的特征值的时候就报错了: {"code":10007,"message":"property not support"}
1***@qq.com
你这个问题解决了吗 我也遇到这个问题了
2021-01-21 13:39