Giter Club home page Giter Club logo

hs100-rust-api's Introduction

HS100 API for Rust

CratesIo

Simple library in Rust to access HS100/110 functions.

Special thanks to: https://github.com/sausheong/hs1xxplug for the Go version (which this library is basically a port from).

Resource on Reverse Engineering the HS110: https://www.softscheck.com/en/reverse-engineering-tp-link-hs110/

Usage

extern crate hs100;

use hs100::SmartPlug;
use hs100::error::Error;

const HOST: &'static str = "192.168.0.37:9999"; // your device IP

fn main() {
    let api = SmartPlug::new(HOST);

    // Quick example:
    println!("[sysinfo]: {:?}\n", api.sysinfo());
    println!("[meterinfo]: {:?}\n", api.meterinfo());
    println!("[dailystats]: {:?}\n", api.dailystats(7, 2017));

    // Handle specific error types:
    match api.sysinfo() {
        Ok(info) => println!("[sysinfo]: {:?}\n", info),
        Err(err) => {
            match err {
                Error::IoError(_) => println!("some io error occurred"),
                Error::EncryptError => println!("error encrypting the message"),
                Error::DeserializeError(_) => println!("couldn't deserialize the message"),
            }
        }
    }

    // See the example folder for more usage patterns.
}

TODO

  • Deserialize json into structs
  • Proper error handling
  • Use Futures / asynchronous I/O

License

MIT

hs100-rust-api's People

Contributors

abronan avatar azdlowry avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.