简体   繁体   English

使用 IONIC CAPACITOR 应用程序在 BLE 设备上写入 20 字节命令

[英]Write 20 Bytes command on BLE device using IONIC CAPACITOR application

Hi there guy's i'm developing an application that connects to a BLE device.大家好,我正在开发一个连接到 BLE 设备的应用程序。 Now i need need to write theese 20 Bytes on the device using BleClient.write现在我需要使用 BleClient.write 在设备上写入 20 个字节

34h 01h 50h 4Fh 4Ch 49h 54h 45h 43h 00 00 00h 00h 00h 00h 00h 00h 00h 00h 00h

but the write function ask me DATAVIEW... how i can send theese bytes to the device?但是写入 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');

According to the documentation of the write method you can create a dataview using the numbersToDataView helper method.根据write方法的文档,您可以使用numbersToDataView辅助方法创建数据视图。 It accepts an array of numbers.它接受一个数字数组。

The usage section even includes an example which uses the helper:用法部分甚至包括一个使用助手的示例:

await BleClient.write(device.deviceId, POLAR_PMD_SERVICE, POLAR_PMD_CONTROL_POINT, numbersToDataView([1, 0]));
console.log('written [1, 0] to control point');

In your case it is probably在你的情况下可能是

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.

相关问题 无法使用UWP API将大字节数组写入BLE设备-例如,将值写入为异步 - Cannot write large byte array to a BLE device using UWP APIs - e.g. Write value as Async 对于大小为 20 的 char[],如果我将 char 从 char[0] 输入到 char[7],然后将 char[] 写入文件,它会占用磁盘上的 20 个字节还是 8 个字节? - For a char[] of size 20, if i enter char from char[0] to char[7], and i write the char[] to a file, does it take up 20 bytes or 8 bytes on the disk? 使用golang写入文件字节进行优化 - Go using for write to file bytes optimize in golang 仅使用 Java.IO 从文件读取/写入字节 - Read/Write Bytes to and From a File Using Only Java.IO 如何创建一个包含 20 个随机字节的数组? - How to create an array of 20 random bytes? 如何将字节数组发送到BLE设备 - How to send byte array to BLE device 将int值写入字节数组 - Write int value into an array of bytes 如何在Java中实现20字节的单调/顺序递增计数器 - How to implement monotonically/sequentially increasing counter of 20 bytes in Java Android 中的 BLE 设备响应:字节数组到 Kotlin 中的右浮点值 - BLE Device Response in Android: Byte Array to right Float Value in Kotlin 编写一个方法来用'%20'替换字符串中的所有空格? - Write a method to replace all spaces in a string with '%20'?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM