From 7ddf494eeb877126b38f86e16bb19f7f4029bc1a Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Thu, 19 Apr 2012 15:58:09 +0200 Subject: device: Initial commit The device layer will define the NFC devices (in peer to peer mode at first) structure and operations. --- Makefile.am | 6 ++--- doc/device-api.txt | 33 +++++++++++++++++++++++ include/device.h | 29 ++++++++++++++++++++ src/device.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.c | 2 ++ src/near.h | 5 ++++ 6 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 doc/device-api.txt create mode 100644 include/device.h create mode 100644 src/device.c 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 + +#include + +#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 +#endif + +#include +#include +#include +#include + +#include + +#include + +#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 + +int __near_device_init(void); +void __near_device_cleanup(void); + #include int __near_netlink_get_adapters(void); -- cgit v1.2.3