Skip to contentSkip to conversation

rfcomm patch

Bluez-devel Sybren Stuvel 3 participants 9 messages Nov 5, 2003 – Nov 6, 2003 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi there,

I've been working with bluetooth for a few months now, trying to let BlueZ (on my PC) talk to Affix (on my Zaurus). One difficulty is that rfcom doesn't flush it's stdout when a new (incoming and/or outgoing) connection has been made.

With the attached patch, scripts can use rfcomm to connect via bluetooth and fork() the process in order to start using the connection (ie. by running pppd over it).

Greetings,
Sybren Stuvel

Signature · 3 lines
(o_   Q: God, root, what is difference?
//\   A: God can change the byte order on the CPU, root can't.
V_/_
bluez-utils-2.3/rfcomm/main.c renamed from bluez-utils-2.3/rfcomm/main.c-orig +10 -0
@@ -339,6 +339,11 @@
 	printf("Connected %s to %s on channel %d\n", devname, dst, req.channel);
 	printf("Press CTRL-C for hangup\n");
 
+	/* Added by Sybren Stuvel <sybren AT thirdtower.com> - Flush
+	 * stdout so other scripts can benefit from rfcomm's output and
+	 * react to connections being made. */
+	fflush(stdout);
+
 	memset(&sa, 0, sizeof(sa));
 	sa.sa_flags   = SA_NOCLDSTOP;
 	sa.sa_handler = SIG_IGN;
@@ -443,6 +448,11 @@
 	printf("Connection from %s to %s\n", dst, devname);
 	printf("Press CTRL-C for hangup\n");
 
+	/* Added by Sybren Stuvel <sybren AT thirdtower.com> - Flush
+	 * stdout so other scripts can benefit from rfcomm's output and
+	 * react to connections being made. */
+	fflush(stdout);
+
 	memset(&sa, 0, sizeof(sa));
 	sa.sa_flags   = SA_NOCLDSTOP;
 	sa.sa_handler = SIG_IGN;
maintainer
#1 lore raw

Hi Sybren,

Quoted 8 lines

I've been working with bluetooth for a few months now, trying to let BlueZ (on my PC) talk to Affix (on my Zaurus). One difficulty is that rfcom doesn't flush it's stdout when a new (incoming and/or outgoing) connection has been made.

With the attached patch, scripts can use rfcomm to connect via bluetooth and fork() the process in order to start using the connection (ie. by running pppd over it).

I have no problem with the patch, but if you talk about PPP over RFCOMM you should better use dund. And why do you need this for scripting? You can bind a RFCOMM channel to a device and all stuff would be done in background without user interaction.

Regards

Marcel

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw
Quoted 2 lines · Marcel Holtmann

I have no problem with the patch, but if you talk about PPP over RFCOMM you should better use dund.

I tried dund, but I couldn't get it to work together with Affix on my Sharp Zaurus (running OpenZaurus 3.2). I'll try again and come up with some info that might actually be useful for solving the mistery ;-)

Quoted 3 lines

And why do you need this for scripting? You can bind a RFCOMM channel to a device and all stuff would be done in background without user interaction.

I wanted to delay the starting of pppd until the connection was actually made. I thought it was the easiest to just parse rfcomm's output.

Greetz,
Sybren

PS: What is the list's policy on PGP-signed messages?

Signature · 3 lines
(o_   Q: God, root, what is difference?
//\   A: God can change the byte order on the CPU, root can't.
V_/_
maintainer
#3 lore raw

Hi Sybren,

Quoted 6 lines
Quoted 3 lines

And why do you need this for scripting? You can bind a RFCOMM channel to a device and all stuff would be done in background without user interaction.

I wanted to delay the starting of pppd until the connection was actually made. I thought it was the easiest to just parse rfcomm's output.

try to implement an updetach feature ;) But I prefer that you use this

	rfcomm bind 0 <bdaddr> [channel]	(only once needed)
	pppd /dev/rfcomm0 ...
Quoted 1 line

PS: What is the list's policy on PGP-signed messages?

We have no policy about that and I never sign messages that go out to a mailing list.

Regards

Marcel

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#4 lore raw
In reply to Sybren Stuvel
Quoted 3 lines · Sybren Stuvel

I tried dund, but I couldn't get it to work together with Affix on my Sharp Zaurus (running OpenZaurus 3.2). I'll try again and come up with some info that might actually be useful for solving the mistery ;-)

Apparently I didn't try dund, or I tried it the wrong way. Now that I'm looking at it with a fresh mind it works like a charm:

sybren root # dund --search --nodetach dund[10733]: DUN daemon ver 1.1
dund[10733]: Inquiring
dund[10733]: Searching for LAP on 00:10:7A:4C:23:02 dund[10733]: Connecting to 00:10:7A:4C:23:02 channel 2 dund[10733]: Connection established
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
local IP address 172.16.0.2
remote IP address 172.16.0.1
BSD-Compress (15) compression enabled

Thank you very much! This saves me a lot of fuss!
You made me a very happy man :)

Greetz,
Sybren

Signature · 3 lines
(o_   Q: God, root, what is difference?
//\   A: God can change the byte order on the CPU, root can't.
V_/_
#5 lore raw
In reply to Sybren Stuvel

Hi,
Regarding this topic that rfcomm doesn't flush. I just want to ask that,
I'm using an USB Bluetooth dongle that's connected to another Bluetooth device using the rfcomm program. This other Bluetooth device is connected to a Windows PC's COM1 port (RS-232) and connected/displayed by hyperterminal... For some unknown reason, what ever the hyperterminal sends on the Windows side can be shown
"cat /dev/rfcomm0". But what ever the USB Bluetooth dongle sends (using "echo hello > /dev/rfcomm0") it can't be shown on the Windows hyperterminal...

On my Windows side, I have a embedded Bluetooth module (CSR's BC02) and the signal is connected to a MAX chip converting betweeen BC02's 3.3V and RS232's logic level.

Regards,

Alan

----- Original Message -----
From: "Sybren Stuvel" <[email protected]>
To: <[email protected]>
Sent: Wednesday, November 05, 2003 10:45 AM
Subject: [Bluez-devel] rfcomm patch

Hi there,

I've been working with bluetooth for a few months now, trying to let BlueZ (on
my PC) talk to Affix (on my Zaurus). One difficulty is that rfcom doesn't flush it's stdout when a new (incoming and/or outgoing) connection has been made.

With the attached patch, scripts can use rfcomm to connect via bluetooth and fork() the process in order to start using the connection (ie. by running pppd over it).

Greetings,
Sybren Stuvel
--
(o_ Q: God, root, what is difference?
//\ A: God can change the byte order on the CPU, root can't.
V_/_

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#6 lore raw

Hi Alan,

Quoted 9 lines

Regarding this topic that rfcomm doesn't flush. I just want to ask that,
I'm using an USB Bluetooth dongle that's connected to another Bluetooth device using the rfcomm program. This other Bluetooth device is connected to a Windows PC's COM1 port (RS-232) and connected/displayed by hyperterminal... For some unknown reason, what ever the hyperterminal sends on the Windows side can be shown
"cat /dev/rfcomm0". But what ever the USB Bluetooth dongle sends (using "echo hello > /dev/rfcomm0") it can't be shown on the Windows hyperterminal...

try to use the --raw switch to set the terminal into RAW mode after connect (this works not for "bind").

Regards

Marcel

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#7 lore raw

Hi,
Thanks again Marcel, for your reply! Can you tell me a bit more how to
switch to raw terminal mode? Does it mean that I'll have to skip the bind action and directly connect after I created the socket?

Hmm... it really seems like I should enhance my socket programming knowledge...Any good online guides/tuts or books anyone can recommend ;-)

Thanks~

Alan

Marcel Holtmann <[email protected]>:

Quoted 17 lines

Hi Alan,

Quoted 1 line

Regarding this topic that rfcomm doesn't flush. I just want to ask

that,

Quoted 1 line

I'm using an USB Bluetooth dongle that's connected to another

Bluetooth

Quoted 1 line

device using the rfcomm program. This other Bluetooth device is

connected to

Quoted 2 lines

a Windows PC's COM1 port (RS-232) and connected/displayed by hyperterminal... For some unknown reason, what ever the hyperterminal

sends

Quoted 2 lines

on the Windows side can be shown
"cat /dev/rfcomm0". But what ever the USB Bluetooth dongle sends

(using

Quoted 2 lines

"echo hello > /dev/rfcomm0") it can't be shown on the Windows hyperterminal...

Quoted 11 lines

try to use the --raw switch to set the terminal into RAW mode after connect (this works not for "bind").

Regards

Marcel

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
Bluez-users mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

maintainer
#8 lore raw

Hi Alan,

Quoted 3 lines

Thanks again Marcel, for your reply! Can you tell me a bit more how to
switch to raw terminal mode? Does it mean that I'll have to skip the bind action and directly connect after I created the socket?

look at the code ;) And the raw stuff is only for TTY terminals and the RFCOMM emulation of it. If you connect through a socket you won't have problems with it.

Quoted 2 lines

Hmm... it really seems like I should enhance my socket programming knowledge...Any good online guides/tuts or books anyone can recommend ;-)

The source code of any socket based program ;)

Regards

Marcel

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
Bluez-users mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users