Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to prevent halt when NFC tag not found on begin() #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions NfcAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NfcAdapter::~NfcAdapter(void)
delete shield;
}

void NfcAdapter::begin(boolean verbose)
bool NfcAdapter::begin(boolean verbose, boolean halt_on_not_found=true)
{
shield->begin();

Expand All @@ -21,7 +21,11 @@ void NfcAdapter::begin(boolean verbose)
#ifdef NDEF_USE_SERIAL
Serial.print(F("Didn't find PN53x board"));
#endif
while (1); // halt
if (halt_on_not_found) {
while (1); // halt
} else {
return false;
}
}

if (verbose)
Expand All @@ -34,6 +38,7 @@ void NfcAdapter::begin(boolean verbose)
}
// configure board to read RFID tags
shield->SAMConfig();
return true;
}

boolean NfcAdapter::tagPresent(unsigned long timeout)
Expand Down
2 changes: 1 addition & 1 deletion NfcAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class NfcAdapter {
NfcAdapter(PN532Interface &interface);

~NfcAdapter(void);
void begin(boolean verbose=true);
boolean begin(boolean verbose=true, boolean halt_on_not_found=true);
boolean tagPresent(unsigned long timeout=0); // tagAvailable
NfcTag read();
boolean write(NdefMessage& ndefMessage);
Expand Down