fix warnings
This commit is contained in:
parent
fcf449ec8b
commit
e3e1c4a5b9
|
@ -1,15 +1,12 @@
|
|||
use crate::AppState;
|
||||
use actix_web::{
|
||||
error::{ErrorBadRequest, ErrorInternalServerError},
|
||||
web,
|
||||
web::Path,
|
||||
Responder,
|
||||
web, Responder,
|
||||
};
|
||||
use chrono::Utc;
|
||||
use entity::{node, node_group, sensor_data};
|
||||
use sea_orm::{entity::*, query::*, ActiveModelTrait, ActiveValue, EntityTrait};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct NodeWithSensorData {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use actix_web::{web, App, HttpServer};
|
||||
use deku::prelude::*;
|
||||
use entity::{node::ActiveModel, sensor_data};
|
||||
use sea_orm::{ActiveModelTrait, ActiveValue, Database, DatabaseConnection};
|
||||
use std::env;
|
||||
use tokio::{io::AsyncReadExt, net::TcpListener};
|
||||
|
@ -13,7 +12,6 @@ use routes::config;
|
|||
#[derive(Clone)]
|
||||
struct AppState {
|
||||
db: DatabaseConnection,
|
||||
secret: String,
|
||||
}
|
||||
|
||||
#[derive(DekuRead, DekuWrite, Debug)]
|
||||
|
@ -34,7 +32,6 @@ async fn main() -> std::io::Result<()> {
|
|||
dotenvy::dotenv().ok();
|
||||
|
||||
let db_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
||||
let jwt_secret = env::var("TOKEN_SECRET").expect("TOKEN_SECRET must be set");
|
||||
|
||||
let conn = Database::connect(&db_url)
|
||||
.await
|
||||
|
@ -42,10 +39,7 @@ async fn main() -> std::io::Result<()> {
|
|||
|
||||
println!("Finished running migrations");
|
||||
|
||||
let state = AppState {
|
||||
db: conn.clone(),
|
||||
secret: jwt_secret,
|
||||
};
|
||||
let state = AppState { db: conn.clone() };
|
||||
|
||||
tokio::spawn(async {
|
||||
let db = conn;
|
||||
|
@ -58,9 +52,9 @@ async fn main() -> std::io::Result<()> {
|
|||
println!("ESP CONNECTED");
|
||||
let mut buffer = vec![0; 24];
|
||||
loop {
|
||||
if let Ok(size) = stream.read(&mut buffer).await {
|
||||
if let Ok(_) = stream.read(&mut buffer).await {
|
||||
println!("{:#x?}", &buffer);
|
||||
if let Ok((data, mut value)) = Data::from_bytes((&buffer, 0)) {
|
||||
if let Ok((_, mut value)) = Data::from_bytes((&buffer, 0)) {
|
||||
println!("Received: {:#?}", value);
|
||||
|
||||
value.mac.rotate_right(2);
|
||||
|
|
|
@ -21,12 +21,10 @@
|
|||
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use tokio::io::AsyncReadExt;
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
use core::str;
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
|
|
Loading…
Reference in a new issue