Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5050497ybi; Sat, 20 Jul 2019 11:46:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeFIH01lpFs08YStBELTuu9/FYeq8u7Y+8JVy788dkd3RDf8WrCGNUKqpGoNeMnSXGiiFm X-Received: by 2002:a63:2364:: with SMTP id u36mr59243300pgm.449.1563648408726; Sat, 20 Jul 2019 11:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563648408; cv=none; d=google.com; s=arc-20160816; b=gL8l+w3I8yLInT/GEAUi4lUT2oufoWOvE/K3s+Z/qCnT9OeO+Re6EHhtpxI8i0BU9a dkXJYWN+DPoptG8lz95vqZausSNixN6+F45Ukzrk9UumguxSfyZ+isy2xaZq9vRZ+Cma TQ3Z7d8OGb1LEQsHgNt3oezSxkLNmgwyNsTqmfrx/RCRqpWKOI9BFd4nfKPMx3P+Yzkc ukDljU07Z2+wLYxeWc8+P9smRiHMQHGKgSxtTGaSE0k13SzxBvnjOss/XsdsUTXlJdfN IAVZCQqj70HvyEYKD6NbCS/oFv0/LoSE8lwh6wlfRBzS/Kj+wMluOzHc8KhDrs8Um+Jn kt1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ozMJJGGFT04CFhErhDJLDyz3XSUZm9/jZbTSk0zRY5E=; b=SSBEQ9xjtCKp+ti7hRbIsf2PAToffStsA69eDB6goq6cp928FiOq934y71tFETKPK0 uVHrgaBPK4I3t0HCxiLwaqRLYvEJLz6+udRetNtkMMN+cYbI5PWjZOomjCV8++snpY/N pc6Yqmrr6o0QoaRcAQA4puDfIGxpJmeWZvXdqp2hw51kvKQd7aeTlrsnRWwN3B8pa3nD wamvsAyUj2M6M80fRNWh0nXr+sH72qmJg2u1O3zstMmu4sHEl4jYzkB74T7Xd7iLk8e6 JYkNFTDealJA97hgxNw0ang+1CWMc5TaELip6sBCS8K7kroehXZkI4XhVSBBaOPxRL1z j0Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gdpc3nTH; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k33si5401734pgi.563.2019.07.20.11.46.34; Sat, 20 Jul 2019 11:46:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gdpc3nTH; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726431AbfGTQo2 (ORCPT + 99 others); Sat, 20 Jul 2019 12:44:28 -0400 Received: from mail-yb1-f178.google.com ([209.85.219.178]:38405 "EHLO mail-yb1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbfGTQo2 (ORCPT ); Sat, 20 Jul 2019 12:44:28 -0400 Received: by mail-yb1-f178.google.com with SMTP id j199so13629484ybg.5 for ; Sat, 20 Jul 2019 09:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=ozMJJGGFT04CFhErhDJLDyz3XSUZm9/jZbTSk0zRY5E=; b=gdpc3nTH1gdqgWp5ytVc4Ctm3xH2XWS66Xl3R0v8NIy428uVw+X2FwAOFPcC1Rhcc+ ytRob+M24arfwhttDULbQOYx/E8lmHp01KcWOG1atf0whusPqMbWfj91Fq0CdirTMjjx AOj6VNaRno0Wsh8pbX1T6HPpl6c503rkmjFMpyeyBdzdxjuGDRX7bxxwVQPOtgN7gw6z +eUHT4UxLyubnZaahBQ2xVBeDlrYrEE04cOCdFNJqRzGA6I/p8pnLe8XqVDKGftkf8G8 0rKF4/4N4SppjrzPhKQpkB+zldyPYDTnfOtU+s3ZJqFwS4dAnh7p+SiMid8ZgipD5HRW FMkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=ozMJJGGFT04CFhErhDJLDyz3XSUZm9/jZbTSk0zRY5E=; b=tXjE3f6KnSv8qZBEZmlKm0je7lDeCx7vxaSVS1RVwcgu7OqBVGZj9VDXod8/d09+7+ 9DWRnNVBQUXB4Zp35h6ABjO33+fClq+gszze09j4mBxCddaA9HKApJyduCitJ2Yv4LS5 rmAiYyPZXdlnfVdjmbPpu5t//I5fHhhmz5rOEpsT8JLeIy+xiSfDATxnMfKLrdcOfOOX Mw8sSUkgvEgImfYt1hXHnCCbln2KqNrVx1qUswECovK1ByW0zawZbhvIisOFQ7lRu6GA VNcjFkZnB3/VAB+35X36S0q6Nc6/PwdUnDJBlXKuDIecUHiZJ5OlHWfvNO682l2MjW6q 0Www== X-Gm-Message-State: APjAAAXGzWL5sa8oPg5/cS7SRyCwJTIwp0l/XQKl6CMWermqJT6Hz4jp 7HtFkZpdIhhbO1dVR/DBrMA1K5QCBcei8nZEpPmRBtVf X-Received: by 2002:a25:6756:: with SMTP id b83mr36238010ybc.37.1563641067274; Sat, 20 Jul 2019 09:44:27 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Barry Byford <31baz66@gmail.com> Date: Sat, 20 Jul 2019 17:44:15 +0100 Message-ID: Subject: Re: DBus LEAdvertisement and Python To: Bluez mailing list Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hello, I have done a little more investigation on this. The difference in behaviour between the working library and the failing library comes down to this line in the BlueZ source. https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/client.c#n720 which is called from: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/advertising.c#n1020 It appears g_hash_table_lookup is returning NULL. I am not familiar with C and have been doing this investigation with fprintf statements. I don't know how to get the values of "proxy->prop_list" and "name". Does anyone know how I can print these values out? Even better would be, if someone could point me at to what this relates to in the Python LE Advertisement setup through DBus. I've looked up the g_hash_table_lookup command: https://developer.gnome.org/glib/stable/glib-Hash-Tables.html#g-hash-table-lookup but this hasn't helped me. Thanks, Barry On Thu, 18 Jul 2019 at 22:04, Barry Byford <31baz66@gmail.com> wrote: > > 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 > 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 > > > Interface org.bluez.GattProfile1 > > > Object path > > > 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 " > > Introspection 1.0//EN\"\n > > > \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n\n\n > > name=\"org.freedesktop.DBus.Properties\">\n \n > > > \n > > > \n > > type=\"v\" name=\"value\" direction=\"out\"/>\n \n > > > \n > > name=\"interface_name\" direction=\"in\"/>\n > > name=\"properties\" direction=\"out\"/>\n \n > > name=\"Set\">\n > > direction=\"in\"/>\n > > direction=\"in\"/>\n > > direction=\"in\"/>\n \n > > name=\"PropertiesChanged\">\n > > name=\"interface_name\"/>\n > > name=\"changed_properties\"/>\n > > name=\"invalidated_properties\"/>\n \n \n > > > \n > > name=\"Introspect\">\n > > direction=\"out\"/>\n \n \n > > name=\"org.freedesktop.DBus.Peer\">\n \n > > > \n > > name=\"machine_uuid\" direction=\"out\"/>\n \n > > > \n > > name=\"org.freedesktop.DBus.ObjectManager\">\n > > name=\"GetManagedObjects\">\n > > name=\"object_paths_interfaces_and_properties\" direction=\"out\">\n > > > \n \n \n > > > \n \n > > type=\"a{sa{sv}}\" name=\"interfaces_and_properties\">\n \n > > > \n \n > > type=\"o\" name=\"object_path\">\n \n > > name=\"interfaces\">\n \n \n \n > > > \n > > name=\"org.freedesktop.DBus.Properties.PropertiesChanged\" > > > value=\"const\">\n \n \n > > > > > value=\"true\">\n \n \n > > type=\"s\" name=\"Type\" access=\"read\">\n \n > > > \n > > > \n > > access=\"read\">\n \n > > name=\"SolicitUUIDs\" access=\"read\">\n \n > > type=\"a{sv}\" name=\"ServiceData\" access=\"read\">\n > > > \n > > access=\"read\">\n \n \n\n" > > > > > > > > -- > > Luiz Augusto von Dentz