You are not logged in.

#1 2018-07-09 12:23:29

DevilToad
Member
Registered: 2018-07-09
Posts: 3

Scripting Bluetooth connection

Hi all, I'm trying to connect to a Bluetooth device from within a script similar to this: https://bbs.archlinux.org/viewtopic.php?id=215194

I want to be able to run the pairing process from the script as well though. Ideally what I want to do is pair the device then interact with it in python. I want to make this as smooth as possible for the user, I don't want them to have to manually run bluetoothctl or hcitool, there should be an option in the CLI of the python script to pair new devices.

I've tried running bluetoothctl as a subprocess and interacting with it but that doesn't pair and it (seemingly inconsistently) steals stdin and stdout from my script.

Offline

#2 2018-07-09 12:41:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: Scripting Bluetooth connection


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2018-07-09 12:43:20

DevilToad
Member
Registered: 2018-07-09
Posts: 3

Re: Scripting Bluetooth connection

PyBluez won't do pairing though, at least as far as I can tell from the terrible documentation.

(Edited) I've been using PyBluez to talk to the device and it works fine but I can't communicate with the device without first pairing. Using bluetoothctl works but I can't do it non-interactively.

Last edited by DevilToad (2018-07-09 12:45:02)

Offline

#4 2018-07-09 13:03:48

DevilToad
Member
Registered: 2018-07-09
Posts: 3

Re: Scripting Bluetooth connection

Just in case someone else needs this, the solution looks to be using rfcomm as per this article: https://www.pcsuggest.com/linux-bluetoo … ool-bluez/

Offline

Board footer

Powered by FluxBB