summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-04-19 15:58:09 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2012-04-19 15:58:09 +0200
commit7ddf494eeb877126b38f86e16bb19f7f4029bc1a (patch)
tree1e0f6885510ee33d60d8c421a7bba830fb1d7901
parentf0976392659e6c7a3675e4bf6b6c3f284809fa82 (diff)
downloadneard-7ddf494eeb877126b38f86e16bb19f7f4029bc1a.tar.gz
neard-7ddf494eeb877126b38f86e16bb19f7f4029bc1a.tar.bz2
neard-7ddf494eeb877126b38f86e16bb19f7f4029bc1a.zip
device: Initial commit
The device layer will define the NFC devices (in peer to peer mode at first) structure and operations.
-rw-r--r--Makefile.am6
-rw-r--r--doc/device-api.txt33
-rw-r--r--include/device.h29
-rw-r--r--src/device.c79
-rw-r--r--src/main.c2
-rw-r--r--src/near.h5
6 files changed, 151 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
index 88a9c80..2c0f0a6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ includedir = @includedir@/near
include_HEADERS = include/types.h include/log.h include/plugin.h \
include/tag.h include/adapter.h include/ndef.h \
- include/tlv.h include/setting.h
+ include/tlv.h include/setting.h include/device.h
nodist_include_HEADERS = include/version.h
@@ -30,7 +30,7 @@ libexec_PROGRAMS = src/neard
src_neard_SOURCES = $(gdbus_sources) $(gweb_sources) $(builtin_sources) \
src/main.c src/error.c src/near.h src/log.c \
- src/dbus.c src/manager.c src/adapter.c \
+ src/dbus.c src/manager.c src/adapter.c src/device.c \
src/tag.c src/plugin.c src/netlink.c src/ndef.c \
src/tlv.c src/bluetooth.c
@@ -59,7 +59,7 @@ else
build_plugindir = $(plugindir)
endif
-doc_files = doc/manager-api.txt doc/tag-api.txt doc/adapter-api.txt
+doc_files = doc/manager-api.txt doc/tag-api.txt doc/device-api.txt doc/adapter-api.txt
EXTRA_DIST = src/genbuiltin $(doc_files)
diff --git a/doc/device-api.txt b/doc/device-api.txt
new file mode 100644
index 0000000..bc783b2
--- /dev/null
+++ b/doc/device-api.txt
@@ -0,0 +1,33 @@
+Device hierarchy
+================
+
+Service org.neard
+Interface org.neard.Device
+Object path [variable prefix]/{nfc0}/{device0, device1...}
+
+Method dict GetProperties()
+
+ Returns all properties for the device. See the
+ properties section for available properties.
+
+ Possible Errors: org.neard.Error.DoesNotExist
+
+ void SetProperty(string name, variant value)
+
+ Changes the value of the specified property. Only
+ properties that are listed a read-write are changeable.
+ On success this will emit a PropertyChanged signal.
+
+ Possible Errors: org.neard.Error.DoesNotExist
+ org.neard.Error.InvalidArguments
+
+
+Signals PropertyChanged(string name, variant value)
+
+ This signal indicates a changed value of the given
+ property.
+
+
+Properties array{object} Records [readonly]
+
+ List of NDEF records object paths.
diff --git a/include/device.h b/include/device.h
new file mode 100644
index 0000000..349fdef
--- /dev/null
+++ b/include/device.h
@@ -0,0 +1,29 @@
+/*
+ *
+ * neard - Near Field Communication manager
+ *
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __NEAR_DEVICE_H
+#define __NEAR_DEVICE_H
+
+#include <stdint.h>
+
+#include <glib.h>
+
+#endif
diff --git a/src/device.c b/src/device.c
new file mode 100644
index 0000000..725367d
--- /dev/null
+++ b/src/device.c
@@ -0,0 +1,79 @@
+/*
+ *
+ * neard - Near Field Communication manager
+ *
+ * Copyright (C) 2011 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include <gdbus.h>
+
+#include "near.h"
+
+struct near_device {
+ char *path;
+
+ uint32_t adapter_idx;
+ uint32_t target_idx;
+
+ uint8_t nfcid[NFC_MAX_NFCID1_LEN];
+ uint8_t nfcid_len;
+
+ size_t data_length;
+ uint8_t *data;
+
+ uint32_t n_records;
+ GList *records;
+};
+
+static DBusConnection *connection = NULL;
+
+static GHashTable *device_hash;
+
+static void free_device(gpointer data)
+{
+}
+
+int __near_device_init(void)
+{
+ DBG("");
+
+ connection = near_dbus_get_connection();
+
+ device_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, free_device);
+
+ return 0;
+}
+
+void __near_device_cleanup(void)
+{
+ DBG("");
+
+ g_hash_table_destroy(device_hash);
+ device_hash = NULL;
+}
diff --git a/src/main.c b/src/main.c
index 447036c..c4f3d79 100644
--- a/src/main.c
+++ b/src/main.c
@@ -204,6 +204,7 @@ int main(int argc, char *argv[])
__near_netlink_init();
__near_tag_init();
+ __near_device_init();
__near_adapter_init();
__near_ndef_init();
__near_manager_init(conn);
@@ -224,6 +225,7 @@ int main(int argc, char *argv[])
__near_manager_cleanup();
__near_ndef_cleanup();
__near_adapter_cleanup();
+ __near_device_cleanup();
__near_tag_cleanup();
__near_netlink_cleanup();
diff --git a/src/near.h b/src/near.h
index f8391c7..b4f2de3 100644
--- a/src/near.h
+++ b/src/near.h
@@ -120,6 +120,11 @@ int __near_tag_add_ndef(struct near_tag *tag,
near_tag_io_cb cb);
int __near_tag_check_presence(struct near_tag *tag, near_tag_io_cb cb);
+#include <near/device.h>
+
+int __near_device_init(void);
+void __near_device_cleanup(void);
+
#include <near/tlv.h>
int __near_netlink_get_adapters(void);