summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArron Wang <arron.wang@intel.com>2013-07-08 16:58:48 +0800
committerArron Wang <arron.wang@intel.com>2013-07-09 08:26:37 +0800
commitd7b798adada7556dcdf4972c4714548761e596e7 (patch)
tree58a212c1c9dc09af961e4fdebf8501e3c27af17e
parent2b9f59d4652df3de56d19aa6ef3974f3b6fdc0f0 (diff)
downloadneard-d7b798adada7556dcdf4972c4714548761e596e7.tar.gz
neard-d7b798adada7556dcdf4972c4714548761e596e7.tar.bz2
neard-d7b798adada7556dcdf4972c4714548761e596e7.zip
Add raw NDEF support for P2P
Change-Id: I516232587f196eebabebe44af12d777f960429d4
-rw-r--r--src/device.c31
-rwxr-xr-xtest/dump-device11
2 files changed, 42 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c
index 4f4306b..6baedea 100644
--- a/src/device.c
+++ b/src/device.c
@@ -238,6 +238,8 @@ static char *sn_from_message(DBusMessage *msg)
return NEAR_DEVICE_SN_HANDOVER;
else if (g_strcmp0(value, "MIME") == 0)
return NEAR_DEVICE_SN_SNEP;
+ else if (g_strcmp0(value, "Raw") == 0)
+ return NEAR_DEVICE_SN_SNEP;
else
return NULL;
@@ -290,6 +292,32 @@ error:
return __near_error_failed(msg, -err);
}
+static DBusMessage *dump_raw_ndef(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct near_device *device = 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, device->records);
+
+ dbus_message_iter_close_container(&iter, &array);
+
+ return reply;
+}
+
static const GDBusMethodTable device_methods[] = {
{ GDBUS_METHOD("GetProperties",
NULL, GDBUS_ARGS({"properties", "a{sv}"}),
@@ -299,6 +327,9 @@ static const GDBusMethodTable device_methods[] = {
NULL, set_property) },
{ GDBUS_ASYNC_METHOD("Push", GDBUS_ARGS({"attributes", "a{sv}"}),
NULL, push_ndef) },
+ { GDBUS_METHOD("DumpRawNDEF",
+ NULL, GDBUS_ARGS({"NDEF", "ay"}),
+ dump_raw_ndef) },
{ },
};
diff --git a/test/dump-device b/test/dump-device
index 6eead93..d19437a 100755
--- a/test/dump-device
+++ b/test/dump-device
@@ -9,6 +9,14 @@ if len(sys.argv) < 2:
bus = dbus.SystemBus()
+def extract_ndef(list):
+ val = "["
+ for i in list:
+ val += " 0x%x" % i
+ val += " ]"
+
+ return val
+
def extract_record(key, list):
for i in list:
record = dbus.Interface(bus.get_object("org.neard", i),
@@ -25,9 +33,12 @@ device = dbus.Interface(bus.get_object("org.neard", sys.argv[1]),
"org.neard.Device")
properties = device.GetProperties()
+raw_ndef = device.DumpRawNDEF()
print "[ %s ]" % (sys.argv[1])
+print " Raw NDEF = %s" % (extract_ndef(raw_ndef))
+
for key in properties.keys():
if key in ["Records"]:
extract_record(key, properties[key])