Merge branch 'master' of mjesec.ffzg.hr:/git/Biblio-RFID
[Biblio-RFID.git] / lib / Biblio / RFID / Reader / API.pm
1 package Biblio::RFID::Reader::API;
2
3 use warnings;
4 use strict;
5
6 use Biblio::RFID::RFID501;
7 use Biblio::RFID::SmartX;
8
9 =head1 NAME
10
11 Biblio::RFID::Reader::API - low-level RFID reader documentation
12
13 =cut
14
15 =head1 MANDATORY METHODS
16
17 Each reader must implement following hooks as sub-classes.
18
19 =head2 init
20
21   $self->init;
22
23 =head2 inventory
24
25   my @tags = $self->invetory;
26
27 =head2 read_blocks
28
29   my $hash = $self->read_blocks( $tag );
30
31 All blocks are under key which is tag UID with array of blocks returned from reader
32
33   $hash = { 'E000000123456789' => [ 'blk1', 'blk2', ... ] };
34
35 L<Biblio::RFID::Reader::3M810> sends tag UID with data payload, so we might expect
36 to receive response from other tags from protocol specification, 
37
38 =head2 write_blocks
39
40   $self->write_blocks( $tag => $bytes );
41
42   $self->write_blocks( $tag => [ 'blk1', 'blk2', ... ] );
43
44 =head2 read_afi
45
46   my $afi = $self->read_afi( $tag );
47
48 =head2 write_afi
49
50   $self->write_afi( $tag => $afi );
51
52 =head2 tag_type
53
54   $self->tag_type( $tag );
55
56 =cut
57
58 sub tag_type { 'RFID501' }
59
60 =head1 METHODS
61
62 =head2 new
63
64 Just calls C<init> in reader implementation so this class
65 can be used as simple stub base class like
66 L<Biblio::RFID::Reader::librfid> does
67
68 =cut
69
70 sub new {
71         my $class = shift;
72         my $self = {@_};
73         bless $self, $class;
74         $self->init && return $self;
75 }
76
77 1;