Answer the question
In order to leave comments, you need to log in
How to create a data package in js?
I am writing an application on react native for android, which should send data to a device with BLE, it is necessary to form a data packet in the following format:
0xA0 0x29 0x84 0x5A 0x10 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xBC 0x20
, I use the react-native-ble-plx library , there is a function writeWithResponse , which accepts data in base64 format as input. Answer the question
In order to leave comments, you need to log in
I hope you are writing on node, but there are browser polyfills accordingly.
There is such a data type (or class) called Buffer.
The string you described is bytes in hexadecimal form.
Translation to and from base 64 is also provided in the buffer functions.
Buffer.from(str, 'base64')
buff.toString('base64')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question