Improve DEP info struct: add more info, and InJumpDEP now fill fully this struct.

This commit is contained in:
Romuald Conty 2010-10-08 20:25:34 +00:00
parent 1d0c7fe68e
commit 1e9c390dfa
6 changed files with 58 additions and 15 deletions

View file

@ -59,10 +59,12 @@ nfc_emulate_uid_LDADD = $(top_builddir)/libnfc/libnfc.la \
libnfcutils.la libnfcutils.la
nfcip_target_SOURCES = nfcip-target.c nfcip_target_SOURCES = nfcip-target.c
nfcip_target_LDADD = $(top_builddir)/libnfc/libnfc.la nfcip_target_LDADD = $(top_builddir)/libnfc/libnfc.la \
libnfcutils.la
nfcip_initiator_SOURCES = nfcip-initiator.c nfcip_initiator_SOURCES = nfcip-initiator.c
nfcip_initiator_LDADD = $(top_builddir)/libnfc/libnfc.la nfcip_initiator_LDADD = $(top_builddir)/libnfc/libnfc.la \
libnfcutils.la
pn53x_diagnose_SOURCES = pn53x-diagnose.c pn53x_diagnose_SOURCES = pn53x-diagnose.c
pn53x_diagnose_LDADD = $(top_builddir)/libnfc/libnfc.la \ pn53x_diagnose_LDADD = $(top_builddir)/libnfc/libnfc.la \

View file

@ -197,6 +197,21 @@ print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi)
} }
} }
void
print_nfc_dep_info (const nfc_dep_info_t ndi)
{
printf (" NFCID3: ");
print_hex (ndi.abtNFCID3, 10);
printf (" BS: %02x\n", ndi.btBS);
printf (" BR: %02x\n", ndi.btBR);
printf (" TO: %02x\n", ndi.btTO);
printf (" PP: %02x\n", ndi.btPP);
if (ndi.szGB) {
printf ("General Bytes: ");
print_hex (ndi.abtGB, ndi.szGB);
}
}
/** /**
* @brief Tries to parse arguments to find device descriptions. * @brief Tries to parse arguments to find device descriptions.
* @return Returns the list of found device descriptions. * @return Returns the list of found device descriptions.

View file

@ -38,6 +38,7 @@ void print_nfc_iso14443a_info (const nfc_iso14443a_info_t nai);
void print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi); void print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi);
void print_nfc_felica_info (const nfc_felica_info_t nfi); void print_nfc_felica_info (const nfc_felica_info_t nfi);
void print_nfc_jewel_info (const nfc_jewel_info_t nji); void print_nfc_jewel_info (const nfc_jewel_info_t nji);
void print_nfc_dep_info (const nfc_dep_info_t ndi);
nfc_device_desc_t *parse_device_desc (int argc, const char *argv[], size_t * szFound); nfc_device_desc_t *parse_device_desc (int argc, const char *argv[], size_t * szFound);

View file

@ -29,18 +29,21 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <nfc/nfc.h> #include <nfc/nfc.h>
#include "nfc-utils.h"
#define MAX_FRAME_LEN 264 #define MAX_FRAME_LEN 264
int int
main (int argc, const char *argv[]) main (int argc, const char *argv[])
{ {
nfc_device_t *pnd; nfc_device_t *pnd;
nfc_target_info_t ti; nfc_target_info_t nti;
byte_t abtRx[MAX_FRAME_LEN]; byte_t abtRx[MAX_FRAME_LEN];
size_t szRx; size_t szRx;
byte_t send[] = "Hello World!"; byte_t abtTx[] = "Hello World!";
if (argc > 1) { if (argc > 1) {
printf ("Usage: %s\n", argv[0]); printf ("Usage: %s\n", argv[0]);
@ -58,13 +61,15 @@ main (int argc, const char *argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if(!nfc_initiator_select_dep_target (pnd, NM_PASSIVE_DEP, NULL, 0, NULL, 0, NULL, 0, &ti)) { if(!nfc_initiator_select_dep_target (pnd, NM_PASSIVE_DEP, NULL, 0, NULL, 0, NULL, 0, &nti)) {
nfc_perror(pnd, "nfc_initiator_select_dep_target"); nfc_perror(pnd, "nfc_initiator_select_dep_target");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
printf( "This D.E.P. target have been found:\n" );
print_nfc_dep_info (nti.ndi);
printf ("Sending: %s\n", send); printf ("Sending: %s\n", abtTx);
if (!nfc_initiator_transceive_bytes (pnd, send, strlen ((char *) send), abtRx, &szRx)) { if (!nfc_initiator_transceive_bytes (pnd, abtTx, sizeof(abtTx), abtRx, &szRx)) {
nfc_perror(pnd, "nfc_initiator_transceive_bytes"); nfc_perror(pnd, "nfc_initiator_transceive_bytes");
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View file

@ -2,6 +2,7 @@
* Public platform independent Near Field Communication (NFC) library * Public platform independent Near Field Communication (NFC) library
* *
* Copyright (C) 2009, Roel Verdult * Copyright (C) 2009, Roel Verdult
* Copyright (C) 2009, Romain Tartière, Romuald Conty
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the * under the terms of the GNU Lesser General Public License as published by the
@ -193,13 +194,24 @@ typedef enum {
/** /**
* @struct nfc_dep_info_t * @struct nfc_dep_info_t
* @brief NFC tag information in Data Exchange Protocol * @brief NFC tag information in D.E.P. (Data Exchange Protocol) see ISO/IEC 18092
*/ */
typedef struct { typedef struct {
byte_t NFCID3i[10]; /** NFCID3 */
byte_t abtNFCID3[10];
/** DID */
byte_t btDID; byte_t btDID;
byte_t btBSt; /** Supported send-bit rate */
byte_t btBRt; byte_t btBS;
/** Supported receive-bit rate */
byte_t btBR;
/** Timeout value */
byte_t btTO;
/** PP Parameters */
byte_t btPP;
/** General Bytes */
byte_t abtGB[48];
size_t szGB;
} nfc_dep_info_t; } nfc_dep_info_t;
/** /**

View file

@ -805,7 +805,7 @@ pn53x_configure (nfc_device_t * pnd, const nfc_device_option_t ndo, const bool b
// Nothing to do // Nothing to do
return true; return true;
} }
// Force pn53x to be in ISO1444-A mode // Force pn53x to be in ISO14443-A mode
if (!pn53x_set_reg (pnd, REG_CIU_TX_MODE, SYMBOL_TX_FRAMING, 0x00)) { if (!pn53x_set_reg (pnd, REG_CIU_TX_MODE, SYMBOL_TX_FRAMING, 0x00)) {
return false; return false;
} }
@ -866,10 +866,18 @@ pn53x_initiator_select_dep_target (nfc_device_t * pnd, const nfc_modulation_t nm
// Is a target info struct available // Is a target info struct available
if (pnti) { if (pnti) {
memcpy (pnti->ndi.NFCID3i, abtRx + 2, 10); memcpy (pnti->ndi.abtNFCID3, abtRx + 2, 10);
pnti->ndi.btDID = abtRx[12]; pnti->ndi.btDID = abtRx[12];
pnti->ndi.btBSt = abtRx[13]; pnti->ndi.btBS = abtRx[13];
pnti->ndi.btBRt = abtRx[14]; pnti->ndi.btBR = abtRx[14];
pnti->ndi.btTO = abtRx[15];
pnti->ndi.btPP = abtRx[16];
if(szRxLen > 17) {
pnti->ndi.szGB = szRxLen - 17;
memcpy (pnti->ndi.abtGB, abtRx + 17, pnti->ndi.szGB);
} else {
pnti->ndi.szGB = 0;
}
} }
return true; return true;
} }