summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-10-26 01:27:03 +0200
committerArron Wang <arron.wang@intel.com>2013-07-09 08:26:23 +0800
commit2a1eb02692def3224bfe4b95617f85a2a85cadde (patch)
treed6f09afc60e90629b27cba729ae5901144186885
parent304e7dcaf536a11625a1694a19228e38babb3611 (diff)
downloadneard-2a1eb02692def3224bfe4b95617f85a2a85cadde.tar.gz
neard-2a1eb02692def3224bfe4b95617f85a2a85cadde.tar.bz2
neard-2a1eb02692def3224bfe4b95617f85a2a85cadde.zip
tag: Implement a raw NDEF accessor
-rw-r--r--doc/tag-api.txt4
-rw-r--r--src/tag.c29
-rwxr-xr-xtest/dump-tag7
3 files changed, 38 insertions, 2 deletions
diff --git a/doc/tag-api.txt b/doc/tag-api.txt
index 579e02e..43050f7 100644
--- a/doc/tag-api.txt
+++ b/doc/tag-api.txt
@@ -36,6 +36,10 @@ Method dict GetProperties()
org.neard.Error.InvalidArguments
org.neard.Error.InProgress
+ array{byte} GetRawNDEF()
+
+ Return the tag's NDEF as a raw bytes stream.
+
Signals PropertyChanged(string name, variant value)
diff --git a/src/tag.c b/src/tag.c
index 62923b1..f196e77 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -445,6 +445,32 @@ fail:
return __near_error_failed(msg, ENOMEM);
}
+static DBusMessage *get_raw_ndef(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct near_tag *tag = data;
+ DBusMessage *reply;
+ DBusMessageIter iter, array;
+
+ DBG("");
+
+ reply = dbus_message_new_method_return(msg);
+ if (reply == NULL)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_BYTE_AS_STRING,
+ &array);
+
+ __near_ndef_append_records(&array, tag->records);
+
+ dbus_message_iter_close_container(&iter, &array);
+
+ return reply;
+}
+
static const GDBusMethodTable tag_methods[] = {
{ GDBUS_METHOD("GetProperties",
NULL, GDBUS_ARGS({"properties", "a{sv}"}),
@@ -454,6 +480,9 @@ static const GDBusMethodTable tag_methods[] = {
NULL, set_property) },
{ GDBUS_ASYNC_METHOD("Write", GDBUS_ARGS({"attributes", "a{sv}"}),
NULL, write_ndef) },
+ { GDBUS_METHOD("GetRawNDEF",
+ NULL, GDBUS_ARGS({"raw NDEF", "ay"}),
+ get_raw_ndef) },
{ },
};
diff --git a/test/dump-tag b/test/dump-tag
index 01652ea..2092f28 100755
--- a/test/dump-tag
+++ b/test/dump-tag
@@ -9,10 +9,10 @@ if len(sys.argv) < 2:
bus = dbus.SystemBus()
-def extract_list(list):
+def extract_ndef(list):
val = "["
for i in list:
- val += " " + str(i)
+ val += " 0x%x" % i
val += " ]"
return val
@@ -36,9 +36,12 @@ tag = dbus.Interface(bus.get_object("org.neard", sys.argv[1]),
"org.neard.Tag")
properties = tag.GetProperties()
+raw_ndef = tag.GetRawNDEF()
print "[ %s ]" % (sys.argv[1])
+print " Raw NDEF = %s" % (extract_ndef(raw_ndef))
+
for key in properties.keys():
if key in ["Type"]:
val = str(properties[key])