* app doesn't recieve signal DeviceDisappeared
@ 2009-01-11 3:52 Ilya Rubtsov
2009-01-18 15:29 ` Marcel Holtmann
0 siblings, 1 reply; 6+ messages in thread
From: Ilya Rubtsov @ 2009-01-11 3:52 UTC (permalink / raw)
To: linux-bluetooth
Hi!
Excuse me for my English.
I need help with using Bluez and dbus. Here is my small program in Python:
------------
import dbus
import dbus.glib
import gobject
def device_found(addr, values):
print 'Found:', addr
def device_disapp(addr):
print 'Disappeared:', addr
bus = dbus.SystemBus()
obj = bus.get_object('org.bluez', '/org/bluez/hci0')
adapter = dbus.Interface(obj, 'org.bluez.Adapter')
adapter.connect_to_signal('DeviceFound', device_found)
adapter.connect_to_signal('DeviceDisappeared', device_disapp)
adapter.StartDiscovery()
gobject.threads_init()
dbus.glib.init_threads()
main_loop = gobject.MainLoop()
main_loop.run()
-----------
And I have problem with DeviceDisappeared signal. I run program, then it
finds my bluetooth enabled phone and prints it's address every ~10
seconds (periodical discovery). Than I turn off bluetooth in phone, but
Bluez doesn't send signal 'DeviceDisappeared', so program doesn't print
"Disappeared: ...". What's wrong in my program? Do I have
misunderstanding of Bluez Adapter API?
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: app doesn't recieve signal DeviceDisappeared 2009-01-11 3:52 app doesn't recieve signal DeviceDisappeared Ilya Rubtsov @ 2009-01-18 15:29 ` Marcel Holtmann 2009-01-18 21:17 ` Ilya Rubtsov 0 siblings, 1 reply; 6+ messages in thread From: Marcel Holtmann @ 2009-01-18 15:29 UTC (permalink / raw) To: Ilya Rubtsov; +Cc: linux-bluetooth Hi Ilya, > I need help with using Bluez and dbus. Here is my small program in Python: > > ------------ > > import dbus > import dbus.glib > import gobject > > def device_found(addr, values): > print 'Found:', addr > > def device_disapp(addr): > print 'Disappeared:', addr > > bus = dbus.SystemBus() > obj = bus.get_object('org.bluez', '/org/bluez/hci0') > adapter = dbus.Interface(obj, 'org.bluez.Adapter') > adapter.connect_to_signal('DeviceFound', device_found) > adapter.connect_to_signal('DeviceDisappeared', device_disapp) > > adapter.StartDiscovery() > > gobject.threads_init() > dbus.glib.init_threads() > main_loop = gobject.MainLoop() > main_loop.run() > > > ----------- > > And I have problem with DeviceDisappeared signal. I run program, then it > finds my bluetooth enabled phone and prints it's address every ~10 > seconds (periodical discovery). Than I turn off bluetooth in phone, but > Bluez doesn't send signal 'DeviceDisappeared', so program doesn't print > "Disappeared: ...". What's wrong in my program? Do I have > misunderstanding of Bluez Adapter API? this might be a bug. Not many applications are actually making full use of the DeviceDisappeared signal. Please run dbus-monitor and check if it is really not present. On another note, you can _NOT_ hardcode /org/bluez/hci0 path in your apps. Nowadays they are totally random. Use FindAdapter() instead. Regards Marcel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: app doesn't recieve signal DeviceDisappeared 2009-01-18 15:29 ` Marcel Holtmann @ 2009-01-18 21:17 ` Ilya Rubtsov 2009-01-19 19:52 ` Tom Patzig 0 siblings, 1 reply; 6+ messages in thread From: Ilya Rubtsov @ 2009-01-18 21:17 UTC (permalink / raw) To: Marcel Holtmann; +Cc: linux-bluetooth Marcel Holtmann пишет: > Hi Ilya, > > >> I need help with using Bluez and dbus. Here is my small program in Python: >> >> ------------ >> >> import dbus >> import dbus.glib >> import gobject >> >> def device_found(addr, values): >> print 'Found:', addr >> >> def device_disapp(addr): >> print 'Disappeared:', addr >> >> bus = dbus.SystemBus() >> obj = bus.get_object('org.bluez', '/org/bluez/hci0') >> adapter = dbus.Interface(obj, 'org.bluez.Adapter') >> adapter.connect_to_signal('DeviceFound', device_found) >> adapter.connect_to_signal('DeviceDisappeared', device_disapp) >> >> adapter.StartDiscovery() >> >> gobject.threads_init() >> dbus.glib.init_threads() >> main_loop = gobject.MainLoop() >> main_loop.run() >> >> >> ----------- >> >> And I have problem with DeviceDisappeared signal. I run program, then it >> finds my bluetooth enabled phone and prints it's address every ~10 >> seconds (periodical discovery). Than I turn off bluetooth in phone, but >> Bluez doesn't send signal 'DeviceDisappeared', so program doesn't print >> "Disappeared: ...". What's wrong in my program? Do I have >> misunderstanding of Bluez Adapter API? >> > > this might be a bug. Not many applications are actually making full use > of the DeviceDisappeared signal. Please run dbus-monitor and check if it > is really not present. > I run 'dbus-monitor --system'. Now I'm sure there are no DeviceDisappeared signal. Besides, I found that the adapter's Discovering property changes to True only _right before_ any device is found. If there are no devices in the field, this property will be False permanently. I use BlueZ 4.12. I understand that before reporting any bug I should update my system with the lastest versions of packages, so if this bug was fixed between 4.12 an current 4.27 version - excuse me and sorry for disturbing. > On another note, you can _NOT_ hardcode /org/bluez/hci0 path in your > apps. Nowadays they are totally random. Use FindAdapter() instead. > > Now I use this method instead of hardcoding paths. Thanks! ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: app doesn't recieve signal DeviceDisappeared 2009-01-18 21:17 ` Ilya Rubtsov @ 2009-01-19 19:52 ` Tom Patzig 2009-01-23 22:11 ` Luiz Augusto von Dentz 0 siblings, 1 reply; 6+ messages in thread From: Tom Patzig @ 2009-01-19 19:52 UTC (permalink / raw) To: Ilya Rubtsov; +Cc: Marcel Holtmann, linux-bluetooth Hi, >> this might be a bug. Not many applications are actually making full use >> of the DeviceDisappeared signal. Please run dbus-monitor and check if it >> is really not present. I also recognized, that the signal DeviceDisappeared never gets thrown. I need this Signal for KBlueLock (Screen lock, when your BT device disappeares) Right now i have located the problem a little deeper and did some tests. I am using bluez-4.27 and use the test-discovery script in the test directory. I expanded the testscript, to also listen for the DeviceDisappeared Signals. With a normal discovery, the signal gets never thrown (dbus-monitor). And the curious thing is, that the 'Discovering' value always switches between true and false ... so the discovery gets enabled and disabled automatically. But jhe told me, this is intended to provide a PeriodicDiscovery. In adapter.c there is a function 'void adapter_set_state(struct btd_adapter *adapter, int state)'. This function anyhow clears the List with out of reach (oor) devices, depending on the discovery state. If i comment out this if clause 'if (!discov_active && adapter->oor_devices)' to not free the oor device list, the Signal gets thrown properly. It gets thrown only once and the list of oor devices is also freed after that (dont know where). So my guess is, that the 'discov_active' boolean is set wrong (?), so that this if clause is reached, but it should not. This variable gets set depending on macros PERIODIC_INQUIRY and STD_INQUIRY. What are these ? So maybe the state is set wrong, but i do not know what the state should be. Also strange is, that this DeviceDisappeared signal (with commented out freeing of the oor list) only works, if more than one devices are in the area. Because of the automatic stop/start of the 'Discovering' value. If your one and only device gets disappeared the 'Discovering' value switches to false and never starts searching again ( so it does not recognize, that the device disappeared). The Discovery starts again, when you device is visible again ... I hope this helps, to find the problem. I would also fix it, but i do not know which discovery state must be set and which not, and when the oor list has to be freed and when not. Regards, Tom ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: app doesn't recieve signal DeviceDisappeared 2009-01-19 19:52 ` Tom Patzig @ 2009-01-23 22:11 ` Luiz Augusto von Dentz 2009-01-26 13:57 ` Tom Patzig 0 siblings, 1 reply; 6+ messages in thread From: Luiz Augusto von Dentz @ 2009-01-23 22:11 UTC (permalink / raw) To: tpatzig; +Cc: Ilya Rubtsov, Marcel Holtmann, linux-bluetooth Hi Tom, It should've been fixed now. Note that you only got those signals while a discovery session is active (someone called Adapter.StartDiscovery()). --=20 Luiz Augusto von Dentz Engenheiro de Computa=E7=E3o ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: app doesn't recieve signal DeviceDisappeared 2009-01-23 22:11 ` Luiz Augusto von Dentz @ 2009-01-26 13:57 ` Tom Patzig 0 siblings, 0 replies; 6+ messages in thread From: Tom Patzig @ 2009-01-26 13:57 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: linux-bluetooth Hi, > It should've been fixed now. Note that you only got those signals > while a discovery session is active (someone called > Adapter.StartDiscovery()). > Thanks a lot. Works great. Now i just need to wait for the next bluez release, to make use of it in KBlueLock :) Tom ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-01-26 13:57 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-01-11 3:52 app doesn't recieve signal DeviceDisappeared Ilya Rubtsov 2009-01-18 15:29 ` Marcel Holtmann 2009-01-18 21:17 ` Ilya Rubtsov 2009-01-19 19:52 ` Tom Patzig 2009-01-23 22:11 ` Luiz Augusto von Dentz 2009-01-26 13:57 ` Tom Patzig
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox