react-native-bluetooth-classic icon indicating copy to clipboard operation
react-native-bluetooth-classic copied to clipboard

The Format of Received Data is unusual?

Open e-taha opened this issue 2 years ago • 2 comments

Hello. Firstly, thank you for this library. I wanted to read and write hex data with an app using Modbus RTU. I could write data without any problem, but I couldn't read data on my device. When I changed the connection type to binary, I began to receive data, but I couldn't figure out what format it is.

The data that should be read in hex format is this:

  • 0F 04 00 00 00 37 B0 F2

I receive this:

  • DwQAAAA3sPI=
Screen Shot 2022-08-09 at 12 54 02

After that, I tried to send another data.

when I sent 00, I receive AA== 01 -> AQ== 02 -> Ag== 03 -> Aw== 04 -> BA== 05 -> BQ== 06 -> Bg== . . . 08 -> CA== . . . 0C -> DA==

It seems that after every 4 values, the first character becomes the next character in the alphabet. After 'Z', it becomes 'a'. After 'z', becomes '0'. After '9', becomes some special characters like +,- . when I sent 2 or more bytes, it becomes more complicated.

I read other issues related to reading hex data, but I couldn't figure out what should I do.

Mobile Device Environment

  • Device: Android (POCO X3 Pro)
  • OS: Android 12

Application Environment

  • React Native version: v0.68.2

e-taha avatar Aug 09 '22 10:08 e-taha

You'll need to provide some information on:

  • What connection implementation you're using
  • How you're connecting (connection options)
  • Etc.

The data transfer is always strings, this is a limitation of React Native, unless they've started being able to transfer binary data, you're going to have to manage the strings to binary conversion in either your react app, or a custom connection implementation.

There are a number of closed issues on how to do this.

kenjdavidson avatar Sep 08 '22 12:09 kenjdavidson

Any update on this?

kenjdavidson avatar Oct 11 '22 12:10 kenjdavidson