#!/bin/bash #---------------------------------- # A proof of concept to watch for # and respond to Meshtastic # messages over serial (USBserial). # # More here than the first paste. # # Can be thought of as a bash-based # BBS or Meshtastic Bot. # # Requires: bash, stty, meshtastic (cli), # sed, tr, grep... # # Make sure "Debug log enabled" # is checked to on in the # Radio Configuration->Device menu # of Meshtastic # # ~HowToPhil Updated 2024/02/17 21:00 EST #---------------------------------- #-------------------------------------- # A Bulletin Board System # at least needs System Bulletins #-------------------------------------- systemBulletins () { meshtastic --sendtext "The system is new and not at all stable. and you can see this bulletin now!" } #-------------------------------------- # A function to handle commands #-------------------------------------- parseCommand () { echo "$1 in parseCommand" #The help/menu if [ "$1" == "help" ]; then meshtastic --sendtext "This is a SUPER-SIMPLE BBS on Meshtastic! Use these commands: @meshbbs help - Show this help message @meshbbs weather [location] - The weather at a location @meshbbs bulletins - System bulletins " fi #The weather if [ $1 == "weather" ]; then meshtastic --sendtext "`ansiweather -l $2 $3 $4 |sed -e 's/\x1b\[[0-9;]*m//g'`" fi #System Bulletins Pass-Off if [ $1 == "bulletins" ]; then systemBulletins fi } #-------------------------------------- # The loop that looks for commands # and responds to those commands #-------------------------------------- while [ 1==1 ]; do #configure the USB serial port properly stty -F /dev/ttyUSB0 115200 -echo -icrnl raw #start watching for a command COMMAND=$(grep -a -m1 "@meshbbs" /dev/ttyUSB0| grep "^INFO"|sed 's/.*@meshbbs //'| tr -d "\r") #do something with the command echo "GOT $COMMAND" parseCommand $COMMAND done