Reputation: 11
I try to read characteristic data out of an BLE based Sensor. Therefore i use the pygatt module
import pygatt
adapter = pygatt.GATTToolBackend()
try:
adapter.start()
device = adapter.connect("2B:01:56:6C:F4:E6")
value= device.char_read("00007502-0000-1000-8000-00805f9b34fb")
finally:
adapter.stop()
Everytime i try to run this in my Linux console (with Python 2.7.16) i get an error :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/device.py", line 17, in wrapper
return func(self, *args, **kwargs)
File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/device.py", line 40, in char_read
return self._backend.char_read(self, uuid, *args, **kwargs)
File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 50, in wrapper
return func(self, *args, **kwargs)
File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 593, in char_read
self.sendline('char-read-uuid %s' % uuid)
File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
self.gen.next()
File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 191, in event
self.wait(event, timeout)
File "/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 157, in wait
raise NotificationTimeout()
pygatt.exceptions.NotificationTimeout: None
I am completely lost on this error. Do you know how to fix this ? Any help on this much appreciated. Thanks in advance...
Upvotes: 1
Views: 1111
Reputation: 1374
Since I was facing the same problem and nobody out there seemed to have this problem...
Well, the problem was that the requested UUID characteristic didn't exist/was invalid. Make sure that you've typed it right or that you haven't clipped some part off when copying from putty or similar (Totally not speaking from experience! Of course!)
If you are pasting a characteristic UUID from the internet or a similar device, maybe your device don't have this UUID.
OR
This could (not tested, but should make sense) also happen if you write to an UUID which is non-writeable (read-only/subscribe-only).
If you're sure that everything is right and that you have triple-checked the UUID with a dedicated sniffer or simply a BLE Scanner on your Phone, then the device is probably closing the connection too fast.
TROUBLESHOOTING:
You can manually connect with the device and issue commands using:
gatttool -I
When you are inside the program, type:
connect aa:bb:cc:dd:ee:ff
And then, before the connection closes:
char-read-uuid xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
and analyse what happens. If it works there, it should also work in python.
Upvotes: 2