alvarojaviervargasm4 | 2021-05-21 23:30:14 UTC | #1
Hello.
I'm developing an application that communicate 2 devices with Bluetooth LE connection, I've been trying with PyBluez but it has been very difficult to get a stable version, so, I found an example (link) in the QT5 documentation for C++ and tried to port it to PyQt5 and added a few lines. So, when I executed it prints the following error, and don't know where to begin to fix it.
Any help or documentation that you could give me will be appreciated.
Error:
Agent error
args (4,)
kwargs {}
qt.bluetooth: Dummy backend running. Qt Bluetooth module is non-functional.
PyQt5 Code
import sys
from PyQt5 import QtBluetooth as QtBt
from PyQt5 import QtCore
class Application(QtCore.QCoreApplication):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.scan_for_devices()
self.exec()
def display_status(self):
print(self.agent.isActive(), self.agent.discoveredDevices())
def show_info(self, info: QtBt.QBluetoothDeviceInfo):
print('Device discovered')
print(info)
print(f'Name: {info.name()}')
print(f'UUID: {info.deviceUuid()}')
pass
def agent_finished(self,*args, **kwargs):
print('Agent finished')
print(f'args {args}')
print(f'kwargs {kwargs}')
def agent_error(self,*args, **kwargs):
print('Agent error')
print(f'args {args}')
print(f'kwargs {kwargs}')
def scan_for_devices(self):
self.agent = QtBt.QBluetoothDeviceDiscoveryAgent()
self.agent.setLowEnergyDiscoveryTimeout(5000)
self.agent.deviceDiscovered.connect(self.show_info)
self.agent.finished.connect(self.agent_finished)
self.agent.error.connect(self.agent_error)
timer = QtCore.QTimer(self.agent)
timer.start(1000)
timer.timeout.connect(self.display_status)
self.agent.start()
if __name__ == '__main__':
app = Application(sys.argv)
Eolinwen | 2021-05-26 19:00:54 UTC | #2
Purchasing Power Parity
Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]Hi alvarojaviervargasm4 and welcome to the forum,
The error that you get is that your Bluetooth module is not functional. You must not to have the Qt Bluetooth installed on your system or you have none Bluetooth key. For me, I don't get this error. However, they are something strange. Because I get nothing.
Python 3.9.5 (default, May 9 2021, 14:00:28)
[GCC 10.2.0] on linux runfile('/home/olivier/.config/JetBrains/PyCharmCE2021.1/scratches/bluetooth_module_test.py', wdir='/home/olivier/.config/JetBrains/PyCharmCE2021.1/scratches') True [] True [] True [] True [] Agent finished args () kwargs {} False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] False [] And yet my BT key is functional but it's a 5.0. Maybe this has an impact. Anyway, I don't understand your logic. Info is not declared. Then, it is normal that you have nothing in output. After I'm not a specialist and I know that's difficult to translate Qt in PyQt.
Packaging Python Applications with PyInstaller by Martin Fitzpatrick — This step-by-step guide walks you through packaging your own Python applications from simple examples to complete installers and signed executables.