使用Web蓝牙API将495字节数组的长度写入设备

问题描述

我正在调用python api端点,该端点向我发送要写入设备的数据。接收到的数据是加密格式,我正在使用下面的方法将其转换为字节数组

 let codePoints = [];

 for (let i = 0; i < encData.length; i++) {
   codePoints.push(encData.codePointAt(i));
 }

 const arraybufferdata = Uint8Array.from(codePoints);

我正在尝试使用以下代码编写此字节数组:

characteristic
.writeValueWithoutResponse(arraybufferdata)
.then(() => {
  console.log("successfully written to the device");
});

我收到以下错误

enter image description here

我还尝试通过如下方式将字节数组分成多个块来进行编写:

writeOut(data,start) {
 if (start >= data.byteLength) {
   console.log("successfully written to the device");
   return;
 }

this.mychar
  .writeValueWithoutResponse(data.slice(start,start + 256))
  .then(() => {
     this.writeOut(data,start + 256);
   });
}

writeBuffer(data,start) {
   this.writeOut(data,start);
}

this.writeBuffer(arraybufferdata,0);

这也引发错误。可能是什么问题?设备也不接受要写入的数据。

UI框架:Angular 7 作业系统:Windows 10 浏览器:Chrome 85

请帮助!

解决方法

发现了问题:

我写的是错误的特征! (facepalm)

现在正在工作!

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...