BLE and Classic BT working together

Dear all,
I was curious to verify whether BLE and classic BT would work in parallel on an Android device.
The answer is yes, the two (completely) different Bluetooth systems can do that.
The .aia and the two .ino here below show how an Android device (in my example a Lenovo Pad 8" with Android release 9) can connect two ESP32 boards, one with the BLE and the second with the Classic BT.
Probably nobody will never have the need to perform such a weird connection but "never say never".

The app connects the first ESP32 via BLE in UART mode to exchange characters and the second one in Classic BT, to receive a string every 500 ms, alternated with a frame counter.
Before all, the two BT's shall be both visible to the Android device, and the classic BT shall be paired with, too. To verify that all, I suggest to use the well known ready made app Serial Bluetooth Terminal (by Kay Morich), free from playstore.
Once verified that both boards are visible by / paired with, your android device, the app can then work with both.
In my example the Classic BT board has the BT nickname "ClassicBT", therefore when the listpicker of addresses and names opens, you shall select that name to allow its pairing.
While the Classic BT is then connected automatically, hit the Scan&Connect button to connect the BLE board. Its status is then shown below the Disconnect button.
The picture below shows how the screen looks like, and some details on buttons and labels. By hitting the A,B,C buttons it is produced a sending via BLE to the BLE ESP, which on its turn, sends back the character's echo to the app.

The file below contains the picture.
Image.pdf (172.0 KB)

The .ino of the two ESP32 and the app's .aia, follow:

BLE_uart.ino (4.2 KB)
ESP32_ClassicBT_AI2.ino (1.0 KB)
BLE_Test.aia (257.4 KB)

So, if you were loosing your sleeping with this doubt (can a BLE work in parallel with a Classic BT?), now you can sleep well... :rofl: :rofl: :rofl:
All the best.

crEDITs to @Taifun for his "must have" extension 'TaifunTools' that allows to make the app always stay-on-the-screen (don't go to sleep).

4 Likes

Good morning! I'm testing your app, but it's not working at the moment. We have the same UUIDs; I just had to change the Bluetooth address. I'll let you know as soon as I get it working.

Blue5.aia (281.4 KB)

my proyect

Dear @Julio_Macias,
I juat had a quick look to your project (i didn't test it, just a look) and I see one possible issue. Clock1 is already enabled at Designer level: as a general hint, this should be avoided. The clocks shall not be enabled until their use becomes effective. In your app it shall be enabled only "after" the BLE successful communication begins, otherwise it would try to work with a non operating (yet) BT comm's. And this will generate errors or weird/unwanted behavious. The same for the attribute "alwaysfires": typically you want to enable this attribute only for timers that shall run in the background, but this can lead to an obverload of multiple clock1.timer events until the rest of the code is free to accomplish the .timer event itself. For example if a long-lasting procedure is blinding the clock1.timer event, multiple ticks will happen and that can lead to variables overwriting, activities overriding...in a nutshell: it's far better to use ths feature only if you are sure of the whole code bahaviour.
Best wishes.

Another hint for communication timers: supposing that you want to update data values coming from and Arduino board every 100 milliseconds. In that case the clock used to see if new data are available shall have (at least) a 50 millisecond tick or, even better, a 20 millisecond tick. Of course if no data are available with such rate, the displayed data will not change, but on the opposite, you will be sure that, in case of new data is available, you will not miss them.

Another doubt:


By using the "OR" operator, whenever you move the slider you try to send data to BLE even if it is not connected (it is just necessary that the TextBox1.Text is empty). Probably you wanted to use the "AND" operator ?

Are you registering for strings in a slider event?

You should register only once.

They pile up.

Slider events fire like a machine gun.

1 Like

"Slider events fire like a machine gun." :rofl:
You're definitely right, but that's not me. My original app was different.
The register_for_string clock in my app fires only once after the BLE device is connected, because I had noticed that allowing a spare time between a successful connection and the register_for_string made the difference.
(Anyway I'm absolutely not a BLE guru, therefore any hint is greatly appreciated :smirk:)

Conal.aia (296.1 KB)
I've fixed everything. I'd like to hear more feedback!
This is perfectly functional; it's a shame I can't submit the complete Python project.
Now I'll see if I can mix the two Bluetooth devices like you did, Uskiara.
Where are you from?
Greetings from Spain.

1 Like

That specific OR is for when you order a print job; it won't run if the text box is empty, or if it's not connected or the text box is empty.

Hola !
Dear Julio, thanks for the feedback !
I'm from Torino (where the ATP finals have been held), so greetings from north Italy :hugs: :hugs: :hugs:

Back to the OR/AND, please be careful, because I understand what you will, but in your implementation (with the OR) you will transmit on the BLE every time that the TextBox1 is empty, "irrespective" of the status of the BLE connection that might be, on the opposite, not active (i.e. if IsDeviceConnected = FALSE your app tries to transmit anyway), and this will produce a runtime error.

Ciao, Ugo.

ps Please let me be an "old coder" (I'm 67) when the ANSI flow charts were used: your blocks can be depicted as the following:


where you can see that the transmission will be done also if the connection is FALSE....

1 Like

I've fixed the charts, now I'm going to do the other part just like yours... Don't worry, it was just to know where I was and not send messages outside of business hours

yo tengo 59 ya ¡¡ y mi experiencia es para hacer mis trabajos electricos

1 Like

So also "old people" still want to play !!! :rofl: :rofl: :rofl:
And I will not feel "completely" old until I'm able to drive my motocross bike... :muscle: :muscle: :muscle:
Buenas tardes.