detect when the control address has a http in front, and do the right thing
This commit is contained in:
parent
9ce7da4147
commit
5dedbc2135
|
@ -38,8 +38,6 @@ require ZoneMinder::Control;
|
||||||
|
|
||||||
our @ISA = qw(ZoneMinder::Control);
|
our @ISA = qw(ZoneMinder::Control);
|
||||||
|
|
||||||
our $VERSION = $ZoneMinder::Base::VERSION;
|
|
||||||
|
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
#
|
#
|
||||||
# Axis V2 Control Protocol
|
# Axis V2 Control Protocol
|
||||||
|
@ -52,8 +50,7 @@ use ZoneMinder::Config qw(:all);
|
||||||
use Time::HiRes qw( usleep );
|
use Time::HiRes qw( usleep );
|
||||||
use URI::Encode qw();
|
use URI::Encode qw();
|
||||||
|
|
||||||
sub new
|
sub new {
|
||||||
{
|
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my $id = shift;
|
my $id = shift;
|
||||||
my $self = ZoneMinder::Control->new( $id );
|
my $self = ZoneMinder::Control->new( $id );
|
||||||
|
@ -64,8 +61,7 @@ sub new
|
||||||
|
|
||||||
our $AUTOLOAD;
|
our $AUTOLOAD;
|
||||||
|
|
||||||
sub AUTOLOAD
|
sub AUTOLOAD {
|
||||||
{
|
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $class = ref($self) || croak( "$self not object" );
|
my $class = ref($self) || croak( "$self not object" );
|
||||||
my $name = $AUTOLOAD;
|
my $name = $AUTOLOAD;
|
||||||
|
@ -111,8 +107,14 @@ sub sendCmd {
|
||||||
printMsg( $cmd, "Tx" );
|
printMsg( $cmd, "Tx" );
|
||||||
#print( "http://$address/$cmd\n" );
|
#print( "http://$address/$cmd\n" );
|
||||||
#my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd" );
|
#my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd" );
|
||||||
my $url = 'http://'.$self->{Monitor}->{ControlAddress}.'/cgi-bin/setGPIO.cgi?preventCache='.time;
|
|
||||||
Debug("Url: $url $cmd");
|
my $url;
|
||||||
|
if ( $self->{Monitor}->{ControlAddress} =~ /^http/ ) {
|
||||||
|
$url = $self->{Monitor}->{ControlAddress}.'/cgi-bin/setGPIO.cgi?preventCache='.time;
|
||||||
|
} else {
|
||||||
|
$url = 'http://'.$self->{Monitor}->{ControlAddress}.'/cgi-bin/setGPIO.cgi?preventCache='.time;
|
||||||
|
} # en dif
|
||||||
|
Error("Url: $url $cmd");
|
||||||
my $uri = URI::Encode->new( { encode_reserved => 0 } );
|
my $uri = URI::Encode->new( { encode_reserved => 0 } );
|
||||||
my $encoded = $uri->encode( $cmd );
|
my $encoded = $uri->encode( $cmd );
|
||||||
my $res = $self->{ua}->post( $url, Content=>"data=$encoded" );
|
my $res = $self->{ua}->post( $url, Content=>"data=$encoded" );
|
||||||
|
|
Loading…
Reference in New Issue