fin 2
This commit is contained in:
		@@ -1,15 +1,14 @@
 | 
			
		||||
use crate::curl::startup;
 | 
			
		||||
 | 
			
		||||
mod json;
 | 
			
		||||
mod curl;
 | 
			
		||||
mod serial;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
fn main() { 
 | 
			
		||||
    let data_file = std::path::Path::new("data.json");
 | 
			
		||||
    let data = json::get_json(data_file);
 | 
			
		||||
    let req; 
 | 
			
		||||
    let dt;
 | 
			
		||||
    (req, dt) = startup(&data);
 | 
			
		||||
    (req, dt) = curl::startup(&data);
 | 
			
		||||
    serial::read_messages(req, &dt);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -23,11 +23,15 @@ pub fn read_messages(mut request: curl::easy::Easy, data: &str) {
 | 
			
		||||
    loop {
 | 
			
		||||
        match connection.read(serial_buf.as_mut_slice()) { 
 | 
			
		||||
            Ok(t) => {
 | 
			
		||||
                if t < 1 { continue; }
 | 
			
		||||
                let output = String::from_utf8_lossy(&serial_buf[..t]);
 | 
			
		||||
                if output.contains("1") {
 | 
			
		||||
                    // send curl request
 | 
			
		||||
                    let res = crate::curl::request(&mut request, &data);
 | 
			
		||||
                    println!("Response code: {}", res.unwrap());
 | 
			
		||||
                    match res { 
 | 
			
		||||
                        Some(t) => println!("Response code: {t}"),
 | 
			
		||||
                        None => eprintln!("[ERROR] Something went wrong with the CURL request"),
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            Err(_) => {}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user