native-docs icon indicating copy to clipboard operation
native-docs copied to clipboard

安卓获取蓝牙的特征属性不正确

Open boronlin opened this issue 5 years ago • 3 comments

问题描述 [问题描述:尽可能简洁清晰地把问题描述清楚] 我们自己开发蓝牙,其中一个特征属性为write为true, 在ios里获取是正确的,但在安卓里为false, 当写入是,如果使用 uni.writeBLECharacteristicValue写入就会提示"该特征属性不可写入",如果把 uni改成plus.bluetooth, 又可以正常写入。

复现步骤 [复现问题的步骤] 使用当前项目源码

预期结果 读取特征属性在安卓和iOS是一至的,都是为true

实际结果 读取特征属性在安卓和iOS是一至的,都是为true

系统信息:

  • 操作系统 [任间 Android 版本]
  • HBuilderX版本 [HBuilderX为最新的 2.5.1 ]
  • uni-app版本 [当前最新的git库直接克隆]
  • 设备信息 [所有iPhone版本]

boronlin avatar Feb 20 '20 06:02 boronlin

请提供一个简单示例工程

hdx-w avatar Feb 20 '20 12:02 hdx-w

		//获取某个服务下的所有特征值
		getBLECharacteristics() {
			let deviceId = this.equipment[0].deviceId;
			let serviceId = this.servicesData[0].uuid;
			console.log(deviceId);
			console.log(serviceId);
			plus.bluetooth.getBLEDeviceCharacteristics({
				deviceId, // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
				serviceId, // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
				success: res => {
					console.log('获取特征值成功:' + JSON.stringify(res));
					this.valueChangeData = {};
					this.showMaskType = 'characteristics';
					this.Ssz = res.characteristics;
					if (this.Ssz.length <= 0) {
						toast('获取特征值失败,请重试!');
						return;
					}
					this.maskShow = true;
				},
				fail: e => {
					console.log('获取特征值失败:' + JSON.stringify(e));
				}
			});
		},
bl

boronlin avatar Feb 21 '20 05:02 boronlin

代码是是当前 dcloudio/uni-app 直接Clone出来的,所以这个问题可能是内部模块问题。 bl

boronlin avatar Feb 21 '20 05:02 boronlin