fix the Weird Errors caused (?) by opt-level, plus minor tweaks
This commit is contained in:
parent
af3a618529
commit
ce989d70af
8
.cargo/config.toml
Normal file
8
.cargo/config.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[profile.release]
|
||||
# somehow there are errors connecting to some devices
|
||||
# - on linux
|
||||
# - on release builds
|
||||
# - when there are other devices too
|
||||
# so i have turned the opt-level down to prevent this
|
||||
# one day i will discover the root cause
|
||||
opt-level = 0
|
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1120,7 +1120,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "homekit-controller"
|
||||
version = "0.3.0"
|
||||
version = "0.4.1"
|
||||
dependencies = [
|
||||
"chacha20poly1305",
|
||||
"ed25519-dalek",
|
||||
|
@ -1143,7 +1143,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "homekit-exporter"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "homekit-controller"
|
||||
version = "0.3.0"
|
||||
version = "0.4.1"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
|
@ -340,6 +340,8 @@ impl DeviceConnection {
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum HomekitError {
|
||||
#[error("could not connect to any devices")]
|
||||
NoSuccessfulConnections,
|
||||
#[error("connection")]
|
||||
Connection(#[from] ConnectionError),
|
||||
#[error("io")]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "homekit-exporter"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
description = "Prometheus exporter for HomeKit sensors"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Maintainer: Alex Janka <alex@alexjanka.com>
|
||||
|
||||
pkgname=homekit-logger
|
||||
pkgver=0.4.0
|
||||
pkgver=0.4.1
|
||||
pkgrel=1
|
||||
pkgdesc="Prometheus exporter for HomeKit sensors"
|
||||
arch=('x86_64' 'aarch64')
|
||||
|
|
|
@ -79,22 +79,29 @@ async fn init(pairing_data: PathBuf) -> Result<HashMap<String, DeviceConnection>
|
|||
let mut connected_devices = HashMap::new();
|
||||
for (k, v) in devices {
|
||||
let mut num = 0;
|
||||
let connected = loop {
|
||||
loop {
|
||||
match v.connect(&discovered).await {
|
||||
Ok(v) => break Some(v),
|
||||
Ok(v) => {
|
||||
connected_devices.insert(k, v);
|
||||
break;
|
||||
}
|
||||
Err(e) => {
|
||||
num += 1;
|
||||
if num > 10 {
|
||||
log::error!("error connecting to {k}: {e:?}");
|
||||
break None;
|
||||
if num > 10 {
|
||||
log::error!("\t...not connecting");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(250)).await;
|
||||
};
|
||||
connected_devices.insert(k, connected.ok_or(HomekitError::DeviceNotFound)?);
|
||||
tokio::time::sleep(Duration::from_millis(1000)).await;
|
||||
}
|
||||
}
|
||||
if connected_devices.is_empty() {
|
||||
Err(HomekitError::NoSuccessfulConnections)
|
||||
} else {
|
||||
Ok(connected_devices)
|
||||
}
|
||||
} else {
|
||||
log::error!("{:?} is not a file!", pairing_data);
|
||||
Err(HomekitError::NoPairingData)
|
||||
|
|
Loading…
Reference in a new issue