mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-03-03 06:11:46 +00:00
Rename dev_config_option to nfc_device_option_t.
Use NULL instead of INVALID_DEVICE_INFO to know if device is valid (all occurences are now replaced).
This commit is contained in:
@@ -79,10 +79,10 @@ nfc_device_t* acr122_connect(const nfc_device_desc_t* pndd)
|
||||
memset(acList,0x00,szListLen);
|
||||
|
||||
// Test if context succeeded
|
||||
if (SCardEstablishContext(SCARD_SCOPE_USER,NULL,NULL,&(as.hCtx)) != SCARD_S_SUCCESS) return INVALID_DEVICE_INFO;
|
||||
if (SCardEstablishContext(SCARD_SCOPE_USER,NULL,NULL,&(as.hCtx)) != SCARD_S_SUCCESS) return NULL;
|
||||
|
||||
// Retrieve the string array of all available pcsc readers
|
||||
if (SCardListReaders(as.hCtx,NULL,acList,(void*)&szListLen) != SCARD_S_SUCCESS) return INVALID_DEVICE_INFO;
|
||||
if (SCardListReaders(as.hCtx,NULL,acList,(void*)&szListLen) != SCARD_S_SUCCESS) return NULL;
|
||||
|
||||
DBG("PCSC reports following device(s):");
|
||||
DBG("- %s",acList);
|
||||
@@ -163,7 +163,7 @@ nfc_device_t* acr122_connect(const nfc_device_desc_t* pndd)
|
||||
}
|
||||
|
||||
// Too bad, the reader could not be located;
|
||||
return INVALID_DEVICE_INFO;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void acr122_disconnect(nfc_device_t* pnd)
|
||||
|
||||
@@ -80,12 +80,12 @@ nfc_device_t* arygon_connect(const nfc_device_desc_t* pndd)
|
||||
uint32_t uiDevNr;
|
||||
serial_port sp;
|
||||
char acConnect[BUFFER_LENGTH];
|
||||
nfc_device_t* pnd = INVALID_DEVICE_INFO;
|
||||
nfc_device_t* pnd = NULL;
|
||||
|
||||
if( pndd == NULL ) {
|
||||
#ifdef DISABLE_SERIAL_AUTOPROBE
|
||||
INFO("Sorry, serial auto-probing have been disabled at compile time.");
|
||||
return INVALID_DEVICE_INFO;
|
||||
return NULL;
|
||||
#else
|
||||
DBG("Trying to find ARYGON device on serial port: %s# at %d bauds.",SERIAL_STRING, SERIAL_DEFAULT_PORT_SPEED);
|
||||
// I have no idea how MAC OS X deals with multiple devices, so a quick workaround
|
||||
@@ -110,14 +110,14 @@ nfc_device_t* arygon_connect(const nfc_device_desc_t* pndd)
|
||||
}
|
||||
#endif
|
||||
// Test if we have found a device
|
||||
if (uiDevNr == DRIVERS_MAX_DEVICES) return INVALID_DEVICE_INFO;
|
||||
if (uiDevNr == DRIVERS_MAX_DEVICES) return NULL;
|
||||
} else {
|
||||
DBG("Connecting to: %s at %d bauds.",pndd->pcPort, pndd->uiSpeed);
|
||||
strcpy(acConnect,pndd->pcPort);
|
||||
sp = uart_open(acConnect);
|
||||
if (sp == INVALID_SERIAL_PORT) ERR("Invalid serial port: %s",acConnect);
|
||||
if (sp == CLAIMED_SERIAL_PORT) ERR("Serial port already claimed: %s",acConnect);
|
||||
if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return INVALID_DEVICE_INFO;
|
||||
if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return NULL;
|
||||
|
||||
uart_set_speed(sp, pndd->uiSpeed);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ nfc_device_t* pn531_usb_connect(const nfc_device_desc_t* pndd)
|
||||
int idproduct_alt = 0x0193;
|
||||
struct usb_bus *bus;
|
||||
struct usb_device *dev;
|
||||
nfc_device_t* pnd = INVALID_DEVICE_INFO;
|
||||
nfc_device_t* pnd = NULL;
|
||||
usb_spec_t* pus;
|
||||
usb_spec_t us;
|
||||
uint32_t uiDevIndex;
|
||||
@@ -100,8 +100,8 @@ nfc_device_t* pn531_usb_connect(const nfc_device_desc_t* pndd)
|
||||
us.pudh = NULL;
|
||||
|
||||
usb_init();
|
||||
if (usb_find_busses() < 0) return INVALID_DEVICE_INFO;
|
||||
if (usb_find_devices() < 0) return INVALID_DEVICE_INFO;
|
||||
if (usb_find_busses() < 0) return NULL;
|
||||
if (usb_find_devices() < 0) return NULL;
|
||||
|
||||
// Initialize the device index we are seaching for
|
||||
if( pndd == NULL ) {
|
||||
@@ -137,14 +137,14 @@ nfc_device_t* pn531_usb_connect(const nfc_device_desc_t* pndd)
|
||||
{
|
||||
DBG("Set config failed");
|
||||
usb_close(us.pudh);
|
||||
return INVALID_DEVICE_INFO;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(usb_claim_interface(us.pudh,0) < 0)
|
||||
{
|
||||
DBG("Can't claim interface");
|
||||
usb_close(us.pudh);
|
||||
return INVALID_DEVICE_INFO;
|
||||
return NULL;
|
||||
}
|
||||
// Allocate memory for the device info and specification, fill it and return the info
|
||||
pus = malloc(sizeof(usb_spec_t));
|
||||
|
||||
@@ -56,12 +56,12 @@ nfc_device_t* pn532_uart_connect(const nfc_device_desc_t* pndd)
|
||||
uint32_t uiDevNr;
|
||||
serial_port sp;
|
||||
char acConnect[BUFFER_LENGTH];
|
||||
nfc_device_t* pnd = INVALID_DEVICE_INFO;
|
||||
nfc_device_t* pnd = NULL;
|
||||
|
||||
if( pndd == NULL ) {
|
||||
#ifdef DISABLE_SERIAL_AUTOPROBE
|
||||
INFO("Sorry, serial auto-probing have been disabled at compile time.");
|
||||
return INVALID_DEVICE_INFO;
|
||||
return NULL;
|
||||
#else
|
||||
DBG("Trying to find ARYGON device on serial port: %s# at %d bauds.",SERIAL_STRING, SERIAL_DEFAULT_PORT_SPEED);
|
||||
// I have no idea how MAC OS X deals with multiple devices, so a quick workaround
|
||||
@@ -86,14 +86,14 @@ nfc_device_t* pn532_uart_connect(const nfc_device_desc_t* pndd)
|
||||
}
|
||||
#endif
|
||||
// Test if we have found a device
|
||||
if (uiDevNr == DRIVERS_MAX_DEVICES) return INVALID_DEVICE_INFO;
|
||||
if (uiDevNr == DRIVERS_MAX_DEVICES) return NULL;
|
||||
} else {
|
||||
DBG("Connecting to: %s at %d bauds.",pndd->pcPort, pndd->uiSpeed);
|
||||
strcpy(acConnect,pndd->pcPort);
|
||||
sp = uart_open(acConnect);
|
||||
if (sp == INVALID_SERIAL_PORT) ERR("Invalid serial port: %s",acConnect);
|
||||
if (sp == CLAIMED_SERIAL_PORT) ERR("Serial port already claimed: %s",acConnect);
|
||||
if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return INVALID_DEVICE_INFO;
|
||||
if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return NULL;
|
||||
|
||||
uart_set_speed(sp, pndd->uiSpeed);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ nfc_device_t* pn533_usb_connect(const nfc_device_desc_t* pndd)
|
||||
int idproduct = 0x5591;
|
||||
struct usb_bus *bus;
|
||||
struct usb_device *dev;
|
||||
nfc_device_t* pnd = INVALID_DEVICE_INFO;
|
||||
nfc_device_t* pnd = NULL;
|
||||
usb_spec_t* pus;
|
||||
usb_spec_t us;
|
||||
uint32_t uiDevIndex;
|
||||
@@ -97,8 +97,8 @@ nfc_device_t* pn533_usb_connect(const nfc_device_desc_t* pndd)
|
||||
us.pudh = NULL;
|
||||
|
||||
usb_init();
|
||||
if (usb_find_busses() < 0) return INVALID_DEVICE_INFO;
|
||||
if (usb_find_devices() < 0) return INVALID_DEVICE_INFO;
|
||||
if (usb_find_busses() < 0) return NULL;
|
||||
if (usb_find_devices() < 0) return NULL;
|
||||
|
||||
// Initialize the device index we are seaching for
|
||||
if( pndd == NULL ) {
|
||||
@@ -133,14 +133,14 @@ nfc_device_t* pn533_usb_connect(const nfc_device_desc_t* pndd)
|
||||
{
|
||||
DBG("Setting config failed");
|
||||
usb_close(us.pudh);
|
||||
return INVALID_DEVICE_INFO;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(usb_claim_interface(us.pudh,0) < 0)
|
||||
{
|
||||
DBG("Can't claim interface");
|
||||
usb_close(us.pudh);
|
||||
return INVALID_DEVICE_INFO;
|
||||
return NULL;
|
||||
}
|
||||
// Allocate memory for the device info and specification, fill it and return the info
|
||||
pus = malloc(sizeof(usb_spec_t));
|
||||
|
||||
Reference in New Issue
Block a user