public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] Patch with small CoD changes in hciconfig and hcitool
@ 2006-11-07  9:56 Luciano Coelho
  2006-12-13 13:37 ` Luciano Coelho
  0 siblings, 1 reply; 2+ messages in thread
From: Luciano Coelho @ 2006-11-07  9:56 UTC (permalink / raw)
  To: BlueZ development

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

Hi all,

I was using hciconfig to perform some tests and I realized that there
were a few omissions and small mistakes in the way hciconfig and hcitool
were converting CoD information to strings.

I've created a small patch to fix this.  It's the first patch I send to
this list, so forgive me if there is any "childish" mistake or style
flaw in it ;-) Any comments are welcome.

Cheers,
Luca.

[-- Attachment #2: hciconfig_cod.patch --]
[-- Type: text/x-patch, Size: 4473 bytes --]

--- tools/hciconfig.c	26 Jul 2006 13:09:44 -0000	1.82
+++ tools/hciconfig.c	7 Nov 2006 09:47:46 -0000
@@ -597,16 +597,51 @@
 			return "Gaming/Toy";
 		}
 		break;
-	case 5:	/* peripheral */
-		switch(minor) {
+	case 5:	/* peripheral */ {
+		static char cls_str[48]; cls_str[0] = 0;
+
+		switch(minor & 48) {
 		case 16:
-			return "Keyboard";
+			strncpy(cls_str, "Keyboard", sizeof(cls_str));
+			break;
 		case 32:
-			return "Pointing device";
+			strncpy(cls_str, "Pointing device", sizeof(cls_str));
+			break;
 		case 48:
-			return "Combo keyboard/pointing device";
+			strncpy(cls_str, "Combo keyboard/pointing device", sizeof(cls_str));
+			break;
 		}
-		break;
+		if((minor & 15) && (strlen(cls_str) > 0))
+			strcat(cls_str, "/");
+
+		switch(minor & 15) {
+		case 0:
+			break;
+		case 1:
+			strncat(cls_str, "Joystick", sizeof(cls_str) - strlen(cls_str));
+			break;
+		case 2:
+			strncat(cls_str, "Gamepad", sizeof(cls_str) - strlen(cls_str));
+			break;
+		case 3:
+			strncat(cls_str, "Remote control", sizeof(cls_str) - strlen(cls_str));
+			break;
+		case 4:
+			strncat(cls_str, "Sensing device", sizeof(cls_str) - strlen(cls_str));
+			break;
+		case 5:
+			strncat(cls_str, "Digitizer tablet", sizeof(cls_str) - strlen(cls_str));
+			break;
+		case 6:
+			strncat(cls_str, "Card reader", sizeof(cls_str) - strlen(cls_str));
+			break;
+		default:
+			strncat(cls_str, "(reserved)", sizeof(cls_str) - strlen(cls_str));
+			break;
+		}
+		if(strlen(cls_str) > 0)
+			return cls_str;
+	}
 	case 6:	/* imaging */
 		if (minor & 4)
 			return "Display";
@@ -617,6 +652,34 @@
 		if (minor & 32)
 			return "Printer";
 		break;
+	case 7: /* wearable */
+		switch(minor) {
+		case 1:
+			return "Wrist Watch";
+		case 2:
+			return "Pager";
+		case 3:
+			return "Jacket";
+		case 4:
+			return "Helmet";
+		case 5:
+			return "Glasses";
+		}
+		break;
+	case 8: /* toy */
+		switch(minor) {
+		case 1:
+			return "Robot";
+		case 2:
+			return "Vehicle";
+		case 3:
+			return "Doll / Action Figure";
+		case 4:
+			return "Controller";
+		case 5:
+			return "Game";
+		}
+		break;
 	case 63:	/* uncategorised */
 		return "";
 	}
Index: tools/hcitool.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/hcitool.c,v
retrieving revision 1.91
diff -u -r1.91 hcitool.c
--- tools/hcitool.c	29 Sep 2006 11:42:14 -0000	1.91
+++ tools/hcitool.c	7 Nov 2006 09:47:47 -0000
@@ -245,16 +245,51 @@
 			return "Gaming/Toy";
 		}
 		break;
-	case 5:	/* peripheral */
-		switch(minor) {
+	case 5:	/* peripheral */ {
+		static char cls_str[48]; cls_str[0] = 0;
+
+		switch(minor & 48) {
 		case 16:
-			return "Keyboard";
+			strncpy(cls_str, "Keyboard", sizeof(cls_str));
+			break;
 		case 32:
-			return "Pointing device";
+			strncpy(cls_str, "Pointing device", sizeof(cls_str));
+			break;
 		case 48:
-			return "Combo keyboard/pointing device";
+			strncpy(cls_str, "Combo keyboard/pointing device", sizeof(cls_str));
+			break;
 		}
+		if((minor & 15) && (strlen(cls_str) > 0))
+			strcat(cls_str, "/");
+
+		switch(minor & 15) {
+		case 0:
+			break;
+		case 1:
+			strncat(cls_str, "Joystick", sizeof(cls_str) - strlen(cls_str));
+			break;
+		case 2:
+			strncat(cls_str, "Gamepad", sizeof(cls_str) - strlen(cls_str));
+			break;
+		case 3:
+			strncat(cls_str, "Remote control", sizeof(cls_str) - strlen(cls_str));
+			break;
+		case 4:
+			strncat(cls_str, "Sensing device", sizeof(cls_str) - strlen(cls_str));
+			break;
+		case 5:
+			strncat(cls_str, "Digitizer tablet", sizeof(cls_str) - strlen(cls_str));
 		break;
+		case 6:
+			strncat(cls_str, "Card reader", sizeof(cls_str) - strlen(cls_str));
+			break;
+		default:
+			strncat(cls_str, "(reserved)", sizeof(cls_str) - strlen(cls_str));
+			break;
+		}
+		if(strlen(cls_str) > 0)
+			return cls_str;
+	}
 	case 6:	/* imaging */
 		if (minor & 4)
 			return "Display";
@@ -265,6 +300,34 @@
 		if (minor & 32)
 			return "Printer";
 		break;
+	case 7: /* wearable */
+		switch(minor) {
+		case 1:
+			return "Wrist Watch";
+		case 2:
+			return "Pager";
+		case 3:
+			return "Jacket";
+		case 4:
+			return "Helmet";
+		case 5:
+			return "Glasses";
+		}
+		break;
+	case 8: /* toy */
+		switch(minor) {
+		case 1:
+			return "Robot";
+		case 2:
+			return "Vehicle";
+		case 3:
+			return "Doll / Action Figure";
+		case 4:
+			return "Controller";
+		case 5:
+			return "Game";
+		}
+		break;
 	case 63:	/* uncategorised */
 		return "";
 	}

[-- Attachment #3: Type: text/plain, Size: 373 bytes --]

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

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

* Re: [Bluez-devel] Patch with small CoD changes in hciconfig and hcitool
  2006-11-07  9:56 [Bluez-devel] Patch with small CoD changes in hciconfig and hcitool Luciano Coelho
@ 2006-12-13 13:37 ` Luciano Coelho
  0 siblings, 0 replies; 2+ messages in thread
From: Luciano Coelho @ 2006-12-13 13:37 UTC (permalink / raw)
  To: BlueZ development

Hello,

Has anyone had the time to look into this patch I submited a while ago? 
It's really a simple patch and not very critical, but it's very useful 
in certain test scenarios.

I've shown this patch to Johan previously and he thought it was ok.  
Would anyone have the time to take a look at it? It would be nice to 
have it included in the main bluez tree...

Cheers,
Luca.

Luciano Coelho wrote:
> Hi all,
>
> I was using hciconfig to perform some tests and I realized that there
> were a few omissions and small mistakes in the way hciconfig and hcitool
> were converting CoD information to strings.
>
> I've created a small patch to fix this.  It's the first patch I send to
> this list, so forgive me if there is any "childish" mistake or style
> flaw in it ;-) Any comments are welcome.
>
> Cheers,
> Luca.
>   
> ------------------------------------------------------------------------
>
> --- tools/hciconfig.c	26 Jul 2006 13:09:44 -0000	1.82
> +++ tools/hciconfig.c	7 Nov 2006 09:47:46 -0000
> @@ -597,16 +597,51 @@
>  			return "Gaming/Toy";
>  		}
>  		break;
> -	case 5:	/* peripheral */
> -		switch(minor) {
> +	case 5:	/* peripheral */ {
> +		static char cls_str[48]; cls_str[0] = 0;
> +
> +		switch(minor & 48) {
>  		case 16:
> -			return "Keyboard";
> +			strncpy(cls_str, "Keyboard", sizeof(cls_str));
> +			break;
>  		case 32:
> -			return "Pointing device";
> +			strncpy(cls_str, "Pointing device", sizeof(cls_str));
> +			break;
>  		case 48:
> -			return "Combo keyboard/pointing device";
> +			strncpy(cls_str, "Combo keyboard/pointing device", sizeof(cls_str));
> +			break;
>  		}
> -		break;
> +		if((minor & 15) && (strlen(cls_str) > 0))
> +			strcat(cls_str, "/");
> +
> +		switch(minor & 15) {
> +		case 0:
> +			break;
> +		case 1:
> +			strncat(cls_str, "Joystick", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		case 2:
> +			strncat(cls_str, "Gamepad", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		case 3:
> +			strncat(cls_str, "Remote control", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		case 4:
> +			strncat(cls_str, "Sensing device", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		case 5:
> +			strncat(cls_str, "Digitizer tablet", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		case 6:
> +			strncat(cls_str, "Card reader", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		default:
> +			strncat(cls_str, "(reserved)", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		}
> +		if(strlen(cls_str) > 0)
> +			return cls_str;
> +	}
>  	case 6:	/* imaging */
>  		if (minor & 4)
>  			return "Display";
> @@ -617,6 +652,34 @@
>  		if (minor & 32)
>  			return "Printer";
>  		break;
> +	case 7: /* wearable */
> +		switch(minor) {
> +		case 1:
> +			return "Wrist Watch";
> +		case 2:
> +			return "Pager";
> +		case 3:
> +			return "Jacket";
> +		case 4:
> +			return "Helmet";
> +		case 5:
> +			return "Glasses";
> +		}
> +		break;
> +	case 8: /* toy */
> +		switch(minor) {
> +		case 1:
> +			return "Robot";
> +		case 2:
> +			return "Vehicle";
> +		case 3:
> +			return "Doll / Action Figure";
> +		case 4:
> +			return "Controller";
> +		case 5:
> +			return "Game";
> +		}
> +		break;
>  	case 63:	/* uncategorised */
>  		return "";
>  	}
> Index: tools/hcitool.c
> ===================================================================
> RCS file: /cvsroot/bluez/utils/tools/hcitool.c,v
> retrieving revision 1.91
> diff -u -r1.91 hcitool.c
> --- tools/hcitool.c	29 Sep 2006 11:42:14 -0000	1.91
> +++ tools/hcitool.c	7 Nov 2006 09:47:47 -0000
> @@ -245,16 +245,51 @@
>  			return "Gaming/Toy";
>  		}
>  		break;
> -	case 5:	/* peripheral */
> -		switch(minor) {
> +	case 5:	/* peripheral */ {
> +		static char cls_str[48]; cls_str[0] = 0;
> +
> +		switch(minor & 48) {
>  		case 16:
> -			return "Keyboard";
> +			strncpy(cls_str, "Keyboard", sizeof(cls_str));
> +			break;
>  		case 32:
> -			return "Pointing device";
> +			strncpy(cls_str, "Pointing device", sizeof(cls_str));
> +			break;
>  		case 48:
> -			return "Combo keyboard/pointing device";
> +			strncpy(cls_str, "Combo keyboard/pointing device", sizeof(cls_str));
> +			break;
>  		}
> +		if((minor & 15) && (strlen(cls_str) > 0))
> +			strcat(cls_str, "/");
> +
> +		switch(minor & 15) {
> +		case 0:
> +			break;
> +		case 1:
> +			strncat(cls_str, "Joystick", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		case 2:
> +			strncat(cls_str, "Gamepad", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		case 3:
> +			strncat(cls_str, "Remote control", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		case 4:
> +			strncat(cls_str, "Sensing device", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		case 5:
> +			strncat(cls_str, "Digitizer tablet", sizeof(cls_str) - strlen(cls_str));
>  		break;
> +		case 6:
> +			strncat(cls_str, "Card reader", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		default:
> +			strncat(cls_str, "(reserved)", sizeof(cls_str) - strlen(cls_str));
> +			break;
> +		}
> +		if(strlen(cls_str) > 0)
> +			return cls_str;
> +	}
>  	case 6:	/* imaging */
>  		if (minor & 4)
>  			return "Display";
> @@ -265,6 +300,34 @@
>  		if (minor & 32)
>  			return "Printer";
>  		break;
> +	case 7: /* wearable */
> +		switch(minor) {
> +		case 1:
> +			return "Wrist Watch";
> +		case 2:
> +			return "Pager";
> +		case 3:
> +			return "Jacket";
> +		case 4:
> +			return "Helmet";
> +		case 5:
> +			return "Glasses";
> +		}
> +		break;
> +	case 8: /* toy */
> +		switch(minor) {
> +		case 1:
> +			return "Robot";
> +		case 2:
> +			return "Vehicle";
> +		case 3:
> +			return "Doll / Action Figure";
> +		case 4:
> +			return "Controller";
> +		case 5:
> +			return "Game";
> +		}
> +		break;
>  	case 63:	/* uncategorised */
>  		return "";
>  	}
>   


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

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

end of thread, other threads:[~2006-12-13 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-07  9:56 [Bluez-devel] Patch with small CoD changes in hciconfig and hcitool Luciano Coelho
2006-12-13 13:37 ` Luciano Coelho

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