ESP32 add more commands for Bluetooth

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

ESP32 add more commands for Bluetooth

Post by stefan.erni »

Hi Ben

Is it possible to add for the Bluetooth from the ESP32 some more commands also like the UART or App Developper comport already have it?

This both makes it easier for me:

SendINTArray and ReceiveINTArray
SendBinary32 and ReceiveBinary32

regards

Stefan
array_2022-03-24_14-01-46.jpg
array_2022-03-24_14-01-46.jpg (82.27 KiB) Viewed 2487 times

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: ESP32 add more commands for Bluetooth

Post by BenR »

Hi Stefan,

Ok I'll get those on the list for you.

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

Re: ESP32 add more commands for Bluetooth

Post by stefan.erni »

Hi Ben

On various projects I have to use 24Bit data. This is not supportet in FC but 32Bit is very well supported. So I will use 32bit instead of 24bit

But not yet the 32-bit (Long) data transmission as Array in AppDeveloper comport, ESP32-Uart and ESP32-BT
Would it be possible to add this command as well:

ReceiveLongArray and SendLongArray

Maybe it would be possible to add this command for the ESP32-BT so the commands are the same.

ReceiveByteArray and SendByteArray
ReceiveIntArray and SendIntArray

The ESP SendArray already exists, you could leave it there so that old programs still work, but you know better than me how to do it.

regards

Stefan

overview commands
commands_2022-09-21_15-06-10.jpg
commands_2022-09-21_15-06-10.jpg (89.7 KiB) Viewed 1949 times

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

Re: ESP32 add more commands for Bluetooth

Post by stefan.erni »

Hi Ben

Would it be possible already add for ESP32 Bluetooth

ReceiveIntArray and SendIntArray

regards

Stefan

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: ESP32 add more commands for Bluetooth

Post by BenR »

Hello,

I've looked at this before and it's tricky to do it well. I'll look again. Basically the esp32 does the queuing for you but expects a char array (shakes fist at strict compiler) and conversion requires an intermediate buffer which has to be of a big enough size to cope with anything a user might throw at it. Any fixed size I make it will probably be both needlessly big and too small. Or we do things piecemeal byte by byte to avoid the buffer but this incurs delays and or missed bytes. Hmm. I'll try again a nice solution may present itself and I do have an idea which is a halfway house. Piecemeal using a reasonable sized buffer.

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

Re: ESP32 add more commands for Bluetooth

Post by stefan.erni »

Hi Ben

I mean these are just suggestions....

There is still a small improvements possible.
To write data to an SD disc relatively quickly, you can fill the buffer and write all at once. But buffer is only possible to fill per byte.
Couldn't this buffer also be filled with an integer? 256 integer will fill 512Byte.....

Could I make the USB/Bluetooth transmit aaray (buffer) to 256x integer and then write it to the sd card right away?

The other little problem.... I need to filter all integers with the DSP component.
I don't know yet whether in the ESP32 program or in the FC9 App or in both. In an array there will be 9 axes per sensor and there will be two sensors.
So 18 integers every 100Hz

All go through a DSP filter but not to the same filter. Once Kalmann, once low pass, possibly also a high pass

There could also be a DSP Component "IMU" where I read in all 9 axes and the DSP Component "IMU" gives me the roll pitch and yaw filtered......

(in the future)

regards

Stefan

SD Card
File_Buffer.JPG
File_Buffer.JPG (42.95 KiB) Viewed 1667 times

mnfisher
Valued Contributor
Posts: 938
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 502 times

Re: ESP32 add more commands for Bluetooth

Post by mnfisher »

For the int to char array in BT - can you just use a cast on the passed array?

Martin

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

Re: ESP32 add more commands for Bluetooth

Post by stefan.erni »

Hi Martin

Yes that would be a possibility. At the moment I'm still using the USB. Maybe Ben will still add this to BT.
For file write/read I'm trying to use the app developer with built-in function File to write array and read it again as a simulationdata.
So I will create a movement file and read it again.
I chose the name "IMU.FMV".
Flowcode MoVment file

Also the 18 DSP filters with input output are much easier to create than I thought.

regards

Stefan

built-in function File in FC AppDevelopper
Snag_288b16.png
Snag_288b16.png (25.24 KiB) Viewed 1650 times

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

Re: ESP32 add more commands for Bluetooth

Post by stefan.erni »

Hi Ben

The use of ESP32 Bluetooth together with the APP developer is very easy, fast and a stable connection.
But two tiny wishes. With the ESP32 the sending (perhaps also receiving) of INTArray and with the App Developer a command like checkConnectionStatus.
Would this be possible to add?

regards

Stefan

Compare both commands ESP32 BT and APP developer comport:
Check_and_IntArray_2023-01-18_14-50-42.jpg
Check_and_IntArray_2023-01-18_14-50-42.jpg (70.7 KiB) Viewed 1453 times

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: ESP32 add more commands for Bluetooth

Post by BenR »

Hello,

Sorry I know this one has been on the request list for a while. I've added the INT array functions for you now and am interested as to how you get on with them.

As for the check connection status function this is tricky, I don't think Windows itself manages this one very well but I could be wrong. The way I do it is I put a simple comms check into the firmware, so for example the App sends out a specific combination of bytes, the embedded side checks for this and replies. If the reply doesn't come then the comms channel is assumed dead, the COM port is closed and the app stopped with an error message.

Post Reply