![](/img/trans.png)
[英]Cannot write large byte array to a BLE device using UWP APIs - e.g. Write value as Async
[英]Write 20 Bytes command on BLE device using IONIC CAPACITOR application
大家好,我正在开发一个连接到 BLE 设备的应用程序。 现在我需要使用 BleClient.write 在设备上写入 20 个字节
34h 01h 50h 4Fh 4Ch 49h 54h 45h 43h 00 00 00h 00h 00h 00h 00h 00h 00h 00h 00h
但是写入 function 问我 DATAVIEW...我如何将这些字节发送到设备?
BleClient.write(device.deviceId, '02366e80-cf3a-11e1-9ab4-0002a5d5c51b', '340a1b80-cf4b-11e1-ac36-0002a5d5c51b', '34h 01h 50h 4Fh 4Ch 49h 54h 45h 43h 00 00 00h 00h 00h 00h 00h 00h 00h 00h 00h');
根据write
方法的文档,您可以使用numbersToDataView
辅助方法创建数据视图。 它接受一个数字数组。
用法部分甚至包括一个使用助手的示例:
await BleClient.write(device.deviceId, POLAR_PMD_SERVICE, POLAR_PMD_CONTROL_POINT, numbersToDataView([1, 0]));
console.log('written [1, 0] to control point');
在你的情况下可能是
numbersToDataView([34h, 01h, 50h, 4Fh, 4Ch, 49h, 54h, 45h, 43h, 00, 00, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.