The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Fritz::Device - represents a TR064 device

VERSION

version v0.0.9

SYNOPSIS

    my $fritz    = Net::Fritz::Box->new();
    my $device   = $fritz->discover();

    # get services to call them later
    my $service_a = $device->get_service('DeviceInfo:1');
    my $service_b = $device->find_service('D.*Info:1');

    # get a subdevice
    my $subdevice = $device->find_device('LANDevice:1');

    # this one can give multiple results
    my $service_list = $device->find_service_names('DeviceInfo:1');
    printf "%d services found\n",
           scalar @{$service_list->data};

    # show all data
    $device->dump();

DESCRIPTION

This class represents a TR064 device that has been discovered. A device gives access to other subdevices (Net::Fritz::Device) as well as Net::Fritz::Services which allow interaction with a Net::Fritz::Device.

ATTRIBUTES (read-only)

fritz

A Net::Fritz::Box instance containing the current configuration information (device address, authentication etc.).

xmltree

A complex hashref containing all information about this Net::Fritz::Device. This is the parsed form of the TR064 XML which describes the device, it's subdevices and Net::Fritz::Services.

service_list

An arrayref of all Net::Fritz::Services that are available on this device.

device_list

An arrayref of all subdevices (Net::Fritz::Device) that are available on this device.

attributes

A hashref that contains the most important information from the XML device description. This allows easier access than via "xmltree". The available attributes are device-dependent. The following attributes are made available as keys in the hashref if present in the XML:

  • deviceType

  • friendlyName

  • manufacturer

  • manufacturerURL

  • modelDescription

  • modelName

  • modelNumber

  • modelURL

  • UDN

  • presentationURL

error

See "error" in Net::Fritz::IsNoError.

METHODS

new

Creates a new Net::Fritz::Device object. You propably don't have to call this method, it's mostly used internally. Expects parameters in key => value form with the following keys:

fritz

Net::Fritz::Box configuration object

xmltree

device information in parsed XML format

get_service(name)

Returns the Net::Fritz::Service whose serviceType equals name.

If no matching service is found, the subdevices are searched for the service in the order they are listed in the device XML, depth first.

If no matching service is found, a Net::Fritz::Error is returned.

find_service(regexp)

Returns the Net::Fritz::Service whose serviceType matches regexp.

If no matching service is found, the subdevices are searched for the service in the order they are listed in the device XML, depth first.

If no matching service is found, a Net::Fritz::Error is returned.

find_service_names(regexp)

Returns all Net::Fritz::Services whose serviceType match regexp.

Searches recursively through all subdevices in the order they are listed in the device XML, depth first.

The resulting arrayref is wrapped in a Net::Fritz::Data to allow error checking. (Although no error should ever occur, an an empty list is returned if nothing matched.)

find_device(name)

Returns the Net::Fritz::Device subdevice whose deviceType equals name.

If no matching service is found, the subdevices are searched for the deviceType in the order they are listed in the device XML, depth first.

If no matching device is found, a Net::Fritz::Error is returned.

call(service_name action_name [argument_hash])

Directly calls the Net::Fritz::Action named action_name of the Net::Fritz::Service matching the regular expression service_name.

This is a convenience method that internally calls find_service() followed by Net::Fritz::Service::call - see those methods for further details.

The intermediate Net::Fritz::Service is cached, so that further calls to the same service_name only need to do one instead of two SOAP requests.

This method is available since v0.0.8.

dump(indent)

Returns some preformatted multiline information about the object. Useful for debugging purposes, printing or logging. The optional parameter indent is used for indentation of the output by prepending it to every line.

Recursively descends into subdevices and services, so dumping the root device of a "discover" in Net::Fritz::Box should show everything that is available.

errorcheck

See "errorcheck" in Net::Fritz::IsNoError.

BUGS AND LIMITATIONS

TODO: Method names are inconsistent: With services, get_* uses exact matching while find_* uses regexp matching. But with devices, find_device() uses exact matching. Change this to match the service methods and add the missing variants.

TODO: Rename find_service_names() to something like find_all_services() as it's basically find_service() with multiple results. It does not return service names but services.

SEE ALSO

See Net::Fritz for general information about this package, especially "INTERFACE" in Net::Fritz for links to the other classes.

AUTHOR

Christian Garbs <mitch@cgarbs.de>

COPYRIGHT AND LICENSE

Copyright (C) 2017 Christian Garbs

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.