Skip to content
Snippets Groups Projects
Verified Commit 7a4ed80e authored by Volkor Barbarian Warrior's avatar Volkor Barbarian Warrior
Browse files

showing off to npc

parents
No related branches found
No related tags found
No related merge requests found
/target
# 0.1.0 (2025-01-12)
- You can connect to a network connected node.
- Packets are logged to a database.
\ No newline at end of file
This diff is collapsed.
[package]
name = "yamm"
version = "0.1.0"
edition = "2021"
[dependencies]
fern = "0.7.1"
humantime = "2.1.0"
log = "0.4.22"
meshtastic = "0.1.6"
tokio = "1.42.0"
tracing = "0.1.41"
tracing-subscriber = "0.3.19"
rusqlite = { version = "0.32.0", features = ["bundled"] }
\ No newline at end of file
This diff is collapsed.
```
▓██ ██▓ ▄▄▄ ███▄ ▄███▓ ███▄ ▄███▓
▒██ ██▒▒████▄ ▓██▒▀█▀ ██▒▓██▒▀█▀ ██▒
▒██ ██░▒██ ▀█▄ ▓██ ▓██░▓██ ▓██░
░ ▐██▓░░██▄▄▄▄██ ▒██ ▒██ ▒██ ▒██
░ ██▒▓░ ▓█ ▓██▒▒██▒ ░██▒▒██▒ ░██▒
██▒▒▒ ▒▒ ▓▒█░░ ▒░ ░ ░░ ▒░ ░ ░
▓██ ░▒░ ▒ ▒▒ ░░ ░ ░░ ░ ░
▒ ▒ ░░ ░ ▒ ░ ░ ░ ░
░ ░ ░ ░ ░ ░
░ ░
```
**Y**et **A**nother **M**eshtastic **M**ap
Inspired slightly by MeshInfo.
## What it does
- Logs meshtastic broadcasts
- Saves them to a database
- Serves the data to a future GUI
- Serves the data to a public webpage
## What it doesn't
- Runs meshtastic
- Had a GUI (yet)
- Lets you send messages (yet)
## Installation
You can install this multiple ways.
### Docker
1. use `/docs/docker-compose.yaml`
2. `docker compose up -d` to run it
### Native
1. `git clone`
2. `cargo run`
## Documentation & Support
make a pr
## Contributing
make a pr
## License
AGPL - don't be a dick, keep it open source.
## Credits
[config]
# Connection Type
# Can be one of the following: Serial, Tcp, Mqtt
connection_type = "Tcp"
# Serial Port
## If connection_type is Serial, use this device to connect
serial_port = "/dev/something"
# IP Port
## If connection_type is Tcp, use this ip & port combo to connect
ip_port = "127.0.0.1:4403"
# MQTT
## If connection_type is MQTT, use this to connect.
### TODO!
/// Full Config Structure to manage application settings
pub struct Config {
pub connection_type: ConnectionType,
pub serial_port: Option<String>,
pub ip_port: Option<String>,
}
/// Enum to define the connection type
#[derive(Default)]
pub enum ConnectionType {
#[default]
Tcp,
Serial,
Mqtt,
}
// New modules for USB and TCP connection types
mod usb {
use meshastic::{UsbConnection, MeshasticClient};
pub fn establish_connection() -> Result<MeshasticClient<UsbConnection>, String> {
let usb_serial = UsbConnection::new("/dev/ttyUSB0", 9600);
let mesh_client = MeshasticClient::new(usb_serial);
println!("Using USB Serial connection");
mesh_client.connect().map_err(|e| format!("Failed to connect via USB: {}", e))?;
Ok(mesh_client)
}
}
mod tcp {
use meshastic::{TcpConnection, MeshasticClient};
pub fn establish_connection() -> Result<MeshasticClient<TcpConnection>, String> {
let tcp_conn = TcpConnection::new("192.168.0.10:1234");
let mesh_client = MeshasticClient::new(tcp_conn);
println!("Using TCP connection");
mesh_client.connect().map_err(|e| format!("Failed to connect via TCP: {}", e))?;
Ok(mesh_client)
}
}
fn main() {
}
use std::io::{self, BufRead};
use std::time::SystemTime;
use meshtastic::api::StreamApi;
use meshtastic::utils;
use meshtastic::protobufs::*;
use tracing::{debug, error, info, Level};
use tracing_subscriber::{fmt, FmtSubscriber};
use tracing_subscriber::prelude::*;
mod nodes;
mod packets;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialise Logging - this isn't final.
let subscriber = FmtSubscriber::builder()
// all events higher than debug are shown
.with_max_level(Level::DEBUG)
.finish();
tracing::subscriber::set_global_default(subscriber)
.expect("setting default subscriber failed");
info!("Y(et) A(nother) M(eshtastic) M(ap) - v0.1.0");
// set up new connection
// TODO: setup multiple types
let stream_api = StreamApi::new();
// Set Address and port
// TODO: read from config
let address = "127.0.0.1:4403".to_string();
// Connect over TCP
let tcp_stream = utils::stream::build_tcp_stream(address).await?;
let (mut decoded_listener, stream_api) = stream_api.connect(tcp_stream).await;
let config_id = utils::generate_rand_id();
let stream_api = stream_api.configure(config_id).await?;
// Read loop, exit with Ctrl+C or disconnecting node.
while let Some(decoded) = decoded_listener.recv().await {
// New Message!
debug!("Received: {:?}", decoded);
// Parse message
// Save to DB
}
// Note that in this specific example, this will only be called when
// the radio is disconnected, as the above loop will never exit.
// Typically you would allow the user to manually kill the loop,
// for example with tokio::select!.
let _stream_api = stream_api.disconnect().await?;
Ok(())
}
\ No newline at end of file
// This contains the datatypes of nodes.
use from_radio::PayloadVariant;
use meshtastic::protobufs::*;
use tracing::{debug, error};
/// Parses all incoming packets, handing them out to the correct handler.
pub fn parse(message: &FromRadio) -> bool {
debug!("Parsing Message from radio");
// Handle all types of messages from the radio here.
match message.payload_variant {
// A normal message
Some(PayloadVariant::Packet(ref packet)) => {
parse_packet(packet);
},
// Information about the local node
Some(PayloadVariant::MyInfo(ref info)) => {
parse_myinfo(info);
},
// Information about a remote node
Some(PayloadVariant::NodeInfo(ref node_info)) => {
parse_nodeinfo(node_info);
},
// Information about the local node's config
Some(PayloadVariant::Config(ref config)) => {
parse_config(config);
},
// Information about the local node's module config
Some(PayloadVariant::ModuleConfig(ref module_config)) => {
parse_module_config(module_config);
},
// Information about one of the 8 channels in (potential) use.
Some(PayloadVariant::Channel(ref channel_info)) => {
parse_channel_info(channel_info);
},
// Information about the queue (messages to send soon)
Some(PayloadVariant::QueueStatus(ref queue_status)) => {
parse_queue_info(queue_status);
},
// Unhandled or empty packet
_ => {
error!("Unhandled Packet: {:?}", message);
}
}
// Return success
true
}
fn parse_packet(packet: &MeshPacket) {
// Handle packet data
todo!()
}
fn parse_myinfo(packet: &MyNodeInfo) {
// Check the last MyNodeInfo packet from the DB. If it's different, save it.
todo!()
}
fn parse_nodeinfo(node_info: &NodeInfo) {
// Handle NodeInfo data
todo!()
}
fn parse_config(config: &Config) {
// Handle Config data
todo!()
}
fn parse_module_config(module_config: &ModuleConfig) {
// Handle ModuleConfig data
todo!()
}
fn parse_channel_info(channel_info: &Channel) {
// Handle ChannelInfo data
todo!()
}
fn parse_queue_info(queue_info: &QueueStatus) {
// Handle QueueInfo data
todo!()
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment