waitReady method
void
waitReady(
{ - int timeout = pn532StandardTimeout,
})
Implementation
void waitReady({int timeout = pn532StandardTimeout}) {
int attemptCount = 0;
final int timeStart = DateTime.now().millisecondsSinceEpoch;
sleep(const Duration(milliseconds: 10));
bool pn532IsReady = pn532ReadyFunction(attemptCount);
while (!pn532IsReady) {
// this sleep is extremly important! (when we don't use the irqPin)
// without you read the pn532 to often which curses to many interrupts
// on the pn532 board which results in to little execution time for the
// actual command/firmware on the pn532 which ends up in only getting
// PN532TimeoutException because the pn532 can't process the actual command
// (this can be avoided by only using the IRQ pin!)
if (!useIrq) {
sleep(const Duration(milliseconds: 20));
}
final int timeDelta = DateTime.now().millisecondsSinceEpoch - timeStart;
if (timeDelta >= timeout) {
throw PN532TimeoutException(timeout: timeout);
}
attemptCount++;
pn532IsReady = pn532ReadyFunction(attemptCount);
}
}