Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More Progress
Added SSDP to find the printer IP
Fix weird JSON struct returned from get_device_ips
Remove unused constants
Added ip to device struct
Misc Cleanup
ran cargo fix and cargo format
  • Loading branch information
Sticks committed Mar 5, 2024
1 parent b1409a3 commit 4cbb3eb
Show file tree
Hide file tree
Showing 14 changed files with 390 additions and 246 deletions.
124 changes: 12 additions & 112 deletions src-tauri/Cargo.lock

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

4 changes: 1 addition & 3 deletions src-tauri/Cargo.toml
Expand Up @@ -21,10 +21,8 @@ tauri = { version = "1.6.0", features = [ "dialog-confirm", "dialog-ask", "dialo
dirs = "5.0.1"
reqwest = "0.11.24"
lazy_static = "1.4.0"
tokio = "1.36.0"
tokio = { version = "1.36.0", features = ["full"] }
jsonwebtoken = "9.2.0"
rumqttc = "0.24.0"
log = "0.4.21"
paho-mqtt = "0.12.3"

[features]
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/build.rs
@@ -1,3 +1,3 @@
fn main() {
tauri_build::build()
tauri_build::build()
}
8 changes: 6 additions & 2 deletions src-tauri/src/commands/bambu/mod.rs
Expand Up @@ -2,6 +2,7 @@ use std::borrow::Borrow;

use crate::handlers::bambu::{BambuClient, BambuDevice};
use lazy_static::lazy_static;
use serde_json::json;

lazy_static! {
static ref BAMBU_CLIENT: BambuClient = BambuClient::new();
Expand Down Expand Up @@ -78,8 +79,11 @@ pub async fn discover_devices(devices: Vec<BambuDevice>) -> Result<String, Strin

match devices {
Ok(devices) => {
// Serialize the response to JSON
let serialized_devices = serde_json::to_string(&devices).map_err(|e| e.to_string())?;
let json = json!({
"devices": devices
});

let serialized_devices = serde_json::to_string(&json).map_err(|e| e.to_string())?;
Ok(serialized_devices)
}
Err(e) => Err(e.to_string()),
Expand Down
4 changes: 0 additions & 4 deletions src-tauri/src/constants.rs
@@ -1,6 +1,2 @@
pub static BAMBU_API_URL: &str = "https://api.bambulab.com";
pub static BAMBU_AUDIENCE: &str = "account";
pub static BAMBU_LOGIN_URL: &str = "https://bambulab.com/api/sign-in/form";
pub static BAMBU_MQTT_URL: &str = "mqtts://us.mqtt.bambulab.com:8883";
pub static BAMBU_MQTT_INIT_PAYLOAD: &str =
r#"{ "pushing": { "sequence_id": "0", "command": "pushall" } }"#;

0 comments on commit 4cbb3eb

Please sign in to comment.