aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2011-02-16 21:07:29 -0200
committerJohan Hedberg <johan.hedberg@nokia.com>2011-02-17 15:35:54 -0300
commitaaa550fe5165a115c32c6eb7b8fca91eac06aed8 (patch)
tree9fb4f8fc7ee5a3bafa092f2163995ed595008b3e /src
parent98ea92d146260bb110abcb87339bc7afe7959a66 (diff)
downloadbluez-aaa550fe5165a115c32c6eb7b8fca91eac06aed8.tar.gz
Update Device Appearance Characteristic based on device class
Appearance Characteristic value is still under discussion. Temporary solution which maps directly the device class of device(major and minor) into Device Characteristic value without shifting the two less significant bits reserved to Format Type. The second byte of the device class contains the major class in the 5 less significant bits.
Diffstat (limited to 'src')
-rw-r--r--src/adapter.c7
-rw-r--r--src/attrib-server.c28
-rw-r--r--src/attrib-server.h2
3 files changed, 35 insertions, 2 deletions
diff --git a/src/adapter.c b/src/adapter.c
index f63d9e45..e7b24957 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -55,6 +55,7 @@
#include "glib-helper.h"
#include "agent.h"
#include "storage.h"
+#include "attrib-server.h"
#include "att.h"
/* Flags Descriptions */
@@ -871,6 +872,12 @@ void btd_adapter_class_changed(struct btd_adapter *adapter, uint32_t new_class)
adapter->dev_class = new_class;
+ if (main_opts.attrib_server) {
+ /* Removes service class */
+ class[1] = class[1] & 0x1f;
+ attrib_gap_set(GATT_CHARAC_APPEARANCE, class, 2);
+ }
+
emit_property_changed(connection, adapter->path,
ADAPTER_INTERFACE, "Class",
DBUS_TYPE_UINT32, &new_class);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index fe5d68c7..b4df1371 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -72,6 +72,8 @@ static GIOChannel *le_io = NULL;
static GSList *clients = NULL;
static uint32_t sdp_handle = 0;
+static uint16_t appearance_handle = 0x0000;
+
static uuid_t prim_uuid = {
.type = SDP_UUID16,
.value.uuid16 = GATT_PRIM_SVC_UUID
@@ -820,16 +822,18 @@ static void register_core_services(void)
(uint8_t *) main_opts.name, len);
/* GAP service: device appearance characteristic */
+ appearance_handle = 0x0008;
sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
atval[0] = ATT_CHAR_PROPER_READ;
- att_put_u16(0x0008, &atval[1]);
+ att_put_u16(appearance_handle, &atval[1]);
att_put_u16(GATT_CHARAC_APPEARANCE, &atval[3]);
attrib_db_add(0x0007, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
/* GAP service: device appearance attribute */
sdp_uuid16_create(&uuid, GATT_CHARAC_APPEARANCE);
att_put_u16(appearance, &atval[0]);
- attrib_db_add(0x0008, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
+ attrib_db_add(appearance_handle, &uuid, ATT_NONE, ATT_NOT_PERMITTED,
+ atval, 2);
/* GATT service: primary service definition */
sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
@@ -1001,3 +1005,23 @@ int attrib_db_del(uint16_t handle)
return 0;
}
+
+int attrib_gap_set(uint16_t uuid, const uint8_t *value, int len)
+{
+ uuid_t u16;
+ uint16_t handle;
+
+ /* FIXME: Missing Name, Privacy and Reconnection Address */
+
+ sdp_uuid16_create(&u16, uuid);
+
+ switch (uuid) {
+ case GATT_CHARAC_APPEARANCE:
+ handle = appearance_handle;
+ break;
+ default:
+ return -ENOSYS;
+ }
+
+ return attrib_db_update(handle, &u16, value, len);
+}
diff --git a/src/attrib-server.h b/src/attrib-server.h
index ba90ff4c..252700fd 100644
--- a/src/attrib-server.h
+++ b/src/attrib-server.h
@@ -30,3 +30,5 @@ int attrib_db_add(uint16_t handle, uuid_t *uuid, int read_reqs, int write_reqs,
int attrib_db_update(uint16_t handle, uuid_t *uuid, const uint8_t *value,
int len);
int attrib_db_del(uint16_t handle);
+
+int attrib_gap_set(uint16_t uuid, const uint8_t *value, int len);