![](/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.