From a2b97fbb77168e026834af50ab47a7494d646cce Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 19 Jun 2024 12:34:08 -0700 Subject: [PATCH 1/4] Update mesh-bot.py --- mesh-bot.py | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/mesh-bot.py b/mesh-bot.py index 6e4ff8f..1517601 100644 --- a/mesh-bot.py +++ b/mesh-bot.py @@ -97,34 +97,36 @@ def onReceive(packet, interface): channel_number = packet['channel'] else: channel_number = 0 - - if packet.get('hopLimit'): - hop_limit = packet['hopLimit'] - else: - hop_limit = 0 - - if packet.get('hopStart'): - hop_start = packet['hopStart'] - else: - hop_start = 0 + # check if the packet has a hop count flag use it if packet.get('hopsAway'): hop_away = packet['hopsAway'] else: + # if the packet does not have a hop count try other methods hop_away = 0 - - # set hop to Direct if the message was sent directly otherwise set the hop count - if hop_start == hop_limit: - hop = "Direct" - else: - if hop_away > 0: - hop_count = hop_away - print (f"Using hopsAway: {hop_count}") + if packet.get('hopLimit'): + hop_limit = packet['hopLimit'] else: - hop_count = hop_start - hop_limit - print (f"calculated hop count: {hop_start} - {hop_limit} = {hop_count}") - hop = f"{hop_count} hops" + hop_limit = 0 + + if packet.get('hopStart'): + hop_start = packet['hopStart'] + else: + hop_start = 0 + + if hop_start == hop_limit: + hop = "Direct" + else: + # set hop to Direct if the message was sent directly otherwise set the hop count + if hop_away > 0: + hop_count = hop_away + print (f"Using hopsAway: {hop_count}") + else: + hop_count = hop_start - hop_limit + print (f"calculated hop count: {hop_start} - {hop_limit} = {hop_count}") + + hop = f"{hop_count} hops" # If the packet is a DM (Direct Message) respond to it, otherwise validate its a message for us if packet['to'] == myNodeNum: From 082652e45850fe161d6cfbb065ecdc879c81dc1c Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 19 Jun 2024 12:38:33 -0700 Subject: [PATCH 2/4] Update mesh-bot.py --- mesh-bot.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mesh-bot.py b/mesh-bot.py index 1517601..709261d 100644 --- a/mesh-bot.py +++ b/mesh-bot.py @@ -115,18 +115,18 @@ def onReceive(packet, interface): else: hop_start = 0 - if hop_start == hop_limit: - hop = "Direct" + if hop_start == hop_limit: + hop = "Direct" + else: + # set hop to Direct if the message was sent directly otherwise set the hop count + if hop_away > 0: + hop_count = hop_away + print (f"Using hopsAway: {hop_count}") else: - # set hop to Direct if the message was sent directly otherwise set the hop count - if hop_away > 0: - hop_count = hop_away - print (f"Using hopsAway: {hop_count}") - else: - hop_count = hop_start - hop_limit - print (f"calculated hop count: {hop_start} - {hop_limit} = {hop_count}") + hop_count = hop_start - hop_limit + print (f"calculated hop count: {hop_start} - {hop_limit} = {hop_count}") - hop = f"{hop_count} hops" + hop = f"{hop_count} hops" # If the packet is a DM (Direct Message) respond to it, otherwise validate its a message for us if packet['to'] == myNodeNum: From 4b79ef3666fb212210bf936927dcf0a8e4e0568c Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 19 Jun 2024 13:20:44 -0700 Subject: [PATCH 3/4] Update pong-bot.py --- pong-bot.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pong-bot.py b/pong-bot.py index 8e73579..2b98d37 100644 --- a/pong-bot.py +++ b/pong-bot.py @@ -18,7 +18,7 @@ interface = meshtastic.serial_interface.SerialInterface() #serial interface trap_list = ("ping","ack","testing","pong","motd","help","lheard") #A list of strings to trap and respond to welcome_message = "PongBot, here for you like a friend who is not. Try sending: ping @foo or, help" -help_message = "Commands are: ping, ack, motd, lheard. Use 'motd $foo' to set MOTD." +help_message = "Commands are: ping, ack, motd, Lheard. Use 'motd $foo' to set MOTD." RESPOND_BY_DM_ONLY = True # Set to True to respond messages via DM only (keeps the channel clean) MOTD = "Thanks for using PongBOT! Have a good day!" # Message of the Day @@ -90,32 +90,33 @@ def onReceive(packet, interface): else: channel_number = 0 - if packet.get('hopLimit'): - hop_limit = packet['hopLimit'] - else: - hop_limit = 0 - - if packet.get('hopStart'): - hop_start = packet['hopStart'] - else: - hop_start = 0 - # check if the packet has a hop count flag use it if packet.get('hopsAway'): hop_away = packet['hopsAway'] else: + # if the packet does not have a hop count try other methods hop_away = 0 + if packet.get('hopLimit'): + hop_limit = packet['hopLimit'] + else: + hop_limit = 0 - # set hop to Direct if the message was sent directly otherwise set the hop count + if packet.get('hopStart'): + hop_start = packet['hopStart'] + else: + hop_start = 0 + if hop_start == hop_limit: hop = "Direct" else: + # set hop to Direct if the message was sent directly otherwise set the hop count if hop_away > 0: hop_count = hop_away print (f"Using hopsAway: {hop_count}") else: hop_count = hop_start - hop_limit print (f"calculated hop count: {hop_start} - {hop_limit} = {hop_count}") + hop = f"{hop_count} hops" # If the packet is a DM (Direct Message) respond to it, otherwise validate its a message for us From 75ca8a04dcc1a78fdf58fc2547791c2907d976ce Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 19 Jun 2024 13:20:46 -0700 Subject: [PATCH 4/4] Update mesh-bot.py --- mesh-bot.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mesh-bot.py b/mesh-bot.py index 709261d..41306af 100644 --- a/mesh-bot.py +++ b/mesh-bot.py @@ -19,7 +19,7 @@ interface = meshtastic.serial_interface.SerialInterface() #serial interface trap_list = ("ping","ack","testing","pong","motd","help","sun","solar","hfcond","lheard") #A list of strings to trap and respond to welcome_message = "MeshBot, here for you like a friend who is not. Try sending: ping @foo or, help" -help_message = "Commands are: ping, ack, motd, sun, solar, hfcond, lheard. Use 'motd $foo' to set MOTD." +help_message = "Commands are: ping, ack, motd, sun, solar, hfcond, Lheard. Use 'motd $foo' to set MOTD." RESPOND_BY_DM_ONLY = True # Set to True to respond messages via DM only (keeps the channel clean) MOTD = "Thanks for using PongBOT! Have a good day!" # Message of the Day @@ -98,7 +98,6 @@ def onReceive(packet, interface): else: channel_number = 0 - # check if the packet has a hop count flag use it if packet.get('hopsAway'): hop_away = packet['hopsAway']