diff --git a/src/lib/drivers/pn531_usb.c b/src/lib/drivers/pn531_usb.c index abcb94e..e62fb49 100644 --- a/src/lib/drivers/pn531_usb.c +++ b/src/lib/drivers/pn531_usb.c @@ -32,20 +32,22 @@ nfc_device_desc_t * pn531_usb_pick_device (void) { nfc_device_desc_t *pndd; - if ((pndd = malloc (sizeof (*pndd)))) { + if ((pndd = malloc (sizeof (*pndd)))) + { size_t szN; - if (!pn531_usb_list_devices (pndd, 1, &szN)) { + if (!pn531_usb_list_devices (pndd, 1, &szN)) + { DBG("%s", "pn531_usb_list_devices failed"); return NULL; } - if (szN == 0) { + if (szN == 0) + { DBG("%s", "No device found"); return NULL; } } - return pndd; } @@ -59,5 +61,5 @@ bool pn531_usb_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, s nfc_device_t* pn531_usb_connect(const nfc_device_desc_t* pndd) { - return(pn53x_usb_connect(pndd, PN531_USB_DRIVER_NAME, NC_PN531)); + return pn53x_usb_connect(pndd, pndd->acDevice, NC_PN531); } diff --git a/src/lib/drivers/pn533_usb.c b/src/lib/drivers/pn533_usb.c index de60ee7..1c9cdad 100644 --- a/src/lib/drivers/pn533_usb.c +++ b/src/lib/drivers/pn533_usb.c @@ -59,5 +59,5 @@ bool pn533_usb_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, s nfc_device_t* pn533_usb_connect(const nfc_device_desc_t* pndd) { - return(pn53x_usb_connect(pndd, PN533_USB_DRIVER_NAME, NC_PN533)); + return pn53x_usb_connect(pndd, pndd->acDevice, NC_PN533); } diff --git a/src/lib/drivers/pn53x_usb.c b/src/lib/drivers/pn53x_usb.c index 2e1aa64..8deff9c 100644 --- a/src/lib/drivers/pn53x_usb.c +++ b/src/lib/drivers/pn53x_usb.c @@ -76,7 +76,9 @@ bool pn53x_usb_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, s struct usb_bus *bus; struct usb_device *dev; + usb_dev_handle *udev; uint32_t uiBusIndex = 0; + char string[256]; usb_init(); @@ -108,7 +110,22 @@ bool pn53x_usb_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, s // Nope, we maybe want the next one, let's try to find another continue; } - strcpy(pnddDevices[*pszDeviceFound].acDevice, target_name); + if (dev->descriptor.iManufacturer || dev->descriptor.iProduct) + { + udev = usb_open(dev); + if(udev) + { + usb_get_string_simple(udev, dev->descriptor.iManufacturer, string, sizeof(string)); + if(strlen(string) > 0) + strcpy(string + strlen(string)," / "); + usb_get_string_simple(udev, dev->descriptor.iProduct, string + strlen(string), sizeof(string) - strlen(string)); + } + usb_close(udev); + } + if(strlen(string) == 0) + strcpy(pnddDevices[*pszDeviceFound].acDevice, target_name); + else + strcpy(pnddDevices[*pszDeviceFound].acDevice, string); pnddDevices[*pszDeviceFound].pcDriver = target_name; pnddDevices[*pszDeviceFound].uiBusIndex = uiBusIndex; (*pszDeviceFound)++;