use Encode;
my $debug = 0;
-my $listen = '127.0.0.1:9000';
-$listen = ':9000';
+my $listen = $ENV{HTTP_LISTEN} || 'localhost:9000';
my $reader;
my $koha_url = $ENV{KOHA_URL};
warn "$koha_url";
sub sip2_message {
my $send = shift;
+ my $retry = 0;
+
send_again:
my $sock = sip2_socket || die "no sip2 socket";
$send .= "\r" unless $send =~ m/\r$/;
$send .= "\n" unless $send =~ m/\n$/;
-
- my $retry = 0;
warn "SIP2 >>>> ",dump($send), "\n";
print $sock $send;
$sock->flush;
die "expected $expect" unless substr($in,0,2) != $expect;
my $hash;
- if ( $in =~ s/^([0-9\s]+)// ) {
+ if ( $in =~ s/^([0-9\s\w]+)// ) {
$hash->{fixed} = $1;
}
foreach ( split(/\|/, $in ) ) {
my ( $f, $v ) = ( $1, $2 ) if m/([A-Z]{2})(.+)/;
- $hash->{$f} = decode('utf-8',$v);
+ $hash->{$f} = decode('utf-8',$v) if $f;
}
warn "# sip2 hash response ",dump($hash);
}
close($fh);
}
+ $rfid_sid_cache = undef if $path eq 'examples/selfcheck.html'; # invalidate on reload
} elsif ( $method =~ m{/scan(/only/(.+))?} ) {
my $only = $2;
my @tags = $rfid->tags( reader => sub {
my $borrower = rfid_borrower $hash;
if ( exists $borrower->{error} ) {
warn "ERROR ", dump($borrower);
+ $hash->{error} = $borrower->{error};
} else {
$hash->{borrower} = $borrower->{borrower};
$hash->{content} = $borrower->{borrower}->{cardnumber}; # compatibile with 3M tags
my $ua = LWP::UserAgent->new;
my $url = URI->new( $rfid_url . '/register.pl');
- $url->query_form(
- local_ip => $ip->{eth0} || $ip->{ (keys %$ip)[0] },
+ $url->query_form( %$ip,
+ HTTP_LISTEN => $listen,
+ RFID_LISTEN => $ENV{RFID_LISTEN},
+ KOHA_URL => $koha_url,
+ RFID_URL => $rfid_url,
);
warn "GET ",$url->as_string;
my $response = $ua->get($url);