Skip to content

coffee-and-telesense/meshtastic-telemetry-daemon-rs

Repository files navigation

Meshtastic Telemetry Daemon

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.

Building

Build debug for X86 or your native architecture

cargo build --features debug

Build release for X86 or your native architecture

cargo build --features release --release

Build release for ARMv8 64 (Raspberry Pi4 B)

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

Build release for X86_64 Alpine Linux Container

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

Build release for ARM 64 bit Alpine Linux Container

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

Build release for MIPS

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.

Build debug for MIPS

This is not recommended due to MIPS devices typically having little free disk space and the debug binary being large.

Running

Debug

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.

Release

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.

Documentation

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.

Notes

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.

About

Meshtastic Rust daemon to pull packets from the network and do whatever we want with them

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages