Page 1 of 1
connected = SerialBT.connect(address) return value
Posted: Mon May 18, 2020 2:04 am
by sporked
I'm calling SerialBT.connect(address) to connect to an HC-05 module by address (Bluetooth classic). It's working fine, but it always returns TRUE regardless of whether it successfully connected or not. I can also call connected() and get the same results. I can't find any way to determine whether I actually have a bluetooth connection. Any tips would be greatly appreciated.
Re: connected = SerialBT.connect(address) return value
Posted: Mon May 18, 2020 6:38 am
by romeo987
i asked almost exactly the same question a few days ago. Still no suggestions
romeo
Re: connected = SerialBT.connect(address) return value
Posted: Mon May 18, 2020 6:55 am
by romeo987
So I tried a function call
if(SerialBT.hasClient())...
and that seems to do exactly what I am looking for. LED comes on when I connect the android, and goes off when I disconnect.
Hope this helps.
Sadly, i don't seem to be able to find any documentation that describes what these functions do.
romeo
Re: connected = SerialBT.connect(address) return value
Posted: Mon May 18, 2020 7:47 am
by sporked
Thanks! It looks like that should do what I'm looking for. Using that as a Google search term I found this...
http://chiselapp.com/user/jschimpf/repo ... P32Lib.pdf
I haven't looked at it closely, but this might give us some more insight to the library.
Thanks again!
Re: connected = SerialBT.connect(address) return value
Posted: Mon May 01, 2023 4:30 pm
by TomasCZ
Hello guys, pls, did this really worked for you ? I tested that connected = SerialBT.connect(address); returns the true value only when it is first connected in my case at least.
When the Master lost the connection I was able to catch this with if (event == ESP_SPP_CLOSE_EVT) and reconnect the the connection.
The reconnected worked OK but the connected = SerialBT.connect(address); returned false for the next attempts.
The same result was with the if(SerialBT.hasClient()). The first attempt worked OK and the connection was recognized but next attempts didn't work. They returned false even if the connection was established and I was able to send/receive messages via serial monitor.