Skip to content

Commit

Permalink
feat: add is tag detected
Browse files Browse the repository at this point in the history
  • Loading branch information
DeimosHall committed Aug 18, 2023
1 parent 27317c0 commit 79b94eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions examples/NDEFRead/NDEFRead.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void setup() {
}

void loop() {
if (!nfc.waitForDiscoveryNotification()) { // Wait for a card
if (nfc.isTagDetected()) { // Wait for a card
displayDeviceInfo();
switch (nfc.remoteDevice.getProtocol()) {
// Read NDEF message from NFC Forum Type 1, 2, 3, 4, 5 tags
Expand All @@ -59,10 +59,10 @@ void loop() {
Serial.println("Remove the Card");
nfc.waitForTagRemoval();
Serial.println("Card removed!");
Serial.println("Restarting...");
nfc.reset(); // TODO: type 4 tags cause discovery failed after reset
}

Serial.println("Restarting...");
nfc.reset();
Serial.println("Waiting for a Card...");
delay(500);
}
Expand Down
10 changes: 7 additions & 3 deletions src/Electroniccats_PN7150.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ bool Electroniccats_PN7150::configureSettings(void) {
getMessage();
if ((rxBuffer[0] != 0x40) || (rxBuffer[1] != 0x02) || (rxBuffer[3] != 0x00) || (rxBuffer[4] != 0x00)) {
#ifdef SerialUSB
Serial.println("NxpNci_CORE_CONF");
Serial.println("NxpNci_CORE_CONF :D");
#endif
return ERROR;
}
Expand Down Expand Up @@ -1060,7 +1060,11 @@ bool Electroniccats_PN7150::waitForDiscoveryNotification(uint8_t tout) {
return Electroniccats_PN7150::waitForDiscoveryNotification(&this->dummyRfInterface, tout);
}

// Deprecated, use waitForDiscoveryNotification() instead
bool Electroniccats_PN7150::isTagDetected() {
return !Electroniccats_PN7150::waitForDiscoveryNotification(500);
}

// Deprecated, use isTagDetected() instead
bool Electroniccats_PN7150::WaitForDiscoveryNotification(RfIntf_t *pRfIntf, uint8_t tout) {
return Electroniccats_PN7150::waitForDiscoveryNotification(pRfIntf, tout);
}
Expand Down Expand Up @@ -1721,7 +1725,7 @@ bool Electroniccats_PN7150::reset() {
return false;
}

if (configureSettings()) {
if (Electroniccats_PN7150::configureSettings()) {
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Electroniccats_PN7150.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ class Electroniccats_PN7150 : public Mode {
bool StopDiscovery(); // Deprecated, use stopDiscovery() instead
bool waitForDiscoveryNotification(RfIntf_t *pRfIntf, uint8_t tout = 0);
bool waitForDiscoveryNotification(uint8_t tout = 0);
bool WaitForDiscoveryNotification(RfIntf_t *pRfIntf, uint8_t tout = 0); // Deprecated, use waitForDiscoveryNotification() instead
bool isTagDetected();
bool WaitForDiscoveryNotification(RfIntf_t *pRfIntf, uint8_t tout = 0); // Deprecated, use isTagDetected() instead
uint8_t connectNCI();
uint8_t wakeupNCI();
bool cardModeSend(unsigned char *pData, unsigned char DataSize);
Expand Down

0 comments on commit 79b94eb

Please sign in to comment.