spacecheese / bluez_peripheral

A library for building BLE peripherals using GATT and bluez
MIT License
42 stars 8 forks source link

dbus_next.errors.InvalidIntrospectionError #11

Closed artem469 closed 1 year ago

artem469 commented 2 years ago

Hi! I`m trying to run your sample HeartRateService and got this error

File "/tmp/BLE_Test/main.py", line 69, in

asyncio.run(main())

File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/tmp/BLE_Test/main.py", line 45, in main await service.register(bus) File "/usr/local/lib/python3.9/dist-packages/bluez_peripheral/gatt/service.py", line 126, in register await self._collection.register(bus, path, adapter) File "/usr/local/lib/python3.9/dist-packages/bluez_peripheral/gatt/service.py", line 236, in register self._adapter = await Adapter.get_first(bus) if adapter is None else adapter File "/usr/local/lib/python3.9/dist-packages/bluez_peripheral/util.py", line 128, in get_first adapters = await cls.get_all(bus) File "/usr/local/lib/python3.9/dist-packages/bluez_peripheral/util.py", line 107, in get_all introspection = await bus.introspect("org.bluez", "/org/bluez/" + node.name) File "/usr/local/lib/python3.9/dist-packages/dbus_next/aio/message_bus.py", line 216, in introspect return await asyncio.wait_for(future, timeout=timeout) File "/usr/lib/python3.9/asyncio/tasks.py", line 481, in wait_for return fut.result() File "/usr/local/lib/python3.9/dist-packages/dbus_next/message_bus.py", line 196, in reply_notify result = intr.Node.parse(reply.body[0]) File "/usr/local/lib/python3.9/dist-packages/dbus_next/introspection.py", line 437, in parse return Node.from_xml(element, is_root=True) File "/usr/local/lib/python3.9/dist-packages/dbus_next/introspection.py", line 414, in from_xml node.interfaces.append(Interface.from_xml(child)) File "/usr/local/lib/python3.9/dist-packages/dbus_next/introspection.py", line 337, in from_xml interface.methods.append(Method.from_xml(child)) File "/usr/local/lib/python3.9/dist-packages/dbus_next/introspection.py", line 198, in from_xml arg = Arg.from_xml(child, direction) File "/usr/local/lib/python3.9/dist-packages/dbus_next/introspection.py", line 72, in from_xml raise InvalidIntrospectionError('a method argument must have a "type" attribute') dbus_next.errors.InvalidIntrospectionError: a method argument must have a "type" attribute

Can you help?

spacecheese commented 2 years ago

Hello, sorry for the slow response. This looks like your bluez service is returning malformed data. Please could you run the command hciconfig -a and take a note of the first adapter name (outlined in red on my screenshot).

image

If you could then run: dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/[PUT ADAPTER NAME HERE] org.freedesktop.DBus.Introspectable.Introspect And send me the output.