Skip to content

Instantly share code, notes, and snippets.

@ssnover
Created August 21, 2020 01:46
Show Gist options
  • Save ssnover/5877fef6b81dc5d8c16ab7518488aa00 to your computer and use it in GitHub Desktop.
Save ssnover/5877fef6b81dc5d8c16ab7518488aa00 to your computer and use it in GitHub Desktop.
Example of discovering Hue bridge with ssdp-client crate
[package]
name = "test-something"
version = "0.1.0"
authors = ["ssnover95 <ssnover95@gmail.com>"]
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"
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