summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/tag-api.txt6
-rw-r--r--packaging/init3
-rw-r--r--packaging/neard.changes24
-rw-r--r--packaging/neard.service11
-rw-r--r--packaging/neard.spec99
-rw-r--r--src/ndef.c61
-rw-r--r--src/tag.c29
-rwxr-xr-xtest/dump-tag7
-rwxr-xr-xtest/write-tag11
9 files changed, 249 insertions, 2 deletions
diff --git a/doc/tag-api.txt b/doc/tag-api.txt
index b13a90c..43050f7 100644
--- a/doc/tag-api.txt
+++ b/doc/tag-api.txt
@@ -29,11 +29,17 @@ Method dict GetProperties()
record type and is described by the Record properties.
For example, one would add a type, a Language, an
Encoding and a Representation for a text record.
+ To push raw NDEF, one should use the NDEF key and use
+ an array of bytes for the NDEF stream.
Possible Errors: org.neard.Error.PermissionDenied
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/packaging/init b/packaging/init
new file mode 100644
index 0000000..759a352
--- /dev/null
+++ b/packaging/init
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+/usr/libexec/neard
diff --git a/packaging/neard.changes b/packaging/neard.changes
new file mode 100644
index 0000000..e3af7b5
--- /dev/null
+++ b/packaging/neard.changes
@@ -0,0 +1,24 @@
+* Tue Sep 11 2012 arron.wang <arron.wang@intel.com> submit/2.0_beta/20120831.083207@3ecb862
+- Update License Info
+
+* Tue Aug 28 2012 Arron < arron.wang@intel.com> - 0.6
+- Upgrade to version 0.6
+
+* Mon Aug 6 10:39:42 CST 2012 Arron <arron.wang@intel.com>
+- Add systemd support
+
+* Fri Aug 03 2012 Anas Nashif <anas.nashif@intel.com> a7864dd
+- fix runtime requirements
+
+* Tue Jul 31 09:22:14 CST 2012 Arron <arron.wang@intel.com> - 0.5
+- Upgrade to version 0.5
+
+* Tue Apr 24 2012 Arron <arron.wang@intel.com> - 0.2.26
+- Upgrade to latest version
+
+* Fri Apr 20 2012 Arron <arron.wang@intel.com> - 0.1.64
+- Add building require for kernel-adaptation-bb-devel to fix the building error
+
+* Fri Mar 30 2012 Arron <arron.wang@intel.com> - 0.1.64
+- Init package for neard
+
diff --git a/packaging/neard.service b/packaging/neard.service
new file mode 100644
index 0000000..5ea1e81
--- /dev/null
+++ b/packaging/neard.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=NFC Manager Daemon
+Before=network.target
+
+[Service]
+Type=dbus
+BusName=org.neard
+ExecStart=/usr/libexec/neard -n
+
+[Install]
+WantedBy=multi-user.target
diff --git a/packaging/neard.spec b/packaging/neard.spec
new file mode 100644
index 0000000..fcdd501
--- /dev/null
+++ b/packaging/neard.spec
@@ -0,0 +1,99 @@
+Name: neard-tizen
+Summary: Near Field Communication Manager
+Version: 0.8
+Release: 1
+Group: System/Networking
+License: GPLv2
+Source0: http://www.kernel.org/pub/linux/network/nfc/neard-%{version}.tar.bz2
+Source1: init
+Source2: neard.service
+Requires(post): /bin/ln
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(libnl-2.0)
+
+Requires: systemd
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+
+%description
+Near Field Communication Manager
+
+
+
+%package devel
+Summary: Development files for NFC Manager
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+neard-devel contains development files for use with neard.
+
+%package test
+Summary: Test Scripts for NFC Manager
+Group: Development/Tools
+Requires: %{name} = %{version}-%{release}
+Requires: dbus-python
+Requires: pygobject
+
+%description test
+Scripts for testing neard and its functionality
+
+%prep
+%setup -q
+
+%build
+./bootstrap
+%configure \
+ --enable-debug \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --enable-nfctype1=builtin \
+ --enable-nfctype2=builtin \
+ --enable-nfctype3=builtin \
+ --enable-nfctype4=builtin \
+ --disable-p2p \
+ --enable-test
+
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+mkdir -p %{buildroot}/etc/rc.d/init.d
+cp %{SOURCE1} %{buildroot}/etc/rc.d/init.d/neard
+chmod +x %{buildroot}/etc/rc.d/init.d/neard
+
+# Systemd service file
+install -d %{buildroot}%{_libdir}/systemd/system/
+install -m 644 %{S:2} %{buildroot}%{_libdir}/systemd/system/neard.service
+install -d %{buildroot}%{_libdir}/systemd/system/network.target.wants/
+ln -s ../neard.service %{buildroot}%{_libdir}/systemd/system/network.target.wants/neard.service
+
+%post
+ln -sf ../init.d/neard /etc/rc.d/rc3.d/S64neard
+systemctl daemon-reload
+systemctl restart neard.service
+
+%preun
+systemctl stop neard.service
+
+%postun
+systemctl daemon-reload
+
+%files
+%doc COPYING
+/usr/libexec/neard
+/etc/dbus-1/system.d/org.neard.conf
+/etc/rc.d/init.d/*
+%{_libdir}/systemd/system/neard.service
+%{_libdir}/systemd/system/network.target.wants/neard.service
+
+%files devel
+%{_includedir}/near/*.h
+%{_libdir}/pkgconfig/*.pc
+
+%files test
+%defattr(-,root,root,-)
+%{_libdir}/neard/test/*
diff --git a/src/ndef.c b/src/ndef.c
index b8d7c2d..930af3e 100644
--- a/src/ndef.c
+++ b/src/ndef.c
@@ -3067,6 +3067,64 @@ static struct near_ndef_message *build_ho_record(DBusMessage *msg)
return ho;
}
+static struct near_ndef_message * build_raw_ndef(DBusMessage *msg)
+{
+ DBusMessageIter iter, arr_iter;
+ struct near_ndef_message *ndef;
+
+ DBG("");
+
+ ndef = NULL;
+
+ dbus_message_iter_init(msg, &iter);
+ dbus_message_iter_recurse(&iter, &arr_iter);
+
+ while (dbus_message_iter_get_arg_type(&arr_iter) !=
+ DBUS_TYPE_INVALID) {
+ const char *key;
+ DBusMessageIter ent_iter;
+ DBusMessageIter var_iter;
+
+ dbus_message_iter_recurse(&arr_iter, &ent_iter);
+ dbus_message_iter_get_basic(&ent_iter, &key);
+ dbus_message_iter_next(&ent_iter);
+ dbus_message_iter_recurse(&ent_iter, &var_iter);
+
+ switch (dbus_message_iter_get_arg_type(&var_iter)) {
+ case DBUS_TYPE_ARRAY:
+ if (g_strcmp0(key, "NDEF") == 0) {
+ DBusMessageIter array;
+ uint8_t *data;
+ int data_size;
+
+ dbus_message_iter_recurse(&var_iter, &array);
+ dbus_message_iter_get_fixed_array(&array,
+ &data,
+ &data_size);
+
+ ndef = g_try_malloc0(data_size);
+ if (ndef == NULL)
+ break;
+
+ ndef->data = g_try_malloc0(data_size);
+ if (ndef->data == NULL) {
+ g_free(ndef);
+ break;
+ }
+
+ ndef->length = data_size;
+ memcpy(ndef->data, data, data_size);
+ }
+
+ break;
+ }
+
+ dbus_message_iter_next(&arr_iter);
+ }
+
+ return ndef;
+}
+
struct near_ndef_message *__ndef_build_from_message(DBusMessage *msg)
{
DBusMessageIter iter;
@@ -3113,6 +3171,9 @@ struct near_ndef_message *__ndef_build_from_message(DBusMessage *msg)
} else if (g_strcmp0(value, "Handover") == 0) {
ndef = build_ho_record(msg);
break;
+ } else if (g_strcmp0(value, "Raw") == 0) {
+ ndef = build_raw_ndef(msg);
+ break;
} else {
near_error("%s not supported", value);
ndef = NULL;
diff --git a/src/tag.c b/src/tag.c
index 54b7a9e..f4801ea 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({"NDEF", "ay"}),
+ get_raw_ndef) },
{ },
};
diff --git a/test/dump-tag b/test/dump-tag
index 8ce8d6b..4e987fc 100755
--- a/test/dump-tag
+++ b/test/dump-tag
@@ -5,10 +5,10 @@ import dbus
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
@@ -29,9 +29,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])
diff --git a/test/write-tag b/test/write-tag
index 912d8a3..c1af319 100755
--- a/test/write-tag
+++ b/test/write-tag
@@ -15,6 +15,7 @@ def help_text():
print "e.g. < %s /org/neard/nfc0/tag0 SmartPoster http://www.nfc-forum.com >" % (sys.argv[0])
print "e.g. < %s /org/neard/nfc0/tag0 SMS 0102030405 YourSMSMessage >" % (sys.argv[0])
print "e.g. < %s /org/neard/nfc0/tag0 E-Mail test@test.com >" % (sys.argv[0])
+ print "e.g. < %s /org/neard/nfc0/tag0 Raw <NDEF_file> >" % (sys.argv[0])
sys.exit(1)
if len(sys.argv) < 2:
@@ -49,5 +50,15 @@ elif sys.argv[2] in ["E-Mail"]:
tag.Write(({ "Type" : "URI",
"URI" : URI }))
+elif sys.argv[2] in ["Raw"]:
+ ndef = file(sys.argv[3]).read().rsplit(' ')
+ ndef_stream = bytearray()
+
+ for b in ndef:
+ ndef_stream.append(int(b, 16))
+
+ tag.Write(({ "Type" : "Raw",
+ "NDEF" : dbus.ByteArray(ndef_stream) }))
+
else:
help_text()