mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-07-02 07:51:37 +02:00
cleanupStartLoop
This commit is contained in:
+20
-25
@@ -262,51 +262,46 @@ def onReceive(packet, interface):
|
||||
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"System: Error processing packet: {e}")
|
||||
print(f"{log_timestamp()} System: Error processing packet: {e}")
|
||||
print(packet) # print the packet for debugging
|
||||
print("END of packet \n")
|
||||
|
||||
def start_rx():
|
||||
print ("\nMeshtastic Autoresponder Bot CTL+C to exit\n")
|
||||
if bbs_enabled:
|
||||
print(f"{log_timestamp()} System: BBS Enabled, using {bbsdb}")
|
||||
if solar_conditions_enabled:
|
||||
print(f"{log_timestamp()} System: Celestial Telemetry Enabled")
|
||||
if location_enabled:
|
||||
print(f"{log_timestamp()} System: Location Telemetry Enabled")
|
||||
if dad_jokes_enabled:
|
||||
print(f"{log_timestamp()} System: Dad Jokes Enabled!")
|
||||
if store_forward_enabled:
|
||||
print(f"Sys{log_timestamp()} Systemtem: Store and Forward Enabled")
|
||||
if useDMForResponse:
|
||||
print(f"{log_timestamp()} System: Respond by DM only")
|
||||
# Start the receive loop
|
||||
pub.subscribe(onReceive, 'meshtastic.receive')
|
||||
print (f"System: Autoresponder Started for device {get_name_from_number(myNodeNum)}")
|
||||
print (f"{log_timestamp()} System: Autoresponder Started for device {get_name_from_number(myNodeNum)}")
|
||||
while True:
|
||||
time.sleep(0.05)
|
||||
pass
|
||||
|
||||
def exit_handler():
|
||||
# Close the interface and save the BBS messages
|
||||
print("\nSystem: Closing Autoresponder")
|
||||
print(f"\n{log_timestamp()} System: Closing Autoresponder\n")
|
||||
interface1.close()
|
||||
print("System: Interface1 Closed")
|
||||
print(f"{log_timestamp()} System: Interface1 Closed")
|
||||
if interface2_enabled:
|
||||
#interface2.close()
|
||||
print("System: Interface2 Closed remember to fix this line")
|
||||
print(f"{log_timestamp()} System: Interface2 Closed remember to fix this line")
|
||||
if bbs_enabled:
|
||||
print("Saving BBS Messages")
|
||||
save_bbsdb()
|
||||
print("System: BBS Messages Saved")
|
||||
print("System: Exiting")
|
||||
print(f"{log_timestamp()} System: BBS Messages Saved")
|
||||
print(f"{log_timestamp()} System: Exiting")
|
||||
exit (0)
|
||||
|
||||
# Hello World
|
||||
print ("\nMeshtastic Autoresponder Bot CTL+C to exit\n")
|
||||
|
||||
if bbs_enabled:
|
||||
print(f"System: BBS Enabled, using {bbsdb}")
|
||||
|
||||
if solar_conditions_enabled:
|
||||
print(f"System: Celestial Telemetry Enabled")
|
||||
|
||||
if location_enabled:
|
||||
print(f"System: Location Telemetry Enabled")
|
||||
|
||||
if dad_jokes_enabled:
|
||||
print(f"System: Dad Jokes Enabled!")
|
||||
|
||||
if store_forward_enabled:
|
||||
print(f"System: Store and Forward Enabled")
|
||||
|
||||
loop = asyncio.new_event_loop()
|
||||
try:
|
||||
loop.run_forever(start_rx())
|
||||
|
||||
+11
-6
@@ -159,21 +159,26 @@ def onReceive(packet, interface):
|
||||
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"System: Error processing packet: {e}")
|
||||
print(f"{log_timestamp()} System: Error processing packet: {e}")
|
||||
print(packet) # print the packet for debugging
|
||||
print("END of packet \n")
|
||||
|
||||
|
||||
def exit_handler():
|
||||
# Close the interface and save the BBS messages
|
||||
print("\nSystem: Closing Autoresponder")
|
||||
interface.close()
|
||||
print("System: Interface Closed")
|
||||
print("System: Exiting")
|
||||
print(f"\n{log_timestamp()} System: Closing Autoresponder\n")
|
||||
interface1.close()
|
||||
print(f"{log_timestamp()} System: Interface1 Closed")
|
||||
if interface2_enabled:
|
||||
#interface2.close()
|
||||
print(f"{log_timestamp()} System: Interface2 Closed remember to fix this line")
|
||||
print(f"{log_timestamp()} System: Exiting")
|
||||
exit (0)
|
||||
|
||||
def start_rx():
|
||||
# Start the receive loop
|
||||
pub.subscribe(onReceive, 'meshtastic.receive')
|
||||
print (f"System: Autoresponder Started for device {get_name_from_number(myNodeNum)}")
|
||||
print (f"{log_timestamp()} System: Autoresponder Started for device {get_name_from_number(myNodeNum)}")
|
||||
while True:
|
||||
time.sleep(0.05)
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user