lsdp

Crates.iolsdp
lib.rslsdp
version0.3.0
sourcesrc
created_at2022-03-20 23:26:50.529525
updated_at2023-04-15 17:09:30.347738
descriptionLenbrook Service Discovery Protocol in Rust
homepage
repositoryhttps://github.com/coral/lsdp
max_upload_size
id553764
size34,294
coral (coral)

documentation

README

LSDP (Lenbrook Service Discovery Protocol) in Rust

You've probably never heard about this protocol. Neither had I before implementing it. Lenbrook Group is the manufacturer behind brands like Bluesound, NAD etc. and have in their infinte wisdom decided that instead of leveraging the multitude of avaliable service discovery protocols out there, they would write their own.

Now why would a manufacturer forego using established standards like mDNS or SSDP? Lenbrook claims it's because their customers lack the ability to configure their networks. Maybe if their customer didn't buy "audiophile" garbage routers this would be less of a problem but here we are.

The protocol is basically a worse version of mDNS over UDP Broadcast instead of UDP Multicast. In an effort to get some more experience with parsing binary protocols in Rust I wrote this crate mostly to explore Nom. The crate ships with tokio features turned on which facilites service discovery but if you for some reason just want the decoding, you can disable the tokio features which gives you a reasonably lightweight crate.

How do I use this?

use anyhow::Result;
use lsdp::{net::Discover, ClassID};

#[tokio::main]
async fn main() -> Result<()> {
    println!("Finding devices using LSDP");

    let d = Discover::start().await?;

    d.query(lsdp::QueryMessage::new(vec![ClassID::All])).await?;

    tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;

    for (_, d) in d.inventory().await.lock().await.iter() {
        println!(
            "Found {}: {:?} with data {:?}",
            d.addr, d.records[0].cid, d.records[0].data
        );
    }

    Ok(())
}
Commit count: 18

cargo fmt