ESP32 to App Developer by Bluetooth with BT ID

Post here to discuss any new features, components, chips, etc, that you would like to see in Flowcode.
Post Reply
stefan.erni
Valued Contributor
Posts: 758
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

ESP32 to App Developer by Bluetooth with BT ID

Post by stefan.erni »

Hi Ben

Connect an ESP32 device to App Devoper work easily and reliably.

Unfortunately, it is not yet possible to connect to a exactly specific ESP32 device with App developer.
But with add two commands this should work simply.

ESP32:
Would it be possible to add another command for the ESP32 Blutooth component. Reading the Bluetooh ID as described in the link. No matter as a string with or without a colon. Even just a C code would be good


https://docs.espressif.com/projects/esp ... evice.html
Snag_7fc0b6.png
Snag_7fc0b6.png (27.87 KiB) Viewed 1515 times


App Developer:
In the App there is the component comport with the command for ScanForDeviceID. This command is very helpfull if you scan for a bluetooth from ESP32 or from Microchip or for a FDTI chip.
But you can't decide between two ESP32 Bluetooth devices.
This is not practical, especially when using two ESP32 devices, one for the left, one for the right or something similar.
Or to be sure that you connect to the right module.
Actually, only the command in the App developer is necessary, but with the ESP32 BT Command you could show the ID on the display or use the BT Id to generate the BT device Name (This command already exists).
i can just add a part from the ID to the name , for example, the last four characters of the BT ID.
From the name "FC10_IMU-tis1" then becomes new "FC10_IMU-tis1-CC6E"

Would it be possible you add a scan for a specific Bluetooth ID to connect to the comport ?

regards

Stefan

BT-ID_2023-01-24_15-05-19.jpg
BT-ID_2023-01-24_15-05-19.jpg (33.39 KiB) Viewed 1515 times
Attachments
BT_Name_2023-01-24_14-21-35.jpg
BT_Name_2023-01-24_14-21-35.jpg (32.16 KiB) Viewed 1515 times

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Flowcode v10 Re: ESP32 to App Developer by Bluetooth with BT ID

Post by stefan.erni »

Hi Ben

With a microchip Bt Modul it's the same problem.

The following problem is probably caused by windows.
I make a bluetooth connection to my own device (programmed with flowcode) on a computer in the lab. Connecting to a comport for example comport4 works and everything works perfectly with the FC10 App.

But then my device is not in the lab for a while and the next time im starting the device,
Windows then assigns com3 or com7 to my device. Depending on whether a USB stick or something else like a card reader is (or was) plugged in. Of course then my device doesn't work anymore.

I also have an Android App for my devices. I can simply save the address of the device and the App always finds the right device.

Is there a way to do something similar with the App Developer?

regards

Stefan

Steve-Matrix
Matrix Staff
Posts: 1252
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: ESP32 to App Developer by Bluetooth with BT ID

Post by Steve-Matrix »

Hi Stefan,

Ben and I have been discussing this and there are issues to solving your problem. One is that the low-level routines we have work with serial ports and are not specific to Bluetooth. This means we don't have direct access to information like the Bluetooth ID.

See here for an earlier discussion: viewtopic.php?p=2914#p2914

Are you able to modify the device description of the modules at all - i.e. the description that is shown in COM Port dropdown list. I suspect this is impossible and will remain something like "Standard Serial over Bluetooth Link" for all devices.

There are a few other solutions to consider. Is it practical for your App to have an interface to allow the modules to be "swapped" easily? Or perhaps if you are in control of the firmware in the modules you can include something in the communication protocol that allows you to differentiate between the modules.

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 to App Developer by Bluetooth with BT ID

Post by stefan.erni »

Hi Steve, Hi Ben


I thought you could just scan the Association endpoint ID instead of the hardware ID with a command.
but it's not as easy as I thought it would be
Snag_40ce45.png
Snag_40ce45.png (51.32 KiB) Viewed 1414 times
Yes I remember the old post...

The Comport from different USB ports or BT devices can be easily detected by FC10.
It also selects the correct com port and does not use the unusable second comport, from the SPP connection.
That is already super good.

Unfortunately, you can't search for two identical modules, it always finds only the first one, for example just from first Microchip BT Modul,
but there is no information about the second Microchip BT Modul comport number.
I have now connected the second sensor to the another device with the first sensor using a cable, so I only read the data via one BT connection.
This also works and perhaps causes fewer problems than two BT modules.


regards

Stefan


Here the list of comport:
Snag_3e94ff.png
Snag_3e94ff.png (11.99 KiB) Viewed 1414 times
and the correct dedection from FC10
Snag_3e6bdb.png
Snag_3e6bdb.png (89.82 KiB) Viewed 1414 times
Attachments
FC10_App_Scan_ID.fcsx
(29.58 KiB) Downloaded 45 times

Steve-Matrix
Matrix Staff
Posts: 1252
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: ESP32 to App Developer by Bluetooth with BT ID

Post by Steve-Matrix »

Thanks, Stefan.

I am going to see if the detection can search and return other instances and not just the first one. I will also try to investigate if there is any other information we can retrieve to differentiate between identical modules.

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 to App Developer by Bluetooth with BT ID

Post by stefan.erni »

Hi Steve

It has worked well when there is only one module, but certainly I would like to search via the BT address if possible.

Another small experience with Bluetooth
In my program I add a switch to open the comport from a Bt modul (Microchip RN4677)
If I use ClosePort and then OpenPort I can press the switch 100times no problem.

But if remove the ClosePort and just open the port twice ( i mean open an open port) something crash very bad.
I have to remove the BT device and sometimes also restart the computer.

So before i open a port with bluetooth i always close the port first.

regards

Stefan

I suspect: Better close the port before opening it
Snag_62722.png
Snag_62722.png (26.94 KiB) Viewed 1350 times

Steve-Matrix
Matrix Staff
Posts: 1252
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: ESP32 to App Developer by Bluetooth with BT ID

Post by Steve-Matrix »

Thanks for the info, Stefan. Sounds like the "OpenPort" should first check to see if it's open and prevent opening a second time (or close the port first before reopening). It might be an idea for us to add that to the component code.

I have also made a new DLL that Ben is now checking. This might allow BT address searching as well as retrieving multiple instances of identical modules.

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 to App Developer by Bluetooth with BT ID

Post by stefan.erni »

Hi Steve


Thanks a lot.

One more question.

From the bluetooth device I always get an array with 8 integer, i.e. 16byte data.
This works very well and quickly and the display in the app seems to be real time.
But once I also get the filename with 12char as a string, i.e. 12byte.

How can I separate the received data?
Can I somehow read how much data is in the buffer before I read as array or string?


regards

Stefan


Snag_41a9ff.png
Snag_41a9ff.png (10.86 KiB) Viewed 1342 times
Snag_4a1370.png
Snag_4a1370.png (30.59 KiB) Viewed 1342 times
Snag_4d5d4c.png
Snag_4d5d4c.png (51.33 KiB) Viewed 1342 times

Steve-Matrix
Matrix Staff
Posts: 1252
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: ESP32 to App Developer by Bluetooth with BT ID

Post by Steve-Matrix »

I'm not sure. Ben should have a better idea on that.

Post Reply