Add error checking to mifare_classic_connect(), mifare_classic_disconnect().

Do not assume nfc_initiator_select_tag() and nfc_initiator_deselect_tag() will not return an error if the provided tag is supposed to be ready for the operation (it might have move out of the field), and let the error propagate through libfreefare to the application calling the functions.
This commit is contained in:
Romain Tartiere 2010-01-08 08:29:19 +00:00
parent 76a8c8e8b1
commit 7fd413789a

View file

@ -1,5 +1,5 @@
/*-
* Copyright (C) 2009, Romain Tartiere, Romuald Conty.
* Copyright (C) 2009, 2010, Romain Tartiere, Romuald Conty.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
@ -257,6 +257,9 @@ mifare_classic_connect (MifareClassicTag tag)
nfc_target_info_t pnti;
if (nfc_initiator_select_tag (tag->device, NM_ISO14443A_106, tag->info.abtUid, 4, &pnti)) {
tag->active = 1;
} else {
errno = EIO;
return -1;
}
return 0;
}
@ -274,6 +277,9 @@ mifare_classic_disconnect (MifareClassicTag tag)
if (nfc_initiator_deselect_tag (tag->device)) {
tag->active = 0;
} else {
errno = EIO;
return -1;
}
return 0;
}