rbroadlink
A rust port of the python-broadlink library.
Devices Tested
The following devices have been tested and found to work with this library:
| Model Code | Device Name | Manufacturer | Type |
|---|---|---|---|
| 0x649B | RM4 Pro | Broadlink | Remote |
Setup
Before a device can be used, it must be connected to a network. Refer to this link on how to get the device into AP mode, connect to its network (e.g. Broadlink_Device_Wifi), and then run the following code:
use Device;
use WirelessConnection;
// Construct the network information
let network_info = WPA2;
// Connect the device to the specified network
connect_to_network
.expect;
You can also use the included cli to do so:
# Pass the password directly
# Prompt for the password safely
Usage
Devices can either be constructed from a known IP or by local discovery:
use Ipv4Addr;
use Device;
// Create a device by IP
// Note: Devices only support Ipv4 addresses
let known_ip = new;
let device = from_ip
.expect;
// You can also specify the local IP of the machine in the case of the device being
// on a different subnet.
let local_ip = new;
let device_with_local_ip = from_ip
.expect;
// You can also just enumerate all of the discovered devices, with an optional
// local ip as well.
let devices = list
.expect;
Once you have a valid device, you probably want to differentiate the kind of device
that you have. Device is a structured enum that contains different types of devices with
more specialized methods.
use Device;
// Assuming that you have a valid device in `device`...
let remote_device = match device ;
// Use a remote-specific method to echo a learned IR code.
let code = remote_device.learn_ir
.expect;
remote_device.send_code
.expect;
Examples
There are a few examples of this library present in the examples folder. Refer to
the examples folder README for more info.