Created
August 21, 2020 01:46
-
-
Save ssnover/5877fef6b81dc5d8c16ab7518488aa00 to your computer and use it in GitHub Desktop.
Example of discovering Hue bridge with ssdp-client crate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "test-something" | |
version = "0.1.0" | |
authors = ["ssnover95 <[email protected]>"] | |
edition = "2018" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
ssdp-client = "0.5.5" | |
tokio = { version = "0.2.20", features = ["macros", "rt-core", "time"] } | |
futures = "0.3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use futures::prelude::*; | |
// https://docs.rs/ssdp-client/0.5.5/ssdp_client/index.html | |
use ssdp_client::{SearchTarget, URN}; | |
#[tokio::main] | |
async fn main() { | |
let urn = URN::device("schemas-upnp-org", "Basic", 1); | |
let search_request = SearchTarget::URN(urn); | |
let mut responses = ssdp_client::search(&search_request, std::time::Duration::from_secs(5), 5).await.unwrap(); | |
while let Some(response) = responses.next().await { | |
println!("{:?}", response.unwrap()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment