IPCamera-Reolink
view release on metacpan or search on metacpan
lib/IPCamera/Reolink.pm view on Meta::CPAN
$self->{_camera_login_lease_time} = $login_lease_time; # New Login token
return 1; # new Login token
}else{
return 0; # failed to acquire new Login token
} # if
}else{
return 1; # Login token still valid
} # if
} # _checkLoginLeaseTime()
# Login() - provides login credentials (username/password) to camera and returns API access token good for specified number of seconds
sub Login(){
my($self) = @_;
my($_camera_rest_client, $camera_url, $camera_user_name, $camera_password, $camera_X509_certificate_file, $camera_X509_key_file, $camera_certificate_authority_file, $_is_https) = ($self->{_camera_rest_client}, $self->{camera_url}, $self->{camera_...
if(!defined($_camera_rest_client)){
# disable check for valid certificate matching the expected hostname
$_camera_rest_client = REST::Client->new(host => $camera_url, timeout => 10, cert => $camera_X509_certificate_file, key => $camera_X509_key_file, ca => $camera_certificate_authority_file);
$_camera_rest_client->getUseragent()->ssl_opts(verify_hostname => 0);
$_camera_rest_client->getUseragent()->ssl_opts(SSL_verify_mode => SSL_VERIFY_NONE);
$self->{_camera_rest_client} = $_camera_rest_client;
} # if
lib/IPCamera/Reolink.pm view on Meta::CPAN
$self->{_camera_login_lease_time} = @$response_r[0]->{value}->{Token}->{leaseTime};
$self->{_camera_login_lease_start_time} = time(); # detect lease expiry
print STDERR scalar(localtime()) . ": info: Camera Login for user '" . $self->{camera_user_name} . "' OK, token leaseTime '" . $self->{_camera_login_lease_time} . "' name '" . $self->{_camera_login_token} . "'\n" if($DEBUG > 0);
return ($self->{_camera_login_token}, $self->{_camera_login_lease_time});
}else{
print STDERR scalar(localtime()) . ": error: Camera Login for user '" . $self->{camera_user_name} . "' failed\n" if($DEBUG > 0);
return (undef, undef);
} # if
} # Login()
# Logout() - release login credentials from previous Login()
sub Logout(){
my($self) = @_;
my($_camera_rest_client, $_camera_login_token) = ($self->{_camera_rest_client}, $self->{_camera_login_token});
if(defined($_camera_rest_client)){
$self->{_camera_login_token} = undef;
$self->{_camera_login_lease_time} = 0;
$self->{_camera_login_lease_start_time} = time();
}else{
# No Login()
return 0;
lib/IPCamera/Reolink.pm view on Meta::CPAN
use IPCamera::Reolink;
my $camera_url = "http://192.168.1.160";
my $camera_user_name = "vlc"; # non-admin user recommended
my $camera_password = 'this-is-a-bad-password';
my $camera = IPCamera::Reolink->new($camera_url, $camera_user_name, $camera_password);
# or
# my $camera = IPCamera::Reolink->new( {camera_url => $camera_url_http, camera_user_name => $camera_user_name, camera_password => $camera_password, camera_x509_certificate_file => undef, camera_x509_key_file => undef, camera_certificate_authority_fi...
# Optionally Login to the camera immmediately to validate the camera URL and credentials, otherwise a Login will be implicitly performed by the API on the first camera command.
die "IPCamera::Reolink::Login failed" if(!$camera->Login());
# Some camera info
my $devinfo_r = $camera->GetDevInfo();
print "Camera model : " . $devinfo_r->{model} . "\n";
print "Camera name : " . $devinfo_r->{name} . "\n";
# Camera presets
lib/IPCamera/Reolink.pm view on Meta::CPAN
TBD.
=item $camera_x509_authority_file
TBD.
=back
=head2 Login()
Login to the camera using the credentials provided to new() (above).
Upon successful Login the camera passes back a Login token and lease time that is used internally by other IPCamera::Reolink camera API methods.
The token is valid for the specified lease time.
IPCamera::Reolink will manage the Login token and will call Login() internally as needed when the Login token expires.
This should all be invisible to the caller.
=over 4
lib/IPCamera/Reolink.pm view on Meta::CPAN
Returns ($camera_login_token, $camera_login_lease_time) if the Login is successful,
where $camera_login_token is the token passed to other API methods and $camera_login_lease_time is the time in seconds for which the token is valid, after which a new token must be aquired.
Usually the caller is not interested in these values as they are used internally by IPCamera::Reolink.
=back
=head2 Logout()
Release Login() credentials.
=over 4
=item return
Returns 1 if Logout() succeeded else 0 (zero) on failure, typically if Login() not called.
=back
=head2 GetChannelstatus()
lib/IPCamera/Reolink.pm view on Meta::CPAN
Current camera zoom value in the range IPCamera::Reolink::ZF_ZoomPosMin, IPCamera::Reolink::ZF_ZoomPosMax.
=back
=back
=head2 StartZoomFocus($camera_channel, $camera_operation, $camera_zoom_pos|$camera_focus_pos)
Set camera current Zoom or Focus value.
Note that the current version of the firmware on the authors camera (Firmware Version v3.1.0.2347_23061923_v1.0.0.93) requires a Login() using admin credentials to use this function.
According to Reolink this may be fixed in a future firmware version.
If in doubt, set $DEBUG to 1 and if you see a log message of the form:
Tue Dec 19 18:17:07 2023: debug: IPCamera::Reolink::_sendCameraCommand(): command 'StartZoomFocus' token '5b34aab0bb481ba' request '[{ action => 0, cmd => "StartZoomFocus", param => { ZoomFocus => { channel => 0, op => "ZoomPos", pos => 1 } } }]' res...
then you need to use admin credentials to use this function.
=over 4
=item return
Returns 1 if StartZoomFocus() succeeded else 0 (zero) on failure.
=back
=over 4
lib/IPCamera/Reolink.pm view on Meta::CPAN
=back
=back
=head2 SetOsd($camera_channel, $enableChannel, $channelName, $channelPos, $enableTime, $timePos)
Set camera On Screen Display (OSD) values.
Note that the current version of the firmware on the authors camera
(Firmware Version v3.1.0.2347_23061923_v1.0.0.93) requires a Login()
using admin credentials to use this function.
=over 4
=item return
Returns 1 if SetOsd() succeeded else 0 (zero) on failure.
=back
=over 4
( run in 0.577 second using v1.01-cache-2.11-cpan-4d50c553e7e )