Unable to readFromDevice, but onDeviceRead and write works #168
Replies: 9 comments 9 replies
-
Almost all the functions return promises, meaning you'll need to
ps. Documentation https://kenjdavidson.com/react-native-bluetooth-classic/react-native/rn-bluetooth-device/#read |
Beta Was this translation helpful? Give feedback.
-
A better method, which I've been attempting to push is:
|
Beta Was this translation helpful? Give feedback.
-
Hi,
the resul was not good:
I have removed and add a async function
So the issue is still there... any other suggestion? |
Beta Was this translation helpful? Give feedback.
-
Looking at your information, I can see the following:
Available says there is nothing there, so you're getting I would assume that your ESP code is not deliminating the messages with a
needs to be sent in order for it to be processed as a message. |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
I have no idea what you're doing (sorry). The code that you've posted is using the MANUAL read logic:
which should NOT be coupled with the automatic read logic:
There is nothing in the code you've posted that leads me to believe you're using the on read listener. |
Beta Was this translation helpful? Give feedback.
-
If you're doing a:
then somewhere else
Then you're:
You don't want to do this, using manual read with automatic read will do some weird stuff. |
Beta Was this translation helpful? Give feedback.
-
Ah no worries at all. and inside readMessage i'm doing the manual reading. if want use the onDeviceRead as a callback to get the data how should i do it? |
Beta Was this translation helpful? Give feedback.
-
Ya, that's not right. I would suggest following the examples on:
They are fully working, they are something like this:
which should get you started. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have a quick question that probalby is a easy fix.
I was able to send a discover, connect and write with RNBluetoothClassic. However, I'm stuck with the read. I'm quite new to react native, so maybe it's just that i don't know how to print the return String (hopefully)
I will put the more intestersting code:
It doesn't work readFromDevice and availableFromDevice but readMessage is called. If i print directly the variable, it says is an object, if i try with stringify it prints:
I will really appreciate any suggestion :)
I couldn't find any example how to use that functions.
Note:anyway I really appreciate your work !
Beta Was this translation helpful? Give feedback.
All reactions