Can´t seem to make Bluetooth agent work in Raspberry Pi

Viewed 246

So, what I'm trying to do is create a Python script which allows me to connect an android phone via Bluetooth with a Raspberry Pi. If I do this manually (writing the instructions in the command line) it works just fine, I can search, pair and connect any device in range.

However, if I do this via script, the message No agent is registered pops up when I try to activate the agent, meaning I won´t be able to pair any device, given this is the instrument which makes shure the confirmation code shown both in the Raspberri Pi and Android phone coincides.

The code I'm using looks somewhat like this.

 import os
 import sys
 import time

 os.system('sudo systemctl enable bluetooth')
 os.system('sudo systemctl start bluetooth')
 os.system('bluetoothctl discoverable on')
 os.system('bluetoothctl agent on')
 os.system('bluetoothctl default-agent')
 os.system('bluetoothctl pairable on')
 os.system('timeout 30 bluetoothctl scan on')
 os.system('bluetoothctl pair XX:XX:XX:XX:XX:XX')

Any help or ideas will be much appreciated

2 Answers

I made it work by using 'hcitool' instructions instead of 'bluetoothctl' and 'btnap' instead of BlueZ.

Related