Re: Query BLE connected status?

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

 



> On Sep 6, 2016, at 1:53 PM, Tobias Svehagen <tobias.svehagen@xxxxxxxxx> wrote:
> 
> Travis,
> 
> 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 ‘Alias’ 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 = '/org/bluez/hci0'

def main():
   dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
   bus = dbus.SystemBus()

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

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


if __name__ == '__main__':
   main()

Unfortunately, that doesn’t work. I got the following error:

root@nelson:/Pilot# ./connected 
Traceback (most recent call last):
 File "./connected", line 28, in <module>
   main()
 File "./connected", line 17, in main
   value = 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 ‘Connected'

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?--
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