connected = SerialBT.connect(address) return value

sporked
Posts: 5
Joined: Fri May 08, 2020 6:30 am

connected = SerialBT.connect(address) return value

Postby sporked » Mon May 18, 2020 2:04 am

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.

romeo987
Posts: 4
Joined: Wed May 13, 2020 3:31 am

Re: connected = SerialBT.connect(address) return value

Postby romeo987 » Mon May 18, 2020 6:38 am

i asked almost exactly the same question a few days ago. Still no suggestions
:(
romeo

romeo987
Posts: 4
Joined: Wed May 13, 2020 3:31 am

Re: connected = SerialBT.connect(address) return value

Postby romeo987 » Mon May 18, 2020 6:55 am

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

sporked
Posts: 5
Joined: Fri May 08, 2020 6:30 am

Re: connected = SerialBT.connect(address) return value

Postby sporked » Mon May 18, 2020 7:47 am

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!

TomasCZ
Posts: 39
Joined: Tue Apr 25, 2023 5:19 am

Re: connected = SerialBT.connect(address) return value

Postby TomasCZ » Mon May 01, 2023 4:30 pm

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.

Who is online

Users browsing this forum: Google [Bot] and 73 guests