mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-04-11 09:06:17 +00:00
make style
This commit is contained in:
@@ -331,7 +331,7 @@ acr122_usb_scan(const nfc_context *context, nfc_connstring connstrings[], const
|
||||
// acr122_usb_get_usb_device_name (dev, udev, pnddDevices[device_found].acDevice, sizeof (pnddDevices[device_found].acDevice));
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "device found: Bus %s Device %s Name %s", bus->dirname, dev->filename, acr122_usb_supported_devices[n].name);
|
||||
usb_close(udev);
|
||||
if(snprintf(connstrings[device_found], sizeof(nfc_connstring), "%s:%s:%s", ACR122_USB_DRIVER_NAME, bus->dirname, dev->filename) >= (int)sizeof(nfc_connstring)) {
|
||||
if (snprintf(connstrings[device_found], sizeof(nfc_connstring), "%s:%s:%s", ACR122_USB_DRIVER_NAME, bus->dirname, dev->filename) >= (int)sizeof(nfc_connstring)) {
|
||||
// truncation occurred, skipping that one
|
||||
continue;
|
||||
}
|
||||
@@ -430,7 +430,7 @@ acr122_usb_open(const nfc_context *context, const nfc_connstring connstring)
|
||||
goto free_mem;
|
||||
}
|
||||
|
||||
// Check if there are more than 0 alternative interfaces and claim the first one
|
||||
// Check if there are more than 0 alternative interfaces and claim the first one
|
||||
if (dev->config->interface->altsetting->bAlternateSetting > 0) {
|
||||
res = usb_set_altinterface(data.pudh, 0);
|
||||
if (res < 0) {
|
||||
|
||||
@@ -138,8 +138,7 @@ int pcsc_transmit(struct nfc_device *pnd, const uint8_t *tx, const size_t tx_len
|
||||
DWORD dw_rx_len = *rx_len;
|
||||
//in libfreefare, tx_len = 1, and it leads to 0x80100008 error, with PC/SC reader, the input tx_len at least two bytes for the SW value
|
||||
//so if found the reader is Feitian reader, we set to 2
|
||||
if (dw_rx_len == 1 && is_pcsc_reader_vendor_feitian(pnd))
|
||||
{
|
||||
if (dw_rx_len == 1 && is_pcsc_reader_vendor_feitian(pnd)) {
|
||||
dw_rx_len = 2;
|
||||
}
|
||||
|
||||
@@ -201,15 +200,14 @@ uint8_t pcsc_get_icc_type(const struct nfc_device *pnd)
|
||||
return it;
|
||||
}
|
||||
|
||||
bool is_pcsc_reader_vendor(const struct nfc_device *pnd, const char * target_vendor_name)
|
||||
bool is_pcsc_reader_vendor(const struct nfc_device *pnd, const char *target_vendor_name)
|
||||
{
|
||||
bool isTarget = false;
|
||||
if (pnd == NULL || strlen(pnd->name) == 0)
|
||||
{
|
||||
if (pnd == NULL || strlen(pnd->name) == 0) {
|
||||
return isTarget;
|
||||
}
|
||||
|
||||
return isTarget = (strstr(pnd->name, target_vendor_name)) ? true:false;
|
||||
return isTarget = (strstr(pnd->name, target_vendor_name)) ? true : false;
|
||||
}
|
||||
|
||||
bool is_pcsc_reader_vendor_feitian(const struct nfc_device *pnd)
|
||||
@@ -340,15 +338,14 @@ int pcsc_props_to_target(struct nfc_device *pnd, uint8_t it, const uint8_t *patr
|
||||
memcpy(pnt->nti.nai.abtUid, puid, szuid);
|
||||
pnt->nti.nai.szUidLen = szuid;
|
||||
}
|
||||
if (is_pcsc_reader_vendor_feitian(pnd))
|
||||
{
|
||||
if (is_pcsc_reader_vendor_feitian(pnd)) {
|
||||
uint8_t atqa[2];
|
||||
pcsc_get_atqa(pnd,atqa,sizeof(atqa));
|
||||
pcsc_get_atqa(pnd, atqa, sizeof(atqa));
|
||||
//memcpy(pnt->nti.nai.abtAtqa,atqa,2);
|
||||
pnt->nti.nai.abtAtqa[0] = atqa[1];
|
||||
pnt->nti.nai.abtAtqa[1] = atqa[0];
|
||||
uint8_t sak[1];
|
||||
pcsc_get_sak(pnd,sak,sizeof(sak));
|
||||
pcsc_get_sak(pnd, sak, sizeof(sak));
|
||||
pnt->nti.nai.btSak = sak[0];
|
||||
uint8_t ats[256];
|
||||
int ats_len = pcsc_get_ats(pnd, ats, sizeof(ats));
|
||||
@@ -776,7 +773,7 @@ int pcsc_initiator_transceive_bytes(struct nfc_device *pnd, const uint8_t *pbtTx
|
||||
// FIXME: timeout is not handled
|
||||
(void) timeout;
|
||||
|
||||
if (is_pcsc_reader_vendor_feitian(pnd)){
|
||||
if (is_pcsc_reader_vendor_feitian(pnd)) {
|
||||
LOG_HEX(NFC_LOG_GROUP_COM, "not feitian reader pcsc apdu send", pbtTx, szTx);
|
||||
|
||||
uint8_t apdu_data[256];
|
||||
@@ -797,7 +794,7 @@ int pcsc_initiator_transceive_bytes(struct nfc_device *pnd, const uint8_t *pbtTx
|
||||
apdu_data[4] = szTx - 2;
|
||||
memcpy(apdu_data + 5, pbtTx + 2, szTx - 2);
|
||||
send_size = 5 + szTx - 2;
|
||||
} else if (pbtTx[0] == 0x60 || pbtTx[0] == 0x61 || pbtTx[0] == 0x1A){//Auth command
|
||||
} else if (pbtTx[0] == 0x60 || pbtTx[0] == 0x61 || pbtTx[0] == 0x1A) { //Auth command
|
||||
apdu_data[0] = 0xFF;
|
||||
apdu_data[1] = 0x86;
|
||||
apdu_data[2] = 0x00;
|
||||
@@ -809,7 +806,7 @@ int pcsc_initiator_transceive_bytes(struct nfc_device *pnd, const uint8_t *pbtTx
|
||||
apdu_data[8] = pbtTx[0];//type a or type b
|
||||
apdu_data[9] = 0x01;
|
||||
send_size = 10;
|
||||
} else if (pbtTx[0] == 0xC0){//DECREMENT cmd
|
||||
} else if (pbtTx[0] == 0xC0) { //DECREMENT cmd
|
||||
apdu_data[0] = 0xFF;
|
||||
apdu_data[1] = 0xD7;
|
||||
apdu_data[2] = 0x00;
|
||||
@@ -817,7 +814,7 @@ int pcsc_initiator_transceive_bytes(struct nfc_device *pnd, const uint8_t *pbtTx
|
||||
apdu_data[4] = 0x05;
|
||||
memcpy(apdu_data + 5, pbtTx + 2, szTx - 2);
|
||||
send_size = 5 + szTx - 2;
|
||||
} else if (pbtTx[0] == 0xC1){//INCREMENT cmd
|
||||
} else if (pbtTx[0] == 0xC1) { //INCREMENT cmd
|
||||
apdu_data[0] = 0xFF;
|
||||
apdu_data[1] = 0xD7;
|
||||
apdu_data[2] = 0x00;
|
||||
@@ -825,7 +822,7 @@ int pcsc_initiator_transceive_bytes(struct nfc_device *pnd, const uint8_t *pbtTx
|
||||
apdu_data[4] = 0x05;
|
||||
memcpy(apdu_data + 5, pbtTx + 2, szTx - 2);
|
||||
send_size = 5 + szTx - 2;
|
||||
} else if (pbtTx[0] == 0xC2){//STORE cmd
|
||||
} else if (pbtTx[0] == 0xC2) { //STORE cmd
|
||||
apdu_data[0] = 0xFF;
|
||||
apdu_data[1] = 0xD8;
|
||||
apdu_data[2] = 0x00;
|
||||
@@ -840,7 +837,7 @@ int pcsc_initiator_transceive_bytes(struct nfc_device *pnd, const uint8_t *pbtTx
|
||||
LOG_HEX(NFC_LOG_GROUP_COM, "feitian reader pcsc apdu send:", apdu_data, send_size);
|
||||
pnd->last_error = pcsc_transmit(pnd, apdu_data, send_size, resp, &resp_len);
|
||||
LOG_HEX(NFC_LOG_GROUP_COM, "feitian reader pcsc apdu received:", resp, resp_len);
|
||||
|
||||
|
||||
memcpy(pbtRx, resp, resp_len);
|
||||
} else {
|
||||
pnd->last_error = pcsc_transmit(pnd, pbtTx, szTx, pbtRx, &resp_len);
|
||||
@@ -938,7 +935,7 @@ pcsc_get_information_about(nfc_device *pnd, char **pbuf)
|
||||
struct pcsc_data *data = pnd->driver_data;
|
||||
LPBYTE name = NULL, version = NULL, type = NULL, serial = NULL;
|
||||
DWORD name_len = SCARD_AUTOALLOCATE, version_len = SCARD_AUTOALLOCATE,
|
||||
type_len = SCARD_AUTOALLOCATE, serial_len = SCARD_AUTOALLOCATE;
|
||||
type_len = SCARD_AUTOALLOCATE, serial_len = SCARD_AUTOALLOCATE;
|
||||
int res = NFC_SUCCESS;
|
||||
SCARDCONTEXT *pscc;
|
||||
|
||||
@@ -974,27 +971,22 @@ pcsc_get_information_about(nfc_device *pnd, char **pbuf)
|
||||
|
||||
error:
|
||||
#ifdef __APPLE__
|
||||
if (pscc != NULL)
|
||||
{
|
||||
if (pscc != NULL) {
|
||||
SCardReleaseContext(*pscc);
|
||||
}
|
||||
if (name != NULL)
|
||||
{
|
||||
if (name != NULL) {
|
||||
free(name);
|
||||
name = NULL;
|
||||
}
|
||||
if (type != NULL)
|
||||
{
|
||||
if (type != NULL) {
|
||||
free(type);
|
||||
type = NULL;
|
||||
}
|
||||
if (version != NULL)
|
||||
{
|
||||
if (version != NULL) {
|
||||
free(version);
|
||||
version = NULL;
|
||||
}
|
||||
if (serial != NULL)
|
||||
{
|
||||
if (serial != NULL) {
|
||||
free(serial);
|
||||
serial = NULL;
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ pn53x_usb_scan(const nfc_context *context, nfc_connstring connstrings[], const s
|
||||
// pn53x_usb_get_usb_device_name (dev, udev, pnddDevices[device_found].acDevice, sizeof (pnddDevices[device_found].acDevice));
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "device found: Bus %s Device %s", bus->dirname, dev->filename);
|
||||
usb_close(udev);
|
||||
if(snprintf(connstrings[device_found], sizeof(nfc_connstring), "%s:%s:%s", PN53X_USB_DRIVER_NAME, bus->dirname, dev->filename) >= (int)sizeof(nfc_connstring)) {
|
||||
if (snprintf(connstrings[device_found], sizeof(nfc_connstring), "%s:%s:%s", PN53X_USB_DRIVER_NAME, bus->dirname, dev->filename) >= (int)sizeof(nfc_connstring)) {
|
||||
// truncation occurred, skipping that one
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -58,16 +58,16 @@ static void onTagDeparture(void);
|
||||
static size_t
|
||||
pn71xx_scan(const nfc_context *context, nfc_connstring connstrings[], const size_t connstrings_len)
|
||||
{
|
||||
size_t device_found = 0;
|
||||
size_t device_found = 0;
|
||||
|
||||
if ((context == NULL) || (connstrings_len == 0)) return 0;
|
||||
if ((context == NULL) || (connstrings_len == 0)) return 0;
|
||||
|
||||
if (nfcManager_doInitialize() == 0) {
|
||||
nfc_connstring connstring = "pn71xx";
|
||||
memcpy(connstrings[device_found++], connstring, sizeof(nfc_connstring));
|
||||
}
|
||||
if (nfcManager_doInitialize() == 0) {
|
||||
nfc_connstring connstring = "pn71xx";
|
||||
memcpy(connstrings[device_found++], connstring, sizeof(nfc_connstring));
|
||||
}
|
||||
|
||||
return device_found;
|
||||
return device_found;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,12 +77,12 @@ pn71xx_scan(const nfc_context *context, nfc_connstring connstrings[], const size
|
||||
*/
|
||||
static void
|
||||
pn71xx_close(nfc_device *pnd)
|
||||
{
|
||||
nfcManager_disableDiscovery();
|
||||
nfcManager_deregisterTagCallback();
|
||||
nfcManager_doDeinitialize();
|
||||
nfc_device_free(pnd);
|
||||
pnd = NULL;
|
||||
{
|
||||
nfcManager_disableDiscovery();
|
||||
nfcManager_deregisterTagCallback();
|
||||
nfcManager_doDeinitialize();
|
||||
nfc_device_free(pnd);
|
||||
pnd = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,157 +95,150 @@ pn71xx_close(nfc_device *pnd)
|
||||
static nfc_device *
|
||||
pn71xx_open(const nfc_context *context, const nfc_connstring connstring)
|
||||
{
|
||||
nfc_device *pnd;
|
||||
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "open: %s", connstring);
|
||||
nfc_device *pnd;
|
||||
|
||||
pnd = nfc_device_new(context, connstring);
|
||||
if (!pnd) {
|
||||
perror("malloc");
|
||||
return NULL;
|
||||
}
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "open: %s", connstring);
|
||||
|
||||
pnd->driver = &pn71xx_driver;
|
||||
strcpy(pnd->name, "pn71xx-device");
|
||||
strcpy(pnd->connstring, connstring);
|
||||
pnd = nfc_device_new(context, connstring);
|
||||
if (!pnd) {
|
||||
perror("malloc");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TagCB.onTagArrival = onTagArrival;
|
||||
TagCB.onTagDeparture = onTagDeparture;
|
||||
nfcManager_registerTagCallback(&TagCB);
|
||||
pnd->driver = &pn71xx_driver;
|
||||
strcpy(pnd->name, "pn71xx-device");
|
||||
strcpy(pnd->connstring, connstring);
|
||||
|
||||
nfcManager_enableDiscovery(DEFAULT_NFA_TECH_MASK, 1, 0, 0);
|
||||
TagCB.onTagArrival = onTagArrival;
|
||||
TagCB.onTagDeparture = onTagDeparture;
|
||||
nfcManager_registerTagCallback(&TagCB);
|
||||
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "wait 1 seconds for polling");
|
||||
sleep(1);
|
||||
nfcManager_enableDiscovery(DEFAULT_NFA_TECH_MASK, 1, 0, 0);
|
||||
|
||||
return pnd;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "wait 1 seconds for polling");
|
||||
sleep(1);
|
||||
|
||||
return pnd;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------------------------ */
|
||||
/** ------------------------------------------------------------------------ */
|
||||
static bool IsTechnology(nfc_tag_info_t *TagInfo, nfc_modulation_type nmt)
|
||||
{
|
||||
switch (nmt) {
|
||||
case NMT_ISO14443A:
|
||||
if (TagInfo->technology == TARGET_TYPE_ISO14443_4
|
||||
|| TagInfo->technology == TARGET_TYPE_ISO14443_3A
|
||||
|| TagInfo->technology == TARGET_TYPE_MIFARE_CLASSIC
|
||||
|| TagInfo->technology == TARGET_TYPE_MIFARE_UL)
|
||||
return true;
|
||||
break;
|
||||
switch (nmt) {
|
||||
case NMT_ISO14443A:
|
||||
if (TagInfo->technology == TARGET_TYPE_ISO14443_4
|
||||
|| TagInfo->technology == TARGET_TYPE_ISO14443_3A
|
||||
|| TagInfo->technology == TARGET_TYPE_MIFARE_CLASSIC
|
||||
|| TagInfo->technology == TARGET_TYPE_MIFARE_UL)
|
||||
return true;
|
||||
break;
|
||||
|
||||
case NMT_ISO14443B:
|
||||
case NMT_ISO14443BI:
|
||||
case NMT_ISO14443B2SR:
|
||||
case NMT_ISO14443B2CT:
|
||||
if (TagInfo->technology == TARGET_TYPE_ISO14443_3B)
|
||||
return true;
|
||||
break;
|
||||
case NMT_ISO14443B:
|
||||
case NMT_ISO14443BI:
|
||||
case NMT_ISO14443B2SR:
|
||||
case NMT_ISO14443B2CT:
|
||||
if (TagInfo->technology == TARGET_TYPE_ISO14443_3B)
|
||||
return true;
|
||||
break;
|
||||
|
||||
case NMT_FELICA:
|
||||
if (TagInfo->technology == TARGET_TYPE_FELICA)
|
||||
return true;
|
||||
break;
|
||||
case NMT_FELICA:
|
||||
if (TagInfo->technology == TARGET_TYPE_FELICA)
|
||||
return true;
|
||||
break;
|
||||
|
||||
case NMT_JEWEL:
|
||||
if (TagInfo->technology == TARGET_TYPE_ISO14443_3A
|
||||
&& TagInfo->protocol == NFA_PROTOCOL_T1T)
|
||||
return true;
|
||||
break;
|
||||
case NMT_JEWEL:
|
||||
if (TagInfo->technology == TARGET_TYPE_ISO14443_3A
|
||||
&& TagInfo->protocol == NFA_PROTOCOL_T1T)
|
||||
return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void BufferPrintBytes(char* buffer, unsigned int buflen, const uint8_t *data, unsigned int datalen)
|
||||
static void BufferPrintBytes(char *buffer, unsigned int buflen, const uint8_t *data, unsigned int datalen)
|
||||
{
|
||||
int cx = 0;
|
||||
for(unsigned int i = 0x00; i < datalen; i++) {
|
||||
cx += snprintf(buffer + cx, buflen - cx, "%02X ", data[i]);
|
||||
}
|
||||
int cx = 0;
|
||||
for (unsigned int i = 0x00; i < datalen; i++) {
|
||||
cx += snprintf(buffer + cx, buflen - cx, "%02X ", data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintTagInfo (nfc_tag_info_t *TagInfo)
|
||||
static void PrintTagInfo(nfc_tag_info_t *TagInfo)
|
||||
{
|
||||
switch (TagInfo->technology)
|
||||
{
|
||||
case TARGET_TYPE_UNKNOWN:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type Unknown'");
|
||||
} break;
|
||||
case TARGET_TYPE_ISO14443_3A:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 3A'");
|
||||
} break;
|
||||
case TARGET_TYPE_ISO14443_3B:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 3B'");
|
||||
} break;
|
||||
case TARGET_TYPE_ISO14443_4:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 4A'");
|
||||
} break;
|
||||
case TARGET_TYPE_FELICA:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type F'");
|
||||
} break;
|
||||
case TARGET_TYPE_ISO15693:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type V'");
|
||||
} break;
|
||||
case TARGET_TYPE_NDEF:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type NDEF'");
|
||||
} break;
|
||||
case TARGET_TYPE_NDEF_FORMATABLE:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type Formatable'");
|
||||
} break;
|
||||
case TARGET_TYPE_MIFARE_CLASSIC:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Mifare Classic'");
|
||||
} break;
|
||||
case TARGET_TYPE_MIFARE_UL:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Mifare Ul'");
|
||||
} break;
|
||||
case TARGET_TYPE_KOVIO_BARCODE:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Kovio Barcode'");
|
||||
} break;
|
||||
case TARGET_TYPE_ISO14443_3A_3B:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A/B'");
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type %d (Unknown or not supported)'\n", TagInfo->technology);
|
||||
} break;
|
||||
}
|
||||
/*32 is max UID len (Kovio tags)*/
|
||||
if((0x00 != TagInfo->uid_length) && (32 >= TagInfo->uid_length))
|
||||
{
|
||||
char buffer [100];
|
||||
int cx = 0;
|
||||
switch (TagInfo->technology) {
|
||||
case TARGET_TYPE_UNKNOWN: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type Unknown'");
|
||||
}
|
||||
break;
|
||||
case TARGET_TYPE_ISO14443_3A: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 3A'");
|
||||
}
|
||||
break;
|
||||
case TARGET_TYPE_ISO14443_3B: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 3B'");
|
||||
}
|
||||
break;
|
||||
case TARGET_TYPE_ISO14443_4: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type 4A'");
|
||||
}
|
||||
break;
|
||||
case TARGET_TYPE_FELICA: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type F'");
|
||||
}
|
||||
break;
|
||||
case TARGET_TYPE_ISO15693: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type V'");
|
||||
}
|
||||
break;
|
||||
case TARGET_TYPE_NDEF: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type NDEF'");
|
||||
}
|
||||
break;
|
||||
case TARGET_TYPE_NDEF_FORMATABLE: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type Formatable'");
|
||||
}
|
||||
break;
|
||||
case TARGET_TYPE_MIFARE_CLASSIC: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Mifare Classic'");
|
||||
}
|
||||
break;
|
||||
case TARGET_TYPE_MIFARE_UL: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Mifare Ul'");
|
||||
}
|
||||
break;
|
||||
case TARGET_TYPE_KOVIO_BARCODE: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A - Kovio Barcode'");
|
||||
}
|
||||
break;
|
||||
case TARGET_TYPE_ISO14443_3A_3B: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type A/B'");
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "'Type %d (Unknown or not supported)'\n", TagInfo->technology);
|
||||
}
|
||||
break;
|
||||
}
|
||||
/*32 is max UID len (Kovio tags)*/
|
||||
if ((0x00 != TagInfo->uid_length) && (32 >= TagInfo->uid_length)) {
|
||||
char buffer [100];
|
||||
int cx = 0;
|
||||
|
||||
if(4 == TagInfo->uid_length || 7 == TagInfo->uid_length || 10 == TagInfo->uid_length)
|
||||
{
|
||||
cx += snprintf(buffer + cx, sizeof(buffer) - cx, "NFCID1 : \t'");
|
||||
}
|
||||
else if(8 == TagInfo->uid_length)
|
||||
{
|
||||
cx += snprintf(buffer + cx, sizeof(buffer) - cx, "NFCID2 : \t'");
|
||||
}
|
||||
else
|
||||
{
|
||||
cx += snprintf(buffer + cx, sizeof(buffer) - cx, "UID : \t'");
|
||||
}
|
||||
if (4 == TagInfo->uid_length || 7 == TagInfo->uid_length || 10 == TagInfo->uid_length) {
|
||||
cx += snprintf(buffer + cx, sizeof(buffer) - cx, "NFCID1 : \t'");
|
||||
} else if (8 == TagInfo->uid_length) {
|
||||
cx += snprintf(buffer + cx, sizeof(buffer) - cx, "NFCID2 : \t'");
|
||||
} else {
|
||||
cx += snprintf(buffer + cx, sizeof(buffer) - cx, "UID : \t'");
|
||||
}
|
||||
|
||||
BufferPrintBytes(buffer + cx, sizeof(buffer) - cx, (unsigned char*) TagInfo->uid, TagInfo->uid_length);
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s'", buffer);
|
||||
}
|
||||
BufferPrintBytes(buffer + cx, sizeof(buffer) - cx, (unsigned char *) TagInfo->uid, TagInfo->uid_length);
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s'", buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------------------------ */
|
||||
@@ -253,194 +246,194 @@ static void PrintTagInfo (nfc_tag_info_t *TagInfo)
|
||||
|
||||
static void onTagArrival(nfc_tag_info_t *pTagInfo)
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "tag found");
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "tag found");
|
||||
|
||||
TagInfo = malloc(sizeof(nfc_tag_info_t));
|
||||
memcpy(TagInfo, pTagInfo, sizeof(nfc_tag_info_t));
|
||||
TagInfo = malloc(sizeof(nfc_tag_info_t));
|
||||
memcpy(TagInfo, pTagInfo, sizeof(nfc_tag_info_t));
|
||||
|
||||
PrintTagInfo(TagInfo);
|
||||
PrintTagInfo(TagInfo);
|
||||
}
|
||||
|
||||
static void onTagDeparture(void)
|
||||
{
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "tag lost");
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "tag lost");
|
||||
|
||||
free(TagInfo);
|
||||
TagInfo = NULL;
|
||||
free(TagInfo);
|
||||
TagInfo = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
pn71xx_initiator_init(struct nfc_device *pnd)
|
||||
{
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
return NFC_SUCCESS;
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
static int
|
||||
pn71xx_initiator_select_passive_target(struct nfc_device *pnd,
|
||||
const nfc_modulation nm,
|
||||
const uint8_t *pbtInitData, const size_t szInitData,
|
||||
nfc_target *pnt)
|
||||
const nfc_modulation nm,
|
||||
const uint8_t *pbtInitData, const size_t szInitData,
|
||||
nfc_target *pnt)
|
||||
{
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "select_passive_target");
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "select_passive_target");
|
||||
|
||||
if (TagInfo) {
|
||||
if (TagInfo) {
|
||||
|
||||
nfc_target nttmp;
|
||||
memset(&nttmp, 0x00, sizeof(nfc_target));
|
||||
nttmp.nm = nm;
|
||||
nfc_target nttmp;
|
||||
memset(&nttmp, 0x00, sizeof(nfc_target));
|
||||
nttmp.nm = nm;
|
||||
|
||||
void* uidPtr = NULL;
|
||||
unsigned int maxLen = 0;
|
||||
void *uidPtr = NULL;
|
||||
unsigned int maxLen = 0;
|
||||
|
||||
switch (nm.nmt) {
|
||||
case NMT_ISO14443A:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 10;
|
||||
uidPtr = nttmp.nti.nai.abtUid;
|
||||
switch (nm.nmt) {
|
||||
case NMT_ISO14443A:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 10;
|
||||
uidPtr = nttmp.nti.nai.abtUid;
|
||||
|
||||
if (TagInfo->technology == TARGET_TYPE_MIFARE_CLASSIC) {
|
||||
nttmp.nti.nai.btSak = 0x08;
|
||||
} else {
|
||||
// make hardcoded desfire for freefare lib check
|
||||
nttmp.nti.nai.btSak = 0x20;
|
||||
nttmp.nti.nai.szAtsLen = 5;
|
||||
memcpy (nttmp.nti.nai.abtAts, "\x75\x77\x81\x02", 4);
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (TagInfo->technology == TARGET_TYPE_MIFARE_CLASSIC) {
|
||||
nttmp.nti.nai.btSak = 0x08;
|
||||
} else {
|
||||
// make hardcoded desfire for freefare lib check
|
||||
nttmp.nti.nai.btSak = 0x20;
|
||||
nttmp.nti.nai.szAtsLen = 5;
|
||||
memcpy(nttmp.nti.nai.abtAts, "\x75\x77\x81\x02", 4);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NMT_ISO14443B:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 4;
|
||||
uidPtr = nttmp.nti.nbi.abtPupi;
|
||||
}
|
||||
break;
|
||||
case NMT_ISO14443B:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 4;
|
||||
uidPtr = nttmp.nti.nbi.abtPupi;
|
||||
}
|
||||
break;
|
||||
|
||||
case NMT_ISO14443BI:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 4;
|
||||
uidPtr = nttmp.nti.nii.abtDIV;
|
||||
}
|
||||
break;
|
||||
case NMT_ISO14443BI:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 4;
|
||||
uidPtr = nttmp.nti.nii.abtDIV;
|
||||
}
|
||||
break;
|
||||
|
||||
case NMT_ISO14443B2SR:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 8;
|
||||
uidPtr = nttmp.nti.nsi.abtUID;
|
||||
}
|
||||
break;
|
||||
case NMT_ISO14443B2SR:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 8;
|
||||
uidPtr = nttmp.nti.nsi.abtUID;
|
||||
}
|
||||
break;
|
||||
|
||||
case NMT_ISO14443B2CT:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 4;
|
||||
uidPtr = nttmp.nti.nci.abtUID;
|
||||
}
|
||||
break;
|
||||
case NMT_ISO14443B2CT:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 4;
|
||||
uidPtr = nttmp.nti.nci.abtUID;
|
||||
}
|
||||
break;
|
||||
|
||||
case NMT_FELICA:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 8;
|
||||
uidPtr = nttmp.nti.nfi.abtId;
|
||||
}
|
||||
break;
|
||||
case NMT_FELICA:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 8;
|
||||
uidPtr = nttmp.nti.nfi.abtId;
|
||||
}
|
||||
break;
|
||||
|
||||
case NMT_JEWEL:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 4;
|
||||
uidPtr = nttmp.nti.nji.btId;
|
||||
}
|
||||
break;
|
||||
case NMT_JEWEL:
|
||||
if (IsTechnology(TagInfo, nm.nmt)) {
|
||||
maxLen = 4;
|
||||
uidPtr = nttmp.nti.nji.btId;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (uidPtr && TagInfo->uid_length) {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "target found");
|
||||
int len = TagInfo->uid_length > maxLen ? maxLen : TagInfo->uid_length;
|
||||
memcpy(uidPtr, TagInfo->uid, len);
|
||||
if (nm.nmt == NMT_ISO14443A)
|
||||
nttmp.nti.nai.szUidLen = len;
|
||||
if (uidPtr && TagInfo->uid_length) {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "target found");
|
||||
int len = TagInfo->uid_length > maxLen ? maxLen : TagInfo->uid_length;
|
||||
memcpy(uidPtr, TagInfo->uid, len);
|
||||
if (nm.nmt == NMT_ISO14443A)
|
||||
nttmp.nti.nai.szUidLen = len;
|
||||
|
||||
// Is a tag info struct available
|
||||
if (pnt) {
|
||||
memcpy(pnt, &nttmp, sizeof(nfc_target));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// Is a tag info struct available
|
||||
if (pnt) {
|
||||
memcpy(pnt, &nttmp, sizeof(nfc_target));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
pn71xx_initiator_deselect_target(struct nfc_device *pnd)
|
||||
{
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "deselect_passive_target");
|
||||
return NFC_SUCCESS;
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "deselect_passive_target");
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
pn71xx_initiator_transceive_bytes(struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx,
|
||||
const size_t szRx, int timeout)
|
||||
const size_t szRx, int timeout)
|
||||
{
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "transceive_bytes timeout=%d", timeout);
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "transceive_bytes timeout=%d", timeout);
|
||||
|
||||
if (!TagInfo) return NFC_EINVARG;
|
||||
if (!TagInfo) return NFC_EINVARG;
|
||||
|
||||
char buffer[500];
|
||||
BufferPrintBytes(buffer, sizeof(buffer), pbtTx, szTx);
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "===> %s", buffer);
|
||||
char buffer[500];
|
||||
BufferPrintBytes(buffer, sizeof(buffer), pbtTx, szTx);
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "===> %s", buffer);
|
||||
|
||||
int received = nfcTag_transceive(TagInfo->handle, (uint8_t *) pbtTx, szTx, pbtRx, szRx, 500);
|
||||
if (received <= 0)
|
||||
return NFC_EIO;
|
||||
int received = nfcTag_transceive(TagInfo->handle, (uint8_t *) pbtTx, szTx, pbtRx, szRx, 500);
|
||||
if (received <= 0)
|
||||
return NFC_EIO;
|
||||
|
||||
BufferPrintBytes(buffer, sizeof(buffer), pbtRx, received);
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "<=== %s", buffer);
|
||||
|
||||
return received;
|
||||
BufferPrintBytes(buffer, sizeof(buffer), pbtRx, received);
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "<=== %s", buffer);
|
||||
|
||||
return received;
|
||||
}
|
||||
|
||||
static int
|
||||
pn71xx_initiator_poll_target(struct nfc_device *pnd,
|
||||
const nfc_modulation *pnmModulations, const size_t szModulations,
|
||||
const uint8_t uiPollNr, const uint8_t uiPeriod,
|
||||
nfc_target *pnt)
|
||||
const nfc_modulation *pnmModulations, const size_t szModulations,
|
||||
const uint8_t uiPollNr, const uint8_t uiPeriod,
|
||||
nfc_target *pnt)
|
||||
{
|
||||
static int periodFactor = 150000;
|
||||
int period = uiPeriod * periodFactor;
|
||||
static int periodFactor = 150000;
|
||||
int period = uiPeriod * periodFactor;
|
||||
|
||||
if (pnd == NULL) return 0;
|
||||
if (pnd == NULL) return 0;
|
||||
|
||||
for (int j = 0; j < uiPollNr; j++) {
|
||||
for (unsigned int i = 0; i < szModulations; i++) {
|
||||
const nfc_modulation nm = pnmModulations[i];
|
||||
|
||||
nfc_target nt;
|
||||
int res = pn71xx_initiator_select_passive_target(pnd, nm, 0, 0, &nt);
|
||||
if (res > 0 && pnt) {
|
||||
memcpy(pnt, &nt, sizeof(nfc_target));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
usleep(period);
|
||||
}
|
||||
for (int j = 0; j < uiPollNr; j++) {
|
||||
for (unsigned int i = 0; i < szModulations; i++) {
|
||||
const nfc_modulation nm = pnmModulations[i];
|
||||
|
||||
return 0;
|
||||
nfc_target nt;
|
||||
int res = pn71xx_initiator_select_passive_target(pnd, nm, 0, 0, &nt);
|
||||
if (res > 0 && pnt) {
|
||||
memcpy(pnt, &nt, sizeof(nfc_target));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
usleep(period);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
pn71xx_initiator_target_is_present(struct nfc_device *pnd, const nfc_target *pnt)
|
||||
{
|
||||
if ((pnd == NULL) || (pnt == NULL)) return 1;
|
||||
return !TagInfo;
|
||||
if ((pnd == NULL) || (pnt == NULL)) return 1;
|
||||
return !TagInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -449,17 +442,17 @@ pn71xx_initiator_target_is_present(struct nfc_device *pnd, const nfc_target *pnt
|
||||
static int
|
||||
pn71xx_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type **const supported_mt)
|
||||
{
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
|
||||
switch (mode) {
|
||||
case N_TARGET:
|
||||
*supported_mt = (nfc_modulation_type *)pn71xx_supported_modulation_as_target;
|
||||
break;
|
||||
case N_INITIATOR:
|
||||
*supported_mt = (nfc_modulation_type *)pn71xx_supported_modulation_as_initiator;
|
||||
break;
|
||||
default:
|
||||
return NFC_EINVARG;
|
||||
switch (mode) {
|
||||
case N_TARGET:
|
||||
*supported_mt = (nfc_modulation_type *)pn71xx_supported_modulation_as_target;
|
||||
break;
|
||||
case N_INITIATOR:
|
||||
*supported_mt = (nfc_modulation_type *)pn71xx_supported_modulation_as_initiator;
|
||||
break;
|
||||
default:
|
||||
return NFC_EINVARG;
|
||||
}
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
@@ -467,32 +460,32 @@ pn71xx_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_
|
||||
static int
|
||||
pn71xx_get_supported_baud_rate(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br)
|
||||
{
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
if (mode) {}
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
if (mode) {}
|
||||
|
||||
switch (nmt) {
|
||||
case NMT_FELICA:
|
||||
*supported_br = (nfc_baud_rate *)pn71xx_felica_supported_baud_rates;
|
||||
break;
|
||||
case NMT_ISO14443A:
|
||||
*supported_br = (nfc_baud_rate *)pn71xx_iso14443a_supported_baud_rates;
|
||||
break;
|
||||
case NMT_ISO14443B:
|
||||
case NMT_ISO14443BI:
|
||||
case NMT_ISO14443B2SR:
|
||||
case NMT_ISO14443B2CT:
|
||||
*supported_br = (nfc_baud_rate *)pn71xx_iso14443b_supported_baud_rates;
|
||||
break;
|
||||
case NMT_JEWEL:
|
||||
*supported_br = (nfc_baud_rate *)pn71xx_jewel_supported_baud_rates;
|
||||
break;
|
||||
case NMT_DEP:
|
||||
*supported_br = (nfc_baud_rate *)pn71xx_dep_supported_baud_rates;
|
||||
break;
|
||||
default:
|
||||
return NFC_EINVARG;
|
||||
}
|
||||
return NFC_SUCCESS;
|
||||
switch (nmt) {
|
||||
case NMT_FELICA:
|
||||
*supported_br = (nfc_baud_rate *)pn71xx_felica_supported_baud_rates;
|
||||
break;
|
||||
case NMT_ISO14443A:
|
||||
*supported_br = (nfc_baud_rate *)pn71xx_iso14443a_supported_baud_rates;
|
||||
break;
|
||||
case NMT_ISO14443B:
|
||||
case NMT_ISO14443BI:
|
||||
case NMT_ISO14443B2SR:
|
||||
case NMT_ISO14443B2CT:
|
||||
*supported_br = (nfc_baud_rate *)pn71xx_iso14443b_supported_baud_rates;
|
||||
break;
|
||||
case NMT_JEWEL:
|
||||
*supported_br = (nfc_baud_rate *)pn71xx_jewel_supported_baud_rates;
|
||||
break;
|
||||
case NMT_DEP:
|
||||
*supported_br = (nfc_baud_rate *)pn71xx_dep_supported_baud_rates;
|
||||
break;
|
||||
default:
|
||||
return NFC_EINVARG;
|
||||
}
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------------------------ */
|
||||
@@ -501,29 +494,29 @@ pn71xx_get_supported_baud_rate(nfc_device *pnd, const nfc_mode mode, const nfc_m
|
||||
static int
|
||||
pn71xx_set_property_bool(struct nfc_device *pnd, const nfc_property property, const bool bEnable)
|
||||
{
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
return NFC_SUCCESS;
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
static int
|
||||
pn71xx_set_property_int(struct nfc_device *pnd, const nfc_property property, const int value)
|
||||
{
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
return NFC_SUCCESS;
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
static int
|
||||
pn71xx_get_information_about(nfc_device *pnd, char **pbuf)
|
||||
{
|
||||
static const char* info = "PN71XX nfc driver using libnfc-nci userspace library";
|
||||
size_t buflen = strlen(info) + 1;
|
||||
static const char *info = "PN71XX nfc driver using libnfc-nci userspace library";
|
||||
size_t buflen = strlen(info) + 1;
|
||||
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
|
||||
*pbuf = malloc(buflen);
|
||||
memcpy(*pbuf, info, buflen);
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
|
||||
return buflen;
|
||||
*pbuf = malloc(buflen);
|
||||
memcpy(*pbuf, info, buflen);
|
||||
|
||||
return buflen;
|
||||
}
|
||||
/**
|
||||
* @brief Abort any pending operation
|
||||
@@ -534,25 +527,25 @@ pn71xx_get_information_about(nfc_device *pnd, char **pbuf)
|
||||
static int
|
||||
pn71xx_abort_command(nfc_device *pnd)
|
||||
{
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "abort_command");
|
||||
return NFC_SUCCESS;
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "abort_command");
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
static int
|
||||
pn71xx_idle(struct nfc_device *pnd)
|
||||
{
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "idle");
|
||||
return NFC_SUCCESS;
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "idle");
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
static int
|
||||
pn71xx_PowerDown(struct nfc_device *pnd)
|
||||
{
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "PowerDown");
|
||||
return NFC_SUCCESS;
|
||||
if (pnd == NULL) return NFC_EIO;
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "PowerDown");
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------------------------ */
|
||||
|
||||
Reference in New Issue
Block a user