Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to 2 or multiple BT serial devices #5447

Closed
emard opened this issue Jul 24, 2021 · 13 comments
Closed

Connecting to 2 or multiple BT serial devices #5447

emard opened this issue Jul 24, 2021 · 13 comments
Labels
Area: BT&Wifi BT & Wifi related issues Resolution: Expired More info wasn't provided

Comments

@emard
Copy link

emard commented Jul 24, 2021

I'd like to connect and communicate at the same
time with 2 different bluetooth devices
each device is providing a single serial port.

Is there some code example how to do it
with BluetoothSerial?

@stale
Copy link

stale bot commented Oct 2, 2021

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Oct 2, 2021
@emard
Copy link
Author

emard commented Oct 2, 2021 via email

@stale
Copy link

stale bot commented Oct 2, 2021

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Oct 2, 2021
@digamesystems
Copy link

Hi. Anyone have any thoughts on this issue?

Connecting to one device works great, but I'd also like to make multiple Bluetooth classic connections to devices so I can aggregate some sensor readings.

If I simply copy the example code for a single connection and create multiple bluetooth connections, I get an indication that connecting to each of them has succeeded, but when data is received, it is only coming from the last bluetooth device I connected to.

I'm running my app within the Arduino IDE using the .available() function.

 if (btUART2.available()) {
    processMessage(btUART2, 1); 
  }

  if (btUART1.available()) {
    processMessage(btUART1, 0); 
  } 

Here I only see .available() returning true for btUART2 -- the last bluetooth UART I connected to. If I reverse the order of the .connect call, I only see data from btUART1.

Any help would be appreciated. Thanks!

@khaled147
Copy link

I haven't tested connecting multiple BLE devices simultaneously but I was able to pull data from different sensors by cycling between disconnecting and connecting to the address of the device I want to connect to. Maybe consider that if it works.

@digamesystems
Copy link

digamesystems commented Jan 20, 2022

I haven't tested connecting multiple BLE devices simultaneously but I was able to pull data from different sensors by cycling between disconnecting and connecting to the address of the device I want to connect to. Maybe consider that if it works.

Thanks for the suggestion @khaled147! I can get that to work as well but I'd like it if the sensors could just send me data asynchronously without my having to poll them. Having the .available() function is really nice for situations where a sensor wakes up and transmits only when it has something to say...

@VojtechBartoska VojtechBartoska added the Area: BT&Wifi BT & Wifi related issues label Apr 7, 2022
@VojtechBartoska
Copy link
Contributor

Hello, are you able to test your issue on development version 2.0.3-RC1 to check if this is still valid?

Take a look on Docs where is explained how to choose development release version in Arduino IDE.

@VojtechBartoska VojtechBartoska added the Resolution: Awaiting response Waiting for response of author label Apr 7, 2022
@digamesystems
Copy link

Hello, are you able to test your issue on development version 2.0.3-RC1 to check if this is still valid? ...

Thanks, @VojtechBartoska . I'll give it a try once my current release is out.

I read through the release notes for 2.0.3-RC1 and didn't see anything directly related to the Bluetooth Serial library except for this issue: #6109

This only seems to be getting rid of a compiler warning...

Am I missing something? -- Thanks again for the suggestion!

@VojtechBartoska
Copy link
Contributor

VojtechBartoska commented Apr 8, 2022

There have been some changes in ESP-IDF itself which can have an influence on this and also from the issue description I wasn't sure on which version you are running your code so it's reasonable to test it on v2.0.3-RC1 to have actual results.

@digamesystems
Copy link

Thanks, @VojtechBartoska.

I'll give it a try as soon as I get my release out the door.

I’ll also dig into the source for the BluetoothSerial library and see how it’s structured. I suspect there might be a single, global pointer that’s being used to reference the port. This would explain the behavior I'm seeing where the last port to be declared is the one that gets the callbacks. --

Thinking about it, it might just be an architectural issue, where sharing of the Bluetooth hardware resource isn't supported. After all, I don't think you can create multiple, independent instances of Serial with their own callbacks.

@VojtechBartoska VojtechBartoska added the Status: Needs investigation We need to do some research before taking next steps on this issue label Apr 22, 2022
@VojtechBartoska
Copy link
Contributor

2.0.3 stable is out, any chance you gave it a shot?

@VojtechBartoska
Copy link
Contributor

@digamesystems Any news?

@VojtechBartoska
Copy link
Contributor

Closing this issue as expired due to no answer, if needed you can reopen it.

@VojtechBartoska VojtechBartoska closed this as not planned Won't fix, can't repro, duplicate, stale Aug 23, 2022
Repository owner moved this from Todo to Done in Arduino ESP32 Core Project Roadmap Aug 23, 2022
@VojtechBartoska VojtechBartoska added Resolution: Expired More info wasn't provided and removed Resolution: Awaiting response Waiting for response of author Status: Needs investigation We need to do some research before taking next steps on this issue labels Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BT&Wifi BT & Wifi related issues Resolution: Expired More info wasn't provided
Projects
None yet
Development

No branches or pull requests

4 participants