| 1 | package Ekahau::Base; | ||||||||||||||||||||||||||||||||
| 2 | 15 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | # Written by Scott Gifford <gifford@umich.edu> | ||||||||||||||||||||||||||||||||
| 5 | # Copyright (C) 2004 The Regents of the University of Michigan. | ||||||||||||||||||||||||||||||||
| 6 | # See the file LICENSE included with the distribution for license | ||||||||||||||||||||||||||||||||
| 7 | # information. | ||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 15 | ▶ | use bytes; # Avoid Unicode crap | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 15 | ▶ | use base 'Ekahau::ErrHandler'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 15 | our $_global_last_error; | |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 15 | ▶ | use constant DEFAULT_PORT => 8548; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 15 | ▶ | use constant DEFAULT_HOST => 'localhost'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | 15 | ▶ | use constant READ_BLOCKSIZE => 8192; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | Ekahau::Base - Low-level interface to Ekahau location sensing system | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | The C<Ekahau::Base> class provides a low-level interface to the Ekahau | ||||||||||||||||||||||||||||||||
| 28 | location sensing system's YAX protocol. In general you don't want to | ||||||||||||||||||||||||||||||||
| 29 | use this class directly; instead the subclasses L<Ekahau|Ekahau> and | ||||||||||||||||||||||||||||||||
| 30 | L<Ekahau::Events|Ekahau::Events> provide a nicer interface. | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | This class implements methods for querying the Ekahau Positioning | ||||||||||||||||||||||||||||||||
| 35 | Engine, and processing the responses. Each object represents a | ||||||||||||||||||||||||||||||||
| 36 | connection to the Ekahau server. Some methods send queries to the | ||||||||||||||||||||||||||||||||
| 37 | server, while others receive responses. Continuous queries generate | ||||||||||||||||||||||||||||||||
| 38 | data until they are asked to stop, so the protocol is not strictly | ||||||||||||||||||||||||||||||||
| 39 | request-response. To deal with this, queries can have a "tag" | ||||||||||||||||||||||||||||||||
| 40 | associated with them, which allows the response to that specific | ||||||||||||||||||||||||||||||||
| 41 | command to be identified. | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | =cut | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | 15 | ▶ | use Ekahau::Response; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 46 | 15 | ▶ | use Ekahau::License; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 15 | ▶ | use IO::Socket::INET; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 49 | 15 | ▶ | use IO::Select; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | =head2 Constructor | ||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | =head3 new ( [ %params ] ) | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | The C<new> constructor creates a new Ekahau object. It takes a series | ||||||||||||||||||||||||||||||||
| 56 | of parameters as arguments, in the C<Name => Value> style. The | ||||||||||||||||||||||||||||||||
| 57 | following parameters are recognized: | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | =over 4 | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | =item Timeout | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | The maximum length of time to wait for a response or connection. | ||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | =item PeerAddr | ||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | The name or IP address of the Ekahau server you'd like to communicate | ||||||||||||||||||||||||||||||||
| 68 | with. This is passed along to the L<IO::Socket::INET|IO::Socket::INET> module, and you | ||||||||||||||||||||||||||||||||
| 69 | can use the alias C<PeerHost> if you prefer. It defaults to C<localhost>. | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | =item PeerPort | ||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | The TCP port where the Ekahau server you'd like to communicate with is | ||||||||||||||||||||||||||||||||
| 74 | running. It defaults to C<8548>. | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | =item Password | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | The password to talk to the Ekahau server. The default password is | ||||||||||||||||||||||||||||||||
| 79 | C<Llama>, which is what the server will use if you haven't configured | ||||||||||||||||||||||||||||||||
| 80 | a password. | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | =item LicenseFile | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | The XML file containing your Ekahau license. If you don't specify a | ||||||||||||||||||||||||||||||||
| 85 | C<LicenseFile>, and anonymous connection will be used, which may be | ||||||||||||||||||||||||||||||||
| 86 | limited by the software. | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | =back | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | =cut | ||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | sub new | ||||||||||||||||||||||||||||||||
| 93 | 19 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 94 | 19 | my $class = shift; | |||||||||||||||||||||||||||||||
| 95 | 19 | my(%p) = @_; | |||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | 19 | my $self = {}; | |||||||||||||||||||||||||||||||
| 98 | 19 | bless $self,$class; | |||||||||||||||||||||||||||||||
| 99 | 19 | $self->{_errhandler} = Ekahau::ErrHandler->errhandler_new($class,%p); | |||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | 19 | $self->{tag} = 0; | |||||||||||||||||||||||||||||||
| 102 | 19 | $self->{_readbuf} = ""; | |||||||||||||||||||||||||||||||
| 103 | 19 | ▶ | $self->{_timeout}=$p{Timeout}||$p{timeout}; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$p{'Timeout'} || $p{'timeout'}
MC/DC0%0/2
$p{'Timeout'} || $p{'timeout'}
$p{'Timeout'}
$p{'timeout'}
Truth table33%1/3
A || B
A= $p{'Timeout'}B= $p{'timeout'}
| |||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | 19 | ▶ | $self->_connect(%p) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 106 | or return undef; | ||||||||||||||||||||||||||||||||
| 107 | 19 | ▶ | $self->_start(%p) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 108 | or return undef; | ||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||
| 110 | 11 | $self->errhandler_constructed(); | |||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | sub ERROBJ | ||||||||||||||||||||||||||||||||
| 114 | 123 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
ERROBJ: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 115 | 123 | my $self = shift; | |||||||||||||||||||||||||||||||
| 116 | 123 | $self->{_errhandler}; | |||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | # Connect to the TCP socket | ||||||||||||||||||||||||||||||||
| 120 | sub _connect | ||||||||||||||||||||||||||||||||
| 121 | 19 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_connect: called CC=12 SCAR=40.5
| |||||||||||||||||||||||||||||||||
| 122 | 19 | my $self = shift; | |||||||||||||||||||||||||||||||
| 123 | 19 | my(%p)=@_; | |||||||||||||||||||||||||||||||
| 124 | 19 | my $sock; | |||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | 19 | ▶ | if ($p{Socket}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 127 | { | ||||||||||||||||||||||||||||||||
| 128 | 19 | $sock = $p{Socket}; | |||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||
| 130 | else | ||||||||||||||||||||||||||||||||
| 131 | { | ||||||||||||||||||||||||||||||||
| 132 | # For IO::Socket::INET | ||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ($p{timeout} && !$p{Timeout}) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$p{"timeout"} and not $p{"Timeout"}
MC/DC0%0/2
$p{"timeout"} and not $p{"Timeout"}
$p{"timeout"}
not $p{"Timeout"}
Truth table0%0/3
A and not(B)
A= $p{"timeout"}B= not $p{"Timeout"}
| |||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||
| 135 | 0 | $p{Timeout}=$p{timeout}; | |||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||
| 137 | elsif ($self->{_timeout}) | ||||||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||||||
| 139 | 0 | $p{Timeout} = $self->{_timeout}; | |||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if (!$p{PeerPort}) { $p{PeerPort} = DEFAULT_PORT }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if (!$p{PeerAddr} and !$p{PeerHost}) { $p{PeerAddr} = DEFAULT_HOST }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$p{"PeerAddr"} or $p{"PeerHost"}
MC/DC0%0/2
$p{"PeerAddr"} or $p{"PeerHost"}
$p{"PeerAddr"}
$p{"PeerHost"}
Truth table0%0/3
A or B
A= $p{"PeerAddr"}B= $p{"PeerHost"}
| |||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | warn "DEBUG Connecting to $p{PeerAddr}:$p{PeerPort}...\n" | ||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ($ENV{VERBOSE}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | $sock = IO::Socket::INET->new(%p, | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 148 | Proto => 'tcp') | ||||||||||||||||||||||||||||||||
| 149 | or return $self->reterr("Couldn't create IO::Socket::INET - $!"); | ||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | 19 | $self->{_sock} = $sock; | |||||||||||||||||||||||||||||||
| 153 | 19 | binmode $self->{_sock}; | |||||||||||||||||||||||||||||||
| 154 | 19 | $self->{_sock}->autoflush(1); | |||||||||||||||||||||||||||||||
| 155 | $self->{_socksel} = IO::Select->new($self->{_sock}) | ||||||||||||||||||||||||||||||||
| 156 | 19 | ▶ | or return $self->reterr("Couldn't create IO::Select - $!"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | warn "DEBUG connected.\n" | ||||||||||||||||||||||||||||||||
| 159 | 19 | ▶ | if ($ENV{VERBOSE}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | 19 | 1; | |||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||
| 164 | # Start the YAX protocol, and authenticate with our license | ||||||||||||||||||||||||||||||||
| 165 | # or anonymously | ||||||||||||||||||||||||||||||||
| 166 | sub _start | ||||||||||||||||||||||||||||||||
| 167 | 19 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_start: called CC=18 SCAR=31.5
| |||||||||||||||||||||||||||||||||
| 168 | 19 | my $self = shift; | |||||||||||||||||||||||||||||||
| 169 | 19 | my $talkresp; | |||||||||||||||||||||||||||||||
| 170 | 19 | my(%p)=@_; | |||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||
| 172 | 19 | ▶ | $p{Password} ||= $p{password}; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$p{"Password"} ||= $p{"password"}
MC/DC50%1/2
$p{"Password"} ||= $p{"password"}
$p{"Password"}
$p{"password"}
Truth table66%2/3
A ||= B
A= $p{"Password"}B= $p{"password"}
| |||||||||||||||||||||||||||||||||
| 173 | 19 | ▶ | if (!defined($p{Password})) { $p{Password}="Llama" }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | 19 | my $hello_resp = $self->nextresponse; | |||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||
| 177 | 19 | my $talk_str = ''; | |||||||||||||||||||||||||||||||
| 178 | 19 | my($lic,$randstr); | |||||||||||||||||||||||||||||||
| 179 | 19 | ▶ | if ($p{LicenseFile}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 180 | { | ||||||||||||||||||||||||||||||||
| 181 | # Make up a random string real quick. | ||||||||||||||||||||||||||||||||
| 182 | # This isn't cryptographically secure, but who cares? | ||||||||||||||||||||||||||||||||
| 183 | 6 | $randstr = sprintf "%02x"x8, map { int(rand(256)) } 1..8; | |||||||||||||||||||||||||||||||
| 184 | # Read in the license file | ||||||||||||||||||||||||||||||||
| 185 | 6 | eval { | |||||||||||||||||||||||||||||||
| 186 | $lic = Ekahau::License->new(LicenseFile => $p{LicenseFile}) | ||||||||||||||||||||||||||||||||
| 187 | 6 | ▶ | or return $self->reterr("Error processing LicenseFile '$p{LicenseFile}': " . Ekahau::License->lasterr); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 188 | }; | ||||||||||||||||||||||||||||||||
| 189 | 6 | ▶ | $@ and return $self->reterr("Error creating Ekahau::License object - $@"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||
| 191 | 6 | ▶ | $self->command(['HELLO',1,'"'.$randstr.'"',$lic->hello_str]) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 192 | or return undef; | ||||||||||||||||||||||||||||||||
| 193 | 6 | ▶ | $talk_str = $lic->talk_str(Password => $p{Password}, HelloStr => $hello_resp->{args}[1]) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 194 | or return $self->reterr("Error getting talk string from LicenseFile '$p{LicenseFile}': ".$lic->lasterr); | ||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||
| 196 | else | ||||||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||||||
| 198 | # No license file, log in anonymously | ||||||||||||||||||||||||||||||||
| 199 | 13 | ▶ | $self->command(['HELLO',1,'""',"password=$p{Password}"]) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 200 | or return undef; | ||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||
| 202 | 19 | ▶ | $self->command(['TALK','yax',1,'yax1','MD5','"'.$talk_str.'"']) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 203 | or return undef; | ||||||||||||||||||||||||||||||||
| 204 | 19 | ▶ | $talkresp = $self->nextresponse | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 205 | or return undef; | ||||||||||||||||||||||||||||||||
| 206 | 19 | ▶ | if ($talkresp->error) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||||||
| 208 | 8 | return $self->reterr("Couldn't initiate session with Ekahau: ".$talkresp->error_description) | |||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||
| 210 | elsif ($talkresp->{cmd} ne 'TALK') | ||||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||||
| 212 | 0 | return $self->reterr("Couldn't initiate session with Ekahau: Unexpected response $talkresp->{string}"); | |||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||
| 215 | 11 | ▶ | if ($talkresp->{args}[0] !~ /^"?yax"?$/i) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 216 | { | ||||||||||||||||||||||||||||||||
| 217 | 0 | return $self->reterr("Server is speaking unknown protocol '$talkresp->{args}[0]'"); | |||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||
| 219 | 11 | ▶ | if ($talkresp->{args}[3] !~ /^"?MD5"?/i) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 220 | { | ||||||||||||||||||||||||||||||||
| 221 | 0 | return $self->reterr("Server is using unknown checksum '$talkresp->{args}[3]'"); | |||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||
| 224 | 11 | ▶ | if ($p{LicenseFile}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||
| 226 | 3 | ▶ | my $server_talk_str = $lic->talk_str(Password => $p{Password}, HelloStr => $randstr) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 227 | or $self->reterr("Error getting server talk string from LicenseFile: ".$lic->lasterr); | ||||||||||||||||||||||||||||||||
| 228 | 3 | ▶ | if ($server_talk_str ne $talkresp->{args}[4]) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||||||
| 230 | 0 | return $self->reterr("Server gave invalid checksum"); | |||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||
| 233 | 11 | 1; | |||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||
| 236 | # Read a response, taking it from the read buffer if a full response | ||||||||||||||||||||||||||||||||
| 237 | # is available, and otherwise reading from the network. | ||||||||||||||||||||||||||||||||
| 238 | sub _readresponse | ||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_readresponse: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 240 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 241 | 0 | my $r; | |||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||
| 243 | 0 | while (1) | |||||||||||||||||||||||||||||||
| 244 | { | ||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if ($r = $self->readpending) { last }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if ($self->can_read($self->{_timeout})) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||||
| 248 | 0 | $self->readsome(); | |||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||
| 250 | else | ||||||||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||||||
| 252 | 0 | return ''; | |||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||
| 255 | 0 | $r; | |||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||
| 258 | sub _set_errhandler | ||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_set_errhandler: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 260 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 261 | 0 | my($eh)=@_; | |||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | if ($eh) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||||||
| 264 | 0 | $self->{_lasterror}=$eh; | |||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||
| 266 | else | ||||||||||||||||||||||||||||||||
| 267 | { | ||||||||||||||||||||||||||||||||
| 268 | 0 | $self->{_lasterror} = \$_global_last_error | |||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||
| 270 | 0 | $self->reterr('no error yet'); | |||||||||||||||||||||||||||||||
| 271 | 0 | 1; | |||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||
| 274 | =head2 Methods | ||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||
| 276 | =head3 close ( ) | ||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||
| 278 | Properly shut down the connection to the Ekahau engine, by sending a | ||||||||||||||||||||||||||||||||
| 279 | C<CLOSE> command then closing the socket. | ||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||
| 281 | =cut | ||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||
| 283 | sub close | ||||||||||||||||||||||||||||||||
| 284 | 19 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 285 | 19 | my $self = shift; | |||||||||||||||||||||||||||||||
| 286 | 19 | ▶ | $self->command('CLOSE') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 287 | or return undef; | ||||||||||||||||||||||||||||||||
| 288 | # It's the same as an abort from here on out. | ||||||||||||||||||||||||||||||||
| 289 | 19 | $self->abort; | |||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | =head3 abort ( ) | ||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||
| 294 | Abort the connection to the Ekahau engine, by closing the socket. | ||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||
| 296 | =cut | ||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||
| 298 | sub abort | ||||||||||||||||||||||||||||||||
| 299 | 28 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
abort: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 300 | 28 | my $self = shift; | |||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||
| 302 | 28 | my $close_ok = 1; | |||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||
| 304 | 28 | $close_ok = CORE::close($self->{_sock}); | |||||||||||||||||||||||||||||||
| 305 | 28 | undef $self->{_sock}; | |||||||||||||||||||||||||||||||
| 306 | 28 | undef $self->{_socksel}; | |||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||
| 308 | 28 | ▶ | $close_ok or return $self->reterr("Error closing socket: $!\n"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 309 | 28 | 1; | |||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||
| 312 | =head3 readsome ( ) | ||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||
| 314 | Read some data from the network into the read buffer. This is the | ||||||||||||||||||||||||||||||||
| 315 | buffer where L<readpending|/readpending> gets pending events from. This call | ||||||||||||||||||||||||||||||||
| 316 | blocks, so if you don't want to wait for events, you should either | ||||||||||||||||||||||||||||||||
| 317 | C<select> on the handles returned by the L<select_handles|/select_handles> method, or | ||||||||||||||||||||||||||||||||
| 318 | call the L<can_read|/can_read> method to determine if data is available to | ||||||||||||||||||||||||||||||||
| 319 | read. | ||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||
| 321 | =cut | ||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||
| 323 | sub readsome | ||||||||||||||||||||||||||||||||
| 324 | 168 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
readsome: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 325 | 168 | my $self = shift; | |||||||||||||||||||||||||||||||
| 326 | 168 | my $sock = $self->{_sock}; | |||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||
| 328 | 168 | ▶ | sysread($sock,$self->{_readbuf},READ_BLOCKSIZE,length($self->{_readbuf})) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 329 | or return $self->reterr("Error reading from socket: $!\n"); | ||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||
| 332 | =head3 getpending ( ) | ||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||
| 334 | Returns the next pending event, or C<undef> if no events are pending. | ||||||||||||||||||||||||||||||||
| 335 | The event returned is an L<Ekahau::Response|Ekahau::Response> object. | ||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||
| 337 | Pending events come from the buffer filled by L<readsome|/readsome>. | ||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||
| 339 | =cut | ||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||
| 341 | sub getpending | ||||||||||||||||||||||||||||||||
| 342 | 359 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
getpending: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 343 | 359 | my $self = shift; | |||||||||||||||||||||||||||||||
| 344 | 359 | ▶ | my $resp_txt = $self->_readpending() | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 345 | or return undef; | ||||||||||||||||||||||||||||||||
| 346 | 174 | return Ekahau::Response->parsenew($resp_txt); | |||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||
| 349 | sub _readpending | ||||||||||||||||||||||||||||||||
| 350 | 359 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_readpending: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||
| 351 | 359 | my $self = shift; | |||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||
| 353 | 359 | ▶ | if ($self->{_readbuf} =~ /^(\s*<.*?(?<!>)>\s*)/s) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 354 | { | ||||||||||||||||||||||||||||||||
| 355 | 174 | my $msg = $1; | |||||||||||||||||||||||||||||||
| 356 | # Is this an object with a size parameter? | ||||||||||||||||||||||||||||||||
| 357 | 174 | ▶ | if ($self->{_readbuf} =~ /^\s*<[^>]*\x0asize=(\d+)[^>]*\x0adata=/sg) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 358 | { | ||||||||||||||||||||||||||||||||
| 359 | 4 | my $data_len = $1; | |||||||||||||||||||||||||||||||
| 360 | 4 | my $data_start = pos($self->{_readbuf}); | |||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||
| 362 | 4 | ▶ | if ((length($self->{_readbuf})-$data_start) < $data_len) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 363 | { | ||||||||||||||||||||||||||||||||
| 364 | # We don't have the whole thing. | ||||||||||||||||||||||||||||||||
| 365 | # This is just a warning. | ||||||||||||||||||||||||||||||||
| 366 | 0 | return $self->reterr('incomplete data response'); | |||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||
| 368 | else | ||||||||||||||||||||||||||||||||
| 369 | { | ||||||||||||||||||||||||||||||||
| 370 | 4 | $msg = substr($self->{_readbuf}, 0,$data_start + $data_len + 3); | |||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||
| 373 | warn "READ: '$msg'\n" | ||||||||||||||||||||||||||||||||
| 374 | 174 | ▶ | if ($ENV{VERBOSE}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 375 | 174 | substr($self->{_readbuf},0,length($msg))=''; | |||||||||||||||||||||||||||||||
| 376 | # Preserve taintedness with substr(X,0,0) | ||||||||||||||||||||||||||||||||
| 377 | 174 | return $msg.substr($self->{_readbuf},0,0); | |||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||
| 379 | 185 | return $self->reterr('no complete response so far'); | |||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||
| 382 | sub nextresponse | ||||||||||||||||||||||||||||||||
| 383 | 128 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
nextresponse: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 384 | 128 | my $self = shift; | |||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||
| 386 | # Wait until we get something, or the timeout expires. | ||||||||||||||||||||||||||||||||
| 387 | 128 | my $started = time; | |||||||||||||||||||||||||||||||
| 388 | 128 | while(1) | |||||||||||||||||||||||||||||||
| 389 | { | ||||||||||||||||||||||||||||||||
| 390 | 231 | ▶ | if (my $resp = $self->getpending) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 391 | { | ||||||||||||||||||||||||||||||||
| 392 | 111 | return $resp; | |||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||
| 394 | # See if we timed out. | ||||||||||||||||||||||||||||||||
| 395 | 120 | ▶ | $self->can_read($self->{_timeout}? $self->{_timeout} : 0) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 396 | or return undef; | ||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||
| 398 | 103 | ▶ | $self->readsome() | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 399 | or return undef; | ||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||
| 404 | =head3 can_read ( $timeout ) | ||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||
| 406 | Returns true if the network socket becomes readable within C<$timeout> | ||||||||||||||||||||||||||||||||
| 407 | seconds; otherwise returns false. | ||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||
| 409 | =cut | ||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||
| 411 | sub can_read | ||||||||||||||||||||||||||||||||
| 412 | 160 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
can_read: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 413 | 160 | my $self = shift; | |||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||
| 415 | $self->{_socksel}->can_read($_[0]||$self->{_timeout}) | ||||||||||||||||||||||||||||||||
| 416 | 160 | ▶ | or return $self->reterr("socket read timed out (probably)"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_[0] || $self->{'_timeout'}
MC/DC0%0/2
$_[0] || $self->{'_timeout'}
$_[0]
$self->{'_timeout'}
Truth table33%1/3
A || B
A= $_[0]B= $self->{'_timeout'}
| |||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||
| 419 | =head3 select_handles | ||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||
| 421 | Returns a list of filehandles suitable for use with C<select>. If | ||||||||||||||||||||||||||||||||
| 422 | you're multiplexing I/O from this module and other sources, you can | ||||||||||||||||||||||||||||||||
| 423 | select these filehandles for readability, then call the L<readsome|/readsome> | ||||||||||||||||||||||||||||||||
| 424 | method to read the available data, and finally call L<getpending|/getpending> in | ||||||||||||||||||||||||||||||||
| 425 | a loop to get all of the pending events. Note that these handles | ||||||||||||||||||||||||||||||||
| 426 | become selectable for read only when there is data on the network; if | ||||||||||||||||||||||||||||||||
| 427 | multiple events come in at once (which is common), the handle will | ||||||||||||||||||||||||||||||||
| 428 | become selectable once, and you'll have to retreive all of the events | ||||||||||||||||||||||||||||||||
| 429 | with L<getpending|/getpending>; it won't be selectable again until there is more | ||||||||||||||||||||||||||||||||
| 430 | data to read. | ||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||
| 432 | =cut | ||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | sub select_handles | ||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
select_handles: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 436 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||
| 438 | 0 | ($self->{_sock}); | |||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||
| 441 | =head3 request_device_list ( [ $props ] ) | ||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||
| 443 | Requests a list of all devices connected to the system. Returns the | ||||||||||||||||||||||||||||||||
| 444 | command tag that was sent (which can be used to identify the | ||||||||||||||||||||||||||||||||
| 445 | response). | ||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||
| 447 | An optional hash reference can be supplied with a list of properties. | ||||||||||||||||||||||||||||||||
| 448 | The special property C<Tag> will be used to set the command tag if | ||||||||||||||||||||||||||||||||
| 449 | given (otherwise a tag will be generated). Other properties will be | ||||||||||||||||||||||||||||||||
| 450 | sent along in the Ekahau request. Properties currently recognized | ||||||||||||||||||||||||||||||||
| 451 | are: | ||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||
| 453 | =over 4 | ||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||
| 455 | =item NETWORK.MAC | ||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||
| 457 | The MAC address of the device you'd like to look for, in | ||||||||||||||||||||||||||||||||
| 458 | colon-seperated format. For example: | ||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||
| 460 | 'NETWORK.MAC' => '00:E0:63:82:65:76' | ||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||
| 462 | =item NETWORK.IP-ADDRESS | ||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||
| 465 | The IP address of the device you'd like to look for, in dotted-quad | ||||||||||||||||||||||||||||||||
| 466 | format. For example: | ||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||
| 468 | 'NETWORK.IP-ADDRESS' => '10.0.0.1' | ||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||
| 470 | =back | ||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||
| 473 | =cut | ||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||
| 475 | sub request_device_list | ||||||||||||||||||||||||||||||||
| 476 | 16 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
request_device_list: called CC=4 SCAR=15.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 477 | 16 | my $self = shift; | |||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | my %p = ref $_[0] ? %{ (shift) } : (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 479 | 16 | ▶ | my $tag = delete $p{Tag} || ++$self->{tag}; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
delete $p{'Tag'} || ++$self->{'tag'}
MC/DC0%0/2
delete $p{'Tag'} || ++$self->{'tag'}
delete $p{'Tag'}
++$self->{'tag'}
Truth table33%1/3
A || B
A= delete $p{'Tag'}B= ++$self->{'tag'}
| |||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||
| 481 | 16 | ▶ | $self->command('GET_DEVICE_LIST',\%p,$tag) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 482 | or return undef; | ||||||||||||||||||||||||||||||||
| 483 | 16 | $tag; | |||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||
| 486 | =head3 request_device_properties ( [ $props ], $device_id ) | ||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||
| 488 | Request the property list for device C<$device_id>. | ||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||
| 490 | The first parameter can be a hash reference containing additional | ||||||||||||||||||||||||||||||||
| 491 | request properties to be sent, but none are documented by Ekahau for | ||||||||||||||||||||||||||||||||
| 492 | this command. The one exception is the special property C<Tag>, which | ||||||||||||||||||||||||||||||||
| 493 | will be used to set the command tag if given (otherwise a tag will be | ||||||||||||||||||||||||||||||||
| 494 | generated). | ||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||
| 496 | =cut | ||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||
| 498 | sub request_device_properties | ||||||||||||||||||||||||||||||||
| 499 | 5 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
request_device_properties: called CC=4 SCAR=15.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 500 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | my %p = ref $_[0] ? %{ (shift) } : (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 502 | 5 | ▶ | my $tag = delete $p{Tag} || ++$self->{tag}; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
delete $p{'Tag'} || ++$self->{'tag'}
MC/DC0%0/2
delete $p{'Tag'} || ++$self->{'tag'}
delete $p{'Tag'}
++$self->{'tag'}
Truth table33%1/3
A || B
A= delete $p{'Tag'}B= ++$self->{'tag'}
| |||||||||||||||||||||||||||||||||
| 503 | 5 | my($dev)=@_; | |||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||
| 505 | 5 | ▶ | $self->command(['GET_DEVICE_PROPERTIES', $dev],\%p,$tag) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 506 | or return undef; | ||||||||||||||||||||||||||||||||
| 507 | 5 | $tag; | |||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||
| 510 | =head3 request_location_context ( [ $props ], $area_id ) | ||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||
| 512 | Request information about logical area C<$location_id>. | ||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||
| 514 | The first parameter can be a hash reference containing additional | ||||||||||||||||||||||||||||||||
| 515 | request properties to be sent, but none are documented by Ekahau for | ||||||||||||||||||||||||||||||||
| 516 | this command. The one exception is the special property C<Tag>, which | ||||||||||||||||||||||||||||||||
| 517 | will be used to set the command tag if given (otherwise a tag will be | ||||||||||||||||||||||||||||||||
| 518 | generated). | ||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||
| 520 | =cut | ||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||
| 522 | sub request_location_context | ||||||||||||||||||||||||||||||||
| 523 | 5 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
request_location_context: called CC=4 SCAR=15.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 524 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | my %p = ref $_[0] ? %{ (shift) } : (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 526 | 5 | ▶ | my $tag = delete $p{Tag} || ++$self->{tag}; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
delete $p{'Tag'} || ++$self->{'tag'}
MC/DC0%0/2
delete $p{'Tag'} || ++$self->{'tag'}
delete $p{'Tag'}
++$self->{'tag'}
Truth table33%1/3
A || B
A= delete $p{'Tag'}B= ++$self->{'tag'}
| |||||||||||||||||||||||||||||||||
| 527 | 5 | my($c)=@_; | |||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||
| 529 | 5 | ▶ | $self->command(['GET_CONTEXT', $c],{},$tag) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 530 | or return undef; | ||||||||||||||||||||||||||||||||
| 531 | 5 | $tag; | |||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||
| 534 | =head3 request_map_image ( [ $props ], $area_id ) | ||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||
| 536 | Request a map of logical area C<$area_id>. Returns an | ||||||||||||||||||||||||||||||||
| 537 | L<Ekahau::Response::MapImage|Ekahau::Response::MapImage> object. | ||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||
| 539 | =cut | ||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||
| 541 | sub request_map_image | ||||||||||||||||||||||||||||||||
| 542 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
request_map_image: called CC=4 SCAR=15.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 543 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | my %p = ref $_[0] ? %{ (shift) } : (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 545 | 4 | ▶ | my $tag = delete $p{Tag} || ++$self->{tag}; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
delete $p{'Tag'} || ++$self->{'tag'}
MC/DC0%0/2
delete $p{'Tag'} || ++$self->{'tag'}
delete $p{'Tag'}
++$self->{'tag'}
Truth table33%1/3
A || B
A= delete $p{'Tag'}B= ++$self->{'tag'}
| |||||||||||||||||||||||||||||||||
| 546 | 4 | my($c)=@_; | |||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||
| 548 | 4 | ▶ | $self->command(['GET_MAP', $c],{},$tag) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 549 | or return undef; | ||||||||||||||||||||||||||||||||
| 550 | 4 | $tag; | |||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||
| 553 | =head3 request_all_areas ( ) | ||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||
| 555 | Request information about all logical areas known to the Ekahau | ||||||||||||||||||||||||||||||||
| 556 | engine. | ||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||
| 558 | =cut | ||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||
| 560 | sub request_all_areas | ||||||||||||||||||||||||||||||||
| 561 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
request_all_areas: called CC=4 SCAR=15.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 562 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | my %p = ref $_[0] ? %{ (shift) } : (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 564 | 2 | ▶ | my $tag = delete $p{Tag} || ++$self->{tag}; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
delete $p{'Tag'} || ++$self->{'tag'}
MC/DC0%0/2
delete $p{'Tag'} || ++$self->{'tag'}
delete $p{'Tag'}
++$self->{'tag'}
Truth table33%1/3
A || B
A= delete $p{'Tag'}B= ++$self->{'tag'}
| |||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||
| 566 | 2 | ▶ | $self->command(['GET_LOGICAL_AREAS'],{},$tag) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 567 | or return undef; | ||||||||||||||||||||||||||||||||
| 568 | 2 | $tag; | |||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||
| 571 | =head3 start_location_track ( [ $properties ], $device_id ) | ||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||
| 573 | Ask the Ekahau engine to start sending location information about | ||||||||||||||||||||||||||||||||
| 574 | device C<$device_id>. You can get responses with L<getpending|/getpending>. | ||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||
| 576 | An optional hash reference can be supplied with a list of properties. | ||||||||||||||||||||||||||||||||
| 577 | The special property C<Tag> will be used to set the command tag if | ||||||||||||||||||||||||||||||||
| 578 | given (otherwise a tag will be generated). Other properties will be | ||||||||||||||||||||||||||||||||
| 579 | sent along in the Ekahau request. Properties currently recognized | ||||||||||||||||||||||||||||||||
| 580 | are: | ||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||
| 582 | =over 4 | ||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||
| 584 | =item EPE.WLAN_SCAN_INTERVAL | ||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||
| 586 | Interval at which wireless LAN devices should scan. See documentation | ||||||||||||||||||||||||||||||||
| 587 | for more information. | ||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||
| 589 | =item EPE.WLAN_SCAN_MODE | ||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||
| 591 | Wireless LAN scan mode. See documentation for more information. | ||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||
| 593 | =item EPE.SNAP_TO_RAIL | ||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||
| 595 | Set to the string C<true> to have all locations correspond to | ||||||||||||||||||||||||||||||||
| 596 | positions on tracking rails, or C<false> to allow any location. | ||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||
| 598 | =item EPE.EXPECTED_ERROR | ||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||
| 600 | Set to the string C<true> if you would like an expected error | ||||||||||||||||||||||||||||||||
| 601 | estimate, or C<false> to avoid this calculation. | ||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||
| 603 | =item EPE.POSITIONING_MODE | ||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||
| 605 | Set to 1 for realtime positioning, or 2 for more accurate | ||||||||||||||||||||||||||||||||
| 606 | positioining. | ||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||
| 608 | =item EPE.LOCATION_UPDATE_INTERVAL | ||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||
| 610 | How often you'd like an update on the device's position. | ||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||
| 612 | =back | ||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||
| 614 | =cut | ||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||
| 616 | sub start_location_track | ||||||||||||||||||||||||||||||||
| 617 | 5 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
start_location_track: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 618 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||
| 619 | 5 | ▶ | my %p = ref $_[0] ? %{ (shift) } : (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 620 | 5 | ▶ | my $tag = delete $p{Tag} || ++$self->{tag}; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
delete $p{'Tag'} || ++$self->{'tag'}
MC/DC0%0/2
delete $p{'Tag'} || ++$self->{'tag'}
delete $p{'Tag'}
++$self->{'tag'}
Truth table33%1/3
A || B
A= delete $p{'Tag'}B= ++$self->{'tag'}
| |||||||||||||||||||||||||||||||||
| 621 | 5 | my($dev) = @_; | |||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||
| 623 | 5 | ▶ | $self->command(['START_LOCATION_TRACK',$dev],\%p,$tag) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 624 | or return undef; | ||||||||||||||||||||||||||||||||
| 625 | 5 | $tag; | |||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||
| 628 | =head3 request_stop_location_track ( $device_id ) | ||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||
| 630 | Ask the Ekahau engine to stop sending location information about | ||||||||||||||||||||||||||||||||
| 631 | device C<$device_id>. | ||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||
| 633 | =cut | ||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||
| 635 | sub request_stop_location_track | ||||||||||||||||||||||||||||||||
| 636 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
request_stop_location_track: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 637 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||
| 638 | 4 | ▶ | my %p = ref $_[0] ? %{ (shift) } : (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 639 | 4 | ▶ | my $tag = delete $p{Tag} || ++$self->{tag}; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
delete $p{'Tag'} || ++$self->{'tag'}
MC/DC0%0/2
delete $p{'Tag'} || ++$self->{'tag'}
delete $p{'Tag'}
++$self->{'tag'}
Truth table66%2/3
A || B
A= delete $p{'Tag'}B= ++$self->{'tag'}
| |||||||||||||||||||||||||||||||||
| 640 | 4 | my($dev) = @_; | |||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||
| 642 | 4 | ▶ | $self->command(['STOP_LOCATION_TRACK',$dev],\%p,$tag) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 643 | or return undef; | ||||||||||||||||||||||||||||||||
| 644 | 4 | $tag; | |||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||
| 647 | =head3 stop_location_track ( $device_id ) | ||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||
| 649 | Alias for C<request_stop_location_track>. | ||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||
| 651 | =cut | ||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||
| 653 | sub stop_location_track | ||||||||||||||||||||||||||||||||
| 654 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
stop_location_track: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 655 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||
| 656 | 2 | $self->request_stop_location_track(@_); | |||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||
| 659 | =head3 start_area_track ( [ $properties ], $device_id ) | ||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||
| 661 | Ask the Ekahau engine to start sending area information about | ||||||||||||||||||||||||||||||||
| 662 | device C<$device_id>. You can get responses with L<getpending|/getpending>. | ||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||
| 664 | An optional hash reference can be supplied with a list of properties. | ||||||||||||||||||||||||||||||||
| 665 | The special property C<Tag> will be used to set the command tag if | ||||||||||||||||||||||||||||||||
| 666 | given (otherwise a tag will be generated). Other properties will be | ||||||||||||||||||||||||||||||||
| 667 | sent along in the Ekahau request. This command recognizes all of the parameters used by L<start_location_track|/start_location_track>, and also these: | ||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||
| 669 | =over 4 | ||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||
| 671 | =item EPE.NUMBER_OF_AREAS | ||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||
| 673 | How many areas you'd like returned with each area response. Each will | ||||||||||||||||||||||||||||||||
| 674 | come with a probability that the user is in that area. | ||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||
| 676 | =back | ||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||
| 678 | =cut | ||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||
| 680 | sub start_area_track | ||||||||||||||||||||||||||||||||
| 681 | 6 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
start_area_track: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 682 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||
| 683 | 6 | ▶ | my %p = ref $_[0] ? %{ (shift) } : (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 684 | 6 | my $dev = shift; | |||||||||||||||||||||||||||||||
| 685 | 6 | ▶ | my $tag = delete $p{Tag} || ++$self->{tag}; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
delete $p{'Tag'} || ++$self->{'tag'}
MC/DC0%0/2
delete $p{'Tag'} || ++$self->{'tag'}
delete $p{'Tag'}
++$self->{'tag'}
Truth table66%2/3
A || B
A= delete $p{'Tag'}B= ++$self->{'tag'}
| |||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||
| 687 | 6 | ▶ | $self->command(['START_AREA_TRACK',$dev], \%p, $tag) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 688 | or return undef; | ||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||
| 691 | =head3 request_stop_area_track ( $device_id ) | ||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||
| 693 | Ask the Ekahau engine to stop sending area information about | ||||||||||||||||||||||||||||||||
| 694 | device C<$device_id>. | ||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||
| 696 | =cut | ||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||
| 698 | sub request_stop_area_track | ||||||||||||||||||||||||||||||||
| 699 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
request_stop_area_track: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 700 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||
| 701 | 4 | ▶ | my %p = ref $_[0] ? %{ (shift) } : (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 702 | 4 | ▶ | my $tag = delete $p{Tag} || ++$self->{tag}; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
delete $p{'Tag'} || ++$self->{'tag'}
MC/DC0%0/2
delete $p{'Tag'} || ++$self->{'tag'}
delete $p{'Tag'}
++$self->{'tag'}
Truth table66%2/3
A || B
A= delete $p{'Tag'}B= ++$self->{'tag'}
| |||||||||||||||||||||||||||||||||
| 703 | 4 | my($dev) = @_; | |||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||
| 705 | 4 | ▶ | $self->command(['STOP_AREA_TRACK',$dev],\%p,$tag) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 706 | or return undef; | ||||||||||||||||||||||||||||||||
| 707 | 4 | $tag; | |||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||
| 710 | =head3 stop_area_track ( $device_id ) | ||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||
| 712 | Alias for C<request_stop_area_track>. | ||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||
| 714 | =cut | ||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||
| 716 | sub stop_area_track | ||||||||||||||||||||||||||||||||
| 717 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
stop_area_track: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 718 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||
| 719 | 1 | $self->request_stop_area_track(@_); | |||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||
| 723 | =head3 command ( $cmd, $props, $tag ) | ||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||
| 725 | This is a fairly low-level routine, and shouldn't be needed in normal | ||||||||||||||||||||||||||||||||
| 726 | use. It is the only way to send an arbitrary command to the YAX | ||||||||||||||||||||||||||||||||
| 727 | engine, however, so it is available and documented. | ||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||
| 729 | YAX commands look like this: | ||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||
| 731 | <#$tag command arguments | ||||||||||||||||||||||||||||||||
| 732 | property1=value1 | ||||||||||||||||||||||||||||||||
| 733 | property2=value2 | ||||||||||||||||||||||||||||||||
| 734 | ... | ||||||||||||||||||||||||||||||||
| 735 | > | ||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||
| 737 | For clarity, we'll call the string sent at the very beginning of first | ||||||||||||||||||||||||||||||||
| 738 | line command the I<tag>, the next whitespace-seperated word the | ||||||||||||||||||||||||||||||||
| 739 | I<command>, and the remainder of the first line a space-seperated list | ||||||||||||||||||||||||||||||||
| 740 | called I<arguments>. Additional information on other lines we'll call | ||||||||||||||||||||||||||||||||
| 741 | I<properties>. | ||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||
| 743 | C<$cmd> is a list reference containing the command and arguments to | ||||||||||||||||||||||||||||||||
| 744 | send. It can also be a string, which is the same as specifying a list | ||||||||||||||||||||||||||||||||
| 745 | with just that string. | ||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||
| 747 | C<$props> is a hash reference containing the properties to be sent | ||||||||||||||||||||||||||||||||
| 748 | with the command. If it is empty or C<undef>, no properties are sent. | ||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||
| 750 | C<$tag> is the command's tag, which allows the response to be picked | ||||||||||||||||||||||||||||||||
| 751 | out of the data coming back from the server. | ||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||
| 753 | Here are some examples: | ||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||
| 755 | $self->command(['GET_DEVICE_PROPERTIES',1], {}, 'A1'); | ||||||||||||||||||||||||||||||||
| 756 | $self->command('GET_DEVICE_LIST',{'NETWORK.IP-ADDRESS' => '10.1.1.1'}, 'B2'); | ||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||
| 758 | =cut | ||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||
| 760 | sub command | ||||||||||||||||||||||||||||||||
| 761 | 184 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=14 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 762 | 184 | my $self = shift; | |||||||||||||||||||||||||||||||
| 763 | 184 | my($cmd,$props,$tag)=@_; | |||||||||||||||||||||||||||||||
| 764 | 184 | my $data; | |||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||
| 766 | my @args; | ||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||
| 768 | 184 | ▶ | if ($cmd and ref($cmd) eq 'ARRAY') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cmd and ref $cmd eq "ARRAY"
MC/DC50%1/2
$cmd and ref $cmd eq "ARRAY"
$cmd
ref $cmd eq "ARRAY"
Truth table66%2/3
A and B
A= $cmdB= ref $cmd eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 769 | { | ||||||||||||||||||||||||||||||||
| 770 | 136 | ▶ | $cmd=join(' ',map { (!defined($_) or $_ eq '') ? '""' : $_ } @$cmd); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $_ or $_ eq ""
MC/DC50%1/2
not defined $_ or $_ eq ""
not defined $_
$_ eq ""
Truth table66%2/3
not(A) or B
A= not defined $_B= $_ eq ""
| |||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||
| 772 | 184 | ▶ | if ($props and ref($props) eq 'HASH') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$props and ref $props eq "HASH"
MC/DC50%1/2
$props and ref $props eq "HASH"
$props
ref $props eq "HASH"
Truth table66%2/3
A and B
A= $propsB= ref $props eq "HASH"
| |||||||||||||||||||||||||||||||||
| 773 | { | ||||||||||||||||||||||||||||||||
| 774 | 109 | $cmd .= "\x0d\x0a"; | |||||||||||||||||||||||||||||||
| 775 | 109 | ▶ | while (my($key,$val)=each(%$props)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 776 | { | ||||||||||||||||||||||||||||||||
| 777 | 217 | ▶ | if ($key eq 'data') | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 778 | { | ||||||||||||||||||||||||||||||||
| 779 | # Data blob | ||||||||||||||||||||||||||||||||
| 780 | 4 | $data = $val; | |||||||||||||||||||||||||||||||
| 781 | 4 | $cmd .= "size=".length($$data)."\x0d\x0a"; | |||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||
| 783 | ▶ | elsif (ref($val) and ref($val) eq 'ARRAY') | |||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $val and ref $val eq "ARRAY"
MC/DC50%1/2
ref $val and ref $val eq "ARRAY"
ref $val
ref $val eq "ARRAY"
Truth table66%2/3
A and B
A= ref $valB= ref $val eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 784 | { | ||||||||||||||||||||||||||||||||
| 785 | 22 | foreach my $prop2 (@$val) | |||||||||||||||||||||||||||||||
| 786 | { | ||||||||||||||||||||||||||||||||
| 787 | 40 | $cmd .= $key ."\x0d\x0a"; | |||||||||||||||||||||||||||||||
| 788 | $cmd .= "$_=$prop2->{$_}\x0d\x0a" | ||||||||||||||||||||||||||||||||
| 789 | 40 | foreach keys %$prop2; | |||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||
| 792 | else | ||||||||||||||||||||||||||||||||
| 793 | { | ||||||||||||||||||||||||||||||||
| 794 | 191 | $cmd .= "$key=$val\x0d\x0a"; | |||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||
| 798 | 184 | ▶ | if ($data) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 799 | { | ||||||||||||||||||||||||||||||||
| 800 | 4 | $cmd .= 'data='.$$data."\x0d\x0a"; | |||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||
| 802 | 184 | $self->_sendcmd($cmd, $tag); | |||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||
| 805 | sub _sendcmd | ||||||||||||||||||||||||||||||||
| 806 | 184 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_sendcmd: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 807 | 184 | my $self = shift; | |||||||||||||||||||||||||||||||
| 808 | 184 | my($params,$tag) = @_; | |||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||
| 810 | 184 | ▶ | if (defined($tag)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 811 | { | ||||||||||||||||||||||||||||||||
| 812 | 109 | $tag = "#$tag "; | |||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||
| 814 | else | ||||||||||||||||||||||||||||||||
| 815 | { | ||||||||||||||||||||||||||||||||
| 816 | 75 | $tag = ''; | |||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||
| 818 | 184 | my $cmd = "<$tag$params>\x0d\x0a"; | |||||||||||||||||||||||||||||||
| 819 | 184 | $self->_write($cmd); | |||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||
| 822 | sub _write | ||||||||||||||||||||||||||||||||
| 823 | 184 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_write: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||
| 824 | 184 | my $self = shift; | |||||||||||||||||||||||||||||||
| 825 | 184 | my $sock = $self->{_sock}; | |||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||
| 827 | warn "SENT: ",join("",@_),"\n" | ||||||||||||||||||||||||||||||||
| 828 | 184 | ▶ | if ($ENV{VERBOSE}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 829 | 184 | ▶ | print $sock @_ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 830 | or return $self->reterr("socket write error: $!\n"); | ||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||
| 833 | =head2 lasterr ( ) | ||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||
| 835 | Returns the last error generated by this object, or when called as a | ||||||||||||||||||||||||||||||||
| 836 | class method the last constructor error that prevented an object from | ||||||||||||||||||||||||||||||||
| 837 | being created. The return value is a string describing the error, | ||||||||||||||||||||||||||||||||
| 838 | suitable for display to the ser. | ||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||
| 840 | =head2 Destructors | ||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||
| 842 | =head3 DESTROY ( ) | ||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||
| 844 | When an C<Ekahau::Base> object is destroyed, its connection is closed | ||||||||||||||||||||||||||||||||
| 845 | using the L<close|/close> method. | ||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||
| 847 | =cut | ||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||
| 849 | sub DESTROY | ||||||||||||||||||||||||||||||||
| 850 | 19 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||
| 851 | 19 | my $self = shift; | |||||||||||||||||||||||||||||||
| 852 | $self->close | ||||||||||||||||||||||||||||||||
| 853 | 19 | ▶ | if ($self->{_sock}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||
| 856 | 15 | 1; | |||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||
| 858 | =head2 Error Handling | ||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||
| 860 | Constructors and most methods return I<undef> on error. To find out | ||||||||||||||||||||||||||||||||
| 861 | details about the error, you can call the L<lasterr|/lasterr> method, which | ||||||||||||||||||||||||||||||||
| 862 | will return a string. If the error happened in the constructor and so | ||||||||||||||||||||||||||||||||
| 863 | you don't have an object to call a method on, call it as a class | ||||||||||||||||||||||||||||||||
| 864 | method: | ||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||
| 866 | my $errstr = Ekahau::Base->lasterr; | ||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||
| 868 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||
| 870 | Scott Gifford E<lt>gifford@umich.eduE<gt>, E<lt>sgifford@suspectclass.comE<gt> | ||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||
| 872 | Copyright (C) 2005 The Regents of the University of Michigan. | ||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||
| 874 | See the file LICENSE included with the distribution for license | ||||||||||||||||||||||||||||||||
| 875 | information. | ||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||
| 878 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||
| 880 | L<http://www.ekahau.com/>, I<Ekahau Positioning | ||||||||||||||||||||||||||||||||
| 881 | Engine User Guide>, L<Ekahau|Ekahau>, L<Ekahau::Events|Ekahau::Events>, L<Ekahau::Response|Ekahau::Response>, | ||||||||||||||||||||||||||||||||
| 882 | L<Ekahau::License|Ekahau::License>, L<IO::Socket::INET|IO::Socket::INET>, L<IO::Select|IO::Select>. | ||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||
| 884 | =cut | ||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||
| 886 | 15 | 1; | |||||||||||||||||||||||||||||||