My python script needs some work, so I switched back to a bash shell:
/config/send_sms.sh
#!/bin/bash
DEST=$1
MD="/dev/ttyUSB2"
if [ -z "$2" ]
then
read message
else
message="$2"
fi
echo "Sending $message to $DEST"
apk add ppp
stty -F $MD 9600 min 100 time 2 -hupcl brkint ignpar -opost -onlcr -isig -icanon -echo
chat TIMEOUT 10 "" "AT+CMGF=1" "OK" > $MD < $MD
chat TIMEOUT 10 "" "AT+CMGS=\"$DEST\"" "OK" > $MD < $MD
chat TIMEOUT 10 "" "$message^Z" "OK" > $MD < $MD
Also, if you are using a RPI4, I found that you need a udev rule in the config USB stick, for me this config was:
udev\10-gsm-modem.rules
ACTION=="add" \
, ATTRS{idVendor}=="12d1" \
, ATTRS{idProduct}=="14fe" \
, RUN+="/sbin/usb_modeswitch -X -v 12d1 -p 14fe"
You get the vendor id and product id from the output of lsusb