Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'NoneType' object is not iterable #15

Closed
asbayer opened this issue Nov 29, 2018 · 8 comments
Closed

TypeError: 'NoneType' object is not iterable #15

asbayer opened this issue Nov 29, 2018 · 8 comments

Comments

@asbayer
Copy link

asbayer commented Nov 29, 2018

Hi,
Do you have an idea how i get rid of that messages?
I did everything you wrote on your page setting up the environment but get stuck with the demo. Here the output (demo.py is taken from you page):
/usr/bin/python2.7 /root/PycharmProjects/mypy/lego/demo.py
INFO:pygatt.backends.bgapi.bgapi:Initialized new BGAPI backend
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port /dev/ttyACM0
INFO:pygatt.backends.bgapi.bgapi:Resetting and reconnecting to device for a clean environment
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port /dev/ttyACM0
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
INFO:pygatt.backends.bgapi.bgapi:Auto-detecting serial port for BLED112
INFO:pygatt.backends.bgapi.bgapi:Found BLED112 on serial port /dev/ttyACM0
INFO:pygatt.backends.bgapi.bgapi:Running receiver
INFO:pygatt.backends.bgapi.bgapi:Disabling advertising
INFO:comms-pygatt:Discovering devices...
INFO:pygatt.backends.bgapi.bgapi:Starting an active scan
INFO:pygatt.backends.bgapi.bgapi:Pausing for 1s to allow scan to complete
INFO:pygatt.backends.bgapi.bgapi:Stopping scan
INFO:pygatt.backends.bgapi.bgapi:Discovered 1 devices: [{'rssi': -55, 'packet_data': {'scan_response_packet': {'tx_power_level': bytearray(b'\x00'), 'slave_connection_interval_range': bytearray(b'\x10\x00 \x00'), 'complete_local_name': u'LEGO Move Hub'}, 'connectable_advertisement_packet': {'complete_list_128-bit_service_class_uuids': [u'0x00:00:16:23:12:12:EF:DE:16:23:78:5F:EA:BC:D1:23'], 'flags': bytearray(b'\x06'), 'manufacturer_specific_data': bytearray(b'\x97\x03\x00@\x06\xfeA\x00')}}, 'name': u'LEGO Move Hub', 'address': u'00:16:53:A5:5A:0B'}]
INFO:root:Found LEGO Move Hub at 00:16:53:A5:5A:0B
INFO:pygatt.backends.bgapi.bgapi:Connecting to device at address 00:16:53:A5:5A:0B (timeout 5s)
INFO:pygatt.backends.bgapi.bgapi:Connection status: handle=0x0, flags=(11, 90, 165, 83, 22, 0), address=0x0b5aa5531600, connection interval=206.250000ms, timeout=830, latency=22 intervals, bonding=0x0
INFO:pygatt.backends.bgapi.bgapi:Connected to 00:16:53:A5:5A:0B
INFO:pygatt.backends.bgapi.bgapi:Fetching characteristics for connection 0
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/pygatt/backends/bgapi/bgapi.py", line 594, in _receive
packet_type, args = self._lib.decode_packet(packet)
TypeError: 'NoneType' object is not iterable

Traceback (most recent call last):
File "/root/PycharmProjects/mypy/lego/demo2.py", line 200, in
connection.disconnect()
File "/usr/local/lib/python2.7/dist-packages/pylgbst/comms/cpygatt.py", line 48, in disconnect
self._conn_hnd.disconnect()
File "/usr/local/lib/python2.7/dist-packages/pygatt/backends/bgapi/device.py", line 21, in wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pygatt/backends/bgapi/device.py", line 134, in disconnect
self._backend.expect(ResponsePacketType.connection_disconnect)
File "/usr/local/lib/python2.7/dist-packages/pygatt/backends/bgapi/bgapi.py", line 532, in expect
return self.expect_any([expected], *args, **kargs)
File "/usr/local/lib/python2.7/dist-packages/pygatt/backends/bgapi/bgapi.py", line 568, in expect_any
raise exc
pygatt.backends.bgapi.exceptions.ExpectedResponseTimeout: Timed out after 1.000000s waiting for [<ResponsePacketType.connection_disconnect: 29>]

Process finished with exit code 1

I would be very happy if you can give me a hint of how to deal with that.
Thank you very much, Andreas

@undera
Copy link
Owner

undera commented Nov 29, 2018

This looks similar to peplin/pygatt#196

What exactly do you have in your demo.py file?

@asbayer
Copy link
Author

asbayer commented Nov 29, 2018

I just copied your demo.py file
https://github.com/undera/pylgbst/blob/master/examples/demo.py

After the first trail I changed the line:
connection = get_connection_auto()
to
connection = get_connection_bluegiga(hub_mac='00:16:53:A5:5A:0B')
Both scenarios prduce the output shown above.
I'm using a Kali-Linux system.

@asbayer asbayer closed this as completed Nov 29, 2018
@asbayer asbayer reopened this Nov 29, 2018
@undera
Copy link
Owner

undera commented Nov 29, 2018

That demo file has no job to do, because it has demo_all() commented out. Try uncommenting it and run again.

@asbayer
Copy link
Author

asbayer commented Nov 29, 2018

This I already did. But nothing changed. This i my current code at the bottom of your demo.py file which produces the message:

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)

    try:
        connection = DebugServerConnection()
    except BaseException:
        logging.debug("Failed to use debug server: %s", traceback.format_exc())
        connection = get_connection_bluegiga(hub_mac='00:16:53:A5:5A:0B')
        #connection =  get_connection_auto()

    try:
        hub = MoveHub(connection)
        sleep(1)
        demo_all(hub)
    finally:
        connection.disconnect()

@undera
Copy link
Owner

undera commented Nov 29, 2018

Ok, I see. Can you try with another backend BLE lib?

@asbayer
Copy link
Author

asbayer commented Nov 29, 2018

This is the output when I try get_connection_gattool

/usr/bin/python2.7 /root/PycharmProjects/mypy/lego/demo.py
Can't get device info: No such device
INFO:pygatt.backends.gatttool.gatttool:Running...
INFO:comms-pygatt:Discovering devices...
INFO:pygatt.backends.gatttool.gatttool:Starting BLE scan
ERROR:pygatt.backends.gatttool.gatttool:No BLE adapter found
Traceback (most recent call last):
  File "/root/PycharmProjects/mypy/lego/demo.py", line 193, in <module>
    connection = get_connection_gattool(hub_mac='00:16:53:A5:5A:0B')
  File "/usr/local/lib/python2.7/dist-packages/pylgbst/__init__.py", line 18, in get_connection_gattool
    return GattoolConnection(controller).connect(hub_mac)
  File "/usr/local/lib/python2.7/dist-packages/pylgbst/comms/cpygatt.py", line 31, in connect
    devices = adapter.scan(1)
  File "/usr/local/lib/python2.7/dist-packages/pygatt/backends/gatttool/gatttool.py", line 326, in scan
    raise BLEError(message)
pygatt.exceptions.BLEError: No BLE adapter found

and with
connection = get_connection_gatt(hub_mac='00:16:53:A5:5A:0B')
i receive this:

/usr/bin/python2.7 /root/PycharmProjects/mypy/lego/demo.py
Traceback (most recent call last):
  File "/root/PycharmProjects/mypy/lego/demo.py", line 192, in <module>
    connection = get_connection_gatt(hub_mac='00:16:53:A5:5A:0B')
  File "/usr/local/lib/python2.7/dist-packages/pylgbst/__init__.py", line 24, in get_connection_gatt
    return GattConnection(controller).connect(hub_mac)
  File "/usr/local/lib/python2.7/dist-packages/pylgbst/comms/cgatt.py", line 93, in connect
    self._manager.start_discovery()
  File "/usr/local/lib/python2.7/dist-packages/gatt/gatt_linux.py", line 149, in start_discovery
    raise _error_from_dbus_error(e)
gatt.errors.Failed: Method "SetDiscoveryFilter" with signature "a{ss}" on interface "org.bluez.Adapter1" doesn't exist

@undera
Copy link
Owner

undera commented Nov 29, 2018

pygatt might require sudo to run properly

@asbayer
Copy link
Author

asbayer commented Nov 29, 2018

I am logged in as user root on that machine. But I also tried now:
sudo python2.7 demo.py
unfortunately with the same result. I will continue investigating

@undera undera closed this as completed Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants