Android Question how to disable input from Bluetooth device?

Reyes5

Member
Licensed User
Longtime User
Hello,

I have to send instructions to a microcontroller over BT.
I use AsyncStreamText and sending the instructions to the micro works fine.
However, the micro does answer.
I do NOT need the answer ...

So, I initialize the inputstream with Null, hoping that would prevent getting stuff back.
like this :
B4X:
ast.Initialize( Me, "Ast" , Null , btconn.serial1.OutputStream)
when the activity containing this ends, I get error message :
java.lang.Exception: Sub ast_Newdata was not found.

It looks like, despite the Null init, the data is still somewhere in a buffer or so.
Anybody has an idea how to prevent this ?

PS. I also did try to comment out the "CallSubDelayed" lines in asyncstreamstext class, but, no difference ...

Thanks, Paul.
 

Beja

Expert
Licensed User
Longtime User
Your app is looking for the response but you are depriving it from that ;)
Check the ast_Newdata code.. this is where you should look into.
 
Upvote 0

Reyes5

Member
Licensed User
Longtime User
Thanks Beja ! Indeed, it is in that code where I did use Null as inputstream, but that makes no difference...
 
Upvote 0

Reyes5

Member
Licensed User
Longtime User
Erel, can you please help ? Do you know a way to prevent incomming stream chunks still to be sent to the event , after the activity which initialised the asyncstreamstext has been closed ? Or another way than "null" to avoid getting incomming data from the Bluetooth?
Or how to "flush" inputstream before closing the activity ?
It would be of great help, thank you !
 
Upvote 0
Top