Expand description
An asynchronous library for finding UPnP control points, performing actions on them
and reading their service descriptions.
UPnP stand for Universal Plug and Play
and is widely used for routers, WiFi-enabled speakers
and media servers.
Specification: http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v2.0.pdf
Example usage:
The following code searches for devices that have a RenderingControl
service
and prints their names along with their current volume.
use futures::prelude::*;
use std::time::Duration;
use rupnp::ssdp::{SearchTarget, URN};
const RENDERING_CONTROL: URN = URN::service("schemas-upnp-org", "RenderingControl", 1);
#[tokio::main]
async fn main() -> Result<(), rupnp::Error> {
let search_target = SearchTarget::URN(RENDERING_CONTROL);
let devices = rupnp::discover(&search_target, Duration::from_secs(3)).await?;
pin_utils::pin_mut!(devices);
while let Some(device) = devices.try_next().await? {
let service = device
.find_service(&RENDERING_CONTROL)
.expect("searched for RenderingControl, got something else");
let args = "<InstanceID>0</InstanceID><Channel>Master</Channel>";
let response = service.action(device.url(), "GetVolume", args).await?;
let volume = response.get("CurrentVolume").unwrap();
println!("'{}' is at volume {}", device.friendly_name(), volume);
}
Ok(())
}
Re-exports
pub use http;
pub use ssdp_client as ssdp;
Modules
- Service Control Protocol Description.
Structs
- A UPnP Device. It stores its
Uri
and aDeviceSpec
, which contains information like the device type and its list of inner devices and services. - Information about a device.
- A UPnP Service is the description of endpoints on a device for performing actions and reading the service definition. For a list of actions and state variables the service provides, take a look at
scpd
.
Enums
- The UPnP Error type.
Functions
- Discovers UPnP devices on the network.