2009-05-01 14:41:11

by Ilya Rubtsov

[permalink] [raw]
Subject: DeviceFound and DeviceDisappeared signals

Hi! I have some troubles with using DeviceFound and DeviceDisappeared
signals. I use simple test script: http://pastebin.com/m45de7894 . There
are two cases: if I use software inquire scheduler and if I use hardware
one.

Hardware scheduler. Bluetooth module in phone is on and I run script:
---
ilya@ilya-laptop:~/blue$ python fodis.py
Fri May 1 16:36:44 2009 Signal: DeviceFound 00:16:B8:53:5F:17
---
And no more signals. Then I wait 2 mins, turn off Bluetooth in phone and
wait 2 more mins, but no one signal is emitted.
I don't know if DeviceFound signal should be emitted on every inquire,
maybe not. But I'm sure DeviceDisappeared signal should be emitted at
least once :)


Software scheduler ("DiscoverSchedulerInterval = 1" at main.conf).
Bluetooth module in phone is on and I run script:
---
ilya@ilya-laptop:~/blue$ python fodis.py
Fri May 1 16:43:52 2009 Signal: DeviceFound 00:16:B8:53:5F:17
Fri May 1 16:44:11 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
Fri May 1 16:44:14 2009 Signal: DeviceFound 00:16:B8:53:5F:17
Fri May 1 16:44:34 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
Fri May 1 16:44:37 2009 Signal: DeviceFound 00:16:B8:53:5F:17
Fri May 1 16:44:57 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
Fri May 1 16:45:00 2009 Signal: DeviceFound 00:16:B8:53:5F:17
Fri May 1 16:45:20 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
Fri May 1 16:45:23 2009 Signal: DeviceFound 00:16:B8:53:5F:17
### At this moment I turn off Bluetooth in phone
Fri May 1 16:45:43 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
---

So, both signals was emitted on every inquiry. I think this is wrong
behavior. Am I right?
And DeviceDisappeared was emitted once after remote device was actually
turned off. That's good :)


2009-05-02 23:31:51

by Ilya Rubtsov

[permalink] [raw]
Subject: Re: DeviceFound and DeviceDisappeared signals

Luiz Augusto von Dentz пишет:
> Hi,
>
> On Fri, May 1, 2009 at 3:14 PM, Ilya Rubtsov <[email protected]> wrote:
>
>> I just would add that with hardware scheduler DeviceDisappeared signal works
>> fine if there two remote devices in the field, and doesn't work if there is
>> only one remote device:
>>
>> ---
>> # Now there only 00:16:B8:53:5F:17 is turned on
>> Fri May 1 20:36:48 2009 Signal: DeviceFound 00:16:B8:53:5F:17
>> # Now I turn off 00:16:B8:53:5F:17 and wait, but no signal being emitted...
>> # So, I turn on 00:02:76:16:F6:8F
>> Fri May 1 20:38:52 2009 Signal: DeviceFound 00:02:76:16:F6:8F
>> Fri May 1 20:39:01 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
>>
>
> You may just have to wait longer to get the DeviceDisappeared signal
> the fact the you turned off the device doesn't mean it will instantly
> disappear it may happen that bluetoothd is idle waiting for scheduler
> to start another discovery round (use Discovering property to check
> that.). I will double check if there is some logic problem while
> emitting DeviceDisappeared but I remember fixing it myself last time
> and have no complaining since then.
>
>
I connected to PropertyChanged signal:

# device (bluetooth module in phone) is turned on. I run script
Sun May 3 02:55:00 2009 Signal: PropertyChanged Discovering 1
Sun May 3 02:55:03 2009 Signal: DeviceFound 00:16:B8:53:5F:17 kkk -45
Sun May 3 02:55:10 2009 Signal: PropertyChanged Discovering 0
Sun May 3 02:55:21 2009 Signal: PropertyChanged Discovering 1
Sun May 3 02:55:31 2009 Signal: PropertyChanged Discovering 0
Sun May 3 02:55:50 2009 Signal: PropertyChanged Discovering 1
Sun May 3 02:56:00 2009 Signal: PropertyChanged Discovering 0
# turn device off
# And then no signal. At all. You even may go and drink cup of coffee or
smth :) There won't be any signal. But LED on my dongle indicates mode
changing: waiting (blinking), inquiry (permanent light), waiting, inquiry...
# turn device on
Sun May 3 02:59:39 2009 Signal: PropertyChanged Discovering 0
Sun May 3 02:59:55 2009 Signal: PropertyChanged Discovering 1
Sun May 3 03:00:05 2009 Signal: PropertyChanged Discovering 0
Sun May 3 03:00:23 2009 Signal: PropertyChanged Discovering 1
Sun May 3 03:00:30 2009 Signal: PropertyChanged Discovering 0
Sun May 3 03:00:46 2009 Signal: PropertyChanged Discovering 1
Sun May 3 03:00:54 2009 Signal: PropertyChanged Discovering 0
Sun May 3 03:01:08 2009 Signal: PropertyChanged Discovering 1
Sun May 3 03:01:15 2009 Signal: PropertyChanged Discovering 0
Sun May 3 03:01:31 2009 Signal: PropertyChanged Discovering 1
Sun May 3 03:01:38 2009 Signal: PropertyChanged Discovering 0
Sun May 3 03:01:49 2009 Signal: PropertyChanged Discovering 1
Sun May 3 03:01:59 2009 Signal: PropertyChanged Discovering 0
Sun May 3 03:02:22 2009 Signal: PropertyChanged Discovering 1
Sun May 3 03:02:30 2009 Signal: PropertyChanged Discovering 0
Sun May 3 03:02:44 2009 Signal: PropertyChanged Discovering 1
# turn device off
Sun May 3 03:02:51 2009 Signal: PropertyChanged Discovering 0
# and then silent...


BlueZ 4.36
Script source: http://pastebin.com/m26afe2e2
Hardware scheduler


2009-05-02 22:20:55

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: DeviceFound and DeviceDisappeared signals

Hi,

On Fri, May 1, 2009 at 3:14 PM, Ilya Rubtsov <[email protected]> wrote:
> I just would add that with hardware scheduler DeviceDisappeared signal works
> fine if there two remote devices in the field, and doesn't work if there is
> only one remote device:
>
> ---
> # Now there only 00:16:B8:53:5F:17 is turned on
> Fri May ?1 20:36:48 2009 Signal: DeviceFound 00:16:B8:53:5F:17
> # Now I turn off 00:16:B8:53:5F:17 and wait, but no signal being emitted...
> # So, I turn on 00:02:76:16:F6:8F
> Fri May ?1 20:38:52 2009 Signal: DeviceFound 00:02:76:16:F6:8F
> Fri May ?1 20:39:01 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17

You may just have to wait longer to get the DeviceDisappeared signal
the fact the you turned off the device doesn't mean it will instantly
disappear it may happen that bluetoothd is idle waiting for scheduler
to start another discovery round (use Discovering property to check
that.). I will double check if there is some logic problem while
emitting DeviceDisappeared but I remember fixing it myself last time
and have no complaining since then.

--
Luiz Augusto von Dentz
Engenheiro de Computa??o

2009-05-01 18:14:48

by Ilya Rubtsov

[permalink] [raw]
Subject: Re: DeviceFound and DeviceDisappeared signals

I just would add that with hardware scheduler DeviceDisappeared signal
works fine if there two remote devices in the field, and doesn't work if
there is only one remote device:

---
# Now there only 00:16:B8:53:5F:17 is turned on
Fri May 1 20:36:48 2009 Signal: DeviceFound 00:16:B8:53:5F:17
# Now I turn off 00:16:B8:53:5F:17 and wait, but no signal being emitted...
# So, I turn on 00:02:76:16:F6:8F
Fri May 1 20:38:52 2009 Signal: DeviceFound 00:02:76:16:F6:8F
Fri May 1 20:39:01 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
# So new device appearing causes emitting DeviceDisappeared signal for
device that was turned off some time ago
---

P.S. I use BlueZ 4.36

Ilya Rubtsov пишет:
> Hi! I have some troubles with using DeviceFound and DeviceDisappeared
> signals. I use simple test script: http://pastebin.com/m45de7894 .
> There are two cases: if I use software inquire scheduler and if I use
> hardware one.
>
> Hardware scheduler. Bluetooth module in phone is on and I run script:
> ---
> ilya@ilya-laptop:~/blue$ python fodis.py
> Fri May 1 16:36:44 2009 Signal: DeviceFound 00:16:B8:53:5F:17
> ---
> And no more signals. Then I wait 2 mins, turn off Bluetooth in phone
> and wait 2 more mins, but no one signal is emitted.
> I don't know if DeviceFound signal should be emitted on every inquire,
> maybe not. But I'm sure DeviceDisappeared signal should be emitted at
> least once :)
>
>
> Software scheduler ("DiscoverSchedulerInterval = 1" at main.conf).
> Bluetooth module in phone is on and I run script:
> ---
> ilya@ilya-laptop:~/blue$ python fodis.py
> Fri May 1 16:43:52 2009 Signal: DeviceFound 00:16:B8:53:5F:17
> Fri May 1 16:44:11 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
> Fri May 1 16:44:14 2009 Signal: DeviceFound 00:16:B8:53:5F:17
> Fri May 1 16:44:34 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
> Fri May 1 16:44:37 2009 Signal: DeviceFound 00:16:B8:53:5F:17
> Fri May 1 16:44:57 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
> Fri May 1 16:45:00 2009 Signal: DeviceFound 00:16:B8:53:5F:17
> Fri May 1 16:45:20 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
> Fri May 1 16:45:23 2009 Signal: DeviceFound 00:16:B8:53:5F:17
> ### At this moment I turn off Bluetooth in phone
> Fri May 1 16:45:43 2009 Signal: DeviceDisappeared 00:16:B8:53:5F:17
> ---
>
> So, both signals was emitted on every inquiry. I think this is wrong
> behavior. Am I right?
> And DeviceDisappeared was emitted once after remote device was
> actually turned off. That's good :)