summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-03-16 11:32:06 +1000
committerJohan Hedberg <johan.hedberg@nokia.com>2009-03-15 23:06:27 -0300
commitb3778a7e531113f1125be0e7cc63a7f0a3340fc0 (patch)
treedbf61aa3544d19375a085fe10d5a5d063e7e6da2
parent53de3ecc006e71e16feed4aa2b572e168d2a00be (diff)
Add "Class" property to org.bluez.Adapter interface.
-rw-r--r--doc/adapter-api.txt4
-rw-r--r--src/adapter.c13
2 files changed, 17 insertions, 0 deletions
diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index eb973ec1..1e03b4e2 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -210,6 +210,10 @@ Properties string Address [readonly]
The Bluetooth friendly name. This value can be
changed and a PropertyChanged signal will be emitted.
+ uint32 Class [readonly]
+
+ The Bluetooth class of device.
+
boolean Powered [readwrite]
Switch an adapter on or off. This will also set the
diff --git a/src/adapter.c b/src/adapter.c
index 52b58c4e..821fd2b1 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1192,6 +1192,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
DBusMessageIter iter;
DBusMessageIter dict;
char str[249], srcaddr[18];
+ uint32_t class;
gboolean value;
char **devices;
int i;
@@ -1224,6 +1225,12 @@ static DBusMessage *get_properties(DBusConnection *conn,
dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &property);
+ /* Class */
+ class = adapter->dev.class[0] |
+ adapter->dev.class[1] << 8 |
+ adapter->dev.class[2] << 16;
+ dict_append_entry(&dict, "Class", DBUS_TYPE_UINT32, &class);
+
/* Powered */
value = adapter->up ? TRUE : FALSE;
dict_append_entry(&dict, "Powered", DBUS_TYPE_BOOLEAN, &value);
@@ -2326,6 +2333,7 @@ int adapter_get_class(struct btd_adapter *adapter, uint8_t *cls)
int adapter_set_class(struct btd_adapter *adapter, uint8_t *cls)
{
struct hci_dev *dev = &adapter->dev;
+ uint32_t class;
if (memcmp(dev->class, cls, 3) == 0)
return 0;
@@ -2334,6 +2342,11 @@ int adapter_set_class(struct btd_adapter *adapter, uint8_t *cls)
write_local_class(&adapter->bdaddr, cls);
+ class = cls[0] | (cls[1] << 8) | (cls[2] << 16);
+
+ emit_property_changed(connection, adapter->path, ADAPTER_INTERFACE,
+ "Class", DBUS_TYPE_UINT32, &class);
+
return 0;
}