ESP32 with ESP-IDF Classic Bluetooth - Mobile Phone - Serial Communication

Edgar1
Posts: 2
Joined: Fri Oct 11, 2019 7:53 am

ESP32 with ESP-IDF Classic Bluetooth - Mobile Phone - Serial Communication

Postby Edgar1 » Fri Oct 11, 2019 8:20 am

I was looking for sample code to create a simple application for serial communication between the ESP32 and a mobile phone.
It took a long time before I figured out how things work.

Here is some information - for a start without code.

I looked at the

ESP-IDF BT-SPP-ACCEPTOR demo
https://github.com/espressif/esp-idf/tr ... p_acceptor

ESP-IDF BT-SPP-INITATOR demo
https://github.com/espressif/esp-idf/tr ... _initiator

and first I could not figure out which I should use to connect my mobile phone (Android) to an ESP32
After some time I figured out that I can connect from my phone to the Acceptor demo.
I have to pair my phone with the ESP_SPP_ACCEPTOR
After that is done I can open a terminal application on the mobile phone (i.e. Serial Bluetooth) and I can send data from my phone to the ESP32.
If the Acceptor is opened with a monitor program I can see that what I send on the phone is received by the ESP32. It is shown in HEX format.
That works with the Acceptor demo without any changes. It's only necessary to set the following to see the received data.

Code: Select all

#define SPP_SHOW_MODE SPP_SHOW_DATA
With that the communication from the phone to the ESP32 worked. But I also want that data is send from the ESP to the mobile phone.
To be able to do that I analyzed how the communication is established and the code for sending and receiving data in the Acceptor and Initiator.
Then I copied the sending code from the Initiator to the Acceptor and the receiving code from the Acceptor to the Initiator.
Now finally that works. I can send and receive data in the Initiator and the Acceptor.

Currently the code which I worked on has lots of additional comment - which I added for my own understanding.
If anybody is interested I can publish that code here.
But maybe it would be better if I do that at GitHub. I have to admit I don't have much experience with them.

Now that this works in principle with the modified Initiator and Acceptor code my next step will be that I will work on the communication between my mobile phone and a modified version of the Acceptor.

Please let me know if you are interested in further info and which info.

entropio
Posts: 1
Joined: Tue Nov 05, 2019 2:39 pm

Re: ESP32 with ESP-IDF Classic Bluetooth - Mobile Phone - Serial Communication

Postby entropio » Thu Nov 07, 2019 8:43 pm

You could put the code here in the forum to get out of my doubts I am trying the same as you but apart I must send the data by the uart :D

Edgar1
Posts: 2
Joined: Fri Oct 11, 2019 7:53 am

Re: ESP32 with ESP-IDF Classic Bluetooth - Mobile Phone - Serial Communication

Postby Edgar1 » Fri Nov 08, 2019 1:48 am

Ok, I will do that. But currently I am a little sick so maybe next week.

Who is online

Users browsing this forum: No registered users and 1 guest