remove dead code

This commit is contained in:
Alex Janka 2024-12-26 22:27:39 +11:00
parent f3a09c9363
commit 33f484846f
3 changed files with 0 additions and 86 deletions

View file

@ -297,15 +297,6 @@ impl Tristar {
self.charge_state_gauges.set(new_state.charge_state);
self.state = new_state;
}
// else {
// self.consecutive_errors += 1;
// if self.consecutive_errors >= MAX_CONSECUTIVE_ERRORS {
// self.modbus.close();
// if let Err(e) = self.modbus.connect() {
// log::error!("error reconnecting to modbus device: {e:?}");
// }
// }
// }
}
async fn get_data(&mut self) -> Result<TristarState, TristarError> {

View file

@ -161,7 +161,6 @@ async fn main() {
pl_state,
api_requests,
pli_requests,
// tcrc_requests,
));
// spawn the api / charge rate control loop

View file

@ -1,76 +0,0 @@
use tesla_common::AuthInfo;
use crate::errors::AuthKeyError;
#[derive(serde::Deserialize, Debug)]
#[allow(dead_code)]
struct AuthKeySuccess {
access_token: String,
refresh_token: String,
id_token: String,
expires_in: usize,
state: String,
token_type: String,
}
impl AuthKeySuccess {
fn get_keys(&self) -> AuthInfo {
AuthInfo {
access_token: tesla_common::AccessToken(self.access_token.clone()),
refresh_token: Some(tesla_common::RefreshToken(self.refresh_token.clone())),
}
}
}
#[derive(serde::Deserialize, Debug)]
#[serde(untagged)]
enum AuthKeyResponse {
Ok(AuthKeySuccess),
Error(crate::errors::TeslaError),
}
pub async fn register_auth_key(code: String) -> Result<AuthInfo, AuthKeyError> {
if let Some(secrets) = super::SECRETS.as_ref() {
let mut headers = reqwest::header::HeaderMap::new();
headers.insert(
"Content-Type",
"application/x-www-form-urlencoded".parse().unwrap(),
);
let client = reqwest::Client::builder()
.redirect(reqwest::redirect::Policy::none())
.build()
.unwrap();
let res = client
.post("https://auth.tesla.com/oauth2/v3/token")
.headers(headers)
.body(
[
"grant_type=authorization_code&client_id=",
&secrets.client_id,
"&client_secret=",
&secrets.client_secret,
"&code=",
&code,
"&audience=",
&secrets.audience,
"&redirect_uri=",
&secrets.redirect_uri,
]
.concat(),
)
.send()
.await?
.text()
.await?;
let keys = match serde_json::from_str(&res) {
Ok(AuthKeyResponse::Ok(v)) => Ok(v),
Ok(AuthKeyResponse::Error(e)) => Err(AuthKeyError::TeslaError(e)),
Err(e) => Err(AuthKeyError::SerdeError(e)),
}?;
Ok(keys.get_keys())
} else {
Err(AuthKeyError::Secrets)
}
}