report device names and a little tidying up
This commit is contained in:
parent
20df0d785d
commit
a3f573cdff
3 changed files with 26 additions and 7 deletions
|
@ -32,20 +32,22 @@ nfc_device_desc_t * pn531_usb_pick_device (void)
|
||||||
{
|
{
|
||||||
nfc_device_desc_t *pndd;
|
nfc_device_desc_t *pndd;
|
||||||
|
|
||||||
if ((pndd = malloc (sizeof (*pndd)))) {
|
if ((pndd = malloc (sizeof (*pndd))))
|
||||||
|
{
|
||||||
size_t szN;
|
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");
|
DBG("%s", "pn531_usb_list_devices failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (szN == 0) {
|
if (szN == 0)
|
||||||
|
{
|
||||||
DBG("%s", "No device found");
|
DBG("%s", "No device found");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pndd;
|
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)
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,9 @@ bool pn53x_usb_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, s
|
||||||
|
|
||||||
struct usb_bus *bus;
|
struct usb_bus *bus;
|
||||||
struct usb_device *dev;
|
struct usb_device *dev;
|
||||||
|
usb_dev_handle *udev;
|
||||||
uint32_t uiBusIndex = 0;
|
uint32_t uiBusIndex = 0;
|
||||||
|
char string[256];
|
||||||
|
|
||||||
usb_init();
|
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
|
// Nope, we maybe want the next one, let's try to find another
|
||||||
continue;
|
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].pcDriver = target_name;
|
||||||
pnddDevices[*pszDeviceFound].uiBusIndex = uiBusIndex;
|
pnddDevices[*pszDeviceFound].uiBusIndex = uiBusIndex;
|
||||||
(*pszDeviceFound)++;
|
(*pszDeviceFound)++;
|
||||||
|
|
Loading…
Add table
Reference in a new issue