pn53x_check_communication() returns now 0 on success and libnfc error code on failure.
This commit is contained in:
parent
240cdcddab
commit
7e1c776bc1
4 changed files with 14 additions and 10 deletions
|
|
@ -870,18 +870,22 @@ pn53x_idle (struct nfc_device *pnd)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
int
|
||||
pn53x_check_communication (struct nfc_device *pnd)
|
||||
{
|
||||
const uint8_t abtCmd[] = { Diagnose, 0x00, 'l', 'i', 'b', 'n', 'f', 'c' };
|
||||
const uint8_t abtExpectedRx[] = { 0x00, 'l', 'i', 'b', 'n', 'f', 'c' };
|
||||
uint8_t abtRx[sizeof(abtExpectedRx)];
|
||||
size_t szRx = sizeof (abtRx);
|
||||
int res = 0;
|
||||
|
||||
if (pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, 1000) < 0)
|
||||
return false;
|
||||
if ((res = pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, &szRx, 1000)) < 0)
|
||||
return res;
|
||||
|
||||
return ((sizeof(abtExpectedRx) == szRx) && (0 == memcmp (abtRx, abtExpectedRx, sizeof(abtExpectedRx))));
|
||||
if (((sizeof(abtExpectedRx) == szRx) && (0 == memcmp (abtRx, abtExpectedRx, sizeof(abtExpectedRx)))) == 0)
|
||||
return NFC_ECHIP;
|
||||
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ int pn53x_get_firmware_version (struct nfc_device *pnd, char abtFirmwareText[
|
|||
int pn53x_set_property_int (struct nfc_device *pnd, const nfc_property property, const int value);
|
||||
int pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, const bool bEnable);
|
||||
|
||||
bool pn53x_check_communication (struct nfc_device *pnd);
|
||||
int pn53x_check_communication (struct nfc_device *pnd);
|
||||
bool pn53x_idle (struct nfc_device *pnd);
|
||||
|
||||
// NFC device as Initiator functions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue