1
Fork 0

manual mode

This commit is contained in:
Andy Killorin 2023-12-20 17:39:40 -06:00
parent f95c9cea35
commit 6b42ac19d1
Signed by: ank
GPG key ID: B6241CA3B552BCA4
2 changed files with 13 additions and 0 deletions

View file

@ -102,6 +102,7 @@ async fn main() -> Result<(), Error> {
.route("/turtle/:id/setGoal", post(set_goal))
.route("/turtle/:id/dig", post(dig))
.route("/turtle/:id/cancelTask", post(cancel))
.route("/turtle/:id/manual", post(run_command))
.route("/turtle/:id/info", get(turtle_info))
//.route("/turtle/:id/placeUp", get(place_up))
.route("/turtle/updateAll", get(update_turtles))
@ -163,6 +164,17 @@ async fn place_up(
Json(response)
}
async fn run_command(
Path(id): Path<u32>,
State(state): State<SharedControl>,
Json(req): Json<TurtleCommand>,
) -> Json<TurtleCommandResponse> {
let state = state.read().await;
let commander = state.get_turtle(id).await.unwrap().clone();
drop(state);
Json(commander.execute(req).await.ret)
}
async fn dig(
Path(id): Path<u32>,
State(state): State<SharedControl>,

View file

@ -355,6 +355,7 @@ pub(crate) async fn process_turtle_update(
}
}
println!("{} idle, connected", turtle.name.to_str());
Ok(TurtleCommand::Wait(IDLE_TIME))
}