linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Barry Byford <31baz66@gmail.com>
To: Bluez mailing list <linux-bluetooth@vger.kernel.org>
Subject: Re: DBus LEAdvertisement and Python
Date: Thu, 18 Jul 2019 22:04:06 +0100	[thread overview]
Message-ID: <CAAu3APaPaDXBNsWcCUhNF2_sM_AxiKe5B6U1xtMOU9tYwpFS2g@mail.gmail.com> (raw)
In-Reply-To: <CABBYNZ+W8dG7qgAe-2QYnSkyVG_1eA4KtMKHyXws0LWwB346Ow@mail.gmail.com>

Hello Luiz,

Thanks for the prompt response. Below are some updates following your input.

On Thu, 18 Jul 2019 at 09:26, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> Hi Barry,
>
> On Thu, Jul 18, 2019 at 10:03 AM Barry Byford <31baz66@gmail.com> wrote:
> >
> > Hello,
> >
> > The Python examples provided in the test directory of the BlueZ
> > repository use the python-dbus library. Looking at the documentation
> > of that library it does start by raising concerns and offering
> > alternatives. I have been looking at some of the alternatives and am
> > having difficultly getting them to work with BlueZ. I have been
> > focusing on the org.bluez.LEAdvertisement1 interface.
> >
> > Looking at the documentation, it says the service, interface and
> > object details are:
> > Service org.bluez
> > Interface org.bluez.LEAdvertisement1
> > Object path freely definable
> >
> > I am not being successful at publishing to the org.bluez service. It
> > is also not where the current examples publish to.
> > Looking at the GattProfile1 documentation, it has service and object
> > as application dependant.
> > Service <application dependent>
> > Interface org.bluez.GattProfile1
> > Object path <application dependent>
> > Should the documentation of Service on LEAdvertisement1 be freely
> > definable also?
>
> Yep, the bus name is up to the application which usually don't
> register a friendly name if you try to register with 'org.bluez' it
> would probably conflict with the daemon itself so you wouldn't be able
> to register that name anyway.
>
> > I have created the LEAdvertisement1 interface so that it has an
> > ObjectManager and is introspectable. When I pass the object to
> > RegisterAdvertisement on the org.bluez.LEAdvertisingManager1 interface
> > it accepts it (does not give an error) but does not register the data
> > and I see no advertisement appear. Is there somewhere I can find a
> > more detailed description of what needs to be on the
> > org.bluez.LEAdvertisement1 interface that will work with
> > RegisterAdvertisement?
>
> Do you have the bluetoothd output when you register, I get the
> following when using bluetoothctl:
>
> bluetooth]# power on
> Changing power on succeeded
> [bluetooth]# advertise on
> [CHG] Controller B8:8A:60:D8:17:D7 SupportedInstances: 0x04
> [CHG] Controller B8:8A:60:D8:17:D7 ActiveInstances: 0x01
> Advertising object registered
> Tx Power: off
> Name: off
> Apperance: off
> Discoverable: off
> [bluetooth]#

Using the new dbus library I get:
Log from bluetoothctl:
[CHG] Controller FC:F8:AE:8F:0C:A4 SupportedInstances: 0x04
[CHG] Controller FC:F8:AE:8F:0C:A4 ActiveInstances: 0x01

From the bluetoothd log:
bluetoothd[2856]: src/advertising.c:register_advertisement()
RegisterAdvertisement
bluetoothd[2856]: src/advertising.c:client_create() Adding proxy for
/ukBaz/bluezero/advertisement1
bluetoothd[2856]: src/advertising.c:register_advertisement()
Registered advertisement at path /ukBaz/bluezero/advertisement1
bluetoothd[2856]: src/advertising.c:refresh_adv() Refreshing
advertisement: /ukBaz/bluezero/advertisement1
bluetoothd[2856]: src/advertising.c:add_adv_callback() Advertisement
registered: /ukBaz/bluezero/advertisement1


With the old pyton-dbus library (that is working) I get:
log from bluetoothctl:
[CHG] Controller FC:F8:AE:8F:0C:A4 SupportedInstances: 0x04
[CHG] Controller FC:F8:AE:8F:0C:A4 ActiveInstances: 0x01

From the bluetoothd log:
bluetoothd[2856]: src/advertising.c:register_advertisement()
RegisterAdvertisement
bluetoothd[2856]: src/advertising.c:client_create() Adding proxy for
/ukBaz/bluezero/advertisement0001
bluetoothd[2856]: src/advertising.c:register_advertisement()
Registered advertisement at path /ukBaz/bluezero/advertisement0001
bluetoothd[2856]: src/advertising.c:parse_service_uuids() Adding
ServiceUUID: FEAA
bluetoothd[2856]: src/advertising.c:parse_service_data() Adding
ServiceData for FEAA
bluetoothd[2856]: src/advertising.c:refresh_adv() Refreshing
advertisement: /ukBaz/bluezero/advertisement0001
bluetoothd[2856]: src/advertising.c:add_adv_callback() Advertisement
registered: /ukBaz/bluezero/advertisement0001


>
> bluetoothd[6103]: src/advertising.c:client_create() Adding proxy for
> /org/bluez/advertising
> bluetoothd[6103]: src/advertising.c:register_advertisement()
> Registered advertisement at path /org/bluez/advertising
> bluetoothd[6103]: src/advertising.c:refresh_adv() Refreshing
> advertisement: /org/bluez/advertising
> bluetoothd[6103]: src/advertising.c:add_adv_callback() Advertisement
> registered: /org/bluez/advertising
>
>
> > For reference, I have put below what I am currently  putting on the
> > org.bluez.LEAdvertisement1 interface.
> >
> > Thanks,
> > Barry
> >
> >
> > $ busctl call ukBaz.bluezero /ukBaz/bluezero/advertisement1
> > org.freedesktop.DBus.ObjectManager GetManagedObjects
> > a{oa{sa{sv}}} 1 "/ukBaz/bluezero/advertisement1" 5
> > "org.freedesktop.DBus.Properties" 0
> > "org.freedesktop.DBus.Introspectable" 0 "org.freedesktop.DBus.Peer" 0
> > "org.freedesktop.DBus.ObjectManager" 0 "org.bluez.LEAdvertisement1" 6
> > "Type" s "broadcast" "ServiceUUIDs" as 0 "ManufacturerData" a{sv} 0
> > "SolicitUUIDs" as 0 "ServiceData" a{sv} 1 "FEAA" ay 18 16 8 3 117 107
> > 66 97 122 46 103 105 116 104 117 98 46 105 111 "IncludeTxPower" b
> > false
>
> Not sure if that is the problem but usually ObjectManager is suppose
> to be on the '/' (root) path.

Good point. It is not clear (to me anyway) exactly what the
requirement is from reading the spec
https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager
I have moved the object manager to the root (/) but this does not seem
to have changed anything.

$ busctl call ukBaz.bluezero / org.freedesktop.DBus.ObjectManager
GetManagedObjects
a{oa{sa{sv}}} 1 "/ukBaz/bluezero/advertisement1" 4
"org.freedesktop.DBus.Properties" 0
"org.freedesktop.DBus.Introspectable" 0 "org.freedesktop.DBus.Peer" 0
"org.bluez.LEAdvertisement1" 6 "Type" s "broadcast" "ServiceUUIDs" as
0 "ManufacturerData" a{sv} 0 "SolicitUUIDs" as 0 "ServiceData" a{sv} 1
"FEAA" ay 18 16 8 3 117 107 66 97 122 46 103 105 116 104 117 98 46 105
111 "IncludeTxPower" b false


>
> > $ busctl call ukBaz.bluezero /ukBaz/bluezero/advertisement1
> > org.freedesktop.DBus.Properties GetAll s org.bluez.LEAdvertisement1
> > a{sv} 6 "Type" s "broadcast" "ServiceUUIDs" as 0 "ManufacturerData"
> > a{sv} 0 "SolicitUUIDs" as 0 "ServiceData" a{sv} 1 "FEAA" ay 18 16 8 3
> > 117 107 66 97 122 46 103 105 116 104 117 98 46 105 111
> > "IncludeTxPower" b false
> >

Using the d-feet application I did a GetAll on the advertisements and
the data looks identical for both
Using the new DBus library:
{'IncludeTxPower': False,
 'ManufacturerData': {},
 'ServiceData': {'FEAA': [16,
                          8,
                          3,
                          117,
                          107,
                          66,
                          97,
                          122,
                          46,
                          103,
                          105,
                          116,
                          104,
                          117,
                          98,
                          46,
                          105,
                          111]},
 'ServiceUUIDs': ['FEAA'],
 'SolicitUUIDs': [],
 'Type': 'broadcast'}

Using the old Python-dbus library:
{'IncludeTxPower': False,
 'ServiceData': {'FEAA': [16,
                          8,
                          3,
                          117,
                          107,
                          66,
                          97,
                          122,
                          46,
                          103,
                          105,
                          116,
                          104,
                          117,
                          98,
                          46,
                          105,
                          111]},
 'ServiceUUIDs': ['FEAA'],
 'Type': 'broadcast'}

> > $ busctl call ukBaz.bluezero /ukBaz/bluezero/advertisement1
> > org.freedesktop.DBus.Introspectable Introspect
> > s "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object
> > Introspection 1.0//EN\"\n
> > \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n<!--
> > GDBus 2.60.4 -->\n<node>\n  <interface
> > name=\"org.freedesktop.DBus.Properties\">\n    <method name=\"Get\">\n
> >      <arg type=\"s\" name=\"interface_name\" direction=\"in\"/>\n
> > <arg type=\"s\" name=\"property_name\" direction=\"in\"/>\n      <arg
> > type=\"v\" name=\"value\" direction=\"out\"/>\n    </method>\n
> > <method name=\"GetAll\">\n      <arg type=\"s\"
> > name=\"interface_name\" direction=\"in\"/>\n      <arg type=\"a{sv}\"
> > name=\"properties\" direction=\"out\"/>\n    </method>\n    <method
> > name=\"Set\">\n      <arg type=\"s\" name=\"interface_name\"
> > direction=\"in\"/>\n      <arg type=\"s\" name=\"property_name\"
> > direction=\"in\"/>\n      <arg type=\"v\" name=\"value\"
> > direction=\"in\"/>\n    </method>\n    <signal
> > name=\"PropertiesChanged\">\n      <arg type=\"s\"
> > name=\"interface_name\"/>\n      <arg type=\"a{sv}\"
> > name=\"changed_properties\"/>\n      <arg type=\"as\"
> > name=\"invalidated_properties\"/>\n    </signal>\n  </interface>\n
> > <interface name=\"org.freedesktop.DBus.Introspectable\">\n    <method
> > name=\"Introspect\">\n      <arg type=\"s\" name=\"xml_data\"
> > direction=\"out\"/>\n    </method>\n  </interface>\n  <interface
> > name=\"org.freedesktop.DBus.Peer\">\n    <method name=\"Ping\"/>\n
> > <method name=\"GetMachineId\">\n      <arg type=\"s\"
> > name=\"machine_uuid\" direction=\"out\"/>\n    </method>\n
> > </interface>\n  <interface
> > name=\"org.freedesktop.DBus.ObjectManager\">\n    <method
> > name=\"GetManagedObjects\">\n      <arg type=\"a{oa{sa{sv}}}\"
> > name=\"object_paths_interfaces_and_properties\" direction=\"out\">\n
> >    </arg>\n    </method>\n    <signal name=\"InterfacesAdded\">\n
> > <arg type=\"o\" name=\"object_path\">\n      </arg>\n      <arg
> > type=\"a{sa{sv}}\" name=\"interfaces_and_properties\">\n      </arg>\n
> >    </signal>\n    <signal name=\"InterfacesRemoved\">\n      <arg
> > type=\"o\" name=\"object_path\">\n      </arg>\n      <arg type=\"as\"
> > name=\"interfaces\">\n      </arg>\n    </signal>\n  </interface>\n
> > <interface name=\"org.bluez.LEAdvertisement1\">\n    <annotation
> > name=\"org.freedesktop.DBus.Properties.PropertiesChanged\"
> > value=\"const\">\n    </annotation>\n    <method name=\"Release\">\n
> >    <annotation name=\"org.freedesktop.DBus.Method.NoReply\"
> > value=\"true\">\n      </annotation>\n    </method>\n    <property
> > type=\"s\" name=\"Type\" access=\"read\">\n    </property>\n
> > <property type=\"as\" name=\"ServiceUUIDs\" access=\"read\">\n
> > </property>\n    <property type=\"a{sv}\" name=\"ManufacturerData\"
> > access=\"read\">\n    </property>\n    <property type=\"as\"
> > name=\"SolicitUUIDs\" access=\"read\">\n    </property>\n    <property
> > type=\"a{sv}\" name=\"ServiceData\" access=\"read\">\n
> > </property>\n    <property type=\"b\" name=\"IncludeTxPower\"
> > access=\"read\">\n    </property>\n  </interface>\n</node>\n"
>
>
>
> --
> Luiz Augusto von Dentz

  reply	other threads:[~2019-07-18 21:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18  7:00 DBus LEAdvertisement and Python Barry Byford
2019-07-18  8:25 ` Luiz Augusto von Dentz
2019-07-18 21:04   ` Barry Byford [this message]
2019-07-20 16:44     ` Barry Byford
2019-07-24  9:37       ` Barry Byford
2019-07-24 10:44         ` Luiz Augusto von Dentz
2019-07-24 13:28           ` Barry Byford
2019-07-24 20:59           ` Barry Byford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAu3APaPaDXBNsWcCUhNF2_sM_AxiKe5B6U1xtMOU9tYwpFS2g@mail.gmail.com \
    --to=31baz66@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).