Skip to content

Commit

Permalink
Merge pull request #4 from wassup-/feature/runner-esp
Browse files Browse the repository at this point in the history
Rename executable targets
  • Loading branch information
wassup- authored Mar 29, 2024
2 parents 3680f03 + 754a1e6 commit 12bc1f4
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 43 deletions.
58 changes: 29 additions & 29 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["aces", "esp", "macos"]
members = ["aces", "runner-esp", "runner-macos"]
resolver = "2"

[workspace.package]
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion esp/Cargo.toml → runner-esp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "esp"
name = "runner-esp"
version.workspace = true
authors.workspace = true
edition.workspace = true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 12 additions & 11 deletions esp/src/main.rs → runner-esp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ mod notifications;

// source: https://github.com/taks/esp32-nimble/blob/develop/examples/ble_client.rs

const SLEEP_DURATION: u64 = 30;
/// The name of the target device (e.g. the device to connect to).
const TARGET_DEVICE_NAME: &str = "AL12V100HFA0191";
/// The sleep duration in seconds.
const SLEEP_DURATION: u64 = 30;

esp_idf_sys::esp_app_desc!();

Expand Down Expand Up @@ -38,23 +40,25 @@ fn app_main() {

let mut notif = notifications::Notifications::subscribe(rx).await;

tx.write_value(aces::REQ_CLEAR, false).await.unwrap();
tx.write_value(aces::Request::Clear.bytes(), false)
.await
.unwrap();
timer.delay(timer.tick_hz()).await.unwrap();

loop {
tx.write_value(aces::REQ_BATTERY_VOLTAGE, false)
tx.write_value(aces::Request::BatteryVoltage.bytes(), false)
.await
.unwrap();
let voltage = aces::read_voltage(&mut notif).await.unwrap();
println!("voltage: {:#?}", voltage);

tx.write_value(aces::REQ_BATTERY_DETAIL, false)
tx.write_value(aces::Request::BatteryDetail.bytes(), false)
.await
.unwrap();
let detail = aces::read_detail(&mut notif).await.unwrap();
println!("detail: {:#?}", detail);

tx.write_value(aces::REQ_BATTERY_PROTECT, false)
tx.write_value(aces::Request::BatteryProtect.bytes(), false)
.await
.unwrap();
let protect = aces::read_protect(&mut notif).await.unwrap();
Expand All @@ -81,21 +85,18 @@ async fn find_target_device(adapter: &BLEDevice) -> BLEAdvertisedDevice {
.interval(100)
.window(99)
.on_result(move |scan, device| {
if device.name().contains(TARGET_DEVICE_NAME) {
if device.name() == TARGET_DEVICE_NAME {
scan.stop().unwrap();
(*device0.lock()) = Some(device.clone());
}
});
scan.start(3000).await.unwrap();
scan.start(3_000).await.unwrap();

log::info!("finished scan");

return match &*device.lock() {
Some(device) => device.clone(),
None => {
log::info!("ACES battery not found");
panic!("ACES battery not found");
}
None => panic!("ACES battery not found"),
};
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion macos/Cargo.toml → runner-macos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "macos"
name = "runner-macos"
version.workspace = true
authors.workspace = true
edition.workspace = true
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 12bc1f4

Please # to comment.