Crate miio_proto

Crate miio_proto 

Source
Expand description

§Simple example

let rt = tokio::runtime::Runtime::new().expect("Async runtime");
rt.block_on(async {
    let conn = Device::new(
        "192.168.1.1:54321",
        1234512345,
        [
            0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0xaa, 0xbb, 0xcc, 0xdd,
            0xee, 0xff,
        ],
    )
    .await
    .expect("Connect");
    conn.send_handshake().await.expect("Handshake");
    let (hello, _) = conn.recv().await.expect("Response");

    conn.send(
        hello.stamp + 1,
        "{'method':'power','id':1,'params':['off']}",
    )
    .await
    .expect("Request");
})

Structs§

Device
Connection holder
MessageHeader
Struct describes protocol message header