Linux bluetooth development
 help / color / mirror / Atom feed
From: Travis Griggs <travisgriggs@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: Re: Query BLE connected status?
Date: Tue, 6 Sep 2016 17:02:52 -0700	[thread overview]
Message-ID: <0176A088-7DFB-415E-9461-CB8BA391E087@gmail.com> (raw)
In-Reply-To: <CADwkJjLm5RF54MHANHYUX3cmh52V4EgHB57hrMu4oXeOA6bR3Q@mail.gmail.com>


> On Sep 6, 2016, at 1:53 PM, Tobias Svehagen =
<tobias.svehagen@gmail.com> wrote:
>=20
> Travis,
>=20
> There is a Connected property on the org.bluez.Device1 interface (see
> =
http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/device-api.txt).
> This will tell you if that specific device is connected or not. Would
> this solve your problem?

I think it would. If I could figure out how to read it. My python/dbus =
skills are very much monkey-see-monkey-do at this point. I was excited, =
because I already have a snippet that sets the =E2=80=98Alias=E2=80=99 =
of the same interface, so I thought I could just modify a little:

#!/usr/bin/env python3

import dbus
import dbus.mainloop.glib
import gi.repository.GLib as glib
import os
import sys

Adapter =3D '/org/bluez/hci0'

def main():
   dbus.mainloop.glib.DBusGMainLoop(set_as_default=3DTrue)
   bus =3D dbus.SystemBus()

   adapterProperties =3D dbus.Interface(bus.get_object('org.bluez', =
Adapter), 'org.freedesktop.DBus.Properties')
   value =3D adapterProperties.Get('org.bluez.Adapter1', 'Connected')
   print('connected', value)

   mainloop =3D glib.MainLoop()
   try:
       mainloop.run()
   except KeyboardInterrupt:
       mainloop.quit()


if __name__ =3D=3D '__main__':
   main()

Unfortunately, that doesn=E2=80=99t work. I got the following error:

root@nelson:/Pilot# ./connected=20
Traceback (most recent call last):
 File "./connected", line 28, in <module>
   main()
 File "./connected", line 17, in main
   value =3D adapterProperties.Get('org.bluez.Adapter1', 'Connected')
 File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 70, in =
__call__
   return self._proxy_method(*args, **keywords)
 File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in =
__call__
   **keywords)
 File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in =
call_blocking
   message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.InvalidArgs: =
No such property =E2=80=98Connected'

My original code had a .Set() call, but maybe I was naive in assuming =
that a .Get() would be the converse? Do I even need to do the runloop =
thing in this case?=

  reply	other threads:[~2016-09-07  0:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06 18:20 Query BLE connected status? Travis Griggs
2016-09-06 20:53 ` Tobias Svehagen
2016-09-07  0:02   ` Travis Griggs [this message]
2016-09-07  7:37     ` Tobias Svehagen
2016-09-07 21:14       ` Travis Griggs
2016-09-07 22:19         ` Barry Byford
2016-09-12 15:52           ` Travis Griggs
2016-09-12 17:49             ` StopNotify not firing? (was: Query BLE connected status?) Travis Griggs
2016-09-13 14:41               ` Luiz Augusto von Dentz
2016-09-12 19:37             ` Query BLE connected status? Barry Byford
2016-09-07 21:23       ` 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=0176A088-7DFB-415E-9461-CB8BA391E087@gmail.com \
    --to=travisgriggs@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