Need help for bluetooth low energy (on Raspberry and ESP32)
Linux - Embedded & Single-board computerThis forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Need help for bluetooth low energy (on Raspberry and ESP32)
Hi, I've got a Raspberry Pi 3 with Buster and I was trying to keep a BLE connection with my ESP32 (with the script I had before it connected just for the reading and then it disconnected) when I found this thread: https://www.linuxquestions.org/quest...ng-4175615328/.
So I ran this script:
Code:
tmux new-session -d -s ServerFault 'sudo bluetoothctl -a |& tee /run/shm/BLUETOOTH_OUTPUT'
tmux send-keys -t ServerFault -l 'pair MAC_OF_MY_ESP32'
tmux send-keys -t ServerFault Enter
but after doing so, my ESP32's BLE characteristic for getting the data I need is now empty. I can't connect to the ESP32 neither by my phone (I used Serial Bluetooth Terminal, but now it shows "write descriptor failed" error when trying to connect) and I don't know how to come back to when it worked.
Bluetooth is a pain. It was an IBM ultra-secure (= nobody can connect with you except by Divine Intervention or immense setup pain on your part).
That said, if you're using a Pi and turning bluetooth off to save current, that may not be wise. Everyone writes their own bluetooth stack and they're nearly all crap. To transfer, bluetooth needs
Tou be turned on
… At BOTH ends
The devices need to see each other
They need to be paired
They need to trust each other.
The default download locations (if applicable) need to be writable.
I would get out your mobile phone and check. You should be able to see and transfer to both devices, There's bluetoothctl on my system which is less crap than anything else I've tried. I needed bluetoothctl to set up and something else to transfer files. bluetoothctl is console mode, and of course you need root for this stuff.
Last edited by business_kid; 10-18-2019 at 11:29 AM.
I don't know if I have written the right code for the ESP32, but it worked for like 2 months. But in a few days I have a test at the university on it and I wanted to edit the raspberry script to add this thing.
I mean, the script worked(ED...). The thing that the ESP32 sent was a detection of temperature and humidity. And using gatttool in a non-interactive mode from the raspberry Pi I could read them in every cycle the script did. But it connected to the device just for the moment of the reading and I thought "if someone that is not my Raspberry connects to my ESP32, the raspberry would stop to receive data!", so I wanted to ensure that there would be a fixed connection between the two devices.
But, as I told, after trying that commands I found in that thread I can't access the data anymore. So I messed up with the bluetooth configuration of the ESP32 in some way from the raspberry. I don't have anymore the module to reprogram the ESP32, so I wanted to undo whatever I did from the raspberry.
I tried to connect the devices by bluetoothctl and it works with connect, trust and pair but I can't access uuid that the raspberry needs to read (it shows "UUIDs has unsupported type"). And since neither the phone can read it I think it's something I changed on ESP.
Sorry if I bothered you, but I don't know what to try. Thank you for the reply anyway!
I've been through College. Fancy me trying to get through hardware engineering with my design: The input HEMTs on my two prototypes blew because I didn't hadn't any anti-static storage space; The pcbs couldn't be prototyped because the 74HCAUC devices were too $%Ł&@! small to be hand soldered, so I had one device working between the two. I designed the pcb with a lot of earth as shielding and capacitance which was supposed to be a component in the circuit, but the pcb manufacturer took it out. I got spare input devices but the techie was afraid to try soldering them on, etc. etc. I couldn't complain because the report went to external examiners!
You can be amazing with that kind of a torch under your backside. The thing about bluetooth is, Nobody, but nobody can connect to it as it should operate. It requires input on both ends. Don't lose your cool; I would purge everything you messed with and set it up as it worked. If that fails, point out that it did work, although it doesn't now, and you know why, but ran out of time to fix it. It won't cost you muchin marks. Highlight the unreliability of bluetooth, and it's unsuitability to the uses it's being put to. Highlight also that you broke the first rule of maintenance "If it ain't broke, don't fix it!" but that was done in the interests of developing a better product and these events are not unusual. Waffle about security and show you understand the principles. You'll be fine. 50% they won't even turn it on. They'll buzz through it during the Christmas hangover period. You have to be straight up for summer papers, but you can be frank & funny in the mid terms. I included this bit in the final mid-term https://drive.google.com/open?id=1dL...V5AgNVCO3KkaHF
Last edited by business_kid; 10-19-2019 at 05:39 AM.
Moved: This thread is more suitable in <Linux - Embedded & Single-board computer > and has been moved accordingly to help your thread/question get the exposure it deserves.
That's the tools to setup connections. You can set some connections as trusted, thus making them persistent -ish. As long as scanning is enabled, the agent is on, and other quirks.
the > command line has a help command to list options. It's not too complex outside of having to type MAC addresses of the device over and over. List it, connect to it, trust it, ... ... ... Kind of annoying, but it works. Just notice-ing that your orignal command did use bluetoothctl. And probably recorded a script of what was done using it. Which would be erased the next time you ran that command. Option 2, use a gui environment with a bluetooth agent (gui) to make it simple. A couple clicks and done.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.