improve documentation
[Biblio-RFID.git] / lib / RFID / Biblio / RFID501.pm
index dc30fe8..131d980 100644 (file)
@@ -57,14 +57,44 @@ L<http://saturn.ffzg.hr/rot13/index.cgi?hitchhikers_guide_to_rfid>
  1   00 00 00 00
  2   00 00 00 00
 
+=head1 Security
+
+AFI byte on RFID tag is used for security.
+
+In my case, we have RFID door which can only read AFI bytes from tag and issue
+alarm sound or ignore it depending on value of byte.
+
+=over 8 
+
+=item 0xD7 214
+
+secured item (door will beep)
+
+=item 0xDA 218
+
+unsecured (door will ignore it)
+
+=back
+
+
 =head1 METHODS
 
-=head2 decode_tag
+=head2 to_hash
 
   my $hash = RFID::Biblio::Decode::RFID501->to_hash( $bytes );
 
   my $hash = RFID::Biblio::Decode::RFID501->to_hash( [ 'blk1', 'blk2', ... , 'blk7' ] );
 
+=head2 from_hash
+
+  my $blocks = RFID::Biblio::Decode::RFID->from_hash({ content => "1301234567" });
+
+=head2 blank_3m
+
+=head2 blank
+
+  my $blocks = RFID::Biblio::Decode::RFID->blank;
+
 =cut
 
 my $item_type = {
@@ -120,6 +150,8 @@ sub to_hash {
 sub from_hash {
        my ( $self, $hash ) = @_;
 
+       warn "## from_hash ",dump($hash);
+
        return pack('C4Z16Nl>l',
                0x04,
                ( $hash->{set} << 4 ) | ( $hash->{total} & 0x0f ),
@@ -135,4 +167,12 @@ sub from_hash {
        );
 }
 
+sub blank_3m {
+       return ( "\x55" x ( 6 * 4 ) ) . ( "\x00" x 4 );
+}
+
+sub blank {
+       return "\x00" x ( 4 * 3 );
+}
+
 1;