Skip to contentSkip to conversation

device major/minor class patch

Bluez-devel Claudio Takahasi 1 participant 1 message Feb 8, 2006 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi,

Here is the first proposal to add device class major/minor class setup. It is not following the BlueZ API document yet. I am considering the class one property (GetProperty / SetProperty).

Some issues to be discussed:
1. Is it needed sent a signal to notify the major/minor class changes?
2. Should we use string to represent the major/minor classes? Define strings to represent the minor class can be painful :)

3. Should the minor class be a writeable property for all device classes?
eg: Access Point uses the minor class to represent the load. IMHO, maybe we need check if the D-Bus clients can overwrite the minor class. Is there another minor class with the same problem?

How test:
$dbus-send --system --type=method_call --dest=org.bluez --print-reply /org/bluez/Device/hci0 org.bluez.Device.SetProperty string:"class" byte:1 byte:3

$dbus-send --system --type=method_call --dest=org.bluez --print-reply /org/bluez/Device/hci0 org.bluez.Device.GetProperty string:"class"

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

hcid/hcid.h +2 -0
@@ -135,6 +135,7 @@
 void hcid_dbus_disconn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t reason);
 void hcid_dbus_auth_complete(bdaddr_t *local, bdaddr_t *peer, const uint8_t status);
 void hcid_dbus_setname_complete(bdaddr_t *local);
+void hcid_dbus_write_class_complete(bdaddr_t *local);
 void hcid_dbus_setscan_enable_complete(bdaddr_t *local);
 #else
 static inline void hcid_dbus_inquiry_start(bdaddr_t *local) {}
@@ -146,6 +147,7 @@
 static inline void hcid_dbus_disconn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t reason) {}
 static inline void hcid_dbus_auth_complete(bdaddr_t *local, bdaddr_t *peer, const uint8_t status) {}
 static inline void hcid_dbus_setname_complete(bdaddr_t *local) {}
+static inline void hcid_dbus_write_class_complete(bdaddr_t *local) {}
 static inline void hcid_dbus_setscan_enable_complete(bdaddr_t *local) {}
 #endif
 
hcid/security.c +3 -0
@@ -503,6 +503,9 @@
 	case cmd_opcode_pack(OGF_HOST_CTL, OCF_CHANGE_LOCAL_NAME):
 		hcid_dbus_setname_complete(sba);
 		break;
+	case cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_CLASS_OF_DEV):
+		hcid_dbus_write_class_complete(sba);
+		break;
 	case cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE):
 		hcid_dbus_setscan_enable_complete(sba);
 		break;
hcid/dbus.h +22 -2
@@ -143,12 +143,28 @@
 
 #define DEV_PROPERTY_AUTH		"auth"
 #define DEV_PROPERTY_ENCRYPT		"encrypt"
-#define DEV_PROPERTY_PSCAN		"connectable"
-#define DEV_PROPERTY_ISCAN		"discoverable"
 #define DEV_PROPERTY_NAME		"name"
+#define DEV_PROPERTY_CLASS		"class"
 #define DEV_PROPERTY_INCMODE		"incmode"
 #define DEV_PROPERTY_DEV_INFO		"info"
 
+/*
+ * Major/minor class constants
+ * Used on class property
+ */
+#define MAJOR_MISCELLANEOUS	0x00
+#define MAJOR_COMPUTER		0x01
+#define MAJOR_PHONE		0x02
+#define MAJOR_LAN		0x03
+#define MAJOR_AUDIOVIDEO	0x04
+#define MAJOR_PERIPHERAL	0x05
+#define MAJOR_IMAGING		0x06
+#define MAJOR_WEARABLE		0x07
+#define MAJOR_TOY		0x08
+#define MAJOR_UNCATEGORIZED	0x1F
+#define MAJOR_MAX_VALUE		MAJOR_TOY
+
+
 #define DEV_UP_SIGNATURE			__END_SIG__
 #define DEV_DOWN_SIGNATURE			__END_SIG__
 #define DEV_SET_MODE_SIGNATURE			DBUS_TYPE_BYTE_AS_STRING\
@@ -163,6 +179,10 @@
 #define DEV_SET_PROPERTY_SIGNATURE_BYTE		DBUS_TYPE_STRING_AS_STRING \
 						DBUS_TYPE_BYTE_AS_STRING \
 						__END_SIG__
+#define DEV_SET_PROPERTY_SIGNATURE_CLASS	DBUS_TYPE_STRING_AS_STRING\
+						DBUS_TYPE_BYTE_AS_STRING\
+						DBUS_TYPE_BYTE_AS_STRING\
+						__END_SIG__
 
 #define DEV_GET_PROPERTY_SIGNATURE		DBUS_TYPE_STRING_AS_STRING \
 						__END_SIG__
hcid/dbus.c +245 -27

360 lines not on this page · raw message

hcid/dbus-test +23 -4
@@ -209,11 +209,30 @@
         elif self.cmd == 'SetProperty':
             if len(self.cmd_args) < 2:
                 print 'Usage: %s -i <dev> SetProperty strPropName arg' % self.name
-                sys.exit(1)
-            try:
-                if self.cmd_args[0].lower() in dev_setprop_bool:
+		cmd_name = self.cmd_args[0].lower()
+		if cmd_name == 'name'
+		    print '\t Example: %s -i hci0 SetProperty name btadapter1' % self.name
+		elif cmd_name == 'class'
+                    print '\t Example: %s -i hci0 SetProperty class 1 3' % self.name
+                    print '\t Where the first property argument is the major class and the second one is the minor class'
+                    print '\t Major classes:'
+                    print '\t\t 0 - Miscellaneous'
+                    print '\t\t 1 - Computer(desktop, notebook, PDA, organizers, ...)'
+                    print '\t\t 2 - Phone(cellular, cordless, payphone, modem, ...)'
+                    print '\t\t 3 - LAN/Network Access Point'
+                    print '\t\t 4 - Audio/Video(headset, speaker, stereo, video display, vcr, ...)'
+                    print '\t\t 5 - Peripheral(mouse, joystick, keyboards, ...)'
+                    print '\t\t 6 - Imaging(printing, scanner, camera, display, ...)'
+                    print '\t\t 7 - Wearable'
+                    print '\t\t 8 - Toy'
+                sys.exit(1)
+            try:
+	        cmd_name = self.cmd_args[0].lower()
+                if cmd_name == 'class':
+                    self.dev.SetProperty(self.cmd_args[0], dbus.Byte(self.cmd_args[1]), dbus.Byte(self.cmd_args[2]))
+                elif cmd_name in dev_setprop_bool:
                     self.dev.SetProperty(self.cmd_args[0], dbus.Boolean(self.cmd_args[1]))
-                elif self.cmd_args[0].lower() in dev_setprop_byte:
+                elif cmd_name in dev_setprop_byte:
                     self.dev.SetProperty(self.cmd_args[0], dbus.Byte(self.cmd_args[1]))
                 else:
                     self.dev.SetProperty(self.cmd_args[0], self.cmd_args[1])