Danke, ja ich habe dies getestet.
Aber zuerst muss ich die
Probleme mit dem LTE-Treiber lösen
-- Zusammenführung Doppelpost gemäß Boardregeln by stoney
In English (sorry, writing German is too hard, at least when I speak it, I can "hide" the spelling mistakes).
SMSTools3 is working well, and I worked around my
LTE dongle problems.
Based on the example event handler, I made one to automatically forward provider SMS to my cell phone, and I can trigger returns by sending SMS with a "Forward: " header.
I decided to unify the more obvious "Forward-from:" and "Forward-to: into a single "Forward:" for easier copy-paste.
Example, The LTE dongle gets a message from the service provider (or anyone, really)
Code:
Your bundle is almost gone, send EXTEND 1GB to extend your bundle
It is forwarded to my real phone, but with the original sender added to the text and "Forward:" added to it (meaning Forward-From)
Code:
Forward: 1266 Your bundle is almost gone, send EXTEND 1GB to extend your bundle
I copy, paste, edit as desired, and send back to the LTE dongle: (now Forward: means Forward-To)
Now SMSTools3 removed the forward, and sends it
So the provider on number 1266 sees the message come from my LTE dongle phone number.
Possible problems:
It will forward messages from anyone to my phone, and if they known, anyone could make the dongle send to anyone else.
When this becomes a security or cost problem, some filter code could/should be added to the script to only allow known service provider numbers.
I think this may also fail if the SMS text has quotes (") or is in non-ISO character format.
How-To
1. Tweak Freetz sources smstools3.cfg & smstools3_conf as show further down and compile & flash
(eventually I may figure out how to add this to the web-ui config page)
1. Configure the event handler script name in Freetz smstools3 config
(as these patches are now part of the Freetz-NG)
2. Make sure the 4G-LTE stick is working (see
here for my Alfa/Quectel model)
3. Configure smstools3 as normal
I put the folder in /var/media/ftp/sms so SMS are retained past reboot, and my SMS device is /dev/ttyUSB2
4. Put this event handler in /var/tmp/flash/smsforward.sh
( don't forget to make executable and modsave flash )
Freetz version, as it is rather non-standard implementation of smstools3
Code:
#!/bin/sh
# Forward for Freetz smstools3 implementation, which is non-standard
#
# Make executable: chmod a+x
# Debug by viewing /var/log/smsd
NUMBER=316xxxxxxxx # My Phone
#NUMBER2=316xxxxxxxx # My alternate Phone
SOURCE=`cat $2|grep ^From:|cut -d " " -f2`
FORWARD=`cat $2|grep ^Forward:|cut -d " " -f2`
SENDSMS="/etc/init.d/rc.smstools3 sendsms"
if [ "$1" = "RECEIVED" ]; then
# line number of the actual message (last line)
line="$(awk '/^\s*$/{print NR}' $2|head -n 1)"
[ -z "$line" ] && exit 0
# extract message
MESSAGE="`sed "1,${line}da" < $2`"
# If forward command, then forward message
if [ -n "$FORWARD" ];then
#remove forward header
MESSAGE2=${MESSAGE#Forward: [0-9]* }
$SENDSMS "$FORWARD" "${MESSAGE2}"
sleep 1 # force sepate timestamp in temp file
fi
# If no forward command, then forward to preprogrammed number
# Even if a forward command, still forward to listed numbers, to show processing was OK
if [ -n "$NUMBER" ];then
$SENDSMS "$NUMBER" "Forward: ${SOURCE} ${MESSAGE}"
fi
if [ -n "$NUMBER2" ];then
sleep 1 # force sepate timestamp in temp file
$SENDSMS "$NUMBER2" "Forward: ${SOURCE} ${MESSAGE}"
fi
fi
Tweaked Freetz source: make/smstools3/files/root/etc/default.smstools3/smstools3.cfg
Code:
export SMSTOOLS3_ENABLED='no'
export SMSTOOLS3_DIR=''
export SMSTOOLS3_DEVICE='/dev/ttyUSB0'
export SMSTOOLS3_PIN=''
export SMSTOOLS3_LOGLEVEL='5'
export SMSTOOLS3_EVENTS='/tmp/flash/smsforward.sh'
Tweaked Freetz source: make/smstools3/files/root/etc/default.smstools3/smstools3_conf
Code:
#!/bin/sh
cat << EOF
devices = GSM
logfile = /var/log/smsd.log
loglevel = $SMSTOOLS3_LOGLEVEL
eventhandler = $SMSTOOLS3_EVENTS
[GSM]
device = $SMSTOOLS3_DEVICE
incoming = yes
EOF
[ -n "$SMSTOOLS3_PIN" ] && echo "pin = $SMSTOOLS3_PIN"
For reference, my similar OpenWRT version (more standard smstools3 implementation)
Code:
#!/bin/sh
NUMBER=316xxxxxxxx # My Phone
NUMBER2=316xxxxxxxx # My alternate Phone
MAIL=
LOCAL=
SOURCE=`cat $2|grep ^From:|cut -d " " -f2`
FORWARD=`cat $2|grep ^Forward:|cut -d " " -f2`
TYPE="international"
if [ "$1" = "RECEIVED" ]; then
line="$(awk '/^\s*$/{print NR}' $2|head -n 1)"
[ -z "$line" ] && exit 0
cat $2 | grep UCS2
if [ $? -eq 0 ]; then
TMPFILE=`mktemp /tmp/forward_XXXXXX`
sed -e "1,${line}d" $2 > $TMPFILE
MESSAGE="`gl_modem convert $TMPFILE`"
else
MESSAGE="`sed "1,${line}da" < $2`"
fi
# If forward command, then forward message
if [ -n "$FORWARD" ];then
#remove forward header
MESSAGE2=${MESSAGE##Forward: [0-9]* }
sendsms "$FORWARD" "${MESSAGE2}"
fi
# If no forward command, then forward to preprogrammed number
# Even if a forward command, still forward to listed numbers, to show processing was OK
if [ -n "$NUMBER" ];then
sendsms "$NUMBER" "Forward: ${SOURCE} ${MESSAGE}"
fi
if [ -n "$NUMBER2" ];then
sendsms "$NUMBER2" "Forward: ${SOURCE} ${MESSAGE}"
fi
fi