22
22
#include " PN5180ISO15693.h"
23
23
#include " Debug.h"
24
24
25
- PN5180ISO15693::PN5180ISO15693 (uint8_t SSpin, uint8_t BUSYpin, uint8_t RSTpin)
25
+ PN5180ISO15693::PN5180ISO15693 (uint8_t SSpin, uint8_t BUSYpin, uint8_t RSTpin)
26
26
: PN5180(SSpin, BUSYpin, RSTpin) {
27
27
}
28
28
@@ -41,9 +41,9 @@ ISO15693ErrorCode PN5180ISO15693::getInventory(uint8_t *uid) {
41
41
PN5180DEBUG (F (" Get Inventory...\n " ));
42
42
43
43
for (int i=0 ; i<8 ; i++) {
44
- uid[i] = 0 ;
44
+ uid[i] = 0 ;
45
45
}
46
-
46
+
47
47
uint8_t *readBuffer;
48
48
ISO15693ErrorCode rc = issueISO15693Command (inventory, sizeof (inventory), &readBuffer);
49
49
if (ISO15693_EC_OK != rc) {
@@ -55,15 +55,15 @@ ISO15693ErrorCode PN5180ISO15693::getInventory(uint8_t *uid) {
55
55
PN5180DEBUG (F (" , Data Storage Format ID: " ));
56
56
PN5180DEBUG (formatHex (readBuffer[1 ]));
57
57
PN5180DEBUG (F (" , UID: " ));
58
-
58
+
59
59
for (int i=0 ; i<8 ; i++) {
60
60
uid[i] = readBuffer[2 +i];
61
61
#ifdef DEBUG
62
62
PN5180DEBUG (formatHex (uid[7 -i])); // LSB comes first
63
63
if (i<2 ) PN5180DEBUG (" :" );
64
64
#endif
65
65
}
66
-
66
+
67
67
PN5180DEBUG (" \n " );
68
68
69
69
return ISO15693_EC_OK;
@@ -126,13 +126,13 @@ ISO15693ErrorCode PN5180ISO15693::readSingleBlock(uint8_t *uid, uint8_t blockNo,
126
126
}
127
127
128
128
PN5180DEBUG (" Value=" );
129
-
129
+
130
130
for (int i=0 ; i<blockSize; i++) {
131
- blockData[i] = resultPtr[2 +i];
131
+ blockData[i] = resultPtr[1 +i];
132
132
#ifdef DEBUG
133
133
PN5180DEBUG (formatHex (blockData[i]));
134
134
PN5180DEBUG (" " );
135
- #endif
135
+ #endif
136
136
}
137
137
138
138
#ifdef DEBUG
@@ -291,7 +291,7 @@ ISO15693ErrorCode PN5180ISO15693::getSystemInfo(uint8_t *uid, uint8_t *blockSize
291
291
for (int i=0 ; i<8 ; i++) {
292
292
uid[i] = readBuffer[2 +i];
293
293
}
294
-
294
+
295
295
#ifdef DEBUG
296
296
PN5180DEBUG (" UID=" );
297
297
for (int i=0 ; i<8 ; i++) {
@@ -300,7 +300,7 @@ ISO15693ErrorCode PN5180ISO15693::getSystemInfo(uint8_t *uid, uint8_t *blockSize
300
300
}
301
301
PN5180DEBUG (" \n " );
302
302
#endif
303
-
303
+
304
304
uint8_t *p = &readBuffer[10 ];
305
305
306
306
uint8_t infoFlags = readBuffer[1 ];
@@ -311,9 +311,9 @@ ISO15693ErrorCode PN5180ISO15693::getSystemInfo(uint8_t *uid, uint8_t *blockSize
311
311
PN5180DEBUG (" \n " );
312
312
}
313
313
#ifdef DEBUG
314
- else PN5180DEBUG (F (" No DSFID\n " ));
314
+ else PN5180DEBUG (F (" No DSFID\n " ));
315
315
#endif
316
-
316
+
317
317
if (infoFlags & 0x02 ) { // AFI flag
318
318
uint8_t afi = *p++;
319
319
PN5180DEBUG (F (" AFI=" )); // Application family identifier
@@ -361,7 +361,7 @@ ISO15693ErrorCode PN5180ISO15693::getSystemInfo(uint8_t *uid, uint8_t *blockSize
361
361
#ifdef DEBUG
362
362
else PN5180DEBUG (F (" No VICC memory size\n " ));
363
363
#endif
364
-
364
+
365
365
if (infoFlags & 0x08 ) { // IC reference
366
366
uint8_t icRef = *p++;
367
367
PN5180DEBUG (" IC Ref=" );
@@ -379,8 +379,8 @@ ISO15693ErrorCode PN5180ISO15693::getSystemInfo(uint8_t *uid, uint8_t *blockSize
379
379
// ICODE SLIX specific commands
380
380
381
381
/*
382
- * The GET RANDOM NUMBER command is required to receive a random number from the label IC.
383
- * The passwords that will be transmitted with the SET PASSWORD,ENABLEPRIVACY and DESTROY commands
382
+ * The GET RANDOM NUMBER command is required to receive a random number from the label IC.
383
+ * The passwords that will be transmitted with the SET PASSWORD,ENABLEPRIVACY and DESTROY commands
384
384
* have to be calculated with the password and therandom number (see Section 9.5.3.2 "SET PASSWORD")
385
385
*/
386
386
ISO15693ErrorCode PN5180ISO15693::getRandomNumber (uint8_t *randomData) {
@@ -395,8 +395,8 @@ ISO15693ErrorCode PN5180ISO15693::getRandomNumber(uint8_t *randomData) {
395
395
}
396
396
397
397
/*
398
- * The SET PASSWORD command enables the different passwords to be transmitted to the label
399
- * to access the different protected functionalities of the following commands.
398
+ * The SET PASSWORD command enables the different passwords to be transmitted to the label
399
+ * to access the different protected functionalities of the following commands.
400
400
* The SET PASSWORD command has to be executed just once for the related passwords if the label is powered
401
401
*/
402
402
ISO15693ErrorCode PN5180ISO15693::setPassword (uint8_t *password, uint8_t *random) {
@@ -430,10 +430,10 @@ ISO15693ErrorCode PN5180ISO15693::unlockICODESLIX2(uint8_t *password) {
430
430
if (rc != ISO15693_EC_OK) {
431
431
return rc;
432
432
}
433
-
433
+
434
434
// set password to unlock the tag
435
435
rc = setPassword (password, random );
436
- return rc;
436
+ return rc;
437
437
}
438
438
439
439
// lock a ICODE SLIX2 tag with given password (set to privacy mode)
@@ -444,10 +444,10 @@ ISO15693ErrorCode PN5180ISO15693::lockICODESLIX2(uint8_t *password) {
444
444
if (rc != ISO15693_EC_OK) {
445
445
return rc;
446
446
}
447
-
447
+
448
448
// enable privacy command to lock the tag
449
449
rc = enablePrivacy (password, random );
450
- return rc;
450
+ return rc;
451
451
}
452
452
453
453
@@ -518,15 +518,15 @@ ISO15693ErrorCode PN5180ISO15693::issueISO15693Command(uint8_t *cmd, uint8_t cmd
518
518
if (0 == (getIRQStatus () & RX_SOF_DET_IRQ_STAT)) {
519
519
return EC_NO_CARD;
520
520
}
521
-
521
+
522
522
uint32_t rxStatus;
523
523
readRegister (RX_STATUS, &rxStatus);
524
-
524
+
525
525
PN5180DEBUG (F (" RX-Status=" ));
526
526
PN5180DEBUG (formatHex (rxStatus));
527
527
528
528
uint16_t len = (uint16_t )(rxStatus & 0x000001ff );
529
-
529
+
530
530
PN5180DEBUG (" , len=" );
531
531
PN5180DEBUG (len);
532
532
PN5180DEBUG (" \n " );
@@ -536,7 +536,7 @@ ISO15693ErrorCode PN5180ISO15693::issueISO15693Command(uint8_t *cmd, uint8_t cmd
536
536
PN5180DEBUG (F (" *** ERROR in readData!\n " ));
537
537
return ISO15693_EC_UNKNOWN_ERROR;
538
538
}
539
-
539
+
540
540
#ifdef DEBUG
541
541
Serial.print (" Read=" );
542
542
for (int i=0 ; i<len; i++) {
@@ -555,7 +555,7 @@ ISO15693ErrorCode PN5180ISO15693::issueISO15693Command(uint8_t *cmd, uint8_t cmd
555
555
uint8_t responseFlags = (*resultPtr)[0 ];
556
556
if (responseFlags & (1 <<0 )) { // error flag
557
557
uint8_t errorCode = (*resultPtr)[1 ];
558
-
558
+
559
559
PN5180DEBUG (" ERROR code=" );
560
560
PN5180DEBUG (formatHex (errorCode));
561
561
PN5180DEBUG (" - " );
@@ -601,7 +601,7 @@ const __FlashStringHelper *PN5180ISO15693::strerror(ISO15693ErrorCode errno) {
601
601
PN5180DEBUG (F (" ISO15693ErrorCode=" ));
602
602
PN5180DEBUG (errno);
603
603
PN5180DEBUG (" \n " );
604
-
604
+
605
605
switch (errno) {
606
606
case EC_NO_CARD: return F (" No card detected!" );
607
607
case ISO15693_EC_OK: return F (" OK!" );
0 commit comments