o***@lfwellness.com
o***@lfwellness.com
  • 发布:2020-02-12 19:21
  • 更新:2020-04-15 19:22
  • 阅读:2662

uni-app在app端(android)调用蓝牙写入特征值报错10013

分类:uni-app

相同代码打包小程序运行是可以写入成功的。

相关代码:

    uni.writeBLECharacteristicValue({  
        // 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取  
        deviceId:deviceId,  
        // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取  
        serviceId:serviceId,  
        // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取  
        characteristicId:characteristicId,  
        // 这里的value是ArrayBuffer类型  
        value: buffer,  
        success(res) {  
            console.log('writeBLECharacteristicValue success', res)  
        },  
        fail: function(res) {  
          // fail  
          console.log("-----writeBLECharacteristicValue--fail----------", res);  
          console.log("-----writeBLECharacteristicValue--fail------typeof deviceId----", typeof deviceId);  
          console.log("-----writeBLECharacteristicValue--fail------deviceId----", deviceId);  
          console.log("-----writeBLECharacteristicValue--fail------serviceId----", serviceId);  
          console.log("-----writeBLECharacteristicValue--fail------characteristicId----", characteristicId);  
        },  
        complete: function(res) {  
          // complete  
          console.log("-----writeBLECharacteristicValue--complete----------", res);  
        }  
    })
2020-02-12 19:21 负责人:无 分享
已邀请:
9***@qq.com

9***@qq.com

我也遇到了相同的问题。你解决了吗 求告知

l***@163.com

l***@163.com

这问题有大仙来解决吗?

l***@163.com

l***@163.com

我的问题是这样解决的,

            let deviceId = this.targetId;  
            let serviceId = this.targetServiceUuid;  
            let **charctId** =this.characteristicsData[0].uuid;// this.targetServiceCharctUuidCmd;  
            uni.writeBLECharacteristicValue({  
                // 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取  
                deviceId,  
                // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取  
                serviceId,  
                // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取  
                charctId,  
                // 这里的value是ArrayBuffer类型  
                value: buffer,  
                success(res) {  
                    console.log('writeBLECharacteristicValue success', res.errMsg)  
                },  
                fail(e) {  
                    console.log('读取设备数据值失败,错误码:' + e.errCode);  
                    if (e.errCode !== 0) {  
                        initTypes(e.errCode);  
                    }  
                }  
            })  
        },  

粗字哪里charctId 改成 characteristicId 没报10013

  • o***@lfwellness.com (作者)

    嗯嗯,这个是语法问题了,es6,“charctId, ” 等价于 “charctId:charctId,” 相当于传参错了

    2020-04-16 09:37

  • tem

    回复 o***@lfwellness.com: 大佬问题解决了吗?。。。。我也遇到同样的问题了。。

    2020-05-26 17:05

  • o***@lfwellness.com (作者)

    回复 tem:我这边后面是勾选了v3编译就可以了

    2020-06-28 21:44

该问题目前已经被锁定, 无法添加新回复