Started to rewrite vrmgrabber in rust.

This commit is contained in:
Kim Baumgartner 2023-07-27 16:51:57 +02:00
parent b4174d09bf
commit 21a0603309
7 changed files with 38 additions and 6 deletions

View File

@ -267,7 +267,7 @@ public class Controller : ControllerBase
if (! await session.Create(installation))
return Unauthorized();
return installation.FillOrderNumbers().HideParentIfUserHasNoAccessToParent(session!.User);
return installation;
}
[HttpPost(nameof(CreateFolder))]

View File

@ -7,7 +7,7 @@
"dotnetRunMessages": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7087;http://localhost:5031",
"applicationUrl": "https://localhost:8000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}

View File

@ -1,4 +1,4 @@
// dotnet publish BmsTunnel.csproj -c Release -r linux-arm -p:PublishSingleFile=true --self-contained true && \
// && \
// rsync -av bin/Release/net6.0/linux-arm/publish/ root@10.2.1.6:/home/root/tunnel && clear && \
// ssh root@10.2.1.6 /home/root/tunnel/BmsTunnel

View File

@ -24,7 +24,7 @@ public static class Program
app.MapControllers();
// app.MapGet("/", () => Controller.Index());
var webTask = app.RunAsync();
await Task.WhenAll(webTask);
await Task.WhenAll(webTask, updateTask);
}
private static OpenApiInfo OpenApiInfo { get; } = new OpenApiInfo

View File

@ -0,0 +1,11 @@
pub struct Installation {
name: String,
vrm: i64,
ip: String,
identifier: String,
serial: String,
online: String,
last_seen: String,
number_of_batteries: String,
batter_firmware_version: String
}

View File

@ -0,0 +1,21 @@
use std::ops::Add;
use reqwest::{Error, Response};
// use serde::{Deserialize, Serialize};
const API_ROOT:&str ="https://vrmapi.victronenergy.com/v2";
const USER_ID:&str = "55450";
const TOKEN:&str = "88b36e7226ff7fa7bf231d0f9f98e916f661923c84e494cd27b6bc795ec0074b";
pub async fn all_installations_request() -> Result<Response, Error> {
// use reqwest::header::AUTHORIZATION;
let client = reqwest::Client::new();
let res = client
.get(API_ROOT.to_owned().add("/users/").add(USER_ID).add("/installations"))
.header("Content-Type", "application/json")
.header("x-authorization","Token ".to_owned()+TOKEN)
.send()
.await;
return res;
}

View File

@ -1,11 +1,11 @@
import axios from "axios";
export const axiosConfigWithoutToken = axios.create({
baseURL: "https://monitor.innov.energy/api",
baseURL: "https://localhost:7087",
});
const axiosConfig = axios.create({
baseURL: "https://monitor.innov.energy/api",
baseURL: "https://localhost:7087",
});
axiosConfig.defaults.params = {};