@@ -763,32 +763,50 @@ void seader_mfc_transmit(
763
763
(format [0 ] == 0x00 && format [1 ] == 0x00 && format [2 ] == 0x40 ) ||
764
764
(format [0 ] == 0x00 && format [1 ] == 0x00 && format [2 ] == 0x24 ) ||
765
765
(format [0 ] == 0x00 && format [1 ] == 0x00 && format [2 ] == 0x44 )) {
766
- //bit_buffer_copy_bytes_with_parity(tx_buffer, buffer, len * 8);
766
+ memset (display , 0 , sizeof (display ));
767
+ for (uint8_t i = 0 ; i < len ; i ++ ) {
768
+ snprintf (display + (i * 2 ), sizeof (display ), "%02x" , buffer [i ]);
769
+ }
770
+ FURI_LOG_D (TAG , "NFC Send with parity %d: %s" , len , display );
767
771
772
+ // Only handles message up to 8 data bytes
768
773
uint8_t tx_parity = 0 ;
774
+ uint8_t len_without_parity = len - 1 ;
769
775
770
776
// Don't forget to swap the bits of buffer[8]
771
777
for (size_t i = 0 ; i < len ; i ++ ) {
772
778
bit_lib_reverse_bits (buffer + i , 0 , 8 );
773
779
}
774
780
775
781
// Pull out parity bits
776
- for (size_t i = 0 ; i < 8 ; i ++ ) {
782
+ for (size_t i = 0 ; i < len_without_parity ; i ++ ) {
777
783
bool val = bit_lib_get_bit (buffer + i + 1 , i );
778
784
bit_lib_set_bit (& tx_parity , i , val );
779
785
}
780
786
781
- for (size_t i = 0 ; i < 8 ; i ++ ) {
787
+ for (size_t i = 0 ; i < len_without_parity ; i ++ ) {
782
788
buffer [i ] = (buffer [i ] << i ) | (buffer [i + 1 ] >> (8 - i ));
783
789
}
784
- bit_buffer_append_bytes (tx_buffer , buffer , 8 );
790
+ bit_buffer_append_bytes (tx_buffer , buffer , len_without_parity );
785
791
786
- for (size_t i = 0 ; i < 8 ; i ++ ) {
792
+ for (size_t i = 0 ; i < len_without_parity ; i ++ ) {
787
793
bit_lib_reverse_bits (buffer + i , 0 , 8 );
788
794
bit_buffer_set_byte_with_parity (
789
795
tx_buffer , i , buffer [i ], bit_lib_get_bit (& tx_parity , i ));
790
796
}
791
797
798
+ memset (display , 0 , sizeof (display ));
799
+ for (uint8_t i = 0 ; i < bit_buffer_get_size_bytes (tx_buffer ); i ++ ) {
800
+ snprintf (
801
+ display + (i * 2 ), sizeof (display ), "%02x" , bit_buffer_get_byte (tx_buffer , i ));
802
+ }
803
+ FURI_LOG_D (
804
+ TAG ,
805
+ "NFC Send without parity %d: %s [%02x]" ,
806
+ bit_buffer_get_size_bytes (tx_buffer ),
807
+ display ,
808
+ tx_parity );
809
+
792
810
MfClassicError error = mf_classic_poller_send_custom_parity_frame (
793
811
mfc_poller , tx_buffer , rx_buffer , MF_CLASSIC_FWT_FC );
794
812
if (error != MfClassicErrorNone ) {
@@ -805,7 +823,8 @@ void seader_mfc_transmit(
805
823
snprintf (
806
824
display + (i * 2 ), sizeof (display ), "%02x" , bit_buffer_get_byte (rx_buffer , i ));
807
825
}
808
- FURI_LOG_D (TAG , "NFC Response %d: %s [%02x]" , length , display , rx_parity [0 ]);
826
+ FURI_LOG_D (
827
+ TAG , "NFC Response without parity %d: %s [%02x]" , length , display , rx_parity [0 ]);
809
828
810
829
uint8_t with_parity [SEADER_POLLER_MAX_BUFFER_SIZE ];
811
830
memset (with_parity , 0 , sizeof (with_parity ));
@@ -848,7 +867,8 @@ void seader_mfc_transmit(
848
867
snprintf (
849
868
display + (i * 2 ), sizeof (display ), "%02x" , bit_buffer_get_byte (rx_buffer , i ));
850
869
}
851
- FURI_LOG_D (TAG , "NFC Response %d: %s [%02x]" , length , display , rx_parity [0 ]);
870
+ FURI_LOG_D (
871
+ TAG , "NFC Response with parity %d: %s [%02x]" , length , display , rx_parity [0 ]);
852
872
853
873
} else {
854
874
FURI_LOG_W (TAG , "UNHANDLED FORMAT" );
0 commit comments