NAME
Net::Fritz::Device - represents a TR064 device
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.
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_service" as it's basically "find_service" with multiple results. It does not return service names but services.
COPYRIGHT
Copyright (C) 2015 by Christian Garbs <mitch@cgarbs.de>
LICENSE
Licensed under GNU GPL v2 or later, see <http://www.gnu.org/licenses/gpl-2.0-standalone.html>
AUTHOR
Christian Garbs <mitch@cgarbs.de>
SEE ALSO
See Net::Fritz for general information about this package, especially "INTERFACE" in Net::Fritz for links to the other classes.