2023-09-09 17:52:25 +00:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import time
|
|
|
|
|
|
|
|
def execute_meshtastic_command(options):
|
|
|
|
"""Execute a meshtastic command with the given options."""
|
2023-11-26 21:51:34 +00:00
|
|
|
command = ["meshtastic", "--host", "mmrelaydevice", "--port", "4403"] + options.split()
|
2023-11-26 22:35:21 +00:00
|
|
|
print(f"Executing command: {' '.join(command)}") # Add this line for debugging
|
|
|
|
result = subprocess.run(command, capture_output=True, text=True)
|
|
|
|
print(result.stdout) # Add this line to print the output
|
|
|
|
time.sleep(15) # Pause for 30 seconds
|
2023-09-09 17:52:25 +00:00
|
|
|
|
|
|
|
# Loop through environment variables in sequence
|
|
|
|
index = 1
|
|
|
|
while True:
|
|
|
|
command = os.environ.get(f'MESHTASTIC_COMMAND_{index}')
|
|
|
|
if command:
|
|
|
|
execute_meshtastic_command(command)
|
|
|
|
index += 1
|
|
|
|
else:
|
2023-11-26 22:35:21 +00:00
|
|
|
break
|