Android Question best way how to restart bluetooth connection

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear friends, I am finding solution, how to reconnect bluetooth conenction with click on button.

I have serialservice, where I am using AStream

After connecting to bt device I am trying for reconnect this:

B4X:
Sleep(1500)
serialservice.AStream.Close   
Sleep(500)           
Serial1.Connect(macadd)
serialservice.AStream.Initialize(Serial1.InputStream,  Serial1.OutputStream, "AStream")

with this this solution the connection between bt devices is OK, but the data I cant send and receive.

How can I complete restart bluetooth connection with button?Please?
Thank you

p4ppc
 

petr4ppc

Well-Known Member
Licensed User
Longtime User
Erel and dear friends,

I am finding solution, but I have solved only 50 percent of this task.

Situation:
1. I am creating simple bluetooth connection as in ADMIN example = everything is OK
2. This connection I interrupted with some way, for eexample I switch off the power of bluetooth in second device
3. If I restart the bluetooth connection from the app then I get this trouble=

I can send data from APP to second BT device, but I can not send data from BT device to APP. The APP is not starting the ASTREAM listening.
If I switch off the app and then run again, everything is OK. Only after restart I can send data but not receive...


Please how can I start or initialize listening of seriál port in the app?

Thank you very much
p4ppc
 
Upvote 0
Top