repeaterFunction

enhance.. enhance..
This commit is contained in:
SpudGunMan
2024-07-25 00:52:58 -07:00
parent 7e76a24b40
commit 4c6c20c327
5 changed files with 48 additions and 10 deletions
+9
View File
@@ -83,6 +83,15 @@ StoreForward = False
```
The BBS has admin and block lists, see the [`config.template`](config.template)
A repeater function for two different nodes and cross posting messages. The `repeater_channels` is a list of repeater channels ex: [2, 3] which will be consumed and rebroadcasted on the same channel on the other device/node/interface. With great power comes great responsibility, danger could be lurking in use of this feature! If you have the two nodes on the same radio configurations, you could create a feedback loop!!!
```
# repeater module
[repeater]
enabled = True
repeater_channels = [2, 3]
```
# requirements
can also be installed with `pip install -r requirements.txt`
+15 -5
View File
@@ -42,10 +42,10 @@ URL_TIMEOUT = 10
[bbs]
enabled = True
# list of banned nodes numbers ex: [2813308004, 4258675309]
bbs_ban_list = []
# list of admin nodes numbers ex: [2813308004, 4258675309]
bbs_admin_list = []
# list of banned nodes numbers ex: 2813308004,4258675309
bbs_ban_list =
# list of admin nodes numbers ex: 2813308004,4258675309
bbs_admin_list =
# location module
[location]
@@ -59,4 +59,14 @@ ALERT_COUNT = 2
# solar module
[solar]
enabled = True
enabled = True
# repeater module
[repeater]
enabled = False
# list of repeater channels ex: 2,3 which will be consumed
# and rebroadcasted on the same channel on the other device/node/interface
# with great power comes great responsibility, danger could be lurking in use of this feature
# if you have the two nodes on the same radio configurations, you could create a feedback loop
repeater_channels =
+18 -1
View File
@@ -257,6 +257,7 @@ def onReceive(packet, interface):
# respond to channel message on the channel itself
send_message(auto_response(message_string, snr, rssi, hop, message_from_id, channel_number, rxNode), channel_number, 0, rxNode)
else:
# ignore the message but add it to the message history and repeat it if enabled
# add the message to the message history but limit
if zuluTime:
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
@@ -269,7 +270,21 @@ def onReceive(packet, interface):
msg_history.pop(0)
msg_history.append((get_name_from_number(message_from_id, 'long', rxNode), message_string, channel_number, timestamp, rxNode))
print(f"{log_timestamp()} System: Ignoring incoming Device:{rxNode} Channel:{channel_number} Message: {message_string} From: {get_name_from_number(message_from_id)}")
# check if repeater is enabled and the other interface is enabled
if repeater_enabled and interface2_enabled:
# repeat the message on the other device
rMsg = (f"{message_string} From:{get_name_from_number(message_from_id, 'short', rxNode)}")
# if channel found in the repeater list repeat the message
if str(channel_number) in repeater_channels:
if rxNode == 1:
print(f"{log_timestamp()} Repeating message on Device2 Channel:{channel_number}")
send_message(rMsg, channel_number, 0, 2)
elif rxNode == 2:
print(f"{log_timestamp()} Repeating message on Device1 Channel:{channel_number}")
send_message(rMsg, channel_number, 0, 1)
else:
print(f"{log_timestamp()} System: Ignoring incoming Device:{rxNode} Channel:{channel_number} Message: {message_string} From: {get_name_from_number(message_from_id)}")
except KeyError as e:
print(f"{log_timestamp()} System: Error processing packet: {e} Device:{rxNode}")
@@ -290,6 +305,8 @@ def start_rx():
print(f"System: Store and Forward Enabled")
if useDMForResponse:
print(f"System: Respond by DM only")
if repeater_enabled:
print(f"System: Repeater Enabled")
# Start the receive loop
pub.subscribe(onReceive, 'meshtastic.receive')
print (f"{log_timestamp()} System: Autoresponder Started for Device1 {get_name_from_number(myNodeNum, 'long', 1)}")
+6 -1
View File
@@ -10,6 +10,7 @@ MOTD = 'Thanks for using MeshBOT! Have a good day!'
msg_history = [] # message history for the store and forward feature
bbs_ban_list = [] # list of banned users
bbs_admin_list = [] # list of admin users
repeater_channels = [] # list of channels to listen on for repeater mode
# Read the config file, if it does not exist, create basic config file
config = configparser.ConfigParser()
@@ -29,6 +30,7 @@ if config.sections() == []:
config['bbs'] = {'enabled': 'True', 'bbsdb': 'bbsdb.pkl'}
config['location'] = {'enabled': 'True','lat': '48.50', 'lon': '-123.0'}
config['solar'] = {'enabled': 'True'}
config['repeater'] = {'enabled': 'false'}
config.write(open(config_file, 'w'))
print (f"System: Config file created, check {config_file} or review the config.template")
@@ -67,4 +69,7 @@ urlTimeoutSeconds = config['general'].getint('URL_TIMEOUT', 10) # default 10 sec
forecastDuration = config['general'].getint('DAYS_OF_WEATHER', 4) # default days of weather
numWxAlerts = config['general'].getint('ALERT_COUNT', 2) # default 2 alerts
bbs_ban_list = config['bbs'].get('ban_list', '').split(',')
bbs_admin_list = config['bbs'].get('admin_list', '').split(',')
bbs_admin_list = config['bbs'].get('admin_list', '').split(',')
repeater_enabled = config['repeater'].getboolean('enabled', False)
repeater_channels = config['repeater'].get('repeater_channels', '').split(',')
-3
View File
@@ -121,7 +121,6 @@ def get_name_from_number(number, type='long', RXnodeId=1):
return name
return ERROR_FETCHING_DATA
def get_node_list(nodeInt=1):
if interface1.nodes:
@@ -181,8 +180,6 @@ def get_node_list(nodeInt=1):
return node1 + node2
def get_node_location(number, nodeInt=1):
# Get the location of a node by its number from nodeDB on device
latitude = 0