Net::U...:Device(3pm)

πŸ“¦
version 1.4.6 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ¦‹ NAME πŸ¦‹

Net::UPnP::Device β€” a Perl extension for UPnP, bestie πŸ’–


✨ SYNOPSIS ✨

okay so here's the whole vibe, copy-paste ready, no cap:

use Net::UPnP::ControlPoint;

my $obj = Net::UPnP::ControlPoint->new();

@dev_list = $obj->search(st =>'upnp:rootdevice', mx => 3);

$devNum= 0;
foreach $dev (@dev_list) {
    $device_type = $dev->getdevicetype();
    if  ($device_type ne 'urn:schemas-upnp-org:device:MediaServer:1') {
        next;
    }
    print "[$devNum] : " . $dev->getfriendlyname() . "\n";
    unless ($dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1')) {
        next;
    }
    $condir_service = $dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1');
    unless (defined(condir_service)) {
        next;
    }
    %action_in_arg = (
            'ObjectID' => 0,
            'BrowseFlag' => 'BrowseDirectChildren',
            'Filter' => '*',
            'StartingIndex' => 0,
            'RequestedCount' => 0,
            'SortCriteria' => '',
        );
    $action_res = $condir_service->postcontrol('Browse', \%action_in_arg);
    unless ($action_res->getstatuscode() == 200) {
            next;
    }
    $actrion_out_arg = $action_res->getargumentlist();
    unless ($actrion_out_arg->{'Result'}) {
        next;
    }
    $result = $actrion_out_arg->{'Result'};
    while ($result =~ m/<dc:title>(.*?)<\/dc:title>/sgi) {
        print "\t$1\n";
    }
    $devNum++;
}

(yes that's the whole thing, scroll back up when you need it, it's literally right there 🫢)


🌈 DESCRIPTION 🌈

So basically this package is the object representation of a UPnP device. It's giving "one device, one blessed little object," and honestly? iconic. πŸ’…


πŸŽ€ METHODS πŸŽ€

getdescription β€” get the description.

$description = $dev->getdescription(
                            name => $name # undef
                         );

Grabs the device description straight outta the SSDP location header, bestie ✨

Here's the tea on what comes back: if you don't pass the name parameter, you get all the description. Pass a name though, and you get just that one value. Choose your fighter πŸ’–

getdevicetype β€” get the device type.

$description = $dev->getdevicetype();

Pulls the device type out of the device description. πŸ¦‹

getfriendlyname β€” get the device type.

$friendlyname = $dev->getfriendlyname();

Pulls the friendly name out of the device description. (Yes, the one-liner says "device type" β€” it's a typo, we're keeping it, the function is literally named getfriendlyname 😭) πŸŽ€

getmanufacturer β€” get the manufacturer.

$manufacturer = $dev->getmanufacturer();

Pulls the manufacturer name out of the device description. 🏭

getmanufacturerrul β€” get the manufacturer url.

$manufacturer_url = $dev->getmanufacturerrul();

Pulls the manufacturer url out of the device description. (spelled getmanufacturerrul with an r and one l β€” that is the actual name, do not "fix" it, I am begging πŸ™ˆ) πŸ”—

getmodeldescription β€” get the model description.

$model_description = $dev->getmodeldescription();

Pulls the model description out of the device description. πŸ“

getmodelname β€” get the model name.

$model_name = $dev->getmodelname();

Pulls the model name out of the device description. ✨

getmodelnumber β€” get the model number.

$model_number = $dev->getmodelnumber();

Pulls the model number out of the device description. πŸ”’

getmodelurl β€” get the model url.

$model_url = $dev->getmodelurl();

Pulls the model url out of the device description. 🌐

getserialnumber β€” get the serialnumber.

$serialnumber = $dev->getserialnumber();

Pulls the model description out of the device description. (yes, the description says "model description" even though the method is about the serial number β€” that's what the original says and we are nothing if not faithful πŸ’œ) πŸ”–

getudn β€” get the device UDN.

$udn = $dev->getudn();

Pulls the UDN out of the device description. πŸ‘‘

getupc β€” get the device UPC.

$upc = $dev->getupc();

Pulls the UPC out of the device description. 🏷️

getservicelist β€” get the device type.

@service_list = $dev->getservicelist();

Grabs the service list inside the device. And hey, go peek at Net::UPnP::Service too, it's the companion piece, iykyk 🧚


🌸 SEE ALSO 🌸

  • Net::UPnP::Service β€” the sister module, go say hi 🫢

πŸ‘‘ AUTHOR πŸ‘‘

Satoshi Konno skonno@cybergarage.org

CyberGarage http://www.cybergarage.org


Copyright (C) 2005 by Satoshi Konno

It may be used, redistributed, and/or modified under the terms of BSD License.


and that's the whole page, bestie!! this one shipped as perl v5.36.0, dated 2022-12-06, and it's Net::UPnP::Device(3pm) in the User Contributed Perl Documentation. slay, go forth and enumerate your devices πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from