0

I am trying to connect to a bluetooth device with my Pi 4 via Bluetooth. Upon boot, I want the Pi 4 to automatically turn on its bluetooth and select the device with the strongest signal and then request for pairing. Assume that the devices shown below are all Pi Zero W. After pairing, the pi 4 should send a text file to the Pi Zero W with the strongest signal. Can anyone give sort of direction I could try to achieve this ? Do let me know if I need to do anything on the Pi Zero W other than making its bluetooth discoverable. Thanks in advance.

enter image description here

1

You probably need to break this into small parts and solve them individually before bringing it back together for the overall solution.

File transfer on Bluetooth is typically done with with the Generic Object Exchange Profile (GOEP). There is some more information about this at:

Raspberry pi 4 bluetooth file transfer rate

Pairing is normally a one-off provisioning/security step the first time two devices want to connect. After this is done the first time, subsequent connections can happen without pairing again. I suspect you don't want to randomly pair with devices as that seems like a security issue.

To do the nearby devices discovery and look at the RSSI value, you might be able to adapt the code in:

Rpi Zero W - How to automatically accept bluetooth pairing and log mac and info request?

The above code looks at the Connected property whereas you are interested in the RSSI property. The full list of properties are available in the BlueZ documentation for the Device API.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.