mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-08-07 09:22:44 +02:00
radioMon Enhancment
This commit is contained in:
@@ -12,6 +12,8 @@ The bot is also capable of using dual radio/nodes, so you can monitor two networ
|
||||
|
||||
Store and forward-like message re-play with `messages`, and there is a repeater module for dual radio bots to cross post messages.
|
||||
|
||||
The bot can alsp monitor a frequency and notify when activy is seen.
|
||||
|
||||
- Various solar details for radio propagation
|
||||
- `sun` and `moon` return info on rise and set local time
|
||||
- `solar` gives an idea of the x-ray flux
|
||||
@@ -96,7 +98,14 @@ A repeater function for two different nodes and cross-posting messages. The'repe
|
||||
enabled = True
|
||||
repeater_channels = [2, 3]
|
||||
```
|
||||
A module allowing a Hamlib compatable radio to connect to the bot, when functiponing it will message the channel configured with a message of in use.
|
||||
|
||||
```
|
||||
[radioMon]
|
||||
enabled = False
|
||||
rigControlServerAddress = localhost:4532
|
||||
sigWatchBrodcastCh = 2
|
||||
```
|
||||
# requirements
|
||||
can also be installed with `pip install -r requirements.txt`
|
||||
|
||||
|
||||
@@ -70,3 +70,8 @@ enabled = False
|
||||
# if you have the two nodes on the same radio configurations, you could create a feedback loop
|
||||
repeater_channels =
|
||||
|
||||
[radioMon]
|
||||
# using Hamlib rig control will monitor and alert on channel use
|
||||
enabled = False
|
||||
rigControlServerAddress = localhost:4532
|
||||
sigWatchBrodcastCh = 2
|
||||
|
||||
+7
-1
@@ -322,6 +322,8 @@ async def start_rx():
|
||||
print(f"System: Respond by DM only")
|
||||
if repeater_enabled:
|
||||
print(f"System: Repeater Enabled for Channels: {repeater_channels}")
|
||||
if radio_dectection_enabled:
|
||||
print(f"System: Radio Detection Enabled using rigctld at {rigControlServerAddress}")
|
||||
|
||||
# Start the receive subscriber using pubsub via meshtastic library
|
||||
pub.subscribe(onReceive, 'meshtastic.receive')
|
||||
@@ -343,7 +345,11 @@ async def start_rx():
|
||||
async def main():
|
||||
meshRxTask = asyncio.create_task(start_rx())
|
||||
watchdogTask = asyncio.create_task(watchdog())
|
||||
await asyncio.wait([meshRxTask, watchdogTask])
|
||||
if radio_dectection_enabled:
|
||||
hamlibTask = asyncio.create_task(handleSignalWatcher())
|
||||
await asyncio.wait([meshRxTask, watchdogTask, hamlibTask])
|
||||
else:
|
||||
await asyncio.wait([meshRxTask, watchdogTask])
|
||||
|
||||
try:
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -14,6 +14,7 @@ repeater_channels = [] # list of channels to listen on for repeater mode
|
||||
antiSpam = True # anti-spam feature to prevent flooding public channel
|
||||
ping_enabled = True # ping feature to respond to pings, ack's etc.
|
||||
sitrep_enabled = True # sitrep feature to respond to sitreps
|
||||
lastHamLibAlert = 0 # last alert from hamlib
|
||||
|
||||
# Read the config file, if it does not exist, create basic config file
|
||||
config = configparser.ConfigParser()
|
||||
@@ -72,6 +73,9 @@ try:
|
||||
bbs_admin_list = config['bbs'].get('bbs_admin_list', '').split(',')
|
||||
repeater_enabled = config['repeater'].getboolean('enabled', False)
|
||||
repeater_channels = config['repeater'].get('repeater_channels', '').split(',')
|
||||
radio_dectection_enabled = config['radioMon'].getboolean('enabled', False)
|
||||
rigControlServerAddress = config['radioMon'].get('rigControlServerAddress', 'localhost:4532')
|
||||
sigWatchBrodcastCh = config['radioMon'].get('sigWatchBrodcastCh', '2').split(',')
|
||||
except KeyError as e:
|
||||
print(f"System: Error reading config file: {e}")
|
||||
print(f"System: Check the config.ini against config.template file for missing sections or values.")
|
||||
|
||||
@@ -5,6 +5,7 @@ import meshtastic.serial_interface #pip install meshtastic
|
||||
import meshtastic.tcp_interface
|
||||
import meshtastic.ble_interface
|
||||
from datetime import datetime
|
||||
import time
|
||||
import asyncio
|
||||
from modules.settings import *
|
||||
|
||||
@@ -54,6 +55,10 @@ if store_forward_enabled:
|
||||
trap_list = trap_list + ("messages",)
|
||||
help_message = help_message + ", messages"
|
||||
|
||||
# Radio Monitor Configuration
|
||||
if radio_dectection_enabled:
|
||||
from modules.radio import * # from the spudgunman/meshing-around repo
|
||||
|
||||
# Interface1 Configuration
|
||||
if interface1_type == 'serial':
|
||||
interface1 = meshtastic.serial_interface.SerialInterface(port1)
|
||||
@@ -348,6 +353,34 @@ async def watchdog():
|
||||
print(f"{log_timestamp()} System: Error communicating with interface2: {e}")
|
||||
await retry_interface(2)
|
||||
|
||||
async def handleSignalWatcher():
|
||||
global lastHamLibAlert, antiSpam, sigWatchBrodcastCh
|
||||
# monitor rigctld for signal strength and frequency
|
||||
while True:
|
||||
msg = await signalWatcher()
|
||||
if msg != ERROR_FETCHING_DATA and msg != None:
|
||||
print(f"{log_timestamp()} System: Detected Alert from Hamlib {msg}")
|
||||
|
||||
# check we are not spammig the channel limit messages to once per minute
|
||||
if time.time() - lastHamLibAlert > 60:
|
||||
lastHamLibAlert = time.time()
|
||||
# if sigWatchBrodcastCh contains multiple channels, broadcast to all
|
||||
if sigWatchBrodcastCh.find(',') != -1:
|
||||
sigWatchBrodcastCh = sigWatchBrodcastCh.split(',')
|
||||
for ch in sigWatchBrodcastCh:
|
||||
if antiSpam and ch != publicChannel:
|
||||
send_message(msg, int(ch), 0, 1)
|
||||
if interface2_enabled:
|
||||
send_message(msg, int(ch), 0, 2)
|
||||
else:
|
||||
if antiSpam and sigWatchBrodcastCh != publicChannel:
|
||||
send_message(msg, int(sigWatchBrodcastCh), 0, 1)
|
||||
if interface2_enabled:
|
||||
send_message(msg, int(sigWatchBrodcastCh), 0, 2)
|
||||
|
||||
await asyncio.sleep(1)
|
||||
pass
|
||||
|
||||
# this is a workaround because .localNode.getMetadata spits out a lot of debug info which cant be suppressed
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
Reference in New Issue
Block a user