Convert byte array to int and float #207
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
React native has a limitation on what data can be transferred between Javascript and native bridge. The connection defaults to string, so you're always going to need to keep this in mind. Rfcomm is good On read the byte array is being converted to a string with this
So on the Javascript side you need to reverse this into a byte array and then I to the ints and floats based on the communication protocol. If you need, you can always write a custom connection that performs the conversion on Java and then send ints and floats to Javascript as strings to just parse. Dealers Choice. |
Beta Was this translation helpful? Give feedback.
-
It looks like the protocol is 5 bytes Byte 1 is the type There is no delimiation in the default logic so let's assume that each message is a byte. So OnRead I'll give you a base64 string Assuming you're doing the receiving. |
Beta Was this translation helpful? Give feedback.
-
Solid. If you want to add to the documentation site I'll accept a pr. |
Beta Was this translation helpful? Give feedback.
React native has a limitation on what data can be transferred between Javascript and native bridge. The connection defaults to string, so you're always going to need to keep this in mind.
Rfcomm is good
Delimiter does nothing
Charset does nothing
All due to binary using byte array connection
On read the byte array is being converted to a string with this
So on the Javascript side you need to reverse this into a byte array and then I to the ints and floats based on the communication protocol.
If you need, you can always write a custom connection that performs the conversion on Java and then send ints and floats to Javascript as strings to just p…