Giter Club home page Giter Club logo

pydbus-manager's People

Contributors

seebz avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

ialpe milindur

pydbus-manager's Issues

Using with Bluez

Thanks for creating this library.

I am trying to apply it to apply it to accessing the BlueZ Advertising API and I am having a few problems.
The API is:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt

Below is the code I am trying to run and also the errors I'm getting. I am struggling to understand how to correct the errors. Do you have any insight?

(process:4118): GLib-GIO-CRITICAL **: 07:47:54.587: g_dbus_connection_register_object: assertion 'object_path != NULL && g_variant_is_object_path (object_path)' failed

(process:4118): GLib-GIO-CRITICAL **: 07:47:54.587: g_dbus_connection_register_object: assertion 'object_path != NULL && g_variant_is_object_path (object_path)' failed

(process:4118): GLib-GIO-CRITICAL **: 07:47:54.587: g_dbus_connection_register_object: assertion 'object_path != NULL && g_variant_is_object_path (object_path)' failed
Traceback (most recent call last):
  File "/home/thinkabit1/PycharmProjects/new_bluez/pydbus_seez.py", line 97, in <module>
    None)
  File "/home/thinkabit1/PycharmProjects/new_bluez/pydbus_manager/registration.py", line 59, in register_object
    manager._add_object(path, object_)
  File "/home/thinkabit1/PycharmProjects/new_bluez/pydbus_manager/registration.py", line 18, in _add_object
    interfaces_and_properties = self._get_interfaces_and_properties(path)
  File "/home/thinkabit1/PycharmProjects/new_bluez/pydbus_manager/registration.py", line 30, in _get_interfaces_and_properties
    proxy = self.get(path)
  File "/home/thinkabit1/PycharmProjects/new_bluez/pydbus_manager/proxy.py", line 11, in get
    composite_object = bus.get(bus_name, object_path, **kwargs)
  File "/home/thinkabit1/PycharmProjects/new_bluez/venv/lib/python3.7/site-packages/pydbus/proxy.py", line 59, in get
    return CompositeInterface(introspection)(self, bus_name, object_path)
  File "/home/thinkabit1/PycharmProjects/new_bluez/venv/lib/python3.7/site-packages/pydbus/proxy.py", line 118, in CompositeInterface
    raise KeyError("object does not export any interfaces; you might need to pass object path as the 2nd argument for get()")
KeyError: 'object does not export any interfaces; you might need to pass object path as the 2nd argument for get()'

from pydbus import SystemBus
from pydbus.generic import signal
from pydbus_manager import Manager
from gi.repository import GLib


class Advertisement:
    """
    <!DOCTYPE node PUBLIC '-//freedesktop//DTD D-BUS Object Introspection 1.0//EN'
    'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>
    <node>
        <interface name='org.freedesktop.DBus.Introspectable'>
            <method name='Introspect'>
                <arg name='data' direction='out' type='s'/>
            </method>
        </interface>
        <interface name='org.freedesktop.DBus.Properties'>
            <method name='Get'>
                <arg name='interface' direction='in' type='s'/>
                <arg name='property' direction='in' type='s'/>
                <arg name='value' direction='out' type='v'/>
            </method>
            <method name="Set">
                <arg name="interface_name" direction="in" type="s"/>
                <arg name="property_name" direction="in" type="s"/>
                <arg name="value" direction="in" type="v"/>
            </method>
            <method name='GetAll'>
                <arg name='interface' direction='in' type='s'/>
                <arg name='properties' direction='out' type='a{sv}'/>
            </method>
        </interface>
        <interface name='org.bluez.LEAdvertisement1'>
            <method name='Release'>
                  <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
            </method>
            <annotation name="org.freedesktop.DBus.Properties.PropertiesChanged" value="const"/>
            <property name="Type" type="s" access="read"/>
            <property name="ServiceUUIDs" type="as" access="read"/>
            <property name="ManufacturerData" type="a{sv}" access="read"/>
            <property name="SolicitUUIDs" type="as" access="read"/>
            <property name="ServiceData" type="a{sv}" access="read"/>
            <property name="IncludeTxPower" type="b" access="read"/>
        </interface>
    </node>
    """
    LE_ADVERTISEMENT_IFACE = 'org.bluez.LEAdvertisement1'

    def Introspect(self):
        return self.__doc__

    def Get(self, interface_name, property_name):
        return self.GetAll(interface_name)[property_name]

    def GetAll(self, interface_name):
        if interface_name == Advertisement.LE_ADVERTISEMENT_IFACE:
            return {'Type': pydbus.Variant('s', self.Type),
                    # 'ServiceUUIDs': pydbus.Variant('as', self.ServiceUUIDs),
                    # 'ServiceData': pydbus.Variant('a{sv}', self.ServiceData),
                    # 'IncludeTxPower': pydbus.Variant('b', self.IncludeTxPower),
                    'SolicitUUIDs': pydbus.Variant('as', self.SolicitUUIDs)}

    def Release(self):
        pass

    @property
    def Type(self):
        return 'peripheral'

    @property
    def SolicitUUIDs(self):
        return ['180F']
    @property
    def ServiceUUIDs(self):
        return ['FEAA']

    @property
    def ServiceData(self):
        return {'FEAA', [0x10, 0x08, 0x03, 0x75, 0x6B, 0x42, 0x61,
                         0x7A, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75,
                         0x62, 0x2E, 0x69, 0x6F]}

    @property
    def IncludeTxPower(self):
        return False

    @property
    def ManufacturerData(self):
        return []


if __name__ == '__main__':
    bus = SystemBus()
    obj_manager = Manager(bus, 'ukBaz.bluezero')
    reg1 = obj_manager.register_object('ukBaz/bluezero/advertisement1',
                                       Advertisement(),
                                       None)

    ad_manager = bus.get('org.bluez', '/org/bluez/hci0')['org.bluez.LEAdvertisingManager1']
    ad_manager.RegisterAdvertisement('/ukBaz/bluezero/advertisement1', {})

    loop = GLib.MainLoop()
    try:
        loop.run()
    except KeyboardInterrupt:
        print("\nStopping ...")
        loop.quit()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.