[-]
[+]
|
Changed |
_service:tar_git:libnciplugin.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:libnciplugin.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,7 +2,7 @@
<service name="tar_git">
<param name="url">https://github.com/mer-hybris/libnciplugin.git</param>
<param name="branch">master</param>
- <param name="revision">1.0.7</param>
+ <param name="revision">1.1.0</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:libnciplugin-1.1.0.tar.bz2/LICENSE
^
|
@@ -1,5 +1,6 @@
-Copyright (C) 2019-2020 Jolla Ltd.
-Copyright (C) 2019-2020 Slava Monich <slava.monich@jolla.com>
+Copyright (C) 2019-2021 Jolla Ltd.
+Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
+Copyright (C) 2020 Open Mobile Platform LLC.
You may use this file under the terms of the BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:libnciplugin-1.1.0.tar.bz2/Makefile
^
|
@@ -1,7 +1,6 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: clean all debug release coverage pkgconfig install install-dev test
-.PHONY: print_debug_lib print_release_lib print_coverage_lib
+.PHONY: clean all debug release coverage pkgconfig install install-dev
#
# Required packages
@@ -33,8 +32,8 @@
#
VERSION_MAJOR = 1
-VERSION_MINOR = 0
-VERSION_RELEASE = 7
+VERSION_MINOR = 1
+VERSION_RELEASE = 0
# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
@@ -45,6 +44,7 @@
SRC = \
nci_adapter.c \
+ nci_initiator.c \
nci_target.c
#
@@ -136,15 +136,6 @@
pkgconfig: $(PKGCONFIG)
-print_debug_lib:
- @echo $(DEBUG_STATIC_LIB)
-
-print_release_lib:
- @echo $(RELEASE_STATIC_LIB)
-
-print_coverage_lib:
- @echo $(COVERAGE_STATIC_LIB)
-
clean:
rm -f *~ $(SRC_DIR)/*~ $(INCLUDE_DIR)/*~ rpm/*~
rm -fr $(BUILD_DIR) RPMS installroot
@@ -231,7 +222,7 @@
INSTALL_PKGCONFIG_DIR = $(DESTDIR)$(ABS_LIBDIR)/pkgconfig
install: $(INSTALL_LIB_DIR)
- $(INSTALL_FILES) $(RELEASE_LIB) $(INSTALL_LIB_DIR)
+ $(INSTALL) -m 755 $(RELEASE_LIB) $(INSTALL_LIB_DIR)
ln -sf $(LIB) $(INSTALL_LIB_DIR)/$(LIB_SYMLINK2)
ln -sf $(LIB_SYMLINK2) $(INSTALL_LIB_DIR)/$(LIB_SYMLINK1)
|
[-]
[+]
|
Changed |
_service:tar_git:libnciplugin-1.1.0.tar.bz2/debian/changelog
^
|
@@ -1,3 +1,33 @@
+libnciplugin (1.1.0) unstable; urgency=low
+
+ * Implemented NfcInitiator for NFC-DEP
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 15 Jan 2021 17:57:59 +0200
+
+libnciplugin (1.0.11) unstable; urgency=low
+
+ * Fixed reactivation logic to handle random UID
+
+ -- Slava Monich <slava.monich@jolla.com> Thu, 24 Sep 2020 17:19:28 +0300
+
+libnciplugin (1.0.10) unstable; urgency=low
+
+ * Add access to poll parameters for Type 4B tags
+
+ -- Slava Monich <slava.monich@jolla.com> Thu, 27 Aug 2020 19:42:56 +0300
+
+libnciplugin (1.0.9) unstable; urgency=low
+
+ * Add missing activation parameters for Type 4A/B tags
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 21 Aug 2020 17:11:13 +0300
+
+libnciplugin (1.0.8) unstable; urgency=low
+
+ * Disable transmit timeouts for ISO-DEP targets
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 07 Aug 2020 13:57:28 +0300
+
libnciplugin (1.0.7) unstable; urgency=low
* Respect arch specific lib dir
|
[-]
[+]
|
Changed |
_service:tar_git:libnciplugin-1.1.0.tar.bz2/debian/control
^
|
@@ -2,13 +2,13 @@
Section: libs
Priority: optional
Maintainer: Slava Monich <slava.monich@jolla.com>
-Build-Depends: debhelper (>= 8.1.3), libglib2.0-dev (>= 2.0), libglibutil-dev, libncicore-dev
+Build-Depends: debhelper (>= 8.1.3), libglib2.0-dev (>= 2.0), libglibutil-dev, libncicore-dev (>= 1.1.11)
Standards-Version: 3.8.4
Package: libnciplugin
Section: libs
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
+Depends: libncicore (>= 1.1.11), ${shlibs:Depends}, ${misc:Depends}
Description: Support library for NCI-based nfcd plugins
Package: libnciplugin-dev
|
[-]
[+]
|
Changed |
_service:tar_git:libnciplugin-1.1.0.tar.bz2/debian/copyright
^
|
@@ -1,5 +1,6 @@
Copyright (C) 2019-2020 Jolla Ltd.
Copyright (C) 2019-2020 Slava Monich <slava.monich@jolla.com>
+Copyright (C) 2020 Open Mobile Platform LLC.
You may use this file under the terms of the BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:libnciplugin-1.1.0.tar.bz2/src/nci_adapter.c
^
|
@@ -1,6 +1,7 @@
/*
- * Copyright (C) 2019-2020 Jolla Ltd.
- * Copyright (C) 2019-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -42,12 +43,16 @@
#include "nci_plugin_log.h"
#include <nfc_adapter_impl.h>
+#include <nfc_initiator_impl.h>
#include <nfc_target_impl.h>
#include <nfc_tag_t2.h>
#include <nfc_tag_t4.h>
+#include <nfc_peer.h>
#include <nci_core.h>
+#include <nci_util.h>
+#include <gutil_misc.h>
#include <gutil_macros.h>
GLOG_MODULE_DEFINE("nciplugin");
@@ -66,6 +71,7 @@
NCI_MODE mode;
GUtilData mode_param;
GUtilData activation_param;
+ NciModeParam* mode_param_parsed;
} NciAdapterIntfInfo;
struct nci_adapter_priv {
@@ -78,21 +84,26 @@
guint presence_check_timer;
NciAdapterIntfInfo* active_intf;
gboolean reactivating;
+ NfcInitiator *initiator;
};
-G_DEFINE_ABSTRACT_TYPE(NciAdapter, nci_adapter, NFC_TYPE_ADAPTER)
+#define PARENT_CLASS nci_adapter_parent_class
+#define THIS_TYPE NCI_TYPE_ADAPTER
+#define THIS(obj) NCI_ADAPTER(obj)
#define NCI_ADAPTER_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), \
NCI_TYPE_ADAPTER, NciAdapterClass)
-#define SUPER_CLASS nci_adapter_parent_class
+
+G_DEFINE_ABSTRACT_TYPE(NciAdapter, nci_adapter, NFC_TYPE_ADAPTER)
#define PRESENCE_CHECK_PERIOD_MS (250)
+#define RANDOM_UID_SIZE (4)
+#define RANDOM_UID_START_BYTE (0x08)
+
/*==========================================================================*
* Implementation
*==========================================================================*/
-#define nci_adapter_intf_info_free(x) g_free(x)
-
static
NciAdapterIntfInfo*
nci_adapter_intf_info_new(
@@ -126,6 +137,10 @@
} else {
info->activation_param.bytes = NULL;
}
+
+ info->mode_param_parsed = nci_util_copy_mode_param(ntf->mode_param,
+ ntf->mode);
+
return info;
}
return NULL;
@@ -133,6 +148,120 @@
static
gboolean
+mode_param_match_poll_a(
+ const NciModeParamPollA* pa1,
+ const NciModeParamPollA* pa2)
+{
+ /*
+ * Compare all fields except UID 'cause UID may be
+ * changed after losing field
+ */
+ return pa1->sel_res == pa2->sel_res &&
+ pa1->sel_res_len == pa2->sel_res_len &&
+ !memcmp(pa1->sens_res, pa2->sens_res, sizeof(pa2->sens_res));
+}
+
+static
+gboolean
+mode_param_match_poll_b(
+ const NciModeParamPollB* pb1,
+ const NciModeParamPollB* pb2)
+{
+ /*
+ * Compare all fields except UID 'cause UID may be
+ * changed after losing field
+ */
+ return pb1->fsc == pb2->fsc &&
+ !memcmp(pb1->app_data, pb2->app_data, sizeof(pb2->app_data)) &&
+ pb1->prot_info.size == pb2->prot_info.size &&
+ gutil_data_equal(&pb1->prot_info, &pb2->prot_info);
+}
+
+static
+gboolean
+mode_param_match_poll_a_t2(
+ const NciModeParamPollA* pa1,
+ const NciModeParamPollA* pa2)
+{
+ gboolean partial_match = mode_param_match_poll_a(pa1, pa2);
+
+ /*
+ * For tag type 2 logic is almost the same, but random UID has some
+ * limitations: according to AN10927 Random UID RID should be handled
+ * separately - single sized (4 bytes) starting with 0x08
+ */
+ if (pa1->nfcid1_len == pa2->nfcid1_len &&
+ pa2->nfcid1_len == RANDOM_UID_SIZE &&
+ pa1->nfcid1[0] == pa2->nfcid1[0] &&
+ pa2->nfcid1[0] == RANDOM_UID_START_BYTE) {
+ return partial_match;
+ } else {
+ /* Otherwise UID should fully match */
+ return partial_match &&
+ pa1->nfcid1_len == pa2->nfcid1_len &&
+ !memcmp(pa1->nfcid1, pa2->nfcid1, pa2->nfcid1_len);
+ }
+}
+
+static
+gboolean
+nci_adapter_info_mode_params_matches(
+ const NciAdapterIntfInfo* info,
+ const NciIntfActivationNtf* ntf)
+{
+ const NciModeParam* mp1 = info->mode_param_parsed;
+ const NciModeParam* mp2 = ntf->mode_param;
+
+ if (mp1 && mp2) {
+ /* Mode params criteria depends on type of tag */
+ switch (ntf->mode) {
+ case NCI_MODE_PASSIVE_POLL_A:
+ switch (ntf->rf_intf) {
+ case NCI_RF_INTERFACE_FRAME:
+ /* Type 2 Tag */
+ return mode_param_match_poll_a_t2(&mp1->poll_a, &mp2->poll_a);
+ case NCI_RF_INTERFACE_ISO_DEP:
+ /* ISO-DEP Type 4A */
+ return mode_param_match_poll_a(&mp1->poll_a, &mp2->poll_a);
+ case NCI_RF_INTERFACE_NFCEE_DIRECT:
+ case NCI_RF_INTERFACE_NFC_DEP:
+ case NCI_RF_INTERFACE_PROPRIETARY:
+ break;
+ }
+ break;
+ case NCI_MODE_PASSIVE_POLL_B:
+ switch (ntf->rf_intf) {
+ case NCI_RF_INTERFACE_ISO_DEP:
+ /* ISO-DEP Type 4B */
+ return mode_param_match_poll_b(&mp1->poll_b, &mp2->poll_b);
+ case NCI_RF_INTERFACE_FRAME:
+ case NCI_RF_INTERFACE_NFCEE_DIRECT:
+ case NCI_RF_INTERFACE_NFC_DEP:
+ case NCI_RF_INTERFACE_PROPRIETARY:
+ break;
+ }
+ break;
+ case NCI_MODE_ACTIVE_POLL_A:
+ case NCI_MODE_PASSIVE_POLL_F:
+ case NCI_MODE_ACTIVE_POLL_F:
+ case NCI_MODE_PASSIVE_POLL_15693:
+ case NCI_MODE_PASSIVE_LISTEN_A:
+ case NCI_MODE_PASSIVE_LISTEN_B:
+ case NCI_MODE_PASSIVE_LISTEN_F:
+ case NCI_MODE_ACTIVE_LISTEN_A:
+ case NCI_MODE_ACTIVE_LISTEN_F:
+ case NCI_MODE_PASSIVE_LISTEN_15693:
+ break;
+ }
+ }
+ /* Full match is expected in other cases */
+ return info->mode_param.size == ntf->mode_param_len &&
+ (!ntf->mode_param_len || !memcmp(info->mode_param.bytes,
+ ntf->mode_param_bytes, ntf->mode_param_len));
+}
+
+static
+gboolean
nci_adapter_intf_info_matches(
const NciAdapterIntfInfo* info,
const NciIntfActivationNtf* ntf)
@@ -141,9 +270,7 @@
info->rf_intf == ntf->rf_intf &&
|
[-]
[+]
|
Added |
_service:tar_git:libnciplugin-1.1.0.tar.bz2/src/nci_initiator.c
^
|
@@ -0,0 +1,285 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "nci_plugin_p.h"
+#include "nci_plugin_log.h"
+#include "nci_adapter_impl.h"
+
+#include <nci_core.h>
+
+#include <nfc_initiator_impl.h>
+
+enum {
+ EVENT_DATA_PACKET,
+ EVENT_COUNT
+};
+
+typedef NfcInitiatorClass NciInitiatorClass;
+typedef struct nci_initiator {
+ NfcInitiator initiator;
+ NciAdapter* adapter;
+ gulong event_id[EVENT_COUNT];
+ guint response_in_progress;
+} NciInitiator;
+
+GType nci_initiator_get_type(void) G_GNUC_INTERNAL;
+#define PARENT_CLASS nci_initiator_parent_class
+#define THIS_TYPE (nci_initiator_get_type())
+#define THIS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), THIS_TYPE, NciInitiator))
+G_DEFINE_TYPE(NciInitiator, nci_initiator, NFC_TYPE_INITIATOR)
+
+static
+NciInitiator*
+nci_initiator_new_with_technology(
+ NFC_TECHNOLOGY technology)
+{
+ NciInitiator* self = g_object_new(THIS_TYPE, NULL);
+
+ self->initiator.technology = technology;
+ return self;
+}
+
+static
+void
+nci_initiator_cancel_response(
+ NciInitiator* self)
+{
+ if (self->response_in_progress) {
+ if (self->adapter) {
+ nci_core_cancel(self->adapter->nci, self->response_in_progress);
+ }
+ self->response_in_progress = 0;
+ }
+}
+
+static
+void
+nci_initiator_drop_adapter(
+ NciInitiator* self)
+{
+ if (self->adapter) {
+ NciAdapter* adapter = self->adapter;
+
+ nci_initiator_cancel_response(self);
+ nci_core_remove_all_handlers(adapter->nci, self->event_id);
+ g_object_remove_weak_pointer(G_OBJECT(adapter), (gpointer*)
+ &self->adapter);
+ self->adapter = NULL;
+ }
+}
+
+static
+void
+nci_initiator_data_packet_handler(
+ NciCore* nci,
+ guint8 cid,
+ const void* data,
+ guint len,
+ void* user_data)
+{
+ if (cid == NCI_STATIC_RF_CONN_ID) {
+ nfc_initiator_transmit(NFC_INITIATOR(user_data), data, len);
+ } else {
+ GDEBUG("Unhandled data packet, cid=0x%02x %u byte(s)", cid, len);
+ }
+}
+
+static
+void
+nci_initiator_response_sent(
+ NciCore* nci,
+ gboolean success,
+ void* user_data)
+{
+ NciInitiator* self = THIS(user_data);
+
+ GASSERT(self->response_in_progress);
+ self->response_in_progress = 0;
+ nfc_initiator_response_sent(&self->initiator, success ?
+ NFC_TRANSMIT_STATUS_OK : NFC_TRANSMIT_STATUS_ERROR);
+}
+
+/*==========================================================================*
+ * Interface
+ *==========================================================================*/
+
+NfcInitiator*
+nci_initiator_new(
+ NciAdapter* adapter,
+ const NciIntfActivationNtf* ntf)
+{
+ NFC_TECHNOLOGY tech = NFC_TECHNOLOGY_UNKNOWN;
+
+ switch (ntf->mode) {
+ case NCI_MODE_ACTIVE_LISTEN_A:
+ case NCI_MODE_PASSIVE_LISTEN_A:
+ tech = NFC_TECHNOLOGY_A;
+ break;
+ case NCI_MODE_PASSIVE_LISTEN_B:
+ tech = NFC_TECHNOLOGY_B;
+ break;
+ case NCI_MODE_ACTIVE_LISTEN_F:
+ case NCI_MODE_PASSIVE_LISTEN_F:
+ tech = NFC_TECHNOLOGY_F;
+ break;
+ case NCI_MODE_PASSIVE_POLL_A:
+ case NCI_MODE_ACTIVE_POLL_A:
+ case NCI_MODE_PASSIVE_POLL_B:
+ case NCI_MODE_PASSIVE_POLL_F:
+ case NCI_MODE_ACTIVE_POLL_F:
+ case NCI_MODE_PASSIVE_POLL_15693:
+ case NCI_MODE_PASSIVE_LISTEN_15693:
+ break;
+ }
+
+ if (tech != NFC_TECHNOLOGY_UNKNOWN) {
+ NFC_PROTOCOL protocol = NFC_PROTOCOL_UNKNOWN;
+
+ switch (ntf->protocol) {
+ case NCI_PROTOCOL_NFC_DEP:
+ protocol = NFC_PROTOCOL_NFC_DEP;
+ break;
+ case NCI_PROTOCOL_ISO_DEP:
+ GDEBUG("Card emulation (ISO-DEP) not supported yet");
+ break;
+ default:
+ GDEBUG("Unsupported initiator protocol 0x%02x", ntf->protocol);
+ break;
+ }
+
+ if (protocol != NFC_PROTOCOL_UNKNOWN) {
+ NciInitiator* self = nci_initiator_new_with_technology(tech);
+ NfcInitiator* initiator = &self->initiator;
+
+ initiator->protocol = NFC_PROTOCOL_NFC_DEP;
+ self->adapter = adapter;
+ g_object_add_weak_pointer(G_OBJECT(adapter),
+ (gpointer*) &self->adapter);
+ self->event_id[EVENT_DATA_PACKET] =
+ nci_core_add_data_packet_handler(adapter->nci,
+ nci_initiator_data_packet_handler, self);
+ return initiator;
+ }
+ }
+ return NULL;
+}
|
[-]
[+]
|
Changed |
_service:tar_git:libnciplugin-1.1.0.tar.bz2/src/nci_plugin_p.h
^
|
@@ -53,6 +53,12 @@
const NciIntfActivationNtf* ntf)
G_GNUC_INTERNAL;
+NfcInitiator*
+nci_initiator_new(
+ NciAdapter* adapter,
+ const NciIntfActivationNtf* ntf)
+ G_GNUC_INTERNAL;
+
guint
nci_target_presence_check(
NfcTarget* target,
@@ -67,11 +73,17 @@
G_GNUC_INTERNAL;
void
-nci_adapter_deactivate(
+nci_adapter_deactivate_target(
NciAdapter* adapter,
NfcTarget* target)
G_GNUC_INTERNAL;
+void
+nci_adapter_deactivate_initiator(
+ NciAdapter* adapter,
+ NfcInitiator* initiator)
+ G_GNUC_INTERNAL;
+
#endif /* NCI_PLUGIN_PRIVATE_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:libnciplugin-1.1.0.tar.bz2/src/nci_target.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019-2020 Jolla Ltd.
- * Copyright (C) 2019-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -41,7 +41,6 @@
#include <nci_core.h>
-#include <nfc_tag.h>
#include <nfc_target_impl.h>
#define T2T_CMD_READ (0x30)
@@ -83,11 +82,22 @@
NciTargetTransmitFinishFunc transmit_finish_fn;
};
-GType nci_target_get_type(void);
+GType nci_target_get_type(void) G_GNUC_INTERNAL;
+#define PARENT_CLASS nci_target_parent_class
+#define THIS_TYPE (nci_target_get_type())
+#define THIS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), THIS_TYPE, NciTarget))
G_DEFINE_TYPE(NciTarget, nci_target, NFC_TYPE_TARGET)
-#define PN547_NFC_TYPE_TARGET (nci_target_get_type())
-#define NCI_TARGET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- PN547_NFC_TYPE_TARGET, NciTarget))
+
+static
+NciTarget*
+nci_target_new_with_technology(
+ NFC_TECHNOLOGY technology)
+{
+ NciTarget* self = g_object_new(THIS_TYPE, NULL);
+
+ self->target.technology = technology;
+ return self;
+}
static
NciTargetPresenceCheck*
@@ -175,7 +185,7 @@
gboolean success,
void* user_data)
{
- NciTarget* self = NCI_TARGET(user_data);
+ NciTarget* self = THIS(user_data);
GASSERT(self->send_in_progress);
self->send_in_progress = 0;
@@ -202,7 +212,7 @@
guint len,
void* user_data)
{
- NciTarget* self = NCI_TARGET(user_data);
+ NciTarget* self = THIS(user_data);
if (cid == NCI_STATIC_RF_CONN_ID && self->transmit_in_progress &&
!self->pending_reply) {
@@ -300,6 +310,21 @@
return TRUE;
}
+static
+gboolean
+nci_target_transmit_finish_nfc_dep(
+ NfcTarget* target,
+ const guint8* payload,
+ guint len)
+{
+ /*
+ * 8.4 NFC-DEP RF Interface
+ * 8.4.1.2 Data from RF to the DH
+ */
+ nfc_target_transmit_done(target, NFC_TRANSMIT_STATUS_OK, payload, len);
+ return TRUE;
+}
+
/*==========================================================================*
* Interface
*==========================================================================*/
@@ -309,80 +334,116 @@
NciAdapter* adapter,
const NciIntfActivationNtf* ntf)
{
- NciTarget* self = g_object_new(PN547_NFC_TYPE_TARGET, NULL);
- NfcTarget* target = &self->target;
+ NFC_TECHNOLOGY tech = NFC_TECHNOLOGY_UNKNOWN;
- switch (ntf->mode) {
- case NCI_MODE_PASSIVE_POLL_A:
- case NCI_MODE_ACTIVE_POLL_A:
- case NCI_MODE_PASSIVE_LISTEN_A:
- case NCI_MODE_ACTIVE_LISTEN_A:
- target->technology = NFC_TECHNOLOGY_A;
- break;
- case NCI_MODE_PASSIVE_POLL_B:
- case NCI_MODE_PASSIVE_LISTEN_B:
- target->technology = NFC_TECHNOLOGY_B;
- break;
- case NCI_MODE_PASSIVE_POLL_F:
- case NCI_MODE_PASSIVE_LISTEN_F:
- case NCI_MODE_ACTIVE_LISTEN_F:
- target->technology = NFC_TECHNOLOGY_F;
- break;
- default:
- break;
- }
-
- switch (ntf->protocol) {
- case NCI_PROTOCOL_T1T:
- target->protocol = NFC_PROTOCOL_T1_TAG;
- break;
- case NCI_PROTOCOL_T2T:
- target->protocol = NFC_PROTOCOL_T2_TAG;
- self->presence_check_fn = nci_target_presence_check_t2;
- break;
- case NCI_PROTOCOL_T3T:
- target->protocol = NFC_PROTOCOL_T3_TAG;
- break;
- case NCI_PROTOCOL_ISO_DEP:
- self->presence_check_fn = nci_target_presence_check_t4;
- switch (target->technology) {
- case NFC_TECHNOLOGY_A:
- target->protocol = NFC_PROTOCOL_T4A_TAG;
- break;
- case NFC_TECHNOLOGY_B:
- target->protocol = NFC_PROTOCOL_T4B_TAG;
- break;
- default:
- GDEBUG("Unexpected ISO_DEP technology");
- break;
- }
- break;
- case NCI_PROTOCOL_NFC_DEP:
- target->protocol = NFC_PROTOCOL_NFC_DEP;
- break;
- default:
- GDEBUG("Unsupported protocol 0x%02x", ntf->protocol);
- break;
- }
-
- switch (ntf->rf_intf) {
- case NCI_RF_INTERFACE_FRAME:
- self->transmit_finish_fn = nci_target_transmit_finish_frame;
- break;
- case NCI_RF_INTERFACE_ISO_DEP:
- self->transmit_finish_fn = nci_target_transmit_finish_iso_dep;
- break;
- default:
- GDEBUG("Unsupported RF interface 0x%02x", ntf->rf_intf);
- break;
- }
-
- self->adapter = adapter;
- g_object_add_weak_pointer(G_OBJECT(adapter), (gpointer*)&self->adapter);
- self->event_id[EVENT_DATA_PACKET] =
- nci_core_add_data_packet_handler(adapter->nci,
- nci_target_data_packet_handler, self);
- return target;
+ switch (ntf->mode) {
+ case NCI_MODE_PASSIVE_POLL_A:
+ case NCI_MODE_ACTIVE_POLL_A:
+ tech = NFC_TECHNOLOGY_A;
+ break;
+ case NCI_MODE_PASSIVE_POLL_B:
+ tech = NFC_TECHNOLOGY_B;
+ break;
+ case NCI_MODE_PASSIVE_POLL_F:
+ case NCI_MODE_ACTIVE_POLL_F:
+ tech = NFC_TECHNOLOGY_F;
+ break;
+ case NCI_MODE_PASSIVE_POLL_V:
+ case NCI_MODE_PASSIVE_LISTEN_V:
+ case NCI_MODE_PASSIVE_LISTEN_A:
+ case NCI_MODE_PASSIVE_LISTEN_B:
+ case NCI_MODE_PASSIVE_LISTEN_F:
+ case NCI_MODE_ACTIVE_LISTEN_A:
+ case NCI_MODE_ACTIVE_LISTEN_F:
+ break;
+ }
+
+ if (tech != NFC_TECHNOLOGY_UNKNOWN) {
+ NFC_PROTOCOL protocol = NFC_PROTOCOL_UNKNOWN;
+ NciTargetPresenceCheckFunc presence_check = NULL;
+
+ switch (ntf->protocol) {
+ case NCI_PROTOCOL_T1T:
+ protocol = NFC_PROTOCOL_T1_TAG;
+ break;
+ case NCI_PROTOCOL_T2T:
+ protocol = NFC_PROTOCOL_T2_TAG;
+ presence_check = nci_target_presence_check_t2;
+ break;
+ case NCI_PROTOCOL_T3T:
+ protocol = NFC_PROTOCOL_T3_TAG;
+ break;
|