2007-05-16 16:52:36

by Frederic Danis

[permalink] [raw]

2007-05-23 20:32:19

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Fix for disconnection in new serial service

Hi Frederic,

> >> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
> >> disconnect the bluetooth connection.
> >
> > that is not the the use case for ConnectService and DisconnectService.
> > It is as simple as that. What you want is more like the CreatePort
> > methods that create persistent RFCOMM bindings.
> >
>
> Regarding the Serial service API, I am not sure to understand difference between ConnectService and CreatePort.
> Is it possible to use port like this : CreatePort, open rfcomm, RemovePort, use file descriptor on rfcomm, than close it (that should disconnect bluetooth) ?

the CreatePort is a permanent binding that will be even restored after
reboot. The ConnectService is one-time use when you can't use the RFCOMM
socket directly or need a TTY. The advantage of ConnectService is that
the daemons cleans up after your process exits.

Regards

Marcel



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-05-23 18:15:16

by Frederic Danis

[permalink] [raw]
Subject: Re: [Bluez-devel] Fix for disconnection in new serial service

Hello Marcel,

>> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
>> disconnect the bluetooth connection.
>
> that is not the the use case for ConnectService and DisconnectService.
> It is as simple as that. What you want is more like the CreatePort
> methods that create persistent RFCOMM bindings.
>

Regarding the Serial service API, I am not sure to understand difference between ConnectService and CreatePort.
Is it possible to use port like this : CreatePort, open rfcomm, RemovePort, use file descriptor on rfcomm, than close it (that should disconnect bluetooth) ?

Regards

Fred

-----------------------------------------------
Danis Frederic Access Company
Software engineer
Mail : mailto:[email protected]
-----------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-05-23 18:10:29

by Frederic Danis

[permalink] [raw]
Subject: Re: [Bluez-devel] Fix for disconnection in new serial service

Hello,

Using the latest cvs revision, I saw that this problem has been fixed (using RFCOMM_HANGUP_NOW when rfcomm device is released).

Sorry

Fred

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-05-22 22:21:13

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Fix for disconnection in new serial service

Hi Frederic,

> >>>> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
> >>>> disconnect the bluetooth connection.
> >>> that is not the the use case for ConnectService and DisconnectService.
> >>> It is as simple as that. What you want is more like the CreatePort
> >>> methods that create persistent RFCOMM bindings.
> >> Even if I change to : ConnectService, open rfcommX, use file descriptor on rfcommX, close rfcommX, DisconnectService
> >> (that is a more classical use), the rfcommX connection is not released (and acl connection, until remote close it), as
> >> serial service keep a file descriptor opened on the rfcommX device (no close on node->io).
> >
> > that is the use case this is designed for. If this doesn't seem to work
> > than it actually looks like a bug. Can you provide further information
> > for Claudio so he can debug it.
>
> To simply check this, I do :
>
> - on remote, I create a SPP server :
> frederic.danis@remote:~$ sdptool add --channel=5 sp
> Serial Port service registered
> frederic.danis@remote:~$ rfcomm listen 0 5
> Waiting for connection on channel 5
>
> - on local, I connect to remote using serial service :
> ~ # dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez org.bluez.Manager.ActivateService string:serial
> method return sender=:1.0 -> dest=:1.22
> string ":1.19"

if the process goes away that called ConnectService() which is the care
here since dbus-send will exit from the system bus, the connection
should be automatically terminated. This is a meant to be cleanup of the
serial service.

> ~ # dbus-send --system --type=method_call --print-reply --dest=:1.19 /org/bluez/serial org.bluez.serial.Manager.ConnectService string:00:01:02:03:04:05
> string:spp
> serial[1040]: /org/bluez/serial: org.bluez.serial.Manager.ConnectService()
> serial[1040]: Connect in progress
> serial[1040]: rfcomm_connect_cb: connected
> serial[1040]: name_listener_add(:1.23)

Claudio, this is way to late to call name_listener_add(). You need to
call it during the method call actually.

Regards

Marcel



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-05-22 22:11:09

by Frederic Danis

[permalink] [raw]
Subject: Re: [Bluez-devel] Fix for disconnection in new serial service

Hello Marcel, Claudio,

>>>> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
>>>> disconnect the bluetooth connection.
>>> that is not the the use case for ConnectService and DisconnectService.
>>> It is as simple as that. What you want is more like the CreatePort
>>> methods that create persistent RFCOMM bindings.
>> Even if I change to : ConnectService, open rfcommX, use file descriptor on rfcommX, close rfcommX, DisconnectService
>> (that is a more classical use), the rfcommX connection is not released (and acl connection, until remote close it), as
>> serial service keep a file descriptor opened on the rfcommX device (no close on node->io).
>
> that is the use case this is designed for. If this doesn't seem to work
> than it actually looks like a bug. Can you provide further information
> for Claudio so he can debug it.

To simply check this, I do :

- on remote, I create a SPP server :
frederic.danis@remote:~$ sdptool add --channel=5 sp
Serial Port service registered
frederic.danis@remote:~$ rfcomm listen 0 5
Waiting for connection on channel 5

- on local, I connect to remote using serial service :
~ # dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez org.bluez.Manager.ActivateService string:serial
method return sender=:1.0 -> dest=:1.22
string ":1.19"
~ # dbus-send --system --type=method_call --print-reply --dest=:1.19 /org/bluez/serial org.bluez.serial.Manager.ConnectService string:00:01:02:03:04:05
string:spp
serial[1040]: /org/bluez/serial: org.bluez.serial.Manager.ConnectService()
serial[1040]: Connect in progress
serial[1040]: rfcomm_connect_cb: connected
serial[1040]: name_listener_add(:1.23)
method return sender=:1.19 -> dest=:1.23
string "/dev/rfcomm0"
serial[1040]: Connect requestor :1.23 exited. Releasing /dev/rfcomm0 node
~ # ls -l /dev/rfcomm0
crw-rw---- 1 root dialout 216, 0 May 22 21:37 /dev/rfcomm0
- on remote I get :
Connection from 00:01:02:03:04:05 to /dev/rfcomm0
Press CTRL-C for hangup

As there is no program using /dev/rfcomm0, and it has been released at end of "ConnectService call by dbus-send", it should no more exist and rfcomm (and acl)
connection should be closed. It does not occur until pressing ctrl-c on remote. (I do not see any way to close the rfcomm connection from local)

- on local I have :
~ # hcitool con
Connections:
< ACL 00:01:02:03:04:05 handle 42 state 1 lm MASTER
~ # ls -l /dev/rfcomm0
crw-rw---- 1 root dialout 216, 0 May 22 21:37 /dev/rfcomm0
- I press ctrl-c on remote :
Disconnected
- on local I have :
~ # hcitool con
Connections:
~ # ls -l /dev/rfcomm0
ls: /dev/rfcomm0: No such file or directory

To me it seems that this bug is due to the file descriptor on /dev/rfcomm0 opened during connection and set in a g_io_channel. This file descriptor is not
closed before the g_io_channel is unreferenced (so reference to this file descriptor is lost, but still opened) preventing rfcomm stack to really release
connection.

Hope this helps,

Regards

Fred

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-05-22 21:08:55

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Fix for disconnection in new serial service

Hi Frederic,

> >> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
> >> disconnect the bluetooth connection.
> >
> > that is not the the use case for ConnectService and DisconnectService.
> > It is as simple as that. What you want is more like the CreatePort
> > methods that create persistent RFCOMM bindings.
>
> Even if I change to : ConnectService, open rfcommX, use file descriptor on rfcommX, close rfcommX, DisconnectService
> (that is a more classical use), the rfcommX connection is not released (and acl connection, until remote close it), as
> serial service keep a file descriptor opened on the rfcommX device (no close on node->io).

that is the use case this is designed for. If this doesn't seem to work
than it actually looks like a bug. Can you provide further information
for Claudio so he can debug it.

Regards

Marcel



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-05-22 19:06:25

by Frederic Danis

[permalink] [raw]
Subject: Re: [Bluez-devel] Fix for disconnection in new serial service

Hello Marcel,

>> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
>> disconnect the bluetooth connection.
>
> that is not the the use case for ConnectService and DisconnectService.
> It is as simple as that. What you want is more like the CreatePort
> methods that create persistent RFCOMM bindings.

Even if I change to : ConnectService, open rfcommX, use file descriptor on rfcommX, close rfcommX, DisconnectService
(that is a more classical use), the rfcommX connection is not released (and acl connection, until remote close it), as
serial service keep a file descriptor opened on the rfcommX device (no close on node->io).

What I want to do is a non persistent rfcomm connection, only use "one-shot", but closable on local side.

Regards

Fred


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-05-22 17:24:18

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Fix for disconnection in new serial service

Hi Frederic,

> What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
> disconnect the bluetooth connection.

that is not the the use case for ConnectService and DisconnectService.
It is as simple as that. What you want is more like the CreatePort
methods that create persistent RFCOMM bindings.

Regards

Marcel



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-05-22 16:59:57

by Frederic Danis

[permalink] [raw]
Subject: Re: [Bluez-devel] Fix for disconnection in new serial service

Claudio Takahasi wrote:
> On 5/20/07, Marcel Holtmann <[email protected]> wrote:
>> Hi Frederic,
>>
>>> I find a little bug preventing disconnection in new serial service.
>> can you check against latest CVS. I am not sure if Claudio fixed this or
>> not. Thanks.
>>
>> Regards
>>
>> Marcel
>
> Hi Frederic,
>
> using g_io_channel_set_close_on_unref(io, TRUE) will trigger the
> following warning for G_IO_NVAL condition:
>
> (process:8085): GLib-WARNING **: Invalid file descriptor.
>
> BR,
> Claudio.

Hello Claudio,

I understand your comment.

But, I am trying to use the serial service and I do not understand one point :
after a ConnectService, the only way to disconnect it (disconnect rfcomm and acl), is by closing connection from remote side.

~ # dbus-send --system --type=method_call --print-reply --dest=:1.19 /org/bluez/serial org.bluez.serial.Manager.ConnectService string:00:01:02:03:05:06
string:spp
serial[1048]: /org/bluez/serial: org.bluez.serial.Manager.ConnectService()
serial[1048]: Connect in progress
serial[1048]: rfcomm_connect_cb: connected
serial[1048]: name_listener_add(:1.28)
method return sender=:1.19 -> dest=:1.28
string "/dev/rfcomm0"
serial[1048]: Connect requestor :1.28 exited. Releasing /dev/rfcomm0 node
~ # dbus-send --system --type=method_call --print-reply --dest=:1.19 /org/bluez/serial org.bluez.serial.Manager.DisconnectService string:/dev/rfcomm0
serial[1048]: /org/bluez/serial: org.bluez.serial.Manager.DisconnectService()
Error org.bluez.serial.Error.DoesNotExist: Invalid node
// Here, the RFComm connection is still up until remote side disconnect

How can I disconnect rfcomm (and acl) connection from local side (currently, the serial service has opened a file descriptor on /dev/rfcommX, that is close only
on remote disconnection, keeping up the /dev/rfcommX device) ?

What I want to do in my program is : ConnectService, open rfcomm, DisconnectService, than use file descriptor on rfcomm. Close rfcomm after, that should
disconnect the bluetooth connection.

Hope I am clear

Regards

Fred

--
-----------------------------------------------
It is not by improving the oil lamp that one invents the electric bulb!
-----------------------------------------------
Danis Frederic Access Company
Software engineer
Mail : mailto:[email protected]
-----------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-05-21 15:12:37

by Claudio Takahasi

[permalink] [raw]
Subject: Re: [Bluez-devel] Fix for disconnection in new serial service

On 5/20/07, Marcel Holtmann <[email protected]> wrote:
> Hi Frederic,
>
> > I find a little bug preventing disconnection in new serial service.
>
> can you check against latest CVS. I am not sure if Claudio fixed this or
> not. Thanks.
>
> Regards
>
> Marcel

Hi Frederic,

using g_io_channel_set_close_on_unref(io, TRUE) will trigger the
following warning for G_IO_NVAL condition:

(process:8085): GLib-WARNING **: Invalid file descriptor.

BR,
Claudio.
--
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-05-20 13:11:24

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Fix for disconnection in new serial service

Hi Frederic,

> I find a little bug preventing disconnection in new serial service.

can you check against latest CVS. I am not sure if Claudio fixed this or
not. Thanks.

Regards

Marcel



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel