* [Bluez-devel] SDP limiting connections?
@ 2008-02-06 7:29 Pooyan McSporran
2008-02-06 9:21 ` Marcel Holtmann
0 siblings, 1 reply; 3+ messages in thread
From: Pooyan McSporran @ 2008-02-06 7:29 UTC (permalink / raw)
To: BlueZ development
I'm having a strange problem with a BlueZ application.
My application advertises a service via SDP (using dbus etc).
Bluetooth clients scan the area for computers providing this service,
and then connect via SPP to my application, and can then exchange
data. The connections are handled in the normal socket/bind/listen
method, each connection forks a thread to handle that connection.
(Using BTPROTO_RFCOMM on the socket)
This is working fine, but with one significant problem. If we have no
connections, clients can scan and connect without problems. If there
is one current connection, this is still the case. But if there are
two current connections, then no clients can see the service via SDP.
If another machine tries to (eg) do "sdptool browse <bdaddr>", it gets
a "server is down" message.
But if either of those two connections then are terminated, all is
well once again. It's as if SDP is refusing to talk to clients once
there are two SPP connections, but is ok with one or zero connections.
(Doing "sdptool browse local" on the server itself still shows the
service that is advertised, so it is still visible locally, but not
remotely.)
I'm using BlueZ 3.25 on a gentoo system, I've had this problem also with 3.24.
I've tried starting hcid with the -d flag (for debug info), and I can
see the SDP queries with no obvious problems there. I've also tried
doing "hcidump -X -V" whilst two clients are connected, and if a
remote machine tries to do a "sdptool browse" against my application,
there is no HCI data visible at all. But if the system is in the
"healthy" state (ie, less than two connections), this does show the
expected HCI traffic.
(The 'backlog' value for listen() is set to 30, so I don't think
that's the problem)
I've tried the same bluetooth adapters on windows, and they do work
with up to seven SPP connections, but obviously with very different
application software. I've tried two different brands of adapters
with the same result.
In short, it looks as if the BlueZ SDP server is not responding at all
whilst my application has two current SPP connections. I don't know
if that's what's actually happening, but that's how the symptoms
appear.
Any suggestions?
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Bluez-devel] SDP limiting connections?
2008-02-06 7:29 [Bluez-devel] SDP limiting connections? Pooyan McSporran
@ 2008-02-06 9:21 ` Marcel Holtmann
2008-02-06 23:34 ` Pooyan McSporran
0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2008-02-06 9:21 UTC (permalink / raw)
To: BlueZ development
Hi Pooyan,
> I'm having a strange problem with a BlueZ application.
>
> My application advertises a service via SDP (using dbus etc).
> Bluetooth clients scan the area for computers providing this service,
> and then connect via SPP to my application, and can then exchange
> data. The connections are handled in the normal socket/bind/listen
> method, each connection forks a thread to handle that connection.
> (Using BTPROTO_RFCOMM on the socket)
>
> This is working fine, but with one significant problem. If we have no
> connections, clients can scan and connect without problems. If there
> is one current connection, this is still the case. But if there are
> two current connections, then no clients can see the service via SDP.
> If another machine tries to (eg) do "sdptool browse <bdaddr>", it gets
> a "server is down" message.
>
> But if either of those two connections then are terminated, all is
> well once again. It's as if SDP is refusing to talk to clients once
> there are two SPP connections, but is ok with one or zero connections.
> (Doing "sdptool browse local" on the server itself still shows the
> service that is advertised, so it is still visible locally, but not
> remotely.)
>
> I'm using BlueZ 3.25 on a gentoo system, I've had this problem also with 3.24.
>
> I've tried starting hcid with the -d flag (for debug info), and I can
> see the SDP queries with no obvious problems there. I've also tried
> doing "hcidump -X -V" whilst two clients are connected, and if a
> remote machine tries to do a "sdptool browse" against my application,
> there is no HCI data visible at all. But if the system is in the
> "healthy" state (ie, less than two connections), this does show the
> expected HCI traffic.
>
> (The 'backlog' value for listen() is set to 30, so I don't think
> that's the problem)
>
> I've tried the same bluetooth adapters on windows, and they do work
> with up to seven SPP connections, but obviously with very different
> application software. I've tried two different brands of adapters
> with the same result.
>
> In short, it looks as if the BlueZ SDP server is not responding at all
> whilst my application has two current SPP connections. I don't know
> if that's what's actually happening, but that's how the symptoms
> appear.
if you don't see anything in hcidump from the other devices, then it is
not a SDP servers problem. Would would see connection attempts.
My guess is that both connection are as slaves. Check with "hcitool con"
and in that case the chip is pretty much busy keeping up. So you need to
have them to role-switch (RFCOMM_LM_MASTER).
Regards
Marcel
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Bluez-devel] SDP limiting connections?
2008-02-06 9:21 ` Marcel Holtmann
@ 2008-02-06 23:34 ` Pooyan McSporran
0 siblings, 0 replies; 3+ messages in thread
From: Pooyan McSporran @ 2008-02-06 23:34 UTC (permalink / raw)
To: BlueZ development
On 06/02/2008, Marcel Holtmann <marcel@holtmann.org> wrote:
> >
> > [snip]
> > In short, it looks as if the BlueZ SDP server is not responding at all
> > whilst my application has two current SPP connections. I don't know
> > if that's what's actually happening, but that's how the symptoms
> > appear.
>
> if you don't see anything in hcidump from the other devices, then it is
> not a SDP servers problem. Would would see connection attempts.
>
> My guess is that both connection are as slaves. Check with "hcitool con"
> and in that case the chip is pretty much busy keeping up. So you need to
> have them to role-switch (RFCOMM_LM_MASTER).
Initial investigations show that your theory is correct (unsurprisingly!).
If we have two connections, "hcitool con" shows:
Connections:
> ACL 00:18:0F:B3:5B:4D handle 47 state 1 lm SLAVE
> ACL 00:19:2D:E2:0A:AA handle 42 state 1 lm SLAVE
I can switch role using "hcitool sr <bdaddr>", a given connection, but
it seems that this fails for the first connection. ie, if I try this
for the first connection it fails, but if I try it for the 2nd, 3rd,
etc it succeeds. The failure looks like this:
< HCI Command: Switch Role (0x02|0x000b) plen 7
bdaddr 00:17:B0:B2:5C:7B role 0x00
Role: Master
> HCI Event: Command Status (0x0f) plen 4
Switch Role (0x02|0x000b) status 0x0c ncmd 1
Error: Command Disallowed
I'm guessing this is a function of the protocol, not an application
error, so I'm not too worried about it. Most importantly, your
suggestion worked :) If I do a role switch for each connection as it
is made (with the exception of the first connection which fails to
switch), I can have more than two SPP connections.
One other question, I can't see a way of performing the role switch
via dbus. Is there a way to do this?
Thanks for your help.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-06 23:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-06 7:29 [Bluez-devel] SDP limiting connections? Pooyan McSporran
2008-02-06 9:21 ` Marcel Holtmann
2008-02-06 23:34 ` Pooyan McSporran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox