Make sure you have Rust installed:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
You might want UPX installed to compress the binary depending on your target. Your distribution's repos should provide it, e.g. sudo apt install upx
.
I've optimized for size a best as I can. Remaining wishes are: gnutls
or mbedtls
support through FFI instead of shipping rustls
. This would save space in the binary.
cargo build --features debug
cargo build --features release --release
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cross +nightly build --features release --release --target aarch64-unknown-linux-gnu -Zbuild-std-features=optimize_for_size,panic_immediate_abort
CARGO_TARGET_x86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cross +nightly build --features alpine --release --target x86_64-unknown-linux-musl -Zbuild-std-features=optimize_for_size,panic_immediate_abort
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cross +nightly build --features alpine --release --target aarch64-unknown-linux-musl -Zbuild-std-features=optimize_for_size,panic_immediate_abort
You must have cross installed with all its dependencies. Unless you are building natively on MIPS
.
CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cross +nightly build --features aredn --release --target mips-unknown-linux-musl -Zbuild-std-features=optimize_for_size,panic_immediate_abort
# Then compress the executable further with upx
upx --brute target/mips-unknown-linux-musl/release/meshtastic-telemetry-daemon-rs
Sometimes, running a cross compile after a normal compile will fail spitting out some errors about GLIBC
versions. This is most likely due to build caching of some sort (I am not entirely sure). If you just run cargo clean
and then re-run the cross compilation command above it should work.
This is not recommended due to MIPS
devices typically having little free disk space and the debug binary being large.
To run the debug version:
cargo run --features debug
This will use the example_config.toml
file provided in the root of this repository.
Then specify the serial device connected via USB when prompted.
If you want to see Meshtastic packets as json
output add --features debug,print-packets
to the above command.
Run the release version with:
cargo run --features release --release
But this is also not recommended due to logs going straight to journalctl
or wherever your system logs things by default.
To view documentation on this, run the following after you install Rust and clone this repo:
cargo doc --features release --release --no-deps --document-private-items --open
Your browser should then open to this repo's documentation as generated from the Rust docstrings.
meshtastic
is their library for Rust. They also have a protobuf library. This crate is already installed using a fork from gatlinnewhouse
that updated protobufs and lowered logging levels of error!
to not pollute system logs.
tokio
is the async runtime, learn it, it's great and already installed here. Ideally we'd be using just threads and threadpools, but the Meshtastic Rust crate uses tokio already.
serde
is the serialization/deserialization library, you can use it to parse the packets and grab what data we want and then do whatever with it.
Cargo.toml has more crates being used.