Home > Mobile >  Write 20 Bytes command on BLE device using IONIC CAPACITOR application
Write 20 Bytes command on BLE device using IONIC CAPACITOR application

Time:10-06

Hi there guy's i'm developing an application that connects to a BLE device. Now i need need to write theese 20 Bytes on the device using BleClient.write

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?

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');

CodePudding user response:

According to the documentation of the write method you can create a dataview using the numbersToDataView helper method. 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])
  • Related