0

I'm trying to figure out how to transfer files with Bluetooth with Python to an Android phone for a project.

I've done my research, and I can't find much documentation and examples that work. For example, this example here: http://recolog.blogspot.com/2013/07/transferring-files-via-bluetooth-using.html, lightblue.findservices is not an attribute in the lightblue library, and other pages on Stack Overflow that I've found only work with python 2.7.

I've asked on #python on freenode and no one could give me an answer either. Lightblue documentation on pip is also very cryptic and doesn't explain how to do what I'm trying to do.

Long story short, I can't figure out how to use bluetooth with python anywhere. Does anyone happen to know how to do this?

Jon Goodwin
  • 9,053
  • 5
  • 35
  • 54
Zachary Haslam
  • 103
  • 1
  • 12

1 Answers1

1

Python itself should provide support for Bluetooth sockets in its sockets module.

Pybluez, or one of its forks on GitHub or elsewhere, will provide higher level functions for discovering devices and finding services.

Once you have information about a service that a device exposes, such as the port needed to access it, you can open a socket and connect to it. Then you need to be able to communicate using the protocol used by that service's "profile". I wrote a Python package called PyOBEX to communicate using the OBEX protocol that some devices use for their file transfer services.

You might also want to look at this answer, already linked to in the comments above.

David Boddie
  • 1,016
  • 7
  • 4