BACnet::Device - High-level interface for BACnet device communication and COV subscriptions

SYNOPSIS

use BACnet::Device;

my $dev = BACnet::Device->new(
    id    => 100,
    addr  => '192.168.1.10',
    sport => 47808,
);

my ($sub, $err) = $dev->subscribe(
    obj_type  => 1,
    obj_inst  => 5,
    host_ip   => '192.168.1.20',
    peer_port => 47808,
    on_COV    => sub {
        my ($dev, $payload, $port, $ip) = @_;
        print "COV update received\n";
    },
);

$dev->run;

DESCRIPTION

BACnet::Device provides a higher-level abstraction for communicating with BACnet devices using BACnet/IP.
It includes:

METHODS

new

Example:

my $dev = BACnet::Device->new(
    id => 100,
    addr => '192.168.1.10',
    sport => 47808,
);

Creates a new BACnet::Device instance.

Parameters (%args):

Returns a new object instance.

read_property

Example:

$dev->read_property(
    obj_type => 0,
    obj_instance => 1,
    property_identifier => 85,
    host_ip => '192.168.1.20',
    peer_port => 47808,
    on_response => sub {
            print "Property value received";
        },
);

Sends a BACnet ReadProperty request.

Parameters (%args):

subscribe

Example:

my ($sub, $err) = $dev->subscribe(
    obj_type  => 1,
    obj_inst  => 5,
    host_ip   => '192.168.1.20',
    peer_port => 47808,
    issue_confirmed_notifications => 1,
    lifetime_in => 300,
    on_COV    => sub {
        my ($dev, $payload, $port, $ip) = @_;
        print "COV update received\n";
    },
    on_response => sub {
        print "Subscription response received\n";
    },
);

Subscribes to a BACnet object to receive COV (Change Of Value) notifications.

Parameters (%args):

Returns:

unsubscribe

Example:

my $err = $dev->unsubscribe(
    $sub,
    sub {
        my ($res) = @_;
        print "Unsubscription response received\n";
    },
);

Cancels an existing subscription on a remote BACnet device.

Parameters:

Returns:

send_error

Example:

$dev->send_error(
    service_choice => 'ReadProperty',
    invoke_id      => 42,
    error_class    => 1,
    error_code     => 32,    
    host_ip        => '192.168.1.20',
    peer_port      => 47808,
);

Sends a BACnet Error APDU.

Parameters (%args):

Returns:

send_approve

Example:

$dev->send_approve(
    service_choice => 'ConfirmedCOVNotification',
    host_ip => '192.168.1.20',
    peer_port => 47808,
    invoke_id => 5,
);

Sends a SimpleACK.

Parameters (%args):

Returns:

run()

Starts the event loop.

Example:

$dev->run();

stop()

Stops the event loop.

Example:

$dev->stop();

subscriptions()

Returns list of active and less than 60 seconds expired subscriptions.

DESTROY()

DATA UNITS

callback functions

Example:

sub callback {
    my ( $device, $message, $port, $ip ) = @_;
}

Callback function are called with parameters:

Service choices

In file /BACnet/PDUTypes/Utils.pm in variables:

INTERNAL METHODS

The following methods are internal and not intended for external use:

AUTHOR

Vojtěch Křenek vojtechkrenek@email.cz Tomas Szaniszlo - xszanisz@fi.muni.cz

LICENSE

This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself.