Device-XBee-API
view release on metacpan or search on metacpan
If no reply is expected, the caller should immediately free the
returned frame ID via free_frame_id to prevent frame ID leaks.
[4mExample[0m
my $at_frame_id = $api->at( 'AO', pack( 'C', 1 ) );
[1mremote_at[0m
Send an AT command to a remote module. Accepts three parameters: a
hashref with endpoint addresses, command options, frame_id; the AT
command name (as two-character string); and the third as the expected
data for that command (if any) as a string. See the XBee datasheet for
a list of supported AT commands and expected data for each.
Endpoint addresses should be specified as a hashref containing the
following keys:
sh The high 32-bits of the destination address.
sl The low 32-bits of the destination address.
'D5', "\x1"
)
) {
die "Transmit failed!";
}
my $rx = $api->rx();
warn Dumper( $rx );
[1mtx[0m
Sends a transmit request to the XBee. Accepts three parameters, the
first is the endpoint address, the second is a scalar containing the
data to be sent, and the third is an optional flag (known as the async
flag) specifying whether or not the method should wait for an
acknowledgement from the XBee.
Endpoint addresses should be specified as a hashref containing the
following keys:
sh The high 32-bits of the destination address.
sl The low 32-bits of the destination address.
lib/Device/XBee/API.pm view on Meta::CPAN
0x90 => 'ZIGBEE_RECEIVE_PACKET',
0x91 => 'ZIGBEE_EXPLICIT_RX_INDICATOR',
0x92 => 'ZIGBEE_IO_DATA_SAMPLE_RX_INDICATOR',
0x94 => 'XBEE_SENSOR_READ_INDICATOR_',
0x95 => 'NODE_IDENTIFICATION_INDICATOR',
};
use constant XBEE_API_TRANSMIT_STATUS_TO_STRING => {
0x00 => 'Success',
0x02 => 'CCA Failure',
0x15 => 'Invalid destination endpoint',
0x21 => 'Network ACK Failure',
0x22 => 'Not Joined to Network',
0x23 => 'Self-addressed',
0x24 => 'Address Not Found',
0x25 => 'Route Not Found',
0x74 => 'Data payload too large',
};
use constant XBEE_API_BAUD_RATE_TABLE => [1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200];
lib/Device/XBee/API.pm view on Meta::CPAN
my ( $self, $command, $data ) = @_;
$data = '' unless $data;
my $frame_id = $self->alloc_frame_id();
$self->send_packet( XBEE_API_TYPE__AT_COMMAND, pack( 'C', $frame_id ) . $command . $data );
return $frame_id;
}
=head2 remote_at
Send an AT command to a remote module. Accepts three parameters: a hashref with
endpoint addresses, command options, frame_id; the AT command name (as
two-character string); and the third as the expected data for that command (if
any) as a string. See the XBee datasheet for a list of supported AT commands
and expected data for each.
Endpoint addresses should be specified as a hashref containing the following
keys:
=over 4
=item sh
lib/Device/XBee/API.pm view on Meta::CPAN
$data = '' unless defined $data;
my $frame_id = $self->alloc_frame_id();
my $tx_req = pack( 'CNNnC', $frame_id, $tx->{sh}, $tx->{sl}, $tx->{na}, $options );
$self->send_packet( XBEE_API_TYPE__REMOTE_COMMAND_REQUEST, $tx_req . $command . $data );
return $frame_id;
}
=head2 tx
Sends a transmit request to the XBee. Accepts three parameters, the first is the
endpoint address, the second is a scalar containing the data to be sent, and the
third is an optional flag (known as the async flag) specifying whether or not
the method should wait for an acknowledgement from the XBee.
Endpoint addresses should be specified as a hashref containing the following
keys:
=over 4
=item sh
( run in 0.296 second using v1.01-cache-2.11-cpan-b61123c0432 )