From abac24b2d6b548c16267eafbe9083b2600ad34e9 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Mon, 2 Jan 2012 20:25:32 +0100 Subject: [PATCH] Add the prototype "find_person" script from our openbeacon tracking experiment --- tools/openbeacon/find_person.pl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tools/openbeacon/find_person.pl diff --git a/tools/openbeacon/find_person.pl b/tools/openbeacon/find_person.pl new file mode 100644 index 0000000..369925b --- /dev/null +++ b/tools/openbeacon/find_person.pl @@ -0,0 +1,31 @@ +use JSON; +use Data::Dumper; + +my $content; + +#open(F,"<",shift); +open(F,"-|","wget -qO- http://176.99.39.100/tracking.json"); +while(){ + $content.=$_; +}; + + +my $json = from_json($content, {ascii => 1}); + +#print Dumper $json; + +my $room; +my $floor; +for (@{$json->{tag}}){ + if($_->{nick} =~ qr/$ARGV[0]/i){ + for my $r (@{$json->{reader}}){ + if($r->{id} eq $_->{reader}){ +# print Dumper $r; + $room=$r->{name}; + $floor=$r->{floor}; + }; + }; + print $_->{nick}, " is at ",$room," (Level ",qw(A B C)[$floor-1],")\n"; +# print Dumper $_ + } +};