public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-users] How to emulate slave serial ports ?
@ 2004-11-09 17:16 Rizzo Davide
  2004-11-09 18:13 ` Marcel Holtmann
  0 siblings, 1 reply; 9+ messages in thread
From: Rizzo Davide @ 2004-11-09 17:16 UTC (permalink / raw)
  To: bluez-users

Hi to all.
I'm experimenting with Bluez, I got some important results, but ...
I found a lot of mailings about how to use RFCOMM as a master, so how to 
use Phones as slaves to connect to internet or phone lines.
My approach is different: I have a target system based on Linux 2.6.9 
(ARM architecture), on which I fitted an USB to Bluetooth dongle. I want 
my target system to make available one virtual serial port, and to 
connect to it from an external Windows-based PC.
Now I have all low-level working, I use hciconfig, hcid and sdpd 
(currently my sdpd has some problems, it doesnt'returns so I have to 
call it as "hcid & ls"). Currently, from the Windows PC I successfully 
browsed my linux device and paired it, but I'm not able to view the list 
of exported services.
I understand how to establish a serial connection to an external device, 
knowing its 6-bytes address, but I didn't found any literature on how to 
export a "virtual" serial port.
Should I use "sdptool add SP" ? Or maybe "rfcomm listen /dev/rfcomm0" ?
Which tool is needed to achieve this ?
Thanks
Davide




-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users/listinfo/bluez-users

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

* Re: [Bluez-users] How to emulate slave serial ports ?
  2004-11-09 17:16 [Bluez-users] How to emulate slave serial ports ? Rizzo Davide
@ 2004-11-09 18:13 ` Marcel Holtmann
  2004-11-10  8:28   ` [Bluez-users] " Davide Rizzo
  0 siblings, 1 reply; 9+ messages in thread
From: Marcel Holtmann @ 2004-11-09 18:13 UTC (permalink / raw)
  To: BlueZ Mailing List

Hi Davide,

> I'm experimenting with Bluez, I got some important results, but ...
> I found a lot of mailings about how to use RFCOMM as a master, so how to 
> use Phones as slaves to connect to internet or phone lines.
> My approach is different: I have a target system based on Linux 2.6.9 
> (ARM architecture), on which I fitted an USB to Bluetooth dongle. I want 
> my target system to make available one virtual serial port, and to 
> connect to it from an external Windows-based PC.
> Now I have all low-level working, I use hciconfig, hcid and sdpd 
> (currently my sdpd has some problems, it doesnt'returns so I have to 
> call it as "hcid & ls"). Currently, from the Windows PC I successfully 
> browsed my linux device and paired it, but I'm not able to view the list 
> of exported services.
> I understand how to establish a serial connection to an external device, 
> knowing its 6-bytes address, but I didn't found any literature on how to 
> export a "virtual" serial port.
> Should I use "sdptool add SP" ? Or maybe "rfcomm listen /dev/rfcomm0" ?
> Which tool is needed to achieve this ?

the question is what do you wanna do with the serial port on your
machine? If you know that, then look for a profile that fits and use
that program or write your own one.

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users/listinfo/bluez-users

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

* [Bluez-users] Re: How to emulate slave serial ports ?
  2004-11-09 18:13 ` Marcel Holtmann
@ 2004-11-10  8:28   ` Davide Rizzo
  2004-11-10  9:18     ` Marcel Holtmann
  0 siblings, 1 reply; 9+ messages in thread
From: Davide Rizzo @ 2004-11-10  8:28 UTC (permalink / raw)
  To: bluez-users

Marcel Holtmann <marcel <at> holtmann.org> writes:

> 
> the question is what do you wanna do with the serial port on your
> machine? If you know that, then look for a profile that fits and use
> that program or write your own one.
> 
> Regards
> 
> Marcel
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Sybase ASE Linux Express Edition - download now for FREE
> LinuxWorld Reader's Choice Award Winner for best database on Linux.
> http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
> 

Hi Marcel,
On the linux machine now I have a program that opens the serial device (and
keeps it opened), periodically polls it for incoming requests, and eventually
responds to the requests.
I wish to substitute this physical RS232 line with a bluetooth connection,
without changing the Windows software on the PC (and the software on the
target), except for the device names. Is it possible ?
Which bluez tools should I run on the init script ?
Thanks
Davide



-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users/listinfo/bluez-users

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

* Re: [Bluez-users] Re: How to emulate slave serial ports ?
  2004-11-10  8:28   ` [Bluez-users] " Davide Rizzo
@ 2004-11-10  9:18     ` Marcel Holtmann
  2004-11-10  9:51       ` Davide Rizzo
  0 siblings, 1 reply; 9+ messages in thread
From: Marcel Holtmann @ 2004-11-10  9:18 UTC (permalink / raw)
  To: BlueZ Mailing List

Hi Davide,

> On the linux machine now I have a program that opens the serial device (and
> keeps it opened), periodically polls it for incoming requests, and eventually
> responds to the requests.

I don't understand this. Show me that program.

> I wish to substitute this physical RS232 line with a bluetooth connection,
> without changing the Windows software on the PC (and the software on the
> target), except for the device names. Is it possible ?

It is possible, but I still don't know what you really wanna do. Replace
some serial port is not a detailed description.

> Which bluez tools should I run on the init script ?

Besides hcid and sdpd, nothing more. But you must write a program that
accepts connections on RFCOMM and that also registers a service record
for your serial port.

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users/listinfo/bluez-users

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

* [Bluez-users] Re: How to emulate slave serial ports ?
  2004-11-10  9:18     ` Marcel Holtmann
@ 2004-11-10  9:51       ` Davide Rizzo
  2004-11-10  9:59         ` Marcel Holtmann
  0 siblings, 1 reply; 9+ messages in thread
From: Davide Rizzo @ 2004-11-10  9:51 UTC (permalink / raw)
  To: bluez-users

Marcel Holtmann <marcel <at> holtmann.org> writes:

> 
> Hi Davide,
> 
> > On the linux machine now I have a program that opens the serial device (and
> > keeps it opened), periodically polls it for incoming requests, and eventually
> > responds to the requests.
> 
> I don't understand this. Show me that program.
> 
> > I wish to substitute this physical RS232 line with a bluetooth connection,
> > without changing the Windows software on the PC (and the software on the
> > target), except for the device names. Is it possible ?
> 
> It is possible, but I still don't know what you really wanna do. Replace
> some serial port is not a detailed description.
> 
> > Which bluez tools should I run on the init script ?
> 
> Besides hcid and sdpd, nothing more. But you must write a program that
> accepts connections on RFCOMM and that also registers a service record
> for your serial port.
> 
> Regards
> 
> Marcel
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Sybase ASE Linux Express Edition - download now for FREE
> LinuxWorld Reader's Choice Award Winner for best database on Linux.
> http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
> 

Hi Marcel,

Let me start from the outside.

The final result I want to obtain is:

>From a PC running Windows (master):
1) I scan the bluetooth devices, and find one (or more) my linux devices
2) I pair the device with the correct PIN code
3) I browse the device's services and find one communication ports
4) I establish a Link with that comm port to a Windows virtual COMx port
5) I use the connected COMx port like any other "true" COMx port, sending
inquiries and reading results in a proprietary format.
Until now I succeeded in points 1) and 2)

>From the target running linux 2.6.9 on an ARM9 (slave):
1) I run hciconfig
2) I start hcid
3) I start sdpd
4) My application opens /dev/rfcomm0 and keeps it opened
5) My application polls with read() on /dev/rfcomm0 for incoming messages

Question 1:
Is necessary to have on the target my application running with /dev/rfcomm0
opened for the Windows PC to look at the exported serial port ?

Question 2:
I setted up /usr/local/etc/bluetooth/pin and /usr/local/etc/bluetooth/hcid.conf
for hcid, and it works OK. Does sdpd needs any configuration file ? Where is
stored the sdpd configuration ? Where is stored the fact that I want to export
one virtual serial port ?

Question 3:
If I run sdpd without any flags, it doesn't fork() because getppid()==1. Why ?
Which is the correct mode of starting sdpd like a daemon ?

Thanks

Davide



-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users/listinfo/bluez-users

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

* Re: [Bluez-users] Re: How to emulate slave serial ports ?
  2004-11-10  9:51       ` Davide Rizzo
@ 2004-11-10  9:59         ` Marcel Holtmann
  2004-11-10 12:17           ` Davide Rizzo
  0 siblings, 1 reply; 9+ messages in thread
From: Marcel Holtmann @ 2004-11-10  9:59 UTC (permalink / raw)
  To: BlueZ Mailing List

Hi Davide,

> Let me start from the outside.
> 
> The final result I want to obtain is:
> 
> From a PC running Windows (master):
> 1) I scan the bluetooth devices, and find one (or more) my linux devices
> 2) I pair the device with the correct PIN code
> 3) I browse the device's services and find one communication ports
> 4) I establish a Link with that comm port to a Windows virtual COMx port
> 5) I use the connected COMx port like any other "true" COMx port, sending
> inquiries and reading results in a proprietary format.
> Until now I succeeded in points 1) and 2)
> 
> From the target running linux 2.6.9 on an ARM9 (slave):
> 1) I run hciconfig
> 2) I start hcid
> 3) I start sdpd
> 4) My application opens /dev/rfcomm0 and keeps it opened
> 5) My application polls with read() on /dev/rfcomm0 for incoming messages

point 4 and 5 don't work this way on the server side, because you need
to listen on incoming connections first before you can use the device
node. What is the program on the ARM9 (slave) doing? I think you need to
rewrite it and add native RFCOMM support.

> Question 1:
> Is necessary to have on the target my application running with /dev/rfcomm0
> opened for the Windows PC to look at the exported serial port ?

No. You need to setup a service record for the serial port profile and
listen on incoming connection on the RFCOMM channel.

> Question 2:
> I setted up /usr/local/etc/bluetooth/pin and /usr/local/etc/bluetooth/hcid.conf
> for hcid, and it works OK. Does sdpd needs any configuration file ? Where is
> stored the sdpd configuration ? Where is stored the fact that I want to export
> one virtual serial port ?

The SDP records are runtime records.

> Question 3:
> If I run sdpd without any flags, it doesn't fork() because getppid()==1. Why ?
> Which is the correct mode of starting sdpd like a daemon ?

Maybe this is problem with your ARM platform or your compiler.

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users/listinfo/bluez-users

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

* [Bluez-users] Re: How to emulate slave serial ports ?
  2004-11-10  9:59         ` Marcel Holtmann
@ 2004-11-10 12:17           ` Davide Rizzo
  2004-11-10 13:46             ` Marcel Holtmann
  0 siblings, 1 reply; 9+ messages in thread
From: Davide Rizzo @ 2004-11-10 12:17 UTC (permalink / raw)
  To: bluez-users

Hi Marcel,

I solved (almost) all problems !

The correct solution is:

hciconfig hci0 up
hcid
sdpd &
sdptool add SP
rfcomm listen /dev/rfcomm0 &

... and now the program on the target can use /dev/rfcomm0 exactly like
before it worked with /dev/TTYSACx !

The only problem is that rfcomm exits when windows closes the connection,
so I need to run it again to be ready to listen for the next connection.
But this is a minor problem, I'll investigate in the rfcomm code to get the
parts I need, so I'll be able also to understand if the connection is on or
not.

Thank you very much for your precious effort.




-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users/listinfo/bluez-users

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

* Re: [Bluez-users] Re: How to emulate slave serial ports ?
  2004-11-10 12:17           ` Davide Rizzo
@ 2004-11-10 13:46             ` Marcel Holtmann
  2004-11-10 14:34               ` Davide Rizzo
  0 siblings, 1 reply; 9+ messages in thread
From: Marcel Holtmann @ 2004-11-10 13:46 UTC (permalink / raw)
  To: bluez-users

Hi Davide,

> I solved (almost) all problems !
> 
> The correct solution is:
> 
> hciconfig hci0 up
> hcid
> sdpd &
> sdptool add SP
> rfcomm listen /dev/rfcomm0 &
> 
> ... and now the program on the target can use /dev/rfcomm0 exactly like
> before it worked with /dev/TTYSACx !

no it is not. This is only a workaround. Change your program to use a
socket descriptor instead of a TTY descriptor and handle the incoming
connection request and the SDP service registration by yourself.

> The only problem is that rfcomm exits when windows closes the connection,
> so I need to run it again to be ready to listen for the next connection.
> But this is a minor problem, I'll investigate in the rfcomm code to get the
> parts I need, so I'll be able also to understand if the connection is on or
> not.

As I said, it is only a workaround.

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users/listinfo/bluez-users

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

* [Bluez-users] Re: How to emulate slave serial ports ?
  2004-11-10 13:46             ` Marcel Holtmann
@ 2004-11-10 14:34               ` Davide Rizzo
  0 siblings, 0 replies; 9+ messages in thread
From: Davide Rizzo @ 2004-11-10 14:34 UTC (permalink / raw)
  To: bluez-users

Marcel Holtmann <marcel <at> holtmann.org> writes:

> 
> Hi Davide,
> 
> > I solved (almost) all problems !
> 
> no it is not. This is only a workaround. Change your program to use a
> socket descriptor instead of a TTY descriptor and handle the incoming
> connection request and the SDP service registration by yourself.
> 
> > The only problem is that rfcomm exits when windows closes the connection,
> > so I need to run it again to be ready to listen for the next connection.
> > But this is a minor problem, I'll investigate in the rfcomm code to get the
> > parts I need, so I'll be able also to understand if the connection is on or
> > not.
> 
> As I said, it is only a workaround.
> 
> Regards
> 
> Marcel

Hi Marcel,

You're absolutely right.
I'll use the socket interface instead of /dev/rfcomm0, it's much more flexible
and powerful.

Thank you again,

Davide

All difficult problems have a simple solution.
That is wrong.
(A. Einstein)




-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users/listinfo/bluez-users

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

end of thread, other threads:[~2004-11-10 14:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-09 17:16 [Bluez-users] How to emulate slave serial ports ? Rizzo Davide
2004-11-09 18:13 ` Marcel Holtmann
2004-11-10  8:28   ` [Bluez-users] " Davide Rizzo
2004-11-10  9:18     ` Marcel Holtmann
2004-11-10  9:51       ` Davide Rizzo
2004-11-10  9:59         ` Marcel Holtmann
2004-11-10 12:17           ` Davide Rizzo
2004-11-10 13:46             ` Marcel Holtmann
2004-11-10 14:34               ` Davide Rizzo

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