Re: BLE Advertisement frustrations with pydbus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Travis,

On Sat, May 6, 2017 at 1:28 AM, Travis Griggs <travisgriggs@xxxxxxxxx> wrote:
> I’m trying to switch to using pydbus (instead of deprecated dbus-python, which the bluez examples are based on). I’m running on stretch with bluez 5.43. My code is at the bottom (and here -> https://gist.github.com/travisgriggs/d8e14dcccf46751804456dc74da1e5e6). I’m running into a problem when I try to RegisterAdvertisement. What I can’t seem to discern is what is different between this and the old approach. The bluetooth driver fails around advertising:c:175
>
>     DBusMessageIter iter;
>     const char *msg_type;
>
>     if (!g_dbus_proxy_get_property(proxy, "Type", &iter))
>         return false;
>
> The g_dbus_proxy_get_property() call fails. What I don’t understand though is this. If I modify my program to NOT RegisterAdvertisement(), but just sit there with the advertisement object on the bus, I can do the following:
>
> $ sudo busctl get-property :1.5 /nic/twigpilot org.bluez.LEAdvertisement1 Type
> s “peripheral"
>
> So I *am* able to get the Type using busctl. Why is that bluetoothd cannot? Using busctl introspect, I see that the pydbus variant automagically makes a lot more available than the dubs-python variant did.
>
> Any hints? Pointers? Help?

Does pydbus have ObjectManager support? What about GetAll properties?
You could perhaps try to sniff the message with eavesdrop option:

https://wiki.ubuntu.com/DebuggingDBus

> TIA
>
> ——
>
> #!/usr/bin/env python3
>
> import pydbus
> from gi.repository import GLib
>
> class Advertisement(object):
>     """
>       <node>
>         <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>
>     """
>
>     def __init__(self, bus):
>         self.Type = 'peripheral'
>         self.ServiceUUIDs = []
>         self.ManufacturerData = {}
>         self.SolicitUUIDs = []
>         self.ServiceData = {}
>         self.IncludeTxPower = False
>         bus.register_object('/nic/twigpilot', self, None)
>
>     def Release(self):
>         print('{}: Advertisement Released!'.format(self))
>
>
> def main():
>     bus = pydbus.SystemBus()
>     adaptor = bus.get('org.bluez', '/org/bluez/hci0')
>     adaptor.Powered = True
>     adaptor.Alias = 'SeeMe'
>
>     advertisement = Advertisement(bus)
>     advertisement.IncludeTxPower = True
>
>     #adaptor.RegisterAdvertisement('/nic/twigpilot', {})
>
>     loop = GLib.MainLoop()
>     try:
>         loop.run()
>     except KeyboardInterrupt:
>         loop.quit()
>
> if __name__ == '__main__':
>     main()--
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux