From: Frederic Danis <frederic.danis@palmsource.com>
To: BlueZ development <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] [PATCH] Minor classes support
Date: Mon, 19 Jun 2006 14:59:15 +0200 [thread overview]
Message-ID: <44969FA3.7030805@palmsource.com> (raw)
In-Reply-To: <1150263854.5359.1.camel@aeonflux.holtmann.net>
[-- Attachment #1: Type: text/plain, Size: 596 bytes --]
Hello Marcel,
Marcel Holtmann wrote:
>Hi Frederic,
>
>
>
>>You can find attached a patch to support minor classes with the new DBus
>>API.
>>This patch updates functions : GetMajorClass, ListAvailableMinorClasses,
>>GetMinorClass, GetRemoteMajorClass, GetRemoteMinorClass and dbus-api.txt.
>>It also adds some call to exerce them (and discoveries) in dbus-test
>>program.
>>
>>
>
>I forgot to include this patch in the final 3.0 release. Can you please
>redo it against latest CVS.
>
>Regards
>
>Marcel
>
>
>
>
You can find attached this patch updated to latest cvs.
Regards
Fred
[-- Attachment #2: update_dbus_minor_classes.patch --]
[-- Type: text/plain, Size: 11923 bytes --]
diff -aur hcid.orig/dbus-adapter.c hcid/dbus-adapter.c
--- hcid.orig/dbus-adapter.c 2006-06-06 11:35:32.000000000 +0200
+++ hcid/dbus-adapter.c 2006-06-06 16:04:48.000000000 +0200
@@ -87,6 +87,79 @@
"isdn"
};
+static const char *access_point_minor_cls[] = {
+ "fully",
+ "1-17 percent",
+ "17-33 percent",
+ "33-50 percent",
+ "50-67 percent",
+ "67-83 percent",
+ "83-99 percent",
+ "not available"
+};
+
+static const char *audio_video_minor_cls[] = {
+ "uncategorized",
+ "headset",
+ "handsfree",
+ "unknown",
+ "microphone",
+ "loudspeaker",
+ "headphones",
+ "portable audio",
+ "car audio",
+ "set-top box",
+ "hifi audio",
+ "vcr",
+ "video camera",
+ "camcorder",
+ "video monitor",
+ "video display and loudspeaker",
+ "video conferencing",
+ "unknown",
+ "gaming/toy"
+};
+
+static const char *peripheral_minor_cls[] = {
+ "uncategorized",
+ "keyboard",
+ "pointing",
+ "combo"
+};
+
+static const char *peripheral_2_minor_cls[] = {
+ "uncategorized",
+ "joystick",
+ "gamepad",
+ "remote control",
+ "sensing",
+ "digitizer tablet",
+ "card reader"
+};
+
+static const char *imaging_minor_cls[] = {
+ "display",
+ "camera",
+ "scanner",
+ "printer"
+};
+
+static const char *wearable_minor_cls[] = {
+ "wrist watch",
+ "pager",
+ "jacket",
+ "helmet",
+ "glasses"
+};
+
+static const char *toy_minor_cls[] = {
+ "robot",
+ "vehicle",
+ "doll",
+ "controller",
+ "game"
+};
+
static int check_address(const char *addr)
{
char tmp[18];
@@ -548,18 +621,35 @@
static DBusHandlerResult handle_dev_get_major_class_req(DBusConnection *conn, DBusMessage *msg, void *data)
{
- DBusMessage *reply;
- const char *str_ptr = "computer";
+ const struct hci_dbus_data *dbus_data = data;
+ DBusMessage *reply = NULL;
+ int dd;
+ uint8_t cls[3];
+ uint8_t major_class;
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
return error_invalid_arguments(conn, msg);
+ dd = hci_open_dev(dbus_data->dev_id);
+ if (dd < 0)
+ return error_no_such_adapter(conn, msg);
+
+ if (hci_read_class_of_dev(dd, cls, 1000) < 0) {
+ error("Can't read class of device on hci%d: %s(%d)",
+ dbus_data->dev_id, strerror(errno), errno);
+ hci_close_dev(dd);
+ return error_failed(conn, msg, errno);
+ }
+
+ hci_close_dev(dd);
+
+ major_class = cls[1] & 0x1F;
+
reply = dbus_message_new_method_return(msg);
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
- /*FIXME: Check the real device major class */
- dbus_message_append_args(reply, DBUS_TYPE_STRING, &str_ptr,
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &major_cls[major_class],
DBUS_TYPE_INVALID);
return send_reply_and_unref(conn, reply);
@@ -603,6 +693,30 @@
minor_ptr = phone_minor_cls;
size = sizeof(phone_minor_cls) / sizeof(*phone_minor_cls);
break;
+ case 3: /* access point */
+ minor_ptr = access_point_minor_cls;
+ size = sizeof(access_point_minor_cls) / sizeof(*access_point_minor_cls);
+ break;
+ case 4: /* audio/video */
+ minor_ptr = audio_video_minor_cls;
+ size = sizeof(audio_video_minor_cls) / sizeof(*audio_video_minor_cls);
+ break;
+ case 5: /* peripheral */
+ minor_ptr = peripheral_minor_cls;
+ size = sizeof(peripheral_minor_cls) / sizeof(*peripheral_minor_cls);
+ break;
+ case 6: /* imaging */
+ minor_ptr = imaging_minor_cls;
+ size = sizeof(imaging_minor_cls) / sizeof(*imaging_minor_cls);
+ break;
+ case 7: /* wearable */
+ minor_ptr = wearable_minor_cls;
+ size = sizeof(wearable_minor_cls) / sizeof(*wearable_minor_cls);
+ break;
+ case 8: /* toy */
+ minor_ptr = toy_minor_cls;
+ size = sizeof(toy_minor_cls) / sizeof(*toy_minor_cls);
+ break;
default:
return error_unsupported_major_class(conn, msg);
}
@@ -629,7 +743,8 @@
const char *str_ptr = "";
uint8_t cls[3];
uint8_t minor_class;
- int dd;
+ const char **minor_ptr;
+ int dd, size;
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
return error_invalid_arguments(conn, msg);
@@ -651,17 +766,56 @@
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
- /* FIXME: Currently, only computer major class is supported */
- if ((cls[1] & 0x1f) != 1)
+ switch ((cls[1] & 0x1f)) {
+ case 1: /* computer */
+ minor_class = cls[0] >> 2;
+ minor_ptr = computer_minor_cls;
+ size = sizeof(computer_minor_cls) / sizeof(*computer_minor_cls);
+ break;
+ case 2: /* phone */
+ minor_class = cls[0] >> 2;
+ minor_ptr = phone_minor_cls;
+ size = sizeof(phone_minor_cls) / sizeof(*phone_minor_cls);
+ break;
+ case 3: /* access point */
+ minor_class = cls[0] >> 5;
+ minor_ptr = access_point_minor_cls;
+ size = sizeof(access_point_minor_cls) / sizeof(*access_point_minor_cls);
+ break;
+ case 4: /* audio/video */
+ minor_class = cls[0] >> 2;
+ minor_ptr = audio_video_minor_cls;
+ size = sizeof(audio_video_minor_cls) / sizeof(*audio_video_minor_cls);
+ break;
+ case 5: /* peripheral */
+ minor_class = cls[0] >> 6;
+ minor_ptr = peripheral_minor_cls;
+ size = sizeof(peripheral_minor_cls) / sizeof(*peripheral_minor_cls);
+ break;
+ case 6: /* imaging */
+ minor_class = cls[0] >> 4;
+ minor_ptr = imaging_minor_cls;
+ size = sizeof(imaging_minor_cls) / sizeof(*imaging_minor_cls);
+ break;
+ case 7: /* wearable */
+ minor_class = cls[0] >> 2;
+ minor_ptr = wearable_minor_cls;
+ size = sizeof(wearable_minor_cls) / sizeof(*wearable_minor_cls);
+ break;
+ case 8: /* toy */
+ minor_class = cls[0] >> 2;
+ minor_ptr = toy_minor_cls;
+ size = sizeof(toy_minor_cls) / sizeof(*toy_minor_cls);
+ break;
+ default:
goto failed;
+ }
- minor_class = cls[0] >> 2;
-
- /* Validate computer minor class */
- if (minor_class > (sizeof(computer_minor_cls) / sizeof(*computer_minor_cls)))
+ /* Validate minor class */
+ if (minor_class > size)
goto failed;
- str_ptr = computer_minor_cls[minor_class];
+ str_ptr = minor_ptr[minor_class];
failed:
dbus_message_append_args(reply, DBUS_TYPE_STRING, &str_ptr,
@@ -2199,13 +2353,33 @@
const char *minor_class_str(uint32_t class)
{
uint8_t major_index = (class >> 8) & 0x1F;
- uint8_t minor_index = (class >> 2) & 0x3F;
+ uint8_t minor_index;
switch (major_index) {
case 1: /* computer */
+ minor_index = (class >> 2) & 0x3F;
return computer_minor_cls[minor_index];
case 2: /* phone */
+ minor_index = (class >> 2) & 0x3F;
return phone_minor_cls[minor_index];
+ case 3: /* access point */
+ minor_index = (class >> 5) & 0x07;
+ return access_point_minor_cls[minor_index];
+ case 4: /* audio/video */
+ minor_index = (class >> 2) & 0x3F;
+ return audio_video_minor_cls[minor_index];
+ case 5: /* peripheral */
+ minor_index = (class >> 6) & 0x03;
+ return peripheral_minor_cls[minor_index];
+ case 6: /* imaging */
+ minor_index = (class >> 4) & 0x0F;
+ return imaging_minor_cls[minor_index];
+ case 7: /* wearable */
+ minor_index = (class >> 2) & 0x3F;
+ return wearable_minor_cls[minor_index];
+ case 8: /* toy */
+ minor_index = (class >> 2) & 0x3F;
+ return toy_minor_cls[minor_index];
}
return "";
diff -aur hcid.orig/dbus-api.txt hcid/dbus-api.txt
--- hcid.orig/dbus-api.txt 2006-06-06 11:35:33.000000000 +0200
+++ hcid/dbus-api.txt 2006-06-06 16:01:33.000000000 +0200
@@ -28,6 +28,23 @@
Minor classes phone uncategorized, cellular, cordless, smart phone,
modem, isdn
+Minor classes access point fully, 1-17 percent, 17-33 percent,
+ 33-50 percent, 50-67 percent, 67-83 percent,
+ 83-99 percent, not available
+
+Minor classes audio video uncategorized, headset, handsfree,microphone,
+ loudspeaker, headphones, portable audio, car audio,
+ set-top box, hifi audio, vcr, video camera, camcorder,
+ video monitor, video display and loudspeaker,
+ video conferencing, gaming/toy, unknown
+
+Minor classes peripheral uncategorized, keyboard, pointing, combo
+
+Minor classes imaging display, camera, scanner, printer
+
+Minor classes wearable wrist watch, pager, jacket, helmet, glasses
+
+Minor classes toy robot, vehicle, doll, controller, game
Error hierarchy
===============
@@ -291,7 +308,7 @@
string GetMajorClass()
Returns the current major class value for this
- system. This value is set to "computer" for now.
+ system.
If the major class can't be matched by a string
the decimal value as string should be returned.
@@ -301,27 +318,14 @@
array{string} ListAvailableMinorClasses()
Returns a list of available minor classes for the
- currently used major class. At the moment this should
- only return a list of minor classes if the major
- class is set to "computer".
-
- If the major class is not "computer" an error should
- be returned.
+ currently used major class.
Possible errors: org.bluez.Error.UnsupportedMajorClass
string GetMinorClass()
Returns the current minor class value for this
- system where the default major class is "computer".
-
- If the major class is not "computer" an error should
- be returned.
-
- Valid values: "uncategorized", "desktop", "server",
- "laptop", "handheld", "palm", "wearable"
-
- The default value is "uncategorized".
+ system.
Possible errors: org.bluez.Error.UnsupportedMajorClass
diff -aur hcid.orig/dbus-test hcid/dbus-test
--- hcid.orig/dbus-test 2006-06-01 14:28:41.000000000 +0200
+++ hcid/dbus-test 2006-06-06 15:21:19.000000000 +0200
@@ -36,6 +36,9 @@
"GetRemoteManufacturer",
"GetRemoteCompany",
"GetRemoteName",
+ "GetRemoteMajorClass",
+ "GetRemoteMinorClass",
+ "GetRemoteServiceClasses",
"GetRemoteAlias",
"SetRemoteAlias",
"ClearRemoteAlias",
@@ -276,7 +279,7 @@
print 'Usage: %s -i <dev> SetName newname' % self.name
elif self.cmd == 'GetRemoteName':
if len(self.cmd_args) == 1:
- print self.device.GetRemoteName()
+ print self.device.GetRemoteName(self.cmd_args[0])
else:
print 'Usage: %s -i <dev> GetRemoteName address' % self.name
elif self.cmd == 'GetRemoteVersion':
@@ -304,6 +307,21 @@
print self.device.GetRemoteAlias(self.cmd_args[0])
else:
print 'Usage: %s -i <dev> GetRemoteAlias address' % self.name
+ elif self.cmd == 'GetRemoteMajorClass':
+ if len(self.cmd_args) == 1:
+ print self.device.GetRemoteMajorClass(self.cmd_args[0])
+ else:
+ print 'Usage: %s -i <dev> GetRemoteMajorClass address' % self.name
+ elif self.cmd == 'GetRemoteMinorClass':
+ if len(self.cmd_args) == 1:
+ print self.device.GetRemoteMinorClass(self.cmd_args[0])
+ else:
+ print 'Usage: %s -i <dev> GetRemoteMinorClass address' % self.name
+ elif self.cmd == 'GetRemoteServiceClasses':
+ if len(self.cmd_args) == 1:
+ print self.device.GetRemoteServiceClasses(self.cmd_args[0])
+ else:
+ print 'Usage: %s -i <dev> GetRemoteServiceClasses address' % self.name
elif self.cmd == 'SetRemoteAlias':
if len(self.cmd_args) == 2:
self.device.SetRemoteAlias(self.cmd_args[0], self.cmd_args[1])
@@ -363,6 +381,10 @@
print self.device.GetEncryptionKeySize(self.cmd_args[0])
else:
print 'Usage: %s -i <dev> GetEncryptionKeySize address' % self.name
+ elif self.cmd == 'DiscoverDevices':
+ print self.device.DiscoverDevices()
+ elif self.cmd == 'DiscoverDevicesWithoutNameResolving':
+ print self.device.DiscoverDevicesWithoutNameResolving()
else:
# FIXME: remove at future version
print 'Script Error: Method %s not found. Maybe a mispelled word.' % (self.cmd_args)
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
[-- 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
next prev parent reply other threads:[~2006-06-19 12:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-06 14:25 [Bluez-devel] [PATCH] Minor classes support Frederic Danis
2006-06-14 5:44 ` Marcel Holtmann
2006-06-19 12:59 ` Frederic Danis [this message]
2006-06-26 12:35 ` Marcel Holtmann
2006-08-08 15:21 ` Frederic Danis
2006-08-09 22:20 ` Marcel Holtmann
2006-08-10 14:42 ` Frederic Danis
2006-08-10 19:02 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44969FA3.7030805@palmsource.com \
--to=frederic.danis@palmsource.com \
--cc=bluez-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).