* [Bluez-devel] [PATCH] Minor classes support
@ 2006-06-06 14:25 Frederic Danis
2006-06-14 5:44 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Frederic Danis @ 2006-06-06 14:25 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 674 bytes --]
Hello,
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.
Hope this helps
Regards
Fred
--
-----------------------------------------------
It is not by improving the oil lamp that one invents the electric bulb!
-----------------------------------------------
Danis Frederic PalmSource Europe
Software engineer
Mail : mailto:frederic.danis@palmsource.com
-----------------------------------------------
[-- 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,
@@ -2173,13 +2327,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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] [PATCH] Minor classes support
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
0 siblings, 1 reply; 8+ messages in thread
From: Marcel Holtmann @ 2006-06-14 5:44 UTC (permalink / raw)
To: BlueZ development
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
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] [PATCH] Minor classes support
2006-06-14 5:44 ` Marcel Holtmann
@ 2006-06-19 12:59 ` Frederic Danis
2006-06-26 12:35 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Frederic Danis @ 2006-06-19 12:59 UTC (permalink / raw)
To: BlueZ development
[-- 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] [PATCH] Minor classes support
2006-06-19 12:59 ` Frederic Danis
@ 2006-06-26 12:35 ` Marcel Holtmann
2006-08-08 15:21 ` Frederic Danis
0 siblings, 1 reply; 8+ messages in thread
From: Marcel Holtmann @ 2006-06-26 12:35 UTC (permalink / raw)
To: BlueZ development
Hi Frederic,
> You can find attached this patch updated to latest cvs.
I only applied parts of your patch. The only available major class is
still computer. This needs a little bit more base work before we can
also support other major classes.
Regards
Marcel
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
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] [PATCH] Minor classes support
2006-06-26 12:35 ` Marcel Holtmann
@ 2006-08-08 15:21 ` Frederic Danis
2006-08-09 22:20 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Frederic Danis @ 2006-08-08 15:21 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1: Type: text/plain, Size: 724 bytes --]
Hello,
We found a bug in DBus function GetRemoteMinorClass when major class is
"imaging". In this case, the minor class can be a combo of minor values
(minor part of the class is not an "index" in a table but a "field of
bit", e.g. "scanner printer").
The patch attached returns the first matching value. It may be useful to
change this API to allow it to return multiple values.
Regards
Fred
-----------------------------------------------
It is not by improving the oil lamp that one invents the electric bulb!
-----------------------------------------------
Danis Frederic PalmSource Europe
Software engineer
Mail : mailto:frederic.danis@palmsource.com
-----------------------------------------------
[-- Attachment #2: minor_imaging_fix.patch --]
[-- Type: text/plain, Size: 1363 bytes --]
--- dbus-adapter.c.orig 2006-08-08 15:35:30.000000000 +0200
+++ dbus-adapter.c 2006-08-08 15:37:42.000000000 +0200
@@ -1222,19 +1222,19 @@
void *data)
{
DBusMessage *reply;
- const char *major_class;
+ const char *minor_class;
uint32_t class;
if (get_remote_class(conn, msg, data, &class) < 0)
return DBUS_HANDLER_RESULT_HANDLED;
- major_class = minor_class_str(class);
+ minor_class = minor_class_str(class);
reply = dbus_message_new_method_return(msg);
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
- dbus_message_append_args(reply, DBUS_TYPE_STRING, &major_class,
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &minor_class,
DBUS_TYPE_INVALID);
return send_reply_and_unref(conn, reply);
@@ -2275,8 +2275,17 @@
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];
+ {
+ uint8_t shift_minor = 0;
+
+ minor_index = (class >> 4) & 0x0F;
+ while (shift_minor < (sizeof(imaging_minor_cls) / sizeof(*imaging_minor_cls))) {
+ if (((minor_index >> shift_minor) & 0x01) == 0x01)
+ return imaging_minor_cls[shift_minor];
+ shift_minor++;
+ }
+ }
+ break;
case 7: /* wearable */
minor_index = (class >> 2) & 0x3F;
return wearable_minor_cls[minor_index];
[-- 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] 8+ messages in thread
* Re: [Bluez-devel] [PATCH] Minor classes support
2006-08-08 15:21 ` Frederic Danis
@ 2006-08-09 22:20 ` Marcel Holtmann
2006-08-10 14:42 ` Frederic Danis
0 siblings, 1 reply; 8+ messages in thread
From: Marcel Holtmann @ 2006-08-09 22:20 UTC (permalink / raw)
To: BlueZ development
Hi Frederic,
> We found a bug in DBus function GetRemoteMinorClass when major class is
> "imaging". In this case, the minor class can be a combo of minor values
> (minor part of the class is not an "index" in a table but a "field of
> bit", e.g. "scanner printer").
> The patch attached returns the first matching value. It may be useful to
> change this API to allow it to return multiple values.
I applied the patch to the CVS. We might need some more defined minor
class strings in the documentation. Feel free to propose something, but
actually I prefer not to return more than one value or a list of
strings. This API is supposed to be simple.
I also added a GetRemoteClass to return the full 3 bytes class value.
Regards
Marcel
-------------------------------------------------------------------------
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
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] [PATCH] Minor classes support
2006-08-09 22:20 ` Marcel Holtmann
@ 2006-08-10 14:42 ` Frederic Danis
2006-08-10 19:02 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Frederic Danis @ 2006-08-10 14:42 UTC (permalink / raw)
To: BlueZ development
Hello,
>>We found a bug in DBus function GetRemoteMinorClass when major class is
>>"imaging". In this case, the minor class can be a combo of minor values
>>(minor part of the class is not an "index" in a table but a "field of
>>bit", e.g. "scanner printer").
>>The patch attached returns the first matching value. It may be useful to
>>change this API to allow it to return multiple values.
>>
>>
>
>I applied the patch to the CVS. We might need some more defined minor
>class strings in the documentation. Feel free to propose something, but
>actually I prefer not to return more than one value or a list of
>strings. This API is supposed to be simple.
>
>
>
>
Personnally, I think that returning a list of strings for minor class
can be the best way (for class of device with minor and subminor like
peripheral (i.e. "keyboard" "card reader"), or class that can have
multiple values for minor like imaging(i.e. "scanner" "printer")). If
you are okay with this I can try to work on a patch.
Regarding documentation in CVS (dbus-api.txt), only subminor for
peripheral seems to be missing. Am I right ?
Regards
Fred
-----------------------------------------------
It is not by improving the oil lamp that one invents the electric bulb!
-----------------------------------------------
Danis Frederic PalmSource Europe
Software engineer
Mail : mailto:frederic.danis@palmsource.com
-----------------------------------------------
-------------------------------------------------------------------------
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
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] [PATCH] Minor classes support
2006-08-10 14:42 ` Frederic Danis
@ 2006-08-10 19:02 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2006-08-10 19:02 UTC (permalink / raw)
To: BlueZ development
Hi Frederic,
> >>We found a bug in DBus function GetRemoteMinorClass when major class is
> >>"imaging". In this case, the minor class can be a combo of minor values
> >>(minor part of the class is not an "index" in a table but a "field of
> >>bit", e.g. "scanner printer").
> >>The patch attached returns the first matching value. It may be useful to
> >>change this API to allow it to return multiple values.
> >
> >I applied the patch to the CVS. We might need some more defined minor
> >class strings in the documentation. Feel free to propose something, but
> >actually I prefer not to return more than one value or a list of
> >strings. This API is supposed to be simple.
> >
> Personnally, I think that returning a list of strings for minor class
> can be the best way (for class of device with minor and subminor like
> peripheral (i.e. "keyboard" "card reader"), or class that can have
> multiple values for minor like imaging(i.e. "scanner" "printer")). If
> you are okay with this I can try to work on a patch.
>
> Regarding documentation in CVS (dbus-api.txt), only subminor for
> peripheral seems to be missing. Am I right ?
the class stuff is messed up and I personally think that we might should
not support all of their weird things. If we can decode it in a sane and
simple way, then we should return an error. In this case the raw three
bytes class values can used and the application has to implement its own
decoder.
Regards
Marcel
-------------------------------------------------------------------------
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
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-08-10 19:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).