This commit is contained in:
Brad Stein 2025-06-02 20:18:19 -05:00
parent 54345dcbc8
commit 51d6c27850
7 changed files with 22 additions and 20 deletions

8
.gitignore vendored
View File

@ -1,7 +1,7 @@
/target/
/Cargo.lock
/override.toml
/.cache/sccache/
target/
Cargo.lock
override.toml
.cache/sccache/
/unit-graph.json
/**/*.rs.bk
**/*.rs.orig

View File

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024"
[dependencies]
tokio = { version = "1.45", features = ["full"] }
tokio = { version = "1.45", features = ["full", "fs"] }
tonic = "0.11"
tokio-stream = { version = "0.1", features = ["sync"] }
anyhow = "1.0"

View File

@ -2,7 +2,7 @@
#![forbid(unsafe_code)]
use anyhow::Result;
use navka_common::navka::{relay_client::RelayClient, HidReport}; // <- only items that exist
use navka_common::navka::{hid_report::*, relay_client::RelayClient, HidReport}; // <- only items that exist
use tokio::{sync::mpsc, time::sleep};
use tokio_stream::wrappers::ReceiverStream;
use tonic::{transport::Channel, Request};
@ -38,7 +38,7 @@ async fn main() -> Result<()> {
});
while let Some(report) = inbound.message().await? {
println!("🔄 got report from server: {:?}", report.data);
println!("🔄 {:?}", report.data);
}
Ok(())
}

View File

@ -24,10 +24,7 @@ sudo -u "$ORIG_USER" bash -c "cd '$SRC/client' && cargo build --release"
# 5. install binary
install -Dm755 "$SRC/client/target/release/navka-client" "$HOME/.local/bin/navka-client"
# 6) Install the client binary
install -Dm755 client/target/release/navka-client "$HOME/.local/bin/navka-client"
# 7) Create the user service file
# 6) Create the user service file
mkdir -p "$HOME/.config/systemd/user"
cat >"$HOME/.config/systemd/user/navka-client.service" <<'EOF'
[Unit]
@ -43,9 +40,9 @@ Restart=on-failure
WantedBy=default.target
EOF
# 8) (Optional) keep running when no session is active
# 7) (Optional) keep running when no session is active
loginctl enable-linger "$ORIG_USER"
# 9) Enable + start as *you*, not root
sudo -u "$ORIG_USER" systemctl --user daemon-reload
sudo -u "$ORIG_USER" systemctl --user enable --now navka-client.service
# 8) Call the *user* instance inside the callers session
sudo -iu "$ORIG_USER" systemctl --user daemon-reload
sudo -iu "$ORIG_USER" systemctl --user enable --now navka-client.service

View File

@ -1,11 +1,16 @@
#!/usr/bin/env bash
# Proven Pi-5 configfs gadget: HID keyboard+mouse + stereo UAC2
set -euo pipefail
modprobe libcomposite
mountpoint -q /sys/kernel/config || mount -t configfs configfs /sys/kernel/config
G=/sys/kernel/config/usb_gadget/navka
[[ -d $G ]] && echo "" >"$G/UDC" && rm -rf "$G"
if [[ -d $G ]]; then
echo "" >"$G/UDC" || true
find "$G/configs" -type l -delete || true
rmdir "$G/functions/"* 2>/dev/null || true
rmdir "$G" 2>/dev/null || true
fi
mkdir -p "$G"
echo 0x1d6b >"$G/idVendor" # Linux Foundation

View File

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024"
[dependencies]
tokio = { version = "1.45", features = ["full"] }
tokio = { version = "1.45", features = ["full", "fs"] }
tokio-stream = "0.1"
tonic = { version = "0.11", features = ["transport"] }
anyhow = "1.0"

View File

@ -11,7 +11,7 @@ use navka_common::navka::{
relay_server::{Relay, RelayServer},
HidReport,
};
systemctl list services
struct RelaySvc {
// shared broadcast channel (unused for now, but kept for future fan-out)
_hub_tx: mpsc::Sender<HidReport>,
@ -24,7 +24,7 @@ impl Relay for RelaySvc {
async fn stream(
&self,
request: Request<tonic::Streaming<HidReport>>,
) -> Result<Response<Self::StreamStream>, Status> {
) -> Result<Response<Pin<Box<dyn Stream<Item = Result<HidReport, Status>> + Send>>>, Status> {
let mut inbound = request.into_inner();
// each connected client gets its own outbound channel