Nabaztag
view release on metacpan or search on metacpan
lib/Nabaztag.pm view on Meta::CPAN
It makes great use of LWP::Simple to interact with the rabbit.
PROXY issues:
If you're behind a proxy, see LWP::Simple proxy issues to know how to deal with that.
Basically, set env variable HTTP_PROXY to your proxi url in order to make it work.
For instance : export HTTP_PROXY=http://my.proxy.company:8080/
=head1 SYNOPSIS
Commandline:
$ nabaztry.pl MAC TOKEN POSLEFT POSRIGHT
Perl code:
use Nabaztag ; # OR
# use Nabaztag { 'debug' => 1 } ;
my $nab = Nabaztag->new();
# MANDATORY
$nab->mac($mac);
$nab->token($tok);
# See new function to have details about how to get these properties.
$nab->leftEarPos($left);
$nab->rightEarPos($right);
$nab->syncState();
$nab->sayThis("Demain, il pleuvra des grillons jusqu'a extinction totale de la race humaine.");
.....
See detailled methods for full possibilities.
Gory details :
You can access or modify BASE_URL by accessing:
$Nabaztag::BASE_URL ;
For application id :
$Nabaztag::ID_APP ;
=head1 FUNCTIONS
=head2 new
Returns a new software nabaztag with ears position fetched from the hardware one if the mac and token is given.
It has following properties:
mac : MAC Adress of nabaztag - equivalent to Serial Number ( SN ). Written at the back
of your nabaztag !!
token : TOKEN Given by nabaztag.com to allow interaction with you nabaztag. See
http://www.nabaztag.com/vl/FR/api_prefs.jsp to obtain yours !!
leftEarPos : position of left ear.
rightEarPos : position of right ear.
usage:
my $nab = Nabaztag->new($mac , $token );
print $nab->leftEarPos();
print $nab->rightEarPos();
OR:
my $nab = Nabaztag->new();
$nab->mac($mac);
$nab->token($token);
$nab->fetchEars();
print $nab->leftEarPos();
print $nab->rightEarPos();
=cut
my $debug = undef ;
sub import{
#my $callerPack = caller ;
my ($class, $options) = @_ ;
if( ! defined $debug ){
$debug = $options->{'debug'} || 0 ;
}
print "\n\nDebug option : $debug \n\n" if ($debug);
}
sub new {
my ($class , $mac, $token ) = @_ ;
my $self = {
'mac' => undef , # MAC Adress of nabaztag - equivalent to Serial Number ( SN )
'token' => undef , # TOKEN Given by nabaztag.com to allow interaction with you nabaztag
'leftEarPos' => undef , # Position of left ear
'rightEarPos' => undef # Position of right ear
};
$self = bless $self, $class ;
$self->mac($mac) ;
$self->token($token);
if( $self->mac() && $self->token() ){
print "Trying to fetch ears position" if ( $debug );
$self->fetchEars();
}
return $self ;
}
=head2 leftEarPos
Get/Sets the left ear position of the nabaztag.
Usage:
$nab->leftEarPos($newPos);
The new position has to be between 0 (vertical ear) and 16 included
( run in 0.866 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )