linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez-devel] [PATCH] rctest DUMP mode with data dump
@ 2005-10-02 19:23 Hartmut Schimmel
  0 siblings, 0 replies; only message in thread
From: Hartmut Schimmel @ 2005-10-02 19:23 UTC (permalink / raw)
  To: bluez-users, bluez-devel

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

Hello,

the attached patch extendes rctest.c with a cmd line switch -D, which writes 
the data recived in DUMP mode to stdout.

Install:
cd bluez-utils-2.21
patch -p0 < rcdump_2.21.patch
make distclean
./configure --enable-test
make

Why I made it:
For me it is usefull as a very simple client program, which waits for incoming 
connections and dumps the incoming data. It can be used from script languages 
like perl.

In real I receive mesurements from a sensor (bluetooth equiped with PicoPlug) 
out there, which wake up from time to time, send measure value via SPP to the 
host, where the pachted rctest runs and sleeps again.

sml@Amadeus:~> rctest -P 5 -d -D
rctest[12071]: Waiting for connection on channel 5 ...
rctest[12072]: Can't get RFCOMM connection information: Protocol not available 
(92)
rctest[12072]: Connect from 00:80:37:15:1A:A9 [handle 0, class 0x000000]
rctest[12072]: Receiving ...
this is line the data payload
rctest[12072]: Disconnect: Connection timed out

Please give me feedback, if this is usefull for anybody else.


Hartmut



[-- Attachment #2: rcdump_2.21.patch --]
[-- Type: text/x-diff, Size: 1506 bytes --]

diff -Naur ../bluez-utils-2.21/test/rctest.c ./test/rctest.c
--- ../bluez-utils-2.21/test/rctest.c	2005-02-01 01:13:02.000000000 +0100
+++ ./test/rctest.c	2005-10-02 20:32:08.164841032 +0200
@@ -75,6 +75,7 @@
 static int secure = 0;
 static int socktype = SOCK_STREAM;
 static int linger = 0;
+static int dump_data = 0;
 
 static float tv2fl(struct timeval tv)
 {
@@ -265,11 +266,23 @@
 
 static void dump_mode(int sk)
 {
-	int len;
+	int len, count;
 
 	syslog(LOG_INFO, "Receiving ...");
-	while ((len = read(sk, buf, data_size)) > 0)
-		syslog(LOG_INFO, "Recevied %d bytes", len);
+
+	if ( !dump_data ) {
+		count = data_size;
+	} else {
+		count = 1;
+	}
+
+	while ((len = read(sk, buf, count)) > 0) {
+		if ( !dump_data ) {
+			syslog(LOG_INFO, "Recevied %d bytes", len);
+		} else {
+			printf("%s", buf);
+		}
+	}
 }
 
 static void recv_mode(int sk)
@@ -407,7 +420,8 @@
 		"\t[-A] request authentication\n"
 		"\t[-E] request encryption\n"
 		"\t[-S] secure connection\n"
-		"\t[-M] become master\n");
+		"\t[-M] become master\n"
+		"\t[-D] dump incoming data (only in dump mode)\n");
 }
 
 int main(int argc ,char *argv[])
@@ -417,7 +431,7 @@
 
 	bacpy(&bdaddr, BDADDR_ANY);
 
-	while ((opt=getopt(argc,argv,"rdscuwmnb:i:P:N:MAESL:")) != EOF) {
+	while ((opt=getopt(argc,argv,"rdscuwmnb:i:P:N:MAESL:D")) != EOF) {
 		switch (opt) {
 		case 'r':
 			mode = RECV;
@@ -483,6 +497,10 @@
 			encrypt = 1;
 			break;
 
+		case 'D':
+			dump_data = 1;
+			break;
+
 		case 'S':
 			secure = 1;
 			break;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-02 19:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-02 19:23 [Bluez-devel] [PATCH] rctest DUMP mode with data dump Hartmut Schimmel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).