linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez-devel] [DBUS PATCH]GetMinorClass
@ 2006-02-23 19:01 Claudio Takahasi
  2006-02-23 19:13 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Claudio Takahasi @ 2006-02-23 19:01 UTC (permalink / raw)
  To: bluez-devel

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

Hi Marcel,

Here is the GetMinorClass service. For major classes diferent than
Computer an empty reply is returned.

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

[-- Attachment #2: get-minor01.patch --]
[-- Type: text/x-patch, Size: 3270 bytes --]

Index: hcid/dbus-device.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-device.c,v
retrieving revision 1.13
diff -u -r1.13 dbus-device.c
--- hcid/dbus-device.c	23 Feb 2006 17:20:36 -0000	1.13
+++ hcid/dbus-device.c	23 Feb 2006 18:55:51 -0000
@@ -140,6 +140,50 @@
 	return reply;
 }
 
+static DBusMessage* handle_dev_get_minor_class_req(DBusMessage *msg, void *data)
+{
+	struct hci_dbus_data *dbus_data = data;
+	DBusMessage *reply;
+	const char *str_ptr;
+	uint8_t cls[3];
+	uint8_t minor_class;
+	int dd;
+
+	dd = hci_open_dev(dbus_data->dev_id);
+	if (dd < 0) {
+		syslog(LOG_ERR, "HCI device open failed: hci%d", dbus_data->dev_id);
+		return bluez_new_failure_msg(msg, BLUEZ_ESYSTEM_ENODEV);
+	}
+
+	if (hci_read_class_of_dev(dd, cls, 1000) < 0) {
+		syslog(LOG_ERR, "Can't read class of device on hci%d: %s(%d)",
+				       dbus_data->dev_id, strerror(errno), errno);
+		reply = bluez_new_failure_msg(msg, BLUEZ_ESYSTEM_OFFSET | errno);
+		goto failed;
+	}
+
+	reply = dbus_message_new_method_return(msg);
+
+	/* FIXME: Currently, only computer major class is supported */
+	if ((cls[1] & 0x1F) != 1)
+		goto failed;
+
+	minor_class = cls[0] >> 2;
+	/* validate computer minor class */
+	if (minor_class > (sizeof(computer_minor_cls) / sizeof(*computer_minor_cls)))
+		goto failed;
+
+	str_ptr = computer_minor_cls[minor_class];
+
+	dbus_message_append_args(reply, DBUS_TYPE_STRING, &str_ptr,
+				 	DBUS_TYPE_INVALID);
+failed:
+	if (dd >= 0)
+		hci_close_dev(dd);
+
+	return reply;
+}
+
 static DBusMessage* handle_dev_get_company_req(DBusMessage *msg, void *data)
 {
 	struct hci_dbus_data *dbus_data = data;
@@ -937,6 +981,7 @@
 	{ DEV_GET_FEATURES,		handle_dev_get_features_req,		DEV_GET_FEATURES_SIGNATURE		},
 	{ DEV_GET_MAJOR_CLASS,		handle_dev_get_major_class_req,		DEV_GET_MAJOR_CLASS_SIGNATURE		},
 	{ DEV_GET_MANUFACTURER,		handle_dev_get_manufacturer_req,	DEV_GET_MANUFACTURER_SIGNATURE		},
+	{ DEV_GET_MINOR_CLASS,		handle_dev_get_minor_class_req,		DEV_GET_MINOR_CLASS_SIGNATURE		},
 	{ DEV_GET_MODE,			handle_dev_get_mode_req,		DEV_GET_MODE_SIGNATURE			},
 	{ DEV_GET_NAME,			handle_dev_get_name_req,		DEV_GET_NAME_SIGNATURE			},
 	{ DEV_GET_REVISION,		handle_dev_get_revision_req,		DEV_GET_REVISION_SIGNATURE		},
Index: hcid/dbus.h
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus.h,v
retrieving revision 1.30
diff -u -r1.30 dbus.h
--- hcid/dbus.h	23 Feb 2006 17:17:18 -0000	1.30
+++ hcid/dbus.h	23 Feb 2006 18:55:51 -0000
@@ -114,6 +114,7 @@
 #define DEV_GET_FEATURES		"GetFeatures"
 #define DEV_GET_MAJOR_CLASS		"GetMajorClass"
 #define DEV_GET_MANUFACTURER		"GetManufacturer"
+#define DEV_GET_MINOR_CLASS		"GetMinorClass"
 #define DEV_GET_MODE			"GetMode"
 #define DEV_GET_NAME			"GetName"
 #define DEV_GET_REVISION		"GetRevision"
@@ -150,6 +151,7 @@
 #define DEV_GET_FEATURES_SIGNATURE			__END_SIG__
 #define DEV_GET_MAJOR_CLASS_SIGNATURE			__END_SIG__
 #define DEV_GET_MANUFACTURER_SIGNATURE			__END_SIG__
+#define DEV_GET_MINOR_CLASS_SIGNATURE                   __END_SIG__
 #define DEV_GET_MODE_SIGNATURE				__END_SIG__
 #define DEV_GET_NAME_SIGNATURE				__END_SIG__
 #define DEV_GET_REVISION_SIGNATURE			__END_SIG__

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

* Re: [Bluez-devel] [DBUS PATCH]GetMinorClass
  2006-02-23 19:01 [Bluez-devel] [DBUS PATCH]GetMinorClass Claudio Takahasi
@ 2006-02-23 19:13 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2006-02-23 19:13 UTC (permalink / raw)
  To: bluez-devel

Hi Claudio,

> Here is the GetMinorClass service. For major classes diferent than
> Computer an empty reply is returned.

the patch has been applied. Thanks and forget about my other email ;)

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
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-02-23 19:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-23 19:01 [Bluez-devel] [DBUS PATCH]GetMinorClass Claudio Takahasi
2006-02-23 19:13 ` Marcel Holtmann

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).