i want to configure my Rapsberry as a SMS Ping Pong Player. So i installed gammu-smsd and configured the gammu-smsdrc as follows:
# Configuration file for Gammu SMS Daemon
# Gammu library configuration, see gammurc(5)
[gammu]
# Please configure this!
port = /dev/ttyUSB3
pin= 4135
connection = at
# Debugging
logformat = textall
# SMSD configuration, see gammu-smsdrc(5)
[smsd]
RunOnReceive = sudo /var/spool/gammu/receivesms.sh
service = files
pin = 4135
# Increase for debugging information
debuglevel = 1
logfile = /var/spool/gammu/gammu.log
include_smsc = 491722270333
# Paths where messages are stored
inboxpath = /var/spool/gammu/inbox/
outboxpath = /var/spool/gammu/outbox/
sentsmspath = /var/spool/gammu/sent/
errorsmspath = /var/spool/gammu/error/
so far, sending sms an receiving sms works fine!
So i tried that runonreceive thing. and wrote a small script which should get the sms sender number and the text. and if the text is "ping" gammu-smsd should send pong back to the sender.
reveivessms.sh:
#!/bin/sh
from=$SMS_1_NUMBER
message=$SMS_1_TEXT
reply=""
if test "$message" = "Ping"; then
reply="Pong!"
else
reply="Y U NO PLAY PING PONG?"
fi
sudo echo "$reply" | /usr/bin/gammu-smsd-inject -c /etc/gammu-smsdrc TEXT "$from"
gammu.log is:
Wed 2016/05/25 09:04:31 gammu-smsd[21681]: Received message from: +49160xxxxx
Wed 2016/05/25 09:04:31 gammu-smsd[21681]: Read 1 messages
Wed 2016/05/25 09:04:31 gammu-smsd[21681]: Received IN20160525_090429_00_+49160xxxxxx_00.txt
Wed 2016/05/25 09:04:31 gammu-smsd[21994]: Starting run on receive: sudo /var/spool/gammu/receivesms.sh IN20160525_090429_00_+49160xxxxxx_00.txt
Wed 2016/05/25 09:04:31 gammu-smsd[21681]: Process finished successfully
Wed 2016/05/25 09:04:53 gammu-smsd[21681]: Found 1 sms to "" with text "Y U NO PLAY PING PONG?" cod 3 lgt 22 udh: t 1 l 0 dlr: -1 fls: -1
Wed 2016/05/25 09:04:53 gammu-smsd[21681]: New message to send: OUTC20160525_090431_00__sms0.smsbackup
Wed 2016/05/25 09:04:53 gammu-smsd[21681]: Message without SMSC, assuming you want to use the one from phone
Wed 2016/05/25 09:05:19 gammu-smsd[21681]: SMS sent on device: "/dev/ttyUSB3" status=500, reference=-1
Wed 2016/05/25 09:05:19 gammu-smsd[21681]: Error getting send status of message: Unknown error. (UNKNOWN[27])
hmm no message replied...
so i tried without passing Parameters and changed the receivesms.sh to:
#!/bin/sh
sudo echo Gude Wie | /usr/bin/gammu-smsd-inject -c /etc/gammu-smsdrc TEXT 49160xxxx
and everything is working. Seems, that the variable passing to the receicesms.sh doesn't work. But i have no idea why?
Getting run on receive to send a sms reply with gammu-smsd-inject was a mission.
For anyone else coming across this issue. I solved it by redirecting stdout and stderr of the gammu-smsd-inject command to /dev/null.
echo "This somehow works" | gammu-smsd-inject TEXT $from > /dev/null 2>&1
Regards