aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/client.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2010-07-30 18:20:31 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2010-08-09 18:06:48 -0400
commit754fce193b32950f83eb425ab025916aec310e0e (patch)
treeacc8f6e6afdb9c135fa142de7e0931846ab2c8c8 /attrib/client.c
parent68299d1d74863d752ee3756493a1be7aaa298794 (diff)
downloadbluez-754fce193b32950f83eb425ab025916aec310e0e.tar.gz
bluez-754fce193b32950f83eb425ab025916aec310e0e.tar.xz
bluez-754fce193b32950f83eb425ab025916aec310e0e.zip
Initial implementation of characteristics GetProperties()
Returns a dictionary of characteristic properties. Format, Value and Representation are not supported yet.
Diffstat (limited to 'attrib/client.c')
-rw-r--r--attrib/client.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/attrib/client.c b/attrib/client.c
index f0fe5e29..36e92129 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -34,8 +34,9 @@
#include <bluetooth/sdp_lib.h>
#include "log.h"
-#include "glib-helper.h"
#include "gdbus.h"
+#include "glib-helper.h"
+#include "dbus-common.h"
#include "btio.h"
#include "storage.h"
@@ -144,7 +145,37 @@ static GDBusMethodTable prim_methods[] = {
static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- return dbus_message_new_method_return(msg);
+ struct characteristic *chr = data;
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+ const char *name = "";
+ char *uuid;
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+
+ uuid = bt_uuid2string(&chr->type);
+ dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, &uuid);
+ g_free(uuid);
+
+ /* FIXME: Translate UUID to name. */
+ dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
+ dict_append_entry(&dict, "Description", DBUS_TYPE_STRING, &name);
+
+ /* FIXME: Missing Format, Value and Representation */
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
}
static GDBusMethodTable char_methods[] = {