File tree Expand file tree Collapse file tree 1 file changed +49
-1
lines changed Expand file tree Collapse file tree 1 file changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -548,6 +548,54 @@ int ECCX08Class::nonce(const byte data[])
548548 return challenge (data);
549549}
550550
551+ long ECCX08Class::incrementCounter (int keyId)
552+ {
553+ uint32_t counter; // the counter can go up to 2,097,151
554+
555+ if (!wakeup ()) {
556+ return -1 ;
557+ }
558+
559+ if (!sendCommand (0x24 , 1 , keyId)) {
560+ return -1 ;
561+ }
562+
563+ delay (20 );
564+
565+ if (!receiveResponse (&counter, sizeof (counter))) {
566+ return -1 ;
567+ }
568+
569+ delay (1 );
570+ idle ();
571+
572+ return counter;
573+ }
574+
575+ long ECCX08Class::readCounter (int keyId)
576+ {
577+ uint32_t counter; // the counter can go up to 2,097,151
578+
579+ if (!wakeup ()) {
580+ return -1 ;
581+ }
582+
583+ if (!sendCommand (0x24 , 0 , keyId)) {
584+ return -1 ;
585+ }
586+
587+ delay (20 );
588+
589+ if (!receiveResponse (&counter, sizeof (counter))) {
590+ return -1 ;
591+ }
592+
593+ delay (1 );
594+ idle ();
595+
596+ return counter;
597+ }
598+
551599int ECCX08Class::wakeup ()
552600{
553601 _wire->setClock (_wakeupFrequency);
@@ -892,4 +940,4 @@ uint16_t ECCX08Class::crc16(const byte data[], size_t length)
892940ECCX08Class ECCX08 (CRYPTO_WIRE, 0x60 );
893941#else
894942ECCX08Class ECCX08 (Wire, 0x60 );
895- #endif
943+ #endif
You can’t perform that action at this time.
0 commit comments