summaryrefslogtreecommitdiff
path: root/src/adapter.c
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2012-07-30 11:01:19 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2012-07-30 13:48:43 +0300
commit1baf8702e15733d45197f5e7cc41dd1f25eff039 (patch)
tree390081b48190fbc8c7bad9f40e58069a6ee1a81e /src/adapter.c
parent43e81d71dd28eefa637b812eeeec413ce45b03fb (diff)
Fix not setting class of device in adapter
Set class of device in adapter when new class is received from kernel. This fix adapters property Class being always zero.
Diffstat (limited to 'src/adapter.c')
-rw-r--r--src/adapter.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/adapter.c b/src/adapter.c
index 1c6e57b4..b7691d00 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -684,27 +684,32 @@ static DBusMessage *set_pairable_timeout(DBusConnection *conn,
return dbus_message_new_method_return(msg);
}
-void btd_adapter_class_changed(struct btd_adapter *adapter, uint32_t new_class)
+void btd_adapter_class_changed(struct btd_adapter *adapter, uint8_t *new_class)
{
- uint8_t class[3];
+ uint32_t class;
- class[2] = (new_class >> 16) & 0xff;
- class[1] = (new_class >> 8) & 0xff;
- class[0] = new_class & 0xff;
+ class = new_class[0] | (new_class[1] << 8) | (new_class[2] << 16);
- write_local_class(&adapter->bdaddr, class);
+ if (class == adapter->dev_class)
+ return;
+
+ write_local_class(&adapter->bdaddr, new_class);
- adapter->dev_class = new_class;
+ adapter->dev_class = class;
if (main_opts.gatt_enabled) {
+ uint8_t cls[3];
+
+ memcpy(cls, new_class, sizeof(cls));
+
/* Removes service class */
- class[1] = class[1] & 0x1f;
- attrib_gap_set(adapter, GATT_CHARAC_APPEARANCE, class, 2);
+ cls[1] = cls[1] & 0x1f;
+ attrib_gap_set(adapter, GATT_CHARAC_APPEARANCE, cls, 2);
}
emit_property_changed(connection, adapter->path,
ADAPTER_INTERFACE, "Class",
- DBUS_TYPE_UINT32, &new_class);
+ DBUS_TYPE_UINT32, &class);
}
void adapter_name_changed(struct btd_adapter *adapter, const char *name)