GithubHelp home page GithubHelp logo

asherry99 / broadlink Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mixcode/broadlink

0.0 1.0 0.0 12 KB

A Go package to control BroadLink RM mini 3 IR controller.

License: MIT License

Go 100.00%

broadlink's Introduction

broadlink

A Go package to control BroadLink RM mini 3 "Black Bean" IR remote controller.

Disclaimer

I built this package just to control my own home appliances, and the RM mini 3 is the only device I have. For other devices, you can fork and implement yourselves. :p

Code Sample

Detect all reachable BroadLink devices

devs, err := broadlink.DiscoverDevices(100*time.Millisecond, 0)
fmt.Println(devs)
// d := devs[0]

Register and auth local machine to detected BroadLink device

myname := "my test server"  // Your local machine's name.
myid := make([]byte, 15)    // Must be 15 bytes long.
// Fill myid[] with some unique ID for your local machine.

err = d.Auth(myid, myname) // d.ID and d.AESKey will be updated on success.

Capture an IR Remote code

var rtype RemoteType
var ircode []byte

// Enter capturing mode.
err = d.StartCaptureRemoteControlCode()

// Point a remote controller toward the device and press a button to have some signal.

// Poll captured data. (Certainly you can do much better than this ;p)
ok := false
for i:=0; i<30; i++ {
	remotetype, ircode, err = d.ReadCapturedRemoteControlCode()
	if err == nil {
		ok = true
		break
	}
	if err != ErrNotCaptured {
		return err // real error
	}
	time.Sleep(time.Second)
	continue
}

if ok {
	// ircode now have captured data
}

Fire an IR code

err = d.SendIRRemoteCode(ircode, 1)	// 1 means once, 2 is twice, ...
// Note that sending IR signals may take a few hundred milliseconds. Set network timout accordingly.

Try to connect a New BroadLink device to local Wifi network

err = broadlink.SetupDeviceWifi("YOUR_WIFI_SSID", "YOUR_WIFI_PASSWORD", broadlink.WIFI_SECURITY_WPA_TKIP, nil)
// try to detect devices below
// devs, err := broadlink.DiscoverDevices(100*time.Millisecond, 0)

References

Note that references may have incorrect and inconsistent information.

broadlink's People

Contributors

mixcode avatar

Watchers

 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.