You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Firstly, great application. I was able to get it up and running on Ubuntu 16.04 LTS Plus in just a few hours. In the connect() function, I had to make these changes to narrow down my problems:
defconnect(MAC, reset_on_start=True):
""" Create and start a new backend adapter and connect it to a device. When connecting to multiple devices at the same time make sure to set reset_on_start to False after the first connection is made, otherwise all connections made before are invalidated. :param string MAC: MAC address of the device to connect to. :param bool reset_on_start: Perhaps due to a bug in gatttool or pygatt, but if the bluez backend isn't restarted, it can sometimes lock up the computer when trying to make a connection to HCI device. """try:
adapter=pygatt.GATTToolBackend()
try:
adapter.start(reset_on_start=reset_on_start)
try:
device=adapter.connect(MAC)
exceptpygatt.exceptions.NotConnectedError:
raisepygatt.exceptions.NotConnectedError("Device not connected!")
exceptpygatt.exceptions.NotConnectedError:
raisepygatt.exceptions.NotConnectedError("Adapter cannot start!")
exceptpygatt.exceptions.NotConnectedError:
raisepygatt.exceptions.NotConnectedError("No Backend Tool for GATT!")
# This is the true error on 2025-01-07 but only happens intermediately# File "./homa.py", line 2214, in __init__# device = tc.connect("36:46:3E:F3:09:5E")# File "/home/rick/HomA/trionesControl/trionesControl.py", line 35, in connect# raise pygatt.exceptions.NotConnectedError("No Backend Tool for GATT!")# pygatt.exceptions.NotConnectedError: No Backend Tool for GATT!''' ORIGINAL CODE: try: adapter = pygatt.GATTToolBackend() adapter.start(reset_on_start=reset_on_start) device = adapter.connect(MAC) except pygatt.exceptions.NotConnectedError: raise pygatt.exceptions.NotConnectedError("Device nor connected!") '''log.info("Device connected")
returndevice
Before narrowing down the exact error I was only seeing "Device nor connected".
Digging into gatttool.py I had to make these changes to fix the REAL error:
@at_most_one_devicedefchar_write_handle(self, handle, value, wait_for_response=True,
timeout=30):
""" Writes a value to a given characteristic handle. :param handle: :param string value: :param wait_for_response: If true, performs an attribute write. If false, sends a command and expects no acknowledgement from the device. :param timeout: """# 2025-01-07 debug error:# ''.join("{0:02x}".format(byte) for byte in value),# ValueError: Unknown format code 'x' for object of type 'str'cmd='char-write-{0} 0x{1:02x} {2}'.format(
'req'ifwait_for_responseelse'cmd',
handle,
#''.join("{0:02x}".format(byte) for byte in value), # 2025-01-07''.join("{0:02x}".format(ord(byte)) forbyteinvalue),
)
(... snip ...)
I was pleasantly surprised how easy it was to turn on the "Happy Lighting" LED light strip automatically from Linux. Note it's Python 2.7.12.
The text was updated successfully, but these errors were encountered:
Firstly, great application. I was able to get it up and running on Ubuntu 16.04 LTS Plus in just a few hours. In the
connect()
function, I had to make these changes to narrow down my problems:Before narrowing down the exact error I was only seeing "Device nor connected".
Digging into
gatttool.py
I had to make these changes to fix the REAL error:I was pleasantly surprised how easy it was to turn on the "Happy Lighting" LED light strip automatically from Linux. Note it's Python 2.7.12.
The text was updated successfully, but these errors were encountered: