From a0f10cdc6457f3703f63d9f7c1c41071187fc1fb Mon Sep 17 00:00:00 2001
From: Stephen D <webmaster@scd31.com>
Date: Sat, 2 Dec 2023 19:18:15 -0400
Subject: [PATCH] basic node info whisker

---
 config.example.toml |  8 +++++++-
 src/config.rs       |  3 +++
 src/gate.rs         | 24 ++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/config.example.toml b/config.example.toml
index 3a6f0f8..b514f20 100644
--- a/config.example.toml
+++ b/config.example.toml
@@ -11,4 +11,10 @@ max_hops = 3
 latitude = 45.0
 longitude = -66.0
 altitude = 30 # meters
-comment = "Check out my cool CATS beacon!"
+comment = "Check out my cool CATS I-gate!"
+# These settings DO NOT change anything about how
+# the software/hardware work. It only changes data
+# in the NodeInfo whisker
+antenna_height = 10 # meters above ground
+antenna_gain = 2 # dBi
+tx_power = 30 # dBm
diff --git a/src/config.rs b/src/config.rs
index b9ecded..d8c2f94 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -20,6 +20,9 @@ pub struct BeaconConfig {
     pub longitude: Option<f64>,
     pub altitude: Option<f64>,
     pub comment: Option<String>,
+    pub antenna_height: Option<u8>,
+    pub antenna_gain: Option<f32>,
+    pub tx_power: Option<f32>,
 }
 
 #[derive(Deserialize, Clone)]
diff --git a/src/gate.rs b/src/gate.rs
index 4657576..68443e1 100644
--- a/src/gate.rs
+++ b/src/gate.rs
@@ -9,6 +9,7 @@ use anyhow::{anyhow, Context};
 use async_stream::stream;
 use half::f16;
 use ham_cats::buffer::Buffer;
+use ham_cats::whisker::NodeInfoBuilder;
 use ham_cats::{
     packet::Packet,
     whisker::{Gps, Identification, Route},
@@ -19,6 +20,9 @@ use tokio_stream::StreamExt;
 use tonic::{transport::Channel, Request};
 use uuid::Uuid;
 
+const HARDWARE_ID: u16 = 0x7c85;
+const SOFTWARE_ID: u8 = 0x00;
+
 pub fn beacon_forever(
     c: &Config,
     modem_send: mpsc::Sender<Vec<u8>>,
@@ -58,6 +62,26 @@ pub fn beacon_forever(
             .map_err(|e| anyhow!("Could not add gps to beacon packet: {e}"))?;
     }
 
+    let mut info_builder = NodeInfoBuilder::default()
+        .hardware_id(HARDWARE_ID)
+        .software_id(SOFTWARE_ID);
+
+    if let Some(height) = c.beacon.antenna_height {
+        info_builder = info_builder.antenna_height(height);
+    }
+
+    if let Some(gain) = c.beacon.antenna_gain {
+        info_builder = info_builder.antenna_gain(gain as f64);
+    }
+
+    if let Some(power) = c.beacon.tx_power {
+        info_builder = info_builder.tx_power(power as f64);
+    }
+
+    packet
+        .add_node_info(info_builder.build())
+        .map_err(|e| anyhow!("Could not add info to beacon packet: {e}"))?;
+
     let mut internet_buf = [0; MAX_PACKET_LEN];
     let mut internet_packet = packet.clone_backing(&mut internet_buf);
     let mut rf_packet = packet;
-- 
GitLab