public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] Cached friendly names never updated when changed
@ 2008-03-26 16:56 Pierre-Yves Paulus
  2008-03-26 17:05 ` Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Pierre-Yves Paulus @ 2008-03-26 16:56 UTC (permalink / raw)
  To: bluez-devel

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

Hello,

It seems that once a friendly name has been cached to 
/var/lib/bluetooth/*/names, RemoteNameUpdated signals contain this 
cached name forever, and user is never informed of a name change unless 
those "names" files are deleted.

It can be easily tested using the small python program attached. Just 
start it and play around with your device's friendly name, and with 
/var/lib/bluetooth/*/names (for example simply delete it).

So is there a way to get notified when a device's name has actually 
changed? Maybe I didn't wait long enough? According to the signal's name 
("RemoteNameUpdated"), I would expect to be notified when the name 
actually change.

Best Regards,
Pierre-Yves

[-- Attachment #2: namesresolver.py --]
[-- Type: text/x-python, Size: 731 bytes --]

#!/usr/bin/python

import dbus
import dbus.glib
import gobject

def rem_dev_name_signal(address, name):
        print 'Signal: RemoteNameUpdated(%s, %s)' % (address, name)

def disc_completed_signal():
        adapter.DiscoverDevices()

bus = dbus.SystemBus();

bus.add_signal_receiver(rem_dev_name_signal, 'RemoteNameUpdated', 'org.bluez.Adapter', 'org.bluez', '/org/bluez/hci0')
bus.add_signal_receiver(disc_completed_signal, 'DiscoveryCompleted', 'org.bluez.Adapter', 'org.bluez', '/org/bluez/hci0')

obj = bus.get_object('org.bluez', '/org/bluez/hci0')
adapter = dbus.Interface(obj, 'org.bluez.Adapter')

adapter.DiscoverDevices()

gobject.threads_init()
dbus.glib.init_threads()
main_loop = gobject.MainLoop()
main_loop.run()

[-- Attachment #3: Type: text/plain, Size: 278 bytes --]

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bluez-devel] Cached friendly names never updated when changed
  2008-03-26 16:56 [Bluez-devel] Cached friendly names never updated when changed Pierre-Yves Paulus
@ 2008-03-26 17:05 ` Marcel Holtmann
  2008-03-27 13:11   ` Pierre-Yves Paulus
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2008-03-26 17:05 UTC (permalink / raw)
  To: BlueZ development

Hi Pierre-Yves,

> It seems that once a friendly name has been cached to /var/lib/ 
> bluetooth/*/names, RemoteNameUpdated signals contain this cached  
> name forever, and user is never informed of a name change unless  
> those "names" files are deleted.

the names are never updated once retrieved. At least not via an  
inquiry run. If you connect to a remote device, it will update the  
name. Another option is Extended Inquiry support if you have the  
hardware for it.

The reason behind this is that the remote name operation is too  
expensive if you don't have an ACL link between two devices. And a lot  
of times the name doesn't change so often or it is unimportant anyway.

Regards

Marcel


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bluez-devel] Cached friendly names never updated when changed
  2008-03-26 17:05 ` Marcel Holtmann
@ 2008-03-27 13:11   ` Pierre-Yves Paulus
  2008-03-27 15:06     ` Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Pierre-Yves Paulus @ 2008-03-27 13:11 UTC (permalink / raw)
  To: BlueZ development

Hi Marcel,

Thanks for your fast answer.

>> It seems that once a friendly name has been cached to /var/lib/ 
>> bluetooth/*/names, RemoteNameUpdated signals contain this cached  
>> name forever, and user is never informed of a name change unless  
>> those "names" files are deleted.
> 
> the names are never updated once retrieved. At least not via an  
> inquiry run. If you connect to a remote device, it will update the  
> name. Another option is Extended Inquiry support if you have the  
> hardware for it.
> 
> The reason behind this is that the remote name operation is too  
> expensive if you don't have an ACL link between two devices. And a lot  
> of times the name doesn't change so often or it is unimportant anyway.

It makes a lot of sense, at least for the python example I submitted, 
which was only performing calls to "DiscoverDevices".

But I've encountered another situation, where bluez' caching behaviour 
produces some nonsense. I have no simple test application to provide, 
but it is quite simple to explain and understand.

I've an application which performs a continuous inquiry (eg when it gets 
DiscoveryCompleted, it calls DiscoverDevices() and so on). In the 
meantime, this application does also perform sdp extraction and rfcomm 
connections to the detected devices. Here is a record of all 
RemoteNameUpdated signals from a particular device:

I delete /var/lib/bluetooth/*/names, set my device's name to "Name 1", 
and start my application

RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1

So far so good. At this point I set my device's name to "Name2": I start 
to get mixed values (I understand that "Name1" are sent out from the 
discovery, and thus use the cached value as you explainded above, and 
"Name2" are from the other operations, which are actually getting the 
current name, because they do connect to the device)

RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name1
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name1

At this point I delete /var/lib/bluetooth/*/names. As cache is recreated 
with the current value (Name2) everything looks good again

RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2

At this point, I change my device's name to "Name3". Things get mixed up 
again.

RemoteNameUpdated signal received: 006057BB4D92 - Name3
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name3
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name3
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name2
RemoteNameUpdated signal received: 006057BB4D92 - Name3
RemoteNameUpdated signal received: 006057BB4D92 - Name2

So, shouldn't the cached value get updated when bluez gets a different 
name later on?

Best Regards,
Pierre-Yves

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bluez-devel] Cached friendly names never updated when changed
  2008-03-27 13:11   ` Pierre-Yves Paulus
@ 2008-03-27 15:06     ` Marcel Holtmann
  2008-03-27 15:24       ` Pierre-Yves Paulus
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Holtmann @ 2008-03-27 15:06 UTC (permalink / raw)
  To: BlueZ development

Hi Pierre-Yves,

>>> It seems that once a friendly name has been cached to /var/lib/
>>> bluetooth/*/names, RemoteNameUpdated signals contain this cached
>>> name forever, and user is never informed of a name change unless
>>> those "names" files are deleted.
>>
>> the names are never updated once retrieved. At least not via an
>> inquiry run. If you connect to a remote device, it will update the
>> name. Another option is Extended Inquiry support if you have the
>> hardware for it.
>>
>> The reason behind this is that the remote name operation is too
>> expensive if you don't have an ACL link between two devices. And a  
>> lot
>> of times the name doesn't change so often or it is unimportant  
>> anyway.
>
> It makes a lot of sense, at least for the python example I submitted,
> which was only performing calls to "DiscoverDevices".
>
> But I've encountered another situation, where bluez' caching behaviour
> produces some nonsense. I have no simple test application to provide,
> but it is quite simple to explain and understand.
>
> I've an application which performs a continuous inquiry (eg when it  
> gets
> DiscoveryCompleted, it calls DiscoverDevices() and so on). In the
> meantime, this application does also perform sdp extraction and rfcomm
> connections to the detected devices. Here is a record of all
> RemoteNameUpdated signals from a particular device:
>
> I delete /var/lib/bluetooth/*/names, set my device's name to "Name 1",
> and start my application
>
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
>
> So far so good. At this point I set my device's name to "Name2": I  
> start
> to get mixed values (I understand that "Name1" are sent out from the
> discovery, and thus use the cached value as you explainded above, and
> "Name2" are from the other operations, which are actually getting the
> current name, because they do connect to the device)
>
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name1
>
> At this point I delete /var/lib/bluetooth/*/names. As cache is  
> recreated
> with the current value (Name2) everything looks good again
>
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
>
> At this point, I change my device's name to "Name3". Things get  
> mixed up
> again.
>
> RemoteNameUpdated signal received: 006057BB4D92 - Name3
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name3
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name3
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
> RemoteNameUpdated signal received: 006057BB4D92 - Name3
> RemoteNameUpdated signal received: 006057BB4D92 - Name2
>
> So, shouldn't the cached value get updated when bluez gets a different
> name later on?

this indeed looks like a bug. Seems like the new name is not written  
to disk. Can you re-produce this with bluez-utils-3.29?

Regards

Marcel


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bluez-devel] Cached friendly names never updated when changed
  2008-03-27 15:06     ` Marcel Holtmann
@ 2008-03-27 15:24       ` Pierre-Yves Paulus
  2008-03-27 15:45         ` Marcel Holtmann
  0 siblings, 1 reply; 6+ messages in thread
From: Pierre-Yves Paulus @ 2008-03-27 15:24 UTC (permalink / raw)
  To: BlueZ development

Hi Marcel,

> this indeed looks like a bug. Seems like the new name is not written  
> to disk. Can you re-produce this with bluez-utils-3.29?

Ok, I'll upgrade this box to 3.29 and try to reproduce it. FYI this 
output comes from a box running v3.28.

Regards,
Pierre-Yves

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Bluez-devel] Cached friendly names never updated when changed
  2008-03-27 15:24       ` Pierre-Yves Paulus
@ 2008-03-27 15:45         ` Marcel Holtmann
  0 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2008-03-27 15:45 UTC (permalink / raw)
  To: BlueZ development

Hi Pierre-Yves,

>> this indeed looks like a bug. Seems like the new name is not written
>> to disk. Can you re-produce this with bluez-utils-3.29?
>
> Ok, I'll upgrade this box to 3.29 and try to reproduce it. FYI this
> output comes from a box running v3.28.
\x7f
my assumption is that it still is broken then. I don't recall changes  
in that area.

Regards

Marcel


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-03-27 15:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-26 16:56 [Bluez-devel] Cached friendly names never updated when changed Pierre-Yves Paulus
2008-03-26 17:05 ` Marcel Holtmann
2008-03-27 13:11   ` Pierre-Yves Paulus
2008-03-27 15:06     ` Marcel Holtmann
2008-03-27 15:24       ` Pierre-Yves Paulus
2008-03-27 15:45         ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox