@@ -448,13 +448,13 @@ void fix_ac_decoding(uint8_t *input, size_t len) {
448
448
// looks at number of received bits.
449
449
// 0 = collision?
450
450
// 32 = good response
451
- static bool hitag_plain (uint8_t * rx , const size_t rxlen , uint8_t * tx , size_t * txlen , bool hitag_s ) {
451
+ static bool hitag1_plain (uint8_t * rx , const size_t rxlen , uint8_t * tx , size_t * txlen , bool hitag_s ) {
452
452
* txlen = 0 ;
453
453
switch (rxlen ) {
454
454
case 0 : {
455
455
// retry waking up card
456
456
/*tx[0] = 0xb0; // Rev 3.0*/
457
- tx [0 ] = 0x30 ; // Rev 2.0
457
+ tx [0 ] = HITAG1_SET_CC ; // Rev 2.0
458
458
* txlen = 5 ;
459
459
if (!bCollision ) blocknr -- ;
460
460
if (blocknr < 0 ) {
@@ -472,7 +472,7 @@ static bool hitag_plain(uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t *tx
472
472
uint8_t crc ;
473
473
if (bCollision ) {
474
474
// Select card by serial from response
475
- tx [0 ] = 0x00 | rx [0 ] >> 5 ;
475
+ tx [0 ] = HITAG1_SELECT | rx [0 ] >> 5 ;
476
476
tx [1 ] = rx [0 ] << 3 | rx [1 ] >> 5 ;
477
477
tx [2 ] = rx [1 ] << 3 | rx [2 ] >> 5 ;
478
478
tx [3 ] = rx [2 ] << 3 | rx [3 ] >> 5 ;
@@ -498,7 +498,7 @@ static bool hitag_plain(uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t *tx
498
498
}
499
499
// read next page of card until done
500
500
Dbprintf ("Reading page %02u" , blocknr );
501
- tx [0 ] = 0xc0 | blocknr >> 4 ; // RDPPAGE
501
+ tx [0 ] = HITAG1_RDPPAGE | blocknr >> 4 ; // RDPPAGE
502
502
tx [1 ] = blocknr << 4 ;
503
503
crc = hitag_crc (tx , 12 );
504
504
tx [1 ] |= crc >> 4 ;
@@ -524,7 +524,7 @@ static bool hitag1_authenticate(uint8_t *rx, const size_t rxlen, uint8_t *tx, si
524
524
case 0 : {
525
525
// retry waking up card
526
526
/*tx[0] = 0xb0; // Rev 3.0*/
527
- tx [0 ] = 0x30 ; // Rev 2.0
527
+ tx [0 ] = HITAG1_SELECT ; // Rev 2.0
528
528
* txlen = 5 ;
529
529
if (bCrypto && byte_value <= 0xff ) {
530
530
// to retry
@@ -554,7 +554,7 @@ static bool hitag1_authenticate(uint8_t *rx, const size_t rxlen, uint8_t *tx, si
554
554
// will receive 32 bit encrypted Logdata
555
555
} else if (bCrypto ) {
556
556
// authed, start reading
557
- tx [0 ] = 0xe0 | blocknr >> 4 ; // RDCPAGE
557
+ tx [0 ] = HITAG1_RDCPAGE | blocknr >> 4 ; // RDCPAGE
558
558
tx [1 ] = blocknr << 4 ;
559
559
crc = hitag_crc (tx , 12 );
560
560
tx [1 ] |= crc >> 4 ;
@@ -567,7 +567,7 @@ static bool hitag1_authenticate(uint8_t *rx, const size_t rxlen, uint8_t *tx, si
567
567
case 32 : {
568
568
if (bCollision ) {
569
569
// Select card by serial from response
570
- tx [0 ] = 0x00 | rx [0 ] >> 5 ;
570
+ tx [0 ] = HITAG1_SELECT | rx [0 ] >> 5 ;
571
571
tx [1 ] = rx [0 ] << 3 | rx [1 ] >> 5 ;
572
572
tx [2 ] = rx [1 ] << 3 | rx [2 ] >> 5 ;
573
573
tx [3 ] = rx [2 ] << 3 | rx [3 ] >> 5 ;
@@ -581,7 +581,7 @@ static bool hitag1_authenticate(uint8_t *rx, const size_t rxlen, uint8_t *tx, si
581
581
// will receive 32-bit configuration page
582
582
} else if (bSelecting ) {
583
583
// Initiate auth
584
- tx [0 ] = 0xa0 | (key_no ); // WRCPAGE
584
+ tx [0 ] = HITAG1_WRCPAGE | (key_no ); // WRCPAGE
585
585
tx [1 ] = blocknr << 4 ;
586
586
crc = hitag_crc (tx , 12 );
587
587
tx [1 ] |= crc >> 4 ;
@@ -621,7 +621,7 @@ static bool hitag1_authenticate(uint8_t *rx, const size_t rxlen, uint8_t *tx, si
621
621
return false;
622
622
/*
623
623
// read next page of card until done
624
- tx[0] = 0xe0 | blocknr >> 4; // RDCPAGE
624
+ tx[0] = HITAG1_RDCPAGE | blocknr >> 4; // RDCPAGE
625
625
tx[1] = blocknr << 4;
626
626
crc = hitag_crc(tx, 12);
627
627
tx[1] |= crc >> 4;
@@ -1820,7 +1820,7 @@ void ReaderHitag(const lf_hitag_data_t *payload, bool ledcontrol) {
1820
1820
tx = txbuf ;
1821
1821
switch (payload -> cmd ) {
1822
1822
case RHT1F_PLAIN : {
1823
- bStop = !hitag_plain (rx , rxlen , tx , & txlen , false);
1823
+ bStop = !hitag1_plain (rx , rxlen , tx , & txlen , false);
1824
1824
break ;
1825
1825
}
1826
1826
case RHT1F_AUTHENTICATE : {
0 commit comments