HarmonyOS 鸿蒙Next BLE蓝牙写特征值出现{"code":-3,"message":"Inner error."该如何处理?
HarmonyOS 鸿蒙Next BLE蓝牙写特征值出现{“code”:-3,“message”:"Inner error."该如何处理?
writeCharacteristicValue failed{“code”:-3,“message”:“Inner error.”}
代码如下,已知Characteristic是可写的
this.gattClientDevice.writeCharacteristicValue(cha,ble.GattWriteType.WRITE, (code:BusinessError) => {
if (code != null) {
console.info(`BLE writeCharacteristicValue failed${JSON.stringify(code)}`);
return;
}
console.info('BLE writeCharacteristicValue success - writeWithResponseWithNeedAuth');
})
catch (err) {
console.info(`BLE writeCharacteristicValue failed catch ${JSON.stringify(err)}`);
}
更多关于HarmonyOS 鸿蒙Next BLE蓝牙写特征值出现{"code":-3,"message":"Inner error."该如何处理?的实战教程也可以访问 https://www.itying.com/category-93-b0.html
3 回复
# GattWriteType
枚举,表示gatt写入类型。
**元服务API**:从API version 12开始,该接口支持在元服务中使用。
**系统能力**:SystemCapability.Communication.Bluetooth.Core。
| 名称 | 值 | 说明 |
|-----------------------|-----------------|--------------------------------------|
| WRITE | 1 | 表示写入特征值,需要对端设备的回复。 |
| WRITE_NO_RESPONSE | 2 | 表示写入特征值,不需要对端设备的回复。|
【WRITE】需要对端回复;
用【WRITE_NO_RESPONSE】也报错吗?
更多关于HarmonyOS 鸿蒙Next BLE蓝牙写特征值出现{"code":-3,"message":"Inner error."该如何处理?的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
我们的这个特征值支持写入并需要设备端回复,因此使用的是WRITE。使用WRITE_NO_RESPONSE是没报错,