morseapi icon indicating copy to clipboard operation
morseapi copied to clipboard

Great library but connection problem

Open paulvanbladel opened this issue 7 years ago • 7 comments

First of all, thanks a lot for sharing this library. Great work. When trying the clock.py, I'm getting following error. Any idea how to proceed?

Thanks in advance

paul@nuc:~/github/morseapi$ examples/clock.py D0:FA:D0:59:57:89
No handlers could be found for logger "robots.position.ros"
Connecting to D0:FA:D0:59:57:89.
DEBUG:root:c804
DEBUG:pygatt.backends.gatttool.gatttool:gatttool_cmd=gatttool -i hci0 -I
INFO:pygatt.backends.gatttool.gatttool:Running...
INFO:pygatt.backends.gatttool.gatttool:Connecting to D0:FA:D0:59:57:89 with timeout=5.0
2018-01-18 12:47:22,050 robots.robot: WARNING - No action packages specified when creating an instance of GenericRobot. Likely an error!
ERROR:pygatt.backends.gatttool.gatttool:Timed out connecting to D0:FA:D0:59:57:89 after 5.0 seconds.
Traceback (most recent call last):
  File "examples/clock.py", line 44, in <module>
    run(bot_address)
  File "examples/clock.py", line 33, in run
    bot.reset()
  File "/home/paul/github/morseapi/morseapi/robot.py", line 117, in reset
    self.command("reset", bytearray([mode]))
  File "/home/paul/github/morseapi/morseapi/robot.py", line 103, in command
    if self.connection:
  File "/home/paul/github/morseapi/morseapi/robot.py", line 84, in connection
    self._connection = adapter.connect(self.address, address_type=pygatt.BLEAddressType.random)
  File "/home/paul/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 388, in connect
    raise NotConnectedError(message)
pygatt.exceptions.NotConnectedError: Timed out connecting to D0:FA:D0:59:57:89 after 5.0 seconds.
paul@nuc:~/github/morseapi$

I believe that the bluetooth connection is ok?

[bluetooth]# info D0:FA:D0:59:57:89 Device D0:FA:D0:59:57:89 Name: Dash Alias: Dash Appearance: 0x1234 Paired: yes Trusted: yes Blocked: no Connected: no LegacyPairing: no UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb) UUID: Vendor specific (af237777-879d-6186-1f49-deca0e85d9c1) [bluetooth]# quit [DEL] Controller 28:C6:3F:B5:86:C2 nuc [default]

paulvanbladel avatar Jan 18 '18 11:01 paulvanbladel

The above was a connection problem which I could solve on bluetooth level. Getting other error now

from morseapi import MorseRobot No handlers could be found for logger "robots.position.ros" bot = MorseRobot("D0:FA:D0:59:57:89") 2018-01-18 13:52:28,233 robots.robot: WARNING - No action packages specified when creating an instance of GenericRobot. Likely an error! bot.reset() WARNING:pygatt.device:No characteristic found matching af230003-879d-6186-1f49-deca0e85d9c1 Traceback (most recent call last): File "", line 1, in File "morseapi/robot.py", line 117, in reset self.command("reset", bytearray([mode])) File "morseapi/robot.py", line 103, in command if self.connection: File "morseapi/robot.py", line 86, in connection self.sense.start() File "morseapi/sensors.py", line 34, in start self.subscribe() File "morseapi/sensors.py", line 51, in subscribe self.connection.subscribe(CHARACTERISTICS["dot_sensor"], self._dot_sensor_decode) File "/home/paul/.local/lib/python2.7/site-packages/pygatt/device.py", line 144, in subscribe self._notification_handles(uuid) File "/home/paul/.local/lib/python2.7/site-packages/pygatt/device.py", line 120, in _notification_handles value_handle = self.get_handle(uuid) File "/home/paul/.local/lib/python2.7/site-packages/pygatt/device.py", line 208, in get_handle raise exceptions.BLEError(message) pygatt.exceptions.BLEError: No characteristic found matching af230003-879d-6186-1f49-deca0e85d9c1

paulvanbladel avatar Jan 18 '18 12:01 paulvanbladel

this did the trick :) https://github.com/peplin/pygatt/issues/161

paulvanbladel avatar Jan 18 '18 12:01 paulvanbladel

See also: https://github.com/peplin/pygatt/issues/152 https://github.com/peplin/pygatt/pull/156

IlyaSukhanov avatar Jan 19 '18 16:01 IlyaSukhanov

I think best option is actually ditch pygatt dependency. Other options include: https://github.com/getsenic/gatt-python https://bitbucket.org/OscarAcena/pygattlib

IlyaSukhanov avatar Jan 19 '18 16:01 IlyaSukhanov

adding pip install pygatt==3.1.1 to the readme will solve a lot of people's problems :)

@IlyaSukhanov thanks a lot for the library! my daughter was super impressed we can use python on the dash and my dog was extremely upset at it haha

jackdoe avatar Dec 05 '21 21:12 jackdoe

@jackdoe Glad you find it useful. Was the problem that the later version of pygatt >4 does not work?

IlyaSukhanov avatar Dec 06 '21 01:12 IlyaSukhanov

ah sorry i should've been more specific, with pygatt > 3.2 i couldnt connect at all after following https://github.com/peplin/pygatt/issues/161 and downgrading to 3.1.1 everything was fine

jackdoe avatar Dec 06 '21 06:12 jackdoe