summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgoodsc.lee <goodsc.lee@samsung.com>2010-10-10 14:43:53 -0700
committerNick Pelly <npelly@google.com>2010-10-12 20:40:19 -0700
commit0fb8aa8edcde194a1ac5e6116a6ce7ee374122b6 (patch)
tree7938eb66b4f3acdc70921dfca329a141e37ba7dd
parent372231c2145fcb97c8900242c2a61247b0db309d (diff)
downloadexternal_libnfc-nxp-0fb8aa8edcde194a1ac5e6116a6ce7ee374122b6.zip
external_libnfc-nxp-0fb8aa8edcde194a1ac5e6116a6ce7ee374122b6.tar.gz
external_libnfc-nxp-0fb8aa8edcde194a1ac5e6116a6ce7ee374122b6.tar.bz2
STANDBY mode and Polling loop
Change-Id: Ib6563a94b29c7eb9de6615881eadbdf0e94994c8 S5PC11X: NFC: Enable the STANDBY mode and add enableDiscovery and disableDiscovery for polling loop.
-rw-r--r--Linux_x86/phDal4Nfc.c6
-rw-r--r--Linux_x86/phOsalNfc.c6
-rw-r--r--inc/phNfcConfig.h4
-rw-r--r--trustedlogic/com_trustedlogic_trustednfc_android_internal_NativeNfcManager.cpp89
-rw-r--r--trustedlogic/trustednfc_jni.h1
5 files changed, 100 insertions, 6 deletions
diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c
index 7683c39..d824d6e 100644
--- a/Linux_x86/phDal4Nfc.c
+++ b/Linux_x86/phDal4Nfc.c
@@ -864,6 +864,12 @@ int phDal4Nfc_WriterThread(void * pArg)
gReadWriteContext.nNbOfBytesWritten = gLinkFunc.write(gReadWriteContext.pWriteBuffer, gReadWriteContext.nNbOfBytesToWrite);
if (gReadWriteContext.nNbOfBytesWritten != gReadWriteContext.nNbOfBytesToWrite)
{
+ /* controller may be in standby. do it again! */
+ usleep(8000);
+ gReadWriteContext.nNbOfBytesWritten = gLinkFunc.write(gReadWriteContext.pWriteBuffer, gReadWriteContext.nNbOfBytesToWrite);
+ }
+ if (gReadWriteContext.nNbOfBytesWritten != gReadWriteContext.nNbOfBytesToWrite)
+ {
/* Report write failure or timeout */
DAL_DEBUG("Write error in write thread\n", 0);
result = PHNFCSTVAL(CID_NFC_DAL, NFCSTATUS_BOARD_COMMUNICATION_ERROR);
diff --git a/Linux_x86/phOsalNfc.c b/Linux_x86/phOsalNfc.c
index ce01d26..7d8e7da 100644
--- a/Linux_x86/phOsalNfc.c
+++ b/Linux_x86/phOsalNfc.c
@@ -81,7 +81,7 @@ void phOsalNfc_DbgString(const char *pString)
#ifndef ANDROID
printf(pString);
#else
- LOGD(pString);
+ LOGD("%s", pString);
#endif
#endif
}
@@ -111,14 +111,14 @@ void phOsalNfc_DbgTrace(uint8_t data[], uint32_t size)
{
if((i % 10) == 0)
{
- LOGD(phOsalNfc_DbgTraceBuffer);
+ LOGD("%s", phOsalNfc_DbgTraceBuffer);
phOsalNfc_DbgTraceBuffer[0] = '\0';
}
snprintf(buf, 10, "%02X ", data[i]);
strncat(phOsalNfc_DbgTraceBuffer, buf, 10);
}
- LOGD(phOsalNfc_DbgTraceBuffer);
+ LOGD("%s", phOsalNfc_DbgTraceBuffer);
LOGD("Block size is: %d", size);
#endif
#endif
diff --git a/inc/phNfcConfig.h b/inc/phNfcConfig.h
index 035d5bd..fd7b8a8 100644
--- a/inc/phNfcConfig.h
+++ b/inc/phNfcConfig.h
@@ -136,12 +136,12 @@
*/
#ifndef NXP_SYSTEM_PWR_STATUS
-#define NXP_SYSTEM_PWR_STATUS 0x00U
+#define NXP_SYSTEM_PWR_STATUS 0x01U
#endif
/**< Default Session ID for Initialisation */
#ifndef DEFAULT_SESSION
-#define DEFAULT_SESSION "NXP-NFC1"
+#define DEFAULT_SESSION "NXP-NFCx"
#endif
diff --git a/trustedlogic/com_trustedlogic_trustednfc_android_internal_NativeNfcManager.cpp b/trustedlogic/com_trustedlogic_trustednfc_android_internal_NativeNfcManager.cpp
index 2d1666d..3e624a5 100644
--- a/trustedlogic/com_trustedlogic_trustednfc_android_internal_NativeNfcManager.cpp
+++ b/trustedlogic/com_trustedlogic_trustednfc_android_internal_NativeNfcManager.cpp
@@ -31,6 +31,8 @@
static phLibNfc_sConfig_t gDrvCfg;
static void *gHWRef;
+static phNfc_sData_t gInputParam;
+static phNfc_sData_t gOutputParam;
static phLibNfc_Handle hLlcpHandle;
static NFCSTATUS lastErrorStatus = NFCSTATUS_FAILED;
@@ -657,6 +659,12 @@ static void trustednfc_jni_discover_callback(void *pContext, NFCSTATUS status)
}
+static void trustednfc_jni_ioctl_callback(void *pContext, phNfc_sData_t *pOutput, NFCSTATUS status)
+{
+ LOG_CALLBACK("trustednfc_jni_ioctl_callback", status);
+}
+
+
static void trustednfc_jni_Discovery_notification_callback(void *pContext,
phLibNfc_RemoteDevList_t *psRemoteDevList,
uint8_t uNofRemoteDev, NFCSTATUS status)
@@ -1275,6 +1283,79 @@ static void trustednfc_jni_start_discovery(struct trustednfc_jni_native_data *na
nat->discovery_cfg.NfcIP_Mode, nat->discovery_cfg.Duration, ret);
}
+static void trustednfc_jni_stop_discovery(struct trustednfc_jni_native_data *nat)
+{
+ phLibNfc_sADD_Cfg_t discovery_cfg;
+ NFCSTATUS ret;
+
+ discovery_cfg.PollDevInfo.PollEnabled = 0;
+ discovery_cfg.Duration = 0xffffffff;
+ /*discovery_cfg.NfcIP_Mode = phNfc_eInvalidP2PMode;*/
+ discovery_cfg.NfcIP_Mode = phNfc_eDefaultP2PMode;
+ discovery_cfg.NfcIP_Tgt_Disable = TRUE;
+
+ /* Start Polling loop */
+ LOGD("****** Stop NFC Discovery ******");
+ REENTRANCE_LOCK();
+ ret = phLibNfc_Mgt_ConfigureDiscovery(NFC_DISCOVERY_CONFIG,discovery_cfg, trustednfc_jni_discover_callback, (void *)nat);
+ REENTRANCE_UNLOCK();
+ LOGD("phLibNfc_Mgt_ConfigureDiscovery(%s-%s-%s-%s-%s-%s, %s-%x-%x) returned 0x%08x\n",
+ discovery_cfg.PollDevInfo.PollCfgInfo.EnableIso14443A==TRUE?"3A":"",
+ discovery_cfg.PollDevInfo.PollCfgInfo.EnableIso14443B==TRUE?"3B":"",
+ discovery_cfg.PollDevInfo.PollCfgInfo.EnableFelica212==TRUE?"F2":"",
+ discovery_cfg.PollDevInfo.PollCfgInfo.EnableFelica424==TRUE?"F4":"",
+ discovery_cfg.PollDevInfo.PollCfgInfo.EnableNfcActive==TRUE?"NFC":"",
+ discovery_cfg.PollDevInfo.PollCfgInfo.EnableIso15693==TRUE?"RFID":"",
+ discovery_cfg.PollDevInfo.PollCfgInfo.DisableCardEmulation==FALSE?"CE":"",
+ discovery_cfg.NfcIP_Mode, discovery_cfg.Duration, ret);
+}
+
+static void trustednfc_jni_reader_discovery(struct trustednfc_jni_native_data *nat)
+{
+ static unsigned char ioctl[2] = {03,00};
+ static unsigned char resp[16];
+ NFCSTATUS ret;
+
+ gInputParam.length = 2;
+ gInputParam.buffer = ioctl;
+ gOutputParam.length = 16;
+ gOutputParam.buffer = resp;
+
+ LOGD("****** Start PRBS Test ******");
+ REENTRANCE_LOCK();
+ ret = phLibNfc_Mgt_IoCtl(gHWRef, DEVMGMT_PRBS_TEST, &gInputParam, &gOutputParam, trustednfc_jni_ioctl_callback, (void *)nat);
+ REENTRANCE_UNLOCK();
+ LOGD("phLibNfc_Mgt_IoCtl(PRBS Test) returned 0x%08x\n", ret);
+}
+
+static void com_trustedlogic_trustednfc_android_internal_NfcManager_readerDiscovery(JNIEnv *e, jobject o)
+{
+ struct trustednfc_jni_native_data *nat;
+
+ CONCURRENCY_LOCK();
+
+ /* Retrieve native structure address */
+ nat = trustednfc_jni_get_nat(e, o);
+
+ trustednfc_jni_reader_discovery(nat);
+
+ CONCURRENCY_UNLOCK();
+}
+
+static void com_trustedlogic_trustednfc_android_internal_NfcManager_disableDiscovery(JNIEnv *e, jobject o)
+{
+ struct trustednfc_jni_native_data *nat;
+
+ CONCURRENCY_LOCK();
+
+ /* Retrieve native structure address */
+ nat = trustednfc_jni_get_nat(e, o);
+
+ trustednfc_jni_stop_discovery(nat);
+
+ CONCURRENCY_UNLOCK();
+}
+
static void com_trustedlogic_trustednfc_android_internal_NfcManager_enableDiscovery(
JNIEnv *e, jobject o, jint mode)
{
@@ -2218,7 +2299,13 @@ static JNINativeMethod gMethods[] =
(void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doGetLastError},
{"doSetProperties", "(II)V",
- (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doSetProperties},
+ (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_doSetProperties},
+
+ {"disableDiscovery", "()V",
+ (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_disableDiscovery},
+
+ {"readerDiscovery", "()V",
+ (void *)com_trustedlogic_trustednfc_android_internal_NfcManager_readerDiscovery},
};
diff --git a/trustedlogic/trustednfc_jni.h b/trustedlogic/trustednfc_jni.h
index bbca3c8..b4d1b79 100644
--- a/trustedlogic/trustednfc_jni.h
+++ b/trustedlogic/trustednfc_jni.h
@@ -32,6 +32,7 @@
extern "C" {
#include <phNfcStatus.h>
#include <phNfcTypes.h>
+#include <phNfcIoctlCode.h>
#include <phLibNfc.h>
#include <phDal4Nfc_messageQueueLib.h>
}