Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This section has all the testing commands. The first rule is the
# default and it tests every subcrate.

test-all: test-api _test-drivers test-drmemd
test-all: format test-api _test-drivers test-drmemd
@echo "All tests passed successfuly!"

test-api:
Expand Down Expand Up @@ -40,10 +40,10 @@ _test-redis-graphql: test-api

test-drmemd: _test-simple _test-simple-graphql _test-redis-graphql

release : test-all
@echo "Building release"
time nice cargo build \
--release \
build mode="dev":
@echo "Building {{ mode }}"
nice cargo build \
{{ if mode == "rel" { "--release" } else { "" } }} \
--features simple-backend,graphql,all-drivers

# This section has the targets for checking the syntax and
Expand All @@ -70,6 +70,11 @@ check: _check-simple _check-simple-graphql _check-redis-graphql
publish: test-all
@echo "DrMem Project published successfully!"

# Formats the project.

format:
nice cargo fmt --all

# Local variables:
# mode: makefile
# End:
66 changes: 33 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions drivers/drmem-drv-ntp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl Instance {
Err(e) => error!("couldn't receive data -> {}", e),
}
},
_ = tokio::time::sleep(std::time::Duration::from_millis(1_000)) => {
_ = tokio::time::sleep(Duration::from_millis(1_000)) => {
warn!("timed-out waiting for reply to \"get synced host\" request")
}
}
Expand Down Expand Up @@ -346,7 +346,7 @@ impl Instance {
}
}
},
_ = tokio::time::sleep(std::time::Duration::from_millis(1_000)) => {
_ = tokio::time::sleep(Duration::from_millis(1_000)) => {
warn!("timed-out waiting for reply to \"get host info\" request")
}
}
Expand All @@ -366,6 +366,7 @@ impl driver::Registrator for Devices {
fn register_devices<'a>(
core: &'a mut driver::RequestChan,
_: &DriverConfig,
_override_timeout: Option<Duration>,
max_history: Option<usize>,
) -> impl Future<Output = Result<Self>> + Send + 'a {
// It's safe to use `.unwrap()` for these names because, in a
Expand Down
9 changes: 5 additions & 4 deletions drivers/drmem-drv-sump/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tokio::{
tcp::{OwnedReadHalf, OwnedWriteHalf},
TcpStream,
},
time,
time::Duration,
};
use tracing::{debug, error, info, warn, Span};

Expand Down Expand Up @@ -225,8 +225,8 @@ impl Instance {
use socket2::{Domain, Socket, TcpKeepalive, Type};

let keepalive = TcpKeepalive::new()
.with_time(time::Duration::from_secs(5))
.with_interval(time::Duration::from_secs(5));
.with_time(Duration::from_secs(5))
.with_interval(Duration::from_secs(5));
let socket = Socket::new(Domain::IPV4, Type::STREAM, None)
.expect("couldn't create socket");

Expand All @@ -236,7 +236,7 @@ impl Instance {

match socket.connect_timeout(
&<SocketAddrV4 as Into<socket2::SockAddr>>::into(*addr),
time::Duration::from_millis(100),
Duration::from_millis(100),
) {
Ok(()) => {
info!("connected");
Expand Down Expand Up @@ -284,6 +284,7 @@ impl driver::Registrator for Devices {
fn register_devices<'a>(
core: &'a mut driver::RequestChan,
_: &DriverConfig,
_override_timeout: Option<Duration>,
max_history: Option<usize>,
) -> impl Future<Output = Result<Self>> + Send + 'a {
let service_name = "service".parse::<device::Base>().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions drivers/drmem-drv-tplink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "drmem-drv-tplink"
version = "0.6.0"
version = "0.6.1"
authors = ["Rich Neswold <rich.neswold@gmail.com>"]
edition = "2021"
homepage = "https://github.com/DrMemCS/drmem"
Expand Down Expand Up @@ -42,7 +42,7 @@ serde_json.workspace = true
serde_json.default-features = false
serde_json.features = ["std"]

drmem-api = { path = "../../drmem-api", version = "0.6" }
drmem-api = { path = "../../drmem-api", version = "0.6.1" }

[dev-dependencies]
tokio.workspace = true
Expand Down
17 changes: 14 additions & 3 deletions drivers/drmem-drv-tplink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This table contains products that are known to work with this driver.

| Device Model | Vendor | Description |
|--------------|--------|---------------|
| HS103 | Kasa | On/off outlet |
| HS220 | Kasa | Dimmer switch. Note: it takes around 200ms for this module to respond to a command. In some instances, it took ~1s! So don't try controlling it rapidly. |

## Configuration
Expand All @@ -23,16 +24,26 @@ The driver needs to know where to access the device.
- `addr` is a string containing the host name, or IP address, and port
number of the TP-Link device (in **"hostname:#"** or
**"\#.#.#.#:#"** format.) The port is almost always 9999.
- `type` is a string that indicates what type of device to use. It can
be "switch", "outlet", or "dimmer".

## Devices

The driver creates these devices:
The driver creates these devices for switch devices:

| Base Name | Type | Units | Comment |
|--------------|----------|-------|----------------------------------------|
| `error` | bool, RO | | If true, there is an error communicating with the device. |
| `brightness` | f64 , RW | % | Accepts 0 - 100 for percent brightness. If the value is out of range, it will be brought back in range. |
| `led` | bool, RW | | `true` and `false` turn the LED indicator on and off, respectively. |
| `state` | bool, RW | | `true` and `false` turn it on and off, respectively. |
| `indicator` | bool, RW | | `true` and `false` turn the LED indicator on and off, respectively. |

The driver creates these devices for dimmer devices:

| Base Name | Type | Units | Comment |
|--------------|----------|-------|----------------------------------------|
| `error` | bool, RO | | If true, there is an error communicating with the device. |
| `brightness` | f64, RW | % | Accepts 0 - 100 for percent brightness. If the value is out of range, it will be brought back in range. |
| `indicator` | bool, RW | | `true` and `false` turn the LED indicator on and off, respectively. |

## History

Expand Down
Loading